From beca13308287e3e354477f372b578e1b5820b0ab Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Mon, 14 Sep 2026 11:03:43 -0600 Subject: [PATCH] style: removed unneccessary path prefixes and organized imports --- src/config/request_context.rs | 29 +++++++++++++++-------------- src/function/user_interaction.rs | 12 +++++++----- src/rag/mod.rs | 5 +++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/config/request_context.rs b/src/config/request_context.rs index 2421809..b669ed6 100644 --- a/src/config/request_context.rs +++ b/src/config/request_context.rs @@ -5268,6 +5268,7 @@ mod tests { use serial_test::serial; use std::fs::{create_dir_all, remove_dir_all, write}; use std::path::PathBuf; + use std::process::Command; use std::time::{Instant, SystemTime, UNIX_EPOCH}; use std::{env, mem}; @@ -8505,7 +8506,7 @@ mod tests { #[test] fn review_gauntlet_readme_states_retry_and_incomplete_contract() { - let readmes = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("assets/agents"); + let readmes = Path::new(env!("CARGO_MANIFEST_DIR")).join("assets/agents"); // Windows checkouts carry CRLF; the paragraph assertion below spans line breaks. let gauntlet = read_to_string(readmes.join("review-gauntlet/README.md")) .unwrap() @@ -9050,11 +9051,11 @@ mod tests { // Scripts' load_state() prefers GRAPH_STATE_FILE over GRAPH_STATE, so an // inherited live state file (adversary verifying this repo) must not win. - fn adversary_script_command(script: &str, state: &serde_json::Value) -> std::process::Command { + fn adversary_script_command(script: &str, state: &serde_json::Value) -> Command { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/adversary/scripts") .join(script); - let mut cmd = std::process::Command::new("python3"); + let mut cmd = Command::new("python3"); cmd.arg(&path) .env("GRAPH_STATE", state.to_string()) .env_remove("GRAPH_STATE_FILE"); @@ -9591,7 +9592,7 @@ mod tests { ); let alive = |pid: &str| { - std::process::Command::new("kill") + Command::new("kill") .args(["-0", pid]) .output() .unwrap() @@ -10950,7 +10951,7 @@ mod tests { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/review-gauntlet/scripts") .join(script); - let out = std::process::Command::new("python3") + let out = Command::new("python3") .arg(&path) .env("GRAPH_STATE", state.to_string()) .env_remove("GRAPH_STATE_FILE") @@ -13246,7 +13247,7 @@ mod tests { ); } let adversary_verdict = read_to_string( - std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/adversary/scripts/verdict.py"), ) .unwrap(); @@ -13403,11 +13404,11 @@ mod tests { eprintln!("skipping: python3 not available"); return; } - let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + let path = Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/review-gauntlet/scripts/build_items.py"); let state = json!({"forced_lanes": ["code-review", "adversary"], "gauntlet_started_at": 5.0}); - let out = std::process::Command::new("python3") + let out = Command::new("python3") .arg(&path) .env("GRAPH_STATE", state.to_string()) .env_remove("GRAPH_STATE_FILE") @@ -13459,7 +13460,7 @@ mod tests { eprintln!("skipping: python3 not available"); return; } - let dir = utils::temp_file("-gauntlet-signals-", ""); + let dir = temp_file("-gauntlet-signals-", ""); create_dir_all(&dir).unwrap(); let project_dir = dir.to_string_lossy().to_string(); let out = run_gauntlet_script( @@ -13585,7 +13586,7 @@ mod tests { fn gauntlet_retry_budget_fits_inside_graph_timeout() { use crate::graph::NodeType; const OTHER_STAGES_MARGIN_SECS: u64 = 1200; - let script = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + let script = Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/review-gauntlet/scripts/retry_gate.py"); let source = read_to_string(&script).unwrap(); let line = source @@ -13707,7 +13708,7 @@ mod tests { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/code-reviewer/scripts") .join(script); - let out = std::process::Command::new("python3") + let out = Command::new("python3") .arg(&path) .env("GRAPH_STATE", raw_state) .env_remove("GRAPH_STATE_FILE") @@ -14517,7 +14518,7 @@ mod tests { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/finding-verifier/scripts") .join(script); - let out = std::process::Command::new("python3") + let out = Command::new("python3") .arg(&path) .env("GRAPH_STATE", raw_state) .env_remove("GRAPH_STATE_FILE") @@ -14819,7 +14820,7 @@ mod tests { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/step-runner/scripts") .join(script); - let out = std::process::Command::new("bash") + let out = Command::new("bash") .arg(&path) .env("GRAPH_STATE", state.to_string()) .env_remove("GRAPH_STATE_FILE") @@ -15123,7 +15124,7 @@ mod tests { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .join("assets/agents/deep-research/scripts") .join(script); - let out = std::process::Command::new("python3") + let out = Command::new("python3") .arg(&path) .env("GRAPH_STATE", raw_state) .env_remove("GRAPH_STATE_FILE") diff --git a/src/function/user_interaction.rs b/src/function/user_interaction.rs index d698fa7..1e62d19 100644 --- a/src/function/user_interaction.rs +++ b/src/function/user_interaction.rs @@ -346,6 +346,8 @@ fn parse_options(args: &Value) -> Result> { #[cfg(test)] mod tests { use super::*; + use std::fs; + use std::path::{Path, PathBuf}; #[test] fn headless_select_returns_structured_json() { @@ -431,9 +433,9 @@ mod tests { concat!("escalation_timeout:", " 300"), concat!("default:", " 5 minutes"), ]; - let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); + let root = Path::new(env!("CARGO_MANIFEST_DIR")); let example = root.join("config.agent.example.yaml"); - let example_text = std::fs::read_to_string(&example).unwrap(); + let example_text = fs::read_to_string(&example).unwrap(); for needle in ["escalation_timeout: 0", "0 = wait indefinitely"] { assert!( example_text.contains(needle), @@ -454,7 +456,7 @@ mod tests { let mut hits = Vec::new(); for path in &files { - let text = String::from_utf8_lossy(&std::fs::read(path).unwrap()).into_owned(); + let text = String::from_utf8_lossy(&fs::read(path).unwrap()).into_owned(); for needle in needles { if text.contains(needle) { hits.push(format!("{}: {needle:?}", path.display())); @@ -468,8 +470,8 @@ mod tests { ); } - fn collect_files(dir: &std::path::Path, out: &mut Vec) { - for entry in std::fs::read_dir(dir).unwrap().flatten() { + fn collect_files(dir: &Path, out: &mut Vec) { + for entry in fs::read_dir(dir).unwrap().flatten() { let path = entry.path(); if path.is_dir() { collect_files(&path, out); diff --git a/src/rag/mod.rs b/src/rag/mod.rs index a88af63..6f5c627 100644 --- a/src/rag/mod.rs +++ b/src/rag/mod.rs @@ -2281,6 +2281,7 @@ where mod tests { use super::*; use std::path::PathBuf; + use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{SystemTime, UNIX_EPOCH}; struct TempDir { @@ -2293,12 +2294,12 @@ mod tests { // (coarse clocks hand the same tick to concurrent callers, so two // tests would share a directory and overwrite each other's files); // a process-wide counter makes every name distinct. - static SEQ: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); + static SEQ: AtomicU64 = AtomicU64::new(0); let nanos = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_nanos(); - let seq = SEQ.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let seq = SEQ.fetch_add(1, Ordering::Relaxed); let unique = format!("{nanos}-{seq}"); let path = env::temp_dir().join(format!("coyote-rag-{tag}-{unique}")); fs::create_dir_all(&path).unwrap();