fix: add --all to cargo fmt in script/test and autoformat codebase

cargo fmt without --all fails with "Failed to find targets" in
workspace repos. This was blocking every story's gates. Also ran
cargo fmt --all to fix all existing formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-13 14:07:08 +00:00
parent ed2526ce41
commit 845b85e7a7
128 changed files with 3566 additions and 2395 deletions
+61 -41
View File
@@ -6,14 +6,15 @@ use std::path::Path;
use std::sync::{Arc, Mutex};
use tokio::sync::broadcast;
use super::super::runtime::{
AgentRuntime, ClaudeCodeRuntime, GeminiRuntime, OpenAiRuntime, RuntimeContext,
};
use super::super::{
AgentEvent, AgentInfo, AgentStatus, PipelineStage, agent_config_stage,
pipeline_stage,
AgentEvent, AgentInfo, AgentStatus, PipelineStage, agent_config_stage, pipeline_stage,
};
use super::types::{PendingGuard, StoryAgent, composite_key};
use super::{AgentPool, auto_assign};
use super::worktree::find_active_story_stage;
use super::super::runtime::{AgentRuntime, ClaudeCodeRuntime, GeminiRuntime, OpenAiRuntime, RuntimeContext};
use super::{AgentPool, auto_assign};
impl AgentPool {
/// Start an agent for a story: load config, create worktree, spawn agent.
@@ -102,7 +103,9 @@ impl AgentPool {
// the auto_assign path (bug 379).
let front_matter_agent: Option<String> = if agent_name.is_none() {
crate::db::read_content(story_id).and_then(|contents| {
crate::io::story_metadata::parse_front_matter(&contents).ok()?.agent
crate::io::story_metadata::parse_front_matter(&contents)
.ok()?
.agent
})
} else {
None
@@ -446,7 +449,10 @@ impl AgentPool {
let run_result = match runtime_name {
"claude-code" => {
let runtime = ClaudeCodeRuntime::new(child_killers_clone.clone(), watcher_tx_clone.clone());
let runtime = ClaudeCodeRuntime::new(
child_killers_clone.clone(),
watcher_tx_clone.clone(),
);
let ctx = RuntimeContext {
story_id: sid.clone(),
agent_name: aname.clone(),
@@ -514,7 +520,10 @@ impl AgentPool {
.find_agent(&aname)
.and_then(|a| a.model.clone());
let record = crate::agents::token_usage::build_record(
&sid, &aname, model, usage.clone(),
&sid,
&aname,
model,
usage.clone(),
);
if let Err(e) = crate::agents::token_usage::append_record(pr, &record) {
slog_error!(
@@ -568,15 +577,13 @@ impl AgentPool {
// re-dispatches a new mergemaster if the story still needs
// merging. This avoids an async call to start_agent inside
// a tokio::spawn (which would require Send).
let _ = watcher_tx_clone.send(
crate::io::watcher::WatcherEvent::WorkItem {
stage: "4_merge".to_string(),
item_id: sid.clone(),
action: "reassign".to_string(),
commit_msg: String::new(),
from_stage: None,
},
);
let _ = watcher_tx_clone.send(crate::io::watcher::WatcherEvent::WorkItem {
stage: "4_merge".to_string(),
item_id: sid.clone(),
action: "reassign".to_string(),
commit_msg: String::new(),
from_stage: None,
});
} else {
// Server-owned completion: run acceptance gates automatically
// when the agent process exits normally.
@@ -712,7 +719,9 @@ stage = "coder"
pool.inject_test_agent("story-1", "coder-1", AgentStatus::Running);
pool.inject_test_agent("story-2", "coder-2", AgentStatus::Pending);
let result = pool.start_agent(tmp.path(), "story-3", None, None, None).await;
let result = pool
.start_agent(tmp.path(), "story-3", None, None, None)
.await;
assert!(result.is_err());
let err = result.unwrap_err();
assert!(
@@ -744,7 +753,9 @@ stage = "coder"
let pool = AgentPool::new_test(3001);
pool.inject_test_agent("story-1", "coder-1", AgentStatus::Running);
let result = pool.start_agent(tmp.path(), "story-3", None, None, None).await;
let result = pool
.start_agent(tmp.path(), "story-3", None, None, None)
.await;
assert!(result.is_err());
let err = result.unwrap_err();
@@ -782,7 +793,9 @@ stage = "coder"
let pool = AgentPool::new_test(3001);
let result = pool.start_agent(tmp.path(), "story-5", None, None, None).await;
let result = pool
.start_agent(tmp.path(), "story-5", None, None, None)
.await;
match result {
Ok(_) => {}
Err(e) => {
@@ -843,7 +856,9 @@ stage = "coder"
let pool = AgentPool::new_test(3001);
pool.inject_test_agent("story-a", "qa", AgentStatus::Running);
let result = pool.start_agent(root, "story-b", Some("qa"), None, None).await;
let result = pool
.start_agent(root, "story-b", Some("qa"), None, None)
.await;
assert!(
result.is_err(),
@@ -870,7 +885,9 @@ stage = "coder"
let pool = AgentPool::new_test(3001);
pool.inject_test_agent("story-a", "qa", AgentStatus::Completed);
let result = pool.start_agent(root, "story-b", Some("qa"), None, None).await;
let result = pool
.start_agent(root, "story-b", Some("qa"), None, None)
.await;
if let Err(ref e) = result {
assert!(
@@ -962,7 +979,9 @@ stage = "coder"
let pool = AgentPool::new_test(3099);
pool.inject_test_agent("story-x", "qa", AgentStatus::Running);
let result = pool.start_agent(root, "story-y", Some("qa"), None, None).await;
let result = pool
.start_agent(root, "story-y", Some("qa"), None, None)
.await;
assert!(result.is_err());
let err = result.unwrap_err();
@@ -1247,11 +1266,7 @@ stage = "coder"
)
.unwrap();
crate::db::ensure_content_store();
crate::db::write_item_with_content(
"310_story_foo",
"2_current",
"---\nname: Foo\n---\n",
);
crate::db::write_item_with_content("310_story_foo", "2_current", "---\nname: Foo\n---\n");
let pool = AgentPool::new_test(3099);
let result = pool
@@ -1323,11 +1338,7 @@ stage = "coder"
)
.unwrap();
crate::db::ensure_content_store();
crate::db::write_item_with_content(
"55_story_baz",
"4_merge",
"---\nname: Baz\n---\n",
);
crate::db::write_item_with_content("55_story_baz", "4_merge", "---\nname: Baz\n---\n");
let pool = AgentPool::new_test(3099);
let result = pool
@@ -1459,7 +1470,13 @@ stage = "coder"
let pool = AgentPool::new_test(3098);
let result = pool
.start_agent(root, "502_story_split_brain", Some("mergemaster"), None, None)
.start_agent(
root,
"502_story_split_brain",
Some("mergemaster"),
None,
None,
)
.await;
// Stage check must not reject mergemaster.
@@ -1475,11 +1492,15 @@ stage = "coder"
// Before the fix, line 53 of start.rs would have demoted it to
// 2_current/ via move_story_to_current finding the 1_backlog shadow.
assert!(
sk_dir.join("work/4_merge/502_story_split_brain.md").exists(),
sk_dir
.join("work/4_merge/502_story_split_brain.md")
.exists(),
"story must still be in 4_merge/ after start_agent(mergemaster, ...)"
);
assert!(
!sk_dir.join("work/2_current/502_story_split_brain.md").exists(),
!sk_dir
.join("work/2_current/502_story_split_brain.md")
.exists(),
"story must NOT have been demoted to 2_current/ — that's bug 502"
);
}
@@ -1564,11 +1585,7 @@ stage = "coder"
)
.unwrap();
let story_content = "---\nname: Test Story\nagent: coder-opus\n---\n# Story 368\n";
std::fs::write(
backlog.join("368_story_test.md"),
story_content,
)
.unwrap();
std::fs::write(backlog.join("368_story_test.md"), story_content).unwrap();
// Also write to the filesystem current dir and content store so that
// start_agent reads the correct front matter even when another test has
// left a stale entry for "368_story_test" in the global CRDT.
@@ -1583,7 +1600,10 @@ stage = "coder"
let result = pool
.start_agent(tmp.path(), "368_story_test", None, None, None)
.await;
assert!(result.is_err(), "expected error when preferred agent is busy");
assert!(
result.is_err(),
"expected error when preferred agent is busy"
);
let err = result.unwrap_err();
assert!(
err.contains("coder-opus"),