Replace qualified crate paths with use imports
Imported types at module level instead of repeating crate:: prefixes
throughout ci.rs, quire.rs, server.rs, secret.rs, and error.rs.

Assisted-by: GLM-5.1 via pi
change xzrmrsypntqxkmystwkklqtrkkwoktpy
commit b14296a4711d5814c13b15a5a668044be0678cfc
author Alpha Chen <alpha@kejadlen.dev>
date
parent mrnqkrsr
diff --git a/src/ci.rs b/src/ci.rs
index 2a0b9f0..21c63e8 100644
--- a/src/ci.rs
+++ b/src/ci.rs
@@ -1,7 +1,9 @@
 use std::path::{Path, PathBuf};
 
-use crate::Result;
-use crate::event::PushEvent;
+use crate::event::{PushEvent, PushRef};
+use crate::fennel::{Fennel, FennelError};
+use crate::quire::Repo;
+use crate::{Error, Result};
 
 /// The state of a CI run.
 #[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
@@ -254,7 +256,7 @@ impl Run {
         let dst_parent = self.base.join(to.dir_name());
 
         if !src.exists() {
-            return Err(crate::Error::Io(std::io::Error::new(
+            return Err(Error::Io(std::io::Error::new(
                 std::io::ErrorKind::NotFound,
                 format!("run directory not found: {}", src.display()),
             )));
@@ -306,11 +308,7 @@ pub struct EvalResult {
 ///
 /// Injects a `job` global that accumulates into a registration table,
 /// evaluates the source, and extracts the registered jobs.
-pub fn eval_ci(
-    fennel: &crate::fennel::Fennel,
-    source: &str,
-    name: &str,
-) -> crate::Result<EvalResult> {
+pub fn eval_ci(fennel: &Fennel, source: &str, name: &str) -> Result<EvalResult> {
     fennel.eval_raw(source, name, |lua| {
         // Create a registration table. `job` will push into this.
         let registry: mlua::Table = lua.create_table()?;
@@ -334,7 +332,7 @@ pub fn eval_ci(
     })?;
 
     // Extract the registration table.
-    let lua_err = |e: mlua::Error| crate::fennel::FennelError::from_lua(source, name, e);
+    let lua_err = |e: mlua::Error| FennelError::from_lua(source, name, e);
     let registry: mlua::Table = fennel.lua().globals().get("_quire_jobs").map_err(lua_err)?;
     let mut jobs = Vec::new();
     for entry in registry.sequence_values::<mlua::Table>() {
@@ -501,7 +499,7 @@ pub async fn dispatch_push(quire: &crate::Quire, event: &PushEvent) {
 }
 
 /// Check each updated ref for .quire/ci.fnl, create runs, and eval + validate.
-fn dispatch_ci(repo: &crate::quire::Repo, event: &PushEvent) {
+fn dispatch_ci(repo: &Repo, event: &PushEvent) {
     for push_ref in event.updated_refs() {
         if let Err(e) = dispatch_ci_ref(repo, &event.pushed_at, push_ref) {
             tracing::error!(
@@ -518,11 +516,7 @@ fn dispatch_ci(repo: &crate::quire::Repo, event: &PushEvent) {
 ///
 /// Returns `Ok(())` if CI ran (regardless of whether the run succeeded
 /// or failed), or `Err` if dispatch itself failed.
-fn dispatch_ci_ref(
-    repo: &crate::quire::Repo,
-    pushed_at: &str,
-    push_ref: &crate::event::PushRef,
-) -> crate::Result<()> {
+fn dispatch_ci_ref(repo: &Repo, pushed_at: &str, push_ref: &PushRef) -> Result<()> {
     if !repo.has_ci_fnl(&push_ref.new_sha) {
         return Ok(());
     }
@@ -565,16 +559,16 @@ fn dispatch_ci_ref(
 }
 
 /// Evaluate ci.fnl at a given SHA and validate the job graph.
-fn eval_and_validate(repo: &crate::quire::Repo, sha: &str) -> crate::Result<()> {
+fn eval_and_validate(repo: &Repo, sha: &str) -> Result<()> {
     let source = repo.ci_fnl_source(sha)?;
-    let fennel = crate::fennel::Fennel::new()?;
+    let fennel = Fennel::new()?;
     let eval_result = eval_ci(&fennel, &source, &format!("{sha}:.quire/ci.fnl"))?;
     validate(&eval_result.jobs)?;
     Ok(())
 }
 
 /// Push updated refs to the configured mirror.
-async fn dispatch_mirror(quire: &crate::Quire, repo: crate::quire::Repo, event: &PushEvent) {
+async fn dispatch_mirror(quire: &crate::Quire, repo: Repo, event: &PushEvent) {
     let config = match repo.config() {
         Ok(c) => c,
         Err(e) => {
@@ -815,8 +809,8 @@ mod tests {
 
     // --- eval_ci tests ---
 
-    fn fennel() -> crate::fennel::Fennel {
-        crate::fennel::Fennel::new().expect("Fennel::new() should succeed")
+    fn fennel() -> Fennel {
+        Fennel::new().expect("Fennel::new() should succeed")
     }
 
     #[test]
diff --git a/src/error.rs b/src/error.rs
index b0c220e..f4aa52b 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,6 +1,7 @@
 use miette::Diagnostic;
 
 use crate::ci::ValidationError;
+use crate::fennel::FennelError;
 
 #[derive(Debug, thiserror::Error, Diagnostic)]
 pub enum Error {
@@ -19,7 +20,7 @@ pub enum Error {
     ConfigNotFound(String),
 
     #[error(transparent)]
-    Fennel(#[from] Box<crate::fennel::FennelError>),
+    Fennel(#[from] Box<FennelError>),
 
     #[error("CI validation failed")]
     #[related]
@@ -41,8 +42,8 @@ pub enum Error {
 
 pub type Result<T> = std::result::Result<T, Error>;
 
-impl From<crate::fennel::FennelError> for Error {
-    fn from(err: crate::fennel::FennelError) -> Self {
+impl From<FennelError> for Error {
+    fn from(err: FennelError) -> Self {
         Error::Fennel(Box::new(err))
     }
 }
diff --git a/src/quire.rs b/src/quire.rs
index e553e80..f7dcbc5 100644
--- a/src/quire.rs
+++ b/src/quire.rs
@@ -2,8 +2,10 @@ use std::path::{Path, PathBuf};
 
 use miette::{Context, IntoDiagnostic, Result, ensure};
 
+use crate::ci::Runs;
 use crate::fennel::Fennel;
 use crate::secret::SecretString;
+use crate::{Error, Result as AppResult};
 
 /// Parsed global configuration (`/var/quire/config.fnl`).
 ///
@@ -148,8 +150,8 @@ impl Repo {
     }
 
     /// Access CI runs for this repo.
-    pub fn runs(&self) -> crate::ci::Runs {
-        crate::ci::Runs::new(self.base_dir.join("runs").join(&self.name))
+    pub fn runs(&self) -> Runs {
+        Runs::new(self.base_dir.join("runs").join(&self.name))
     }
 
     /// Check whether this bare repo has `.quire/ci.fnl` at a given commit SHA.
@@ -165,7 +167,7 @@ impl Repo {
     }
 
     /// Read the contents of `.quire/ci.fnl` at a given commit SHA.
-    pub fn ci_fnl_source(&self, sha: &str) -> crate::Result<String> {
+    pub fn ci_fnl_source(&self, sha: &str) -> AppResult<String> {
         let output = self
             .git(&["show", &format!("{sha}:.quire/ci.fnl")])
             .stdout(std::process::Stdio::piped())
@@ -174,7 +176,7 @@ impl Repo {
 
         if !output.status.success() {
             let stderr = String::from_utf8_lossy(&output.stderr);
-            return Err(crate::Error::Git(format!(
+            return Err(Error::Git(format!(
                 "failed to read ci.fnl at {sha}: {stderr}"
             )));
         }
@@ -195,7 +197,7 @@ impl Repo {
         mirror: &MirrorConfig,
         token: &str,
         refs: &[&str],
-    ) -> crate::Result<()> {
+    ) -> AppResult<()> {
         let mut args = vec!["push", "--porcelain", &mirror.url];
         args.extend(refs);
 
@@ -209,7 +211,7 @@ impl Repo {
             .status()?;
 
         if !status.success() {
-            return Err(crate::Error::Git(format!("push to {} failed", mirror.url)));
+            return Err(Error::Git(format!("push to {} failed", mirror.url)));
         }
         Ok(())
     }
@@ -223,7 +225,7 @@ impl Repo {
     ///
     /// Returns an error when the config file exists but contains
     /// malformed Fennel — source labels point at the right line.
-    pub fn config(&self) -> crate::Result<RepoConfig> {
+    pub fn config(&self) -> AppResult<RepoConfig> {
         // Check whether HEAD exists first — exit code distinguishes this
         // reliably without parsing stderr text.
         let has_head = self
@@ -307,12 +309,10 @@ impl Quire {
     ///
     /// Re-reads on every call. Cheap at current call volume; revisit if
     /// `quire serve` ends up loading per-request.
-    pub fn global_config(&self) -> crate::Result<GlobalConfig> {
+    pub fn global_config(&self) -> AppResult<GlobalConfig> {
         let config_path = self.config_path();
         if !config_path.exists() {
-            return Err(crate::Error::ConfigNotFound(
-                config_path.display().to_string(),
-            ));
+            return Err(Error::ConfigNotFound(config_path.display().to_string()));
         }
         let fennel = Fennel::new()?;
         Ok(fennel.load_file(&config_path)?)
@@ -684,7 +684,7 @@ mod tests {
         };
         let err = q.global_config().unwrap_err();
         assert!(
-            matches!(err, crate::Error::ConfigNotFound(_)),
+            matches!(err, Error::ConfigNotFound(_)),
             "expected ConfigNotFound, got {err:?}"
         );
     }
@@ -830,7 +830,7 @@ mod tests {
         };
         let err = repo.push_to_mirror(&mirror, "x", &["main"]).unwrap_err();
         assert!(
-            matches!(err, crate::Error::Git(_)),
+            matches!(err, Error::Git(_)),
             "expected Git error, got {err:?}"
         );
     }
diff --git a/src/secret.rs b/src/secret.rs
index 3ac5a1a..0778bdb 100644
--- a/src/secret.rs
+++ b/src/secret.rs
@@ -1,6 +1,11 @@
 use std::path::PathBuf;
 use std::sync::OnceLock;
 
+use crate::{Error, Result};
+
+#[cfg(test)]
+use crate::fennel::Fennel;
+
 /// A string value that deserializes from either a plain literal or a file path.
 ///
 /// Fennel config can provide a secret as:
@@ -47,7 +52,7 @@ impl SecretString {
     /// the closure output to be `Sized` + ownable. Once `once_cell_try`
     /// stabilizes (allowing `OnceLock::get_or_try_init` with a separate error
     /// type), we can store a structured error instead of a string.
-    pub fn reveal(&self) -> crate::Result<&str> {
+    pub fn reveal(&self) -> Result<&str> {
         match &self.0 {
             SecretSource::Plain(s) => Ok(s.as_str()),
             SecretSource::File { path, resolved } => resolved
@@ -58,7 +63,7 @@ impl SecretString {
                 })
                 .as_ref()
                 .map(|s| s.as_str())
-                .map_err(|msg| crate::Error::SecretResolve(msg.clone())),
+                .map_err(|msg| Error::SecretResolve(msg.clone())),
         }
     }
 }
@@ -87,7 +92,7 @@ impl SecretString {
 }
 
 impl<'de> serde::Deserialize<'de> for SecretString {
-    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
     where
         D: serde::Deserializer<'de>,
     {
@@ -173,7 +178,7 @@ mod tests {
         let secret = SecretString::from_file(PathBuf::from("/no/such/file/ever").as_path());
         let err = secret.reveal().unwrap_err();
         assert!(
-            matches!(err, crate::Error::SecretResolve(_)),
+            matches!(err, Error::SecretResolve(_)),
             "expected SecretResolve error, got {err:?}"
         );
     }
@@ -246,7 +251,7 @@ mod tests {
             token: SecretString,
         }
 
-        let fennel = crate::fennel::Fennel::new().expect("fennel");
+        let fennel = Fennel::new().expect("fennel");
         let config: Config = fennel
             .load_string(r#"{:token "hunter2"}"#, "test.fnl")
             .expect("deserialize from fennel");
@@ -264,7 +269,7 @@ mod tests {
         let path = dir.path().join("pw");
         fs_err::write(&path, "secret_from_file\n").expect("write");
 
-        let fennel = crate::fennel::Fennel::new().expect("fennel");
+        let fennel = Fennel::new().expect("fennel");
         // Fennel table syntax: {:token {:file "/path"}}
         let source = format!("{{:token {{:file \"{}\"}}}}", path.display(),);
         let config: Config = fennel
diff --git a/src/server.rs b/src/server.rs
index e14547a..3bab935 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -6,6 +6,8 @@ use axum::routing::get;
 use miette::{Context, IntoDiagnostic, Result};
 
 use crate::Quire;
+use crate::ci;
+use crate::event::PushEvent;
 
 async fn health() -> &'static str {
     "ok"
@@ -93,7 +95,7 @@ async fn handle_event_connection(mut stream: tokio::net::UnixStream, quire: Quir
         }
     }
 
-    let event: crate::event::PushEvent = match serde_json::from_str(&line) {
+    let event: PushEvent = match serde_json::from_str(&line) {
         Ok(e) => e,
         Err(e) => {
             tracing::error!(%e, "failed to parse push event");
@@ -108,5 +110,5 @@ async fn handle_event_connection(mut stream: tokio::net::UnixStream, quire: Quir
         return;
     }
 
-    crate::ci::dispatch_push(&quire, &event).await;
+    ci::dispatch_push(&quire, &event).await;
 }