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
+106 -43
View File
@@ -161,7 +161,6 @@ pub fn load_pipeline_state(ctx: &AppContext) -> Result<PipelineState, String> {
Ok(state)
}
/// Build a map from story_id → AgentAssignment for all pending/running agents.
fn build_active_agent_map(ctx: &AppContext) -> HashMap<String, AgentAssignment> {
let agents = match ctx.agents.list_agents() {
@@ -196,7 +195,6 @@ fn build_active_agent_map(ctx: &AppContext) -> HashMap<String, AgentAssignment>
map
}
pub fn load_upcoming_stories(_ctx: &AppContext) -> Result<Vec<UpcomingStory>, String> {
use crate::pipeline_state::Stage;
@@ -244,9 +242,7 @@ pub fn load_upcoming_stories(_ctx: &AppContext) -> Result<Vec<UpcomingStory>, St
Ok(stories)
}
pub fn validate_story_dirs(
_root: &std::path::Path,
) -> Result<Vec<StoryValidationResult>, String> {
pub fn validate_story_dirs(_root: &std::path::Path) -> Result<Vec<StoryValidationResult>, String> {
use crate::pipeline_state::Stage;
let mut results = Vec::new();
@@ -309,7 +305,12 @@ pub(super) fn read_story_content(_project_root: &Path, story_id: &str) -> Result
}
/// Write story content to the DB content store and CRDT.
pub(super) fn write_story_content(_project_root: &Path, story_id: &str, stage: &str, content: &str) {
pub(super) fn write_story_content(
_project_root: &Path,
story_id: &str,
stage: &str,
content: &str,
) {
crate::db::write_item_with_content(story_id, stage, content);
}
@@ -321,13 +322,16 @@ pub(super) fn story_stage(story_id: &str) -> Option<String> {
.map(|item| item.stage.dir_name().to_string())
}
/// Replace the content of a named `## Section` in a story file.
///
/// Finds the first occurrence of `## {section_name}` and replaces everything
/// until the next `##` heading (or end of file) with the provided text.
/// Returns an error if the section is not found.
pub(super) fn replace_section_content(content: &str, section_name: &str, new_text: &str) -> Result<String, String> {
pub(super) fn replace_section_content(
content: &str,
section_name: &str,
new_text: &str,
) -> Result<String, String> {
let lines: Vec<&str> = content.lines().collect();
let heading = format!("## {section_name}");
@@ -517,18 +521,24 @@ mod tests {
("4_merge", "9840_story_merge"),
("5_done", "9850_story_done"),
] {
crate::db::write_item_with_content(
id,
stage,
&format!("---\nname: {id}\n---\n"),
);
crate::db::write_item_with_content(id, stage, &format!("---\nname: {id}\n---\n"));
}
let ctx = crate::http::context::AppContext::new_test(root);
let state = load_pipeline_state(&ctx).unwrap();
assert!(state.backlog.iter().any(|s| s.story_id == "9810_story_upcoming"));
assert!(state.current.iter().any(|s| s.story_id == "9820_story_current"));
assert!(
state
.backlog
.iter()
.any(|s| s.story_id == "9810_story_upcoming")
);
assert!(
state
.current
.iter()
.any(|s| s.story_id == "9820_story_current")
);
assert!(state.qa.iter().any(|s| s.story_id == "9830_story_qa"));
assert!(state.merge.iter().any(|s| s.story_id == "9840_story_merge"));
assert!(state.done.iter().any(|s| s.story_id == "9850_story_done"));
@@ -558,12 +568,23 @@ mod tests {
);
let ctx = crate::http::context::AppContext::new_test(root);
ctx.agents.inject_test_agent("9860_story_test", "coder-1", crate::agents::AgentStatus::Running);
ctx.agents.inject_test_agent(
"9860_story_test",
"coder-1",
crate::agents::AgentStatus::Running,
);
let state = load_pipeline_state(&ctx).unwrap();
let item = state.current.iter().find(|s| s.story_id == "9860_story_test").unwrap();
assert!(item.agent.is_some(), "running agent should appear on work item");
let item = state
.current
.iter()
.find(|s| s.story_id == "9860_story_test")
.unwrap();
assert!(
item.agent.is_some(),
"running agent should appear on work item"
);
let agent = item.agent.as_ref().unwrap();
assert_eq!(agent.agent_name, "coder-1");
assert_eq!(agent.status, "running");
@@ -582,11 +603,19 @@ mod tests {
);
let ctx = crate::http::context::AppContext::new_test(root);
ctx.agents.inject_test_agent("9861_story_done", "coder-1", crate::agents::AgentStatus::Completed);
ctx.agents.inject_test_agent(
"9861_story_done",
"coder-1",
crate::agents::AgentStatus::Completed,
);
let state = load_pipeline_state(&ctx).unwrap();
let item = state.current.iter().find(|s| s.story_id == "9861_story_done").unwrap();
let item = state
.current
.iter()
.find(|s| s.story_id == "9861_story_done")
.unwrap();
assert!(
item.agent.is_none(),
"completed agent should not appear on work item"
@@ -606,12 +635,23 @@ mod tests {
);
let ctx = crate::http::context::AppContext::new_test(root);
ctx.agents.inject_test_agent("9862_story_pending", "coder-1", crate::agents::AgentStatus::Pending);
ctx.agents.inject_test_agent(
"9862_story_pending",
"coder-1",
crate::agents::AgentStatus::Pending,
);
let state = load_pipeline_state(&ctx).unwrap();
let item = state.current.iter().find(|s| s.story_id == "9862_story_pending").unwrap();
assert!(item.agent.is_some(), "pending agent should appear on work item");
let item = state
.current
.iter()
.find(|s| s.story_id == "9862_story_pending")
.unwrap();
assert!(
item.agent.is_some(),
"pending agent should appear on work item"
);
assert_eq!(item.agent.as_ref().unwrap().status, "pending");
}
@@ -633,10 +673,18 @@ mod tests {
let ctx = crate::http::context::AppContext::new_test(tmp.path().to_path_buf());
let state = load_pipeline_state(&ctx).unwrap();
let dependent = state.backlog.iter().find(|s| s.story_id == "9863_story_dependent").unwrap();
let dependent = state
.backlog
.iter()
.find(|s| s.story_id == "9863_story_dependent")
.unwrap();
assert_eq!(dependent.depends_on, Some(vec![10, 11]));
let independent = state.backlog.iter().find(|s| s.story_id == "9864_story_independent").unwrap();
let independent = state
.backlog
.iter()
.find(|s| s.story_id == "9864_story_independent")
.unwrap();
assert_eq!(independent.depends_on, None);
}
@@ -657,9 +705,15 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let ctx = crate::http::context::AppContext::new_test(tmp.path().to_path_buf());
let stories = load_upcoming_stories(&ctx).unwrap();
let s1 = stories.iter().find(|s| s.story_id == "9870_story_view_upcoming").unwrap();
let s1 = stories
.iter()
.find(|s| s.story_id == "9870_story_view_upcoming")
.unwrap();
assert_eq!(s1.name.as_deref(), Some("View Upcoming"));
let s2 = stories.iter().find(|s| s.story_id == "9871_story_worktree").unwrap();
let s2 = stories
.iter()
.find(|s| s.story_id == "9871_story_worktree")
.unwrap();
assert_eq!(s2.name.as_deref(), Some("Worktree Orchestration"));
}
@@ -696,24 +750,29 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let results = validate_story_dirs(tmp.path()).unwrap();
let r1 = results.iter().find(|r| r.story_id == "9873_story_todos").unwrap();
let r1 = results
.iter()
.find(|r| r.story_id == "9873_story_todos")
.unwrap();
assert!(r1.valid);
let r2 = results.iter().find(|r| r.story_id == "9874_story_front_matter").unwrap();
let r2 = results
.iter()
.find(|r| r.story_id == "9874_story_front_matter")
.unwrap();
assert!(r2.valid);
}
#[test]
fn validate_story_dirs_missing_front_matter() {
crate::db::ensure_content_store();
crate::db::write_item_with_content(
"9875_story_no_fm",
"2_current",
"# No front matter\n",
);
crate::db::write_item_with_content("9875_story_no_fm", "2_current", "# No front matter\n");
let tmp = tempfile::tempdir().unwrap();
let results = validate_story_dirs(tmp.path()).unwrap();
let r = results.iter().find(|r| r.story_id == "9875_story_no_fm").unwrap();
let r = results
.iter()
.find(|r| r.story_id == "9875_story_no_fm")
.unwrap();
assert!(!r.valid);
assert_eq!(r.error.as_deref(), Some("Missing front matter"));
}
@@ -729,7 +788,10 @@ mod tests {
let tmp = tempfile::tempdir().unwrap();
let results = validate_story_dirs(tmp.path()).unwrap();
let r = results.iter().find(|r| r.story_id == "9876_story_no_name").unwrap();
let r = results
.iter()
.find(|r| r.story_id == "9876_story_no_name")
.unwrap();
assert!(!r.valid);
let err = r.error.as_deref().unwrap();
assert!(err.contains("Missing 'name' field"));
@@ -789,11 +851,7 @@ mod tests {
#[test]
fn next_item_number_increments_beyond_existing() {
crate::db::ensure_content_store();
crate::db::write_item_with_content(
"9877_story_foo",
"1_backlog",
"---\nname: Foo\n---\n",
);
crate::db::write_item_with_content("9877_story_foo", "1_backlog", "---\nname: Foo\n---\n");
let tmp = tempfile::tempdir().unwrap();
assert!(next_item_number(tmp.path()).unwrap() >= 9878);
}
@@ -824,7 +882,8 @@ mod tests {
#[test]
fn replace_or_append_section_appends_when_absent() {
let contents = "---\nname: T\n---\n# Story\n";
let new = replace_or_append_section(contents, "## Test Results", "## Test Results\n\nfoo\n");
let new =
replace_or_append_section(contents, "## Test Results", "## Test Results\n\nfoo\n");
assert!(new.contains("## Test Results"));
assert!(new.contains("foo"));
assert!(new.contains("# Story"));
@@ -833,7 +892,11 @@ mod tests {
#[test]
fn replace_or_append_section_replaces_existing() {
let contents = "# Story\n\n## Test Results\n\nold content\n\n## Other\n\nother content\n";
let new = replace_or_append_section(contents, "## Test Results", "## Test Results\n\nnew content\n");
let new = replace_or_append_section(
contents,
"## Test Results",
"## Test Results\n\nnew content\n",
);
assert!(new.contains("new content"));
assert!(!new.contains("old content"));
assert!(new.contains("## Other"));