feat(929): delete db/yaml_legacy.rs entirely — CRDT is the sole source of truth
Final 929 sweep: every YAML-shaped helper is gone. No production code
parses or writes YAML front matter anywhere.
Surface removed:
- db/yaml_legacy.rs (FrontMatter/StoryMetadata structs, parse_front_matter,
set_front_matter_field, yaml_residue marker) — file deleted.
- ItemMeta::from_yaml — deleted; callers pass typed ItemMeta::named(...) or
ItemMeta::default() and use typed CRDT setters (set_depends_on,
set_blocked, set_retry_count, set_agent, set_qa_mode, set_review_hold,
set_item_type, set_epic, set_mergemaster_attempted) for the rest.
- write_coverage_baseline_to_story_file + read_coverage_percent_from_json —
the coverage_baseline YAML field was write-only (nothing read it back);
removed along with its caller in agent_tools/lifecycle.rs.
- update_story_in_file's generic `front_matter` HashMap parameter —
tool_update_story now intercepts every known field name and routes it
to a typed CRDT setter; unknown keys are rejected with an explicit error
pointing at the typed setters. The function only takes user_story /
description sections now.
- All 117 ItemMeta::from_yaml callsites migrated. Where tests previously
passed a YAML-shaped content blob and relied on the helper to extract
name/depends_on/blocked/agent/qa, they now pass:
write_item_with_content(id, stage, content, ItemMeta::named("Foo"))
crate::crdt_state::set_depends_on(id, &[...]) // when needed
crate::crdt_state::set_blocked(id, true) // when needed
crate::crdt_state::set_agent(id, Some("...")) // when needed
- write_story_content + write_story_file (test helper) now take an
explicit `name: Option<&str>` instead of parsing it from content.
- db::ops::move_item_stage stopped re-parsing YAML on every stage
transition; metadata is read straight from the CRDT view when mirroring
the row into SQLite.
New CRDT setters added for symmetry:
- crdt_state::set_name (mirrors set_agent — explicit name updates).
cargo fmt --check, clippy --all-targets -- -D warnings, and the
2830-test suite all pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9912_story_foo.md",
|
||||
"---\nname: Foo\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = depends_cmd_with_root(tmp.path(), "9912 abc").unwrap();
|
||||
assert!(
|
||||
@@ -182,6 +183,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9910_story_foo.md",
|
||||
"---\nname: Foo\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = depends_cmd_with_root(tmp.path(), "9910 477 478").unwrap();
|
||||
assert!(
|
||||
@@ -212,6 +214,7 @@ mod tests {
|
||||
"2_current",
|
||||
"9911_story_bar.md",
|
||||
"---\nname: Bar\n---\n",
|
||||
None,
|
||||
);
|
||||
// Pre-seed CRDT with deps so we can verify clearing.
|
||||
crate::crdt_state::set_depends_on("9911_story_bar", &[477]);
|
||||
@@ -248,6 +251,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"8790_story_chat_dep.md",
|
||||
"---\nname: Chat Dep\n---\n",
|
||||
None,
|
||||
);
|
||||
|
||||
let out = depends_cmd_with_root(tmp.path(), "8790 500 501").unwrap();
|
||||
@@ -282,6 +286,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9920_story_scr.md",
|
||||
"---\nname: SCR\n---\n",
|
||||
None,
|
||||
);
|
||||
|
||||
// Set to [1, 2, 3].
|
||||
@@ -322,6 +327,7 @@ mod tests {
|
||||
"3_qa",
|
||||
"9913_story_inqa.md",
|
||||
"---\nname: In QA\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = depends_cmd_with_root(tmp.path(), "9913 100").unwrap();
|
||||
assert!(
|
||||
|
||||
@@ -212,6 +212,7 @@ mod tests {
|
||||
"2_current",
|
||||
"55551_story_no_worktree.md",
|
||||
"---\nname: No Worktree\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = diff_cmd(tmp.path(), "55551").unwrap();
|
||||
assert!(
|
||||
|
||||
@@ -193,7 +193,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"9940_story_freezeme.md",
|
||||
"---\nname: Freeze Me\n---\n# Story\n",
|
||||
"# Story\n",
|
||||
Some("Freeze Me"),
|
||||
);
|
||||
let output = freeze_cmd_with_root(tmp.path(), "9940").unwrap();
|
||||
assert!(
|
||||
@@ -219,7 +220,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"9941_story_frozen.md",
|
||||
"---\nname: Frozen Story\n---\n# Story\n",
|
||||
"# Story\n",
|
||||
Some("Frozen Story"),
|
||||
);
|
||||
// Freeze first.
|
||||
let freeze_out = freeze_cmd_with_root(tmp.path(), "9941").unwrap();
|
||||
@@ -253,6 +255,7 @@ mod tests {
|
||||
"2_current",
|
||||
"9942_story_notfrozen.md",
|
||||
"---\nname: Not Frozen\n---\n# Story\n",
|
||||
None,
|
||||
);
|
||||
let output = unfreeze_cmd_with_root(tmp.path(), "9942").unwrap();
|
||||
assert!(
|
||||
@@ -271,6 +274,7 @@ mod tests {
|
||||
"2_current",
|
||||
"9943_story_alreadyfrozen.md",
|
||||
"---\nname: Already Frozen\n---\n# Story\n",
|
||||
None,
|
||||
);
|
||||
// Freeze it first.
|
||||
freeze_cmd_with_root(tmp.path(), "9943").unwrap();
|
||||
|
||||
@@ -202,6 +202,7 @@ mod tests {
|
||||
"2_current",
|
||||
"77_story_no_log.md",
|
||||
"---\nname: No Log\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = logs_cmd(tmp.path(), "77").unwrap();
|
||||
assert!(
|
||||
@@ -221,6 +222,7 @@ mod tests {
|
||||
"2_current",
|
||||
"88_story_has_log.md",
|
||||
"---\nname: Has Log\n---\n",
|
||||
None,
|
||||
);
|
||||
// Write a log file in the expected location.
|
||||
let log_dir = tmp
|
||||
|
||||
@@ -170,7 +170,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"1_backlog",
|
||||
"42_story_some_feature.md",
|
||||
"---\nname: Some Feature\n---\n\n# Story 42\n",
|
||||
"# Story 42\n",
|
||||
Some("Some Feature"),
|
||||
);
|
||||
|
||||
let output = move_cmd_with_root(tmp.path(), "42 current").unwrap();
|
||||
@@ -201,7 +202,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"8810_story_case_test.md",
|
||||
"---\nname: CaseTest\n---\n",
|
||||
"",
|
||||
Some("CaseTest"),
|
||||
);
|
||||
let output = move_cmd_with_root(tmp.path(), "8810 BACKLOG").unwrap();
|
||||
assert!(
|
||||
@@ -218,6 +220,7 @@ mod tests {
|
||||
"2_current",
|
||||
"5_story_already_current.md",
|
||||
"---\nname: Already Current\n---\n",
|
||||
None,
|
||||
);
|
||||
// Moving to the stage it's already in should return a success message.
|
||||
let output = move_cmd_with_root(tmp.path(), "5 current").unwrap();
|
||||
|
||||
@@ -209,6 +209,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"305_story_show_command.md",
|
||||
"---\nname: Show command\n---\n\n# Story 305\n\nFull story text here.",
|
||||
None,
|
||||
);
|
||||
let output = show_cmd_with_root(tmp.path(), "305").unwrap();
|
||||
assert!(
|
||||
@@ -225,6 +226,7 @@ mod tests {
|
||||
"2_current",
|
||||
"42_story_do_something.md",
|
||||
"---\nname: Do something\n---\n\n# Story 42\n\nIn progress.",
|
||||
None,
|
||||
);
|
||||
let output = show_cmd_with_root(tmp.path(), "42").unwrap();
|
||||
assert!(
|
||||
@@ -241,6 +243,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"7_bug_crash_on_login.md",
|
||||
"---\nname: Crash on login\n---\n\n## Symptom\n\nCrashes.",
|
||||
None,
|
||||
);
|
||||
let output = show_cmd_with_root(tmp.path(), "7").unwrap();
|
||||
assert!(
|
||||
|
||||
@@ -630,10 +630,8 @@ fn merge_item_det_merge_running_preferred_over_failure() {
|
||||
crate::db::write_item_with_content(
|
||||
"906_story_det_over_fail",
|
||||
"4_merge",
|
||||
"---\nname: Det Over Fail\nmerge_failure: \"old failure\"\n---\n",
|
||||
crate::db::ItemMeta::from_yaml(
|
||||
"---\nname: Det Over Fail\nmerge_failure: \"old failure\"\n---\n",
|
||||
),
|
||||
"---\nname: Det Over Fail\n---\n",
|
||||
crate::db::ItemMeta::named("Det Over Fail"),
|
||||
);
|
||||
// Record a running deterministic merge in the CRDT.
|
||||
crate::crdt_state::write_merge_job("906_story_det_over_fail", "running", 0.0, None, None);
|
||||
|
||||
@@ -307,7 +307,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"99_story_my_feature.md",
|
||||
"---\nname: My Feature\n---\n\n## Acceptance Criteria\n\n- [ ] First thing\n- [x] Done thing\n",
|
||||
"## Acceptance Criteria\n\n- [ ] First thing\n- [x] Done thing\n",
|
||||
Some("My Feature"),
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "99").unwrap();
|
||||
assert!(output.contains("99"), "should show story number: {output}");
|
||||
@@ -328,7 +329,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"1_backlog",
|
||||
"9901_story_backlog_item.md",
|
||||
"---\nname: Backlog Item\n---\n",
|
||||
"",
|
||||
Some("Backlog Item"),
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "9901").unwrap();
|
||||
assert!(
|
||||
@@ -352,7 +354,8 @@ mod tests {
|
||||
tmp.path(),
|
||||
"3_qa",
|
||||
"9902_story_qa_item.md",
|
||||
"---\nname: QA Item\n---\n",
|
||||
"",
|
||||
Some("QA Item"),
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "9902").unwrap();
|
||||
assert!(
|
||||
@@ -373,6 +376,7 @@ mod tests {
|
||||
"2_current",
|
||||
"99_story_criteria_test.md",
|
||||
"---\nname: Criteria Test\n---\n\n- [ ] First thing\n- [x] Done thing\n- [ ] Second thing\n",
|
||||
None,
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "99").unwrap();
|
||||
assert!(
|
||||
@@ -398,6 +402,7 @@ mod tests {
|
||||
"2_current",
|
||||
"55_story_blocked_story.md",
|
||||
"---\nname: Blocked Story\nblocked: true\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "55").unwrap();
|
||||
assert!(
|
||||
@@ -413,8 +418,10 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"55_story_agent_story.md",
|
||||
"---\nname: Agent Story\nagent: coder-1\n---\n",
|
||||
"",
|
||||
Some("Agent Story"),
|
||||
);
|
||||
crate::crdt_state::set_agent("55_story_agent_story", Some("coder-1"));
|
||||
let output = status_triage_cmd(tmp.path(), "55").unwrap();
|
||||
assert!(
|
||||
output.contains("coder-1"),
|
||||
@@ -429,8 +436,10 @@ mod tests {
|
||||
tmp.path(),
|
||||
"2_current",
|
||||
"55_story_depends_story.md",
|
||||
"---\nname: Depends Story\ndepends_on: [477, 478]\n---\n",
|
||||
"",
|
||||
Some("Depends Story"),
|
||||
);
|
||||
crate::crdt_state::set_depends_on("55_story_depends_story", &[477, 478]);
|
||||
let output = status_triage_cmd(tmp.path(), "55").unwrap();
|
||||
assert!(
|
||||
output.contains("depends_on") || output.contains("#477"),
|
||||
@@ -450,6 +459,7 @@ mod tests {
|
||||
"2_current",
|
||||
"77_story_no_worktree.md",
|
||||
"---\nname: No Worktree\n---\n",
|
||||
None,
|
||||
);
|
||||
let output = status_triage_cmd(tmp.path(), "77").unwrap();
|
||||
// Branch name should still appear
|
||||
|
||||
@@ -181,6 +181,7 @@ mod tests {
|
||||
"2_current",
|
||||
"42_story_test.md",
|
||||
"---\nname: Test Story\nretry_count: 2\n---\n# Story\n",
|
||||
None,
|
||||
);
|
||||
let output = unblock_cmd_with_root(tmp.path(), "42").unwrap();
|
||||
assert!(
|
||||
@@ -200,6 +201,7 @@ mod tests {
|
||||
"2_blocked",
|
||||
"9903_story_stuck.md",
|
||||
"---\nname: Stuck Story\nblocked: true\nretry_count: 5\n---\n# Story\n",
|
||||
None,
|
||||
);
|
||||
// Seed the story in the CRDT in 2_blocked stage so the typed
|
||||
// Blocked → Coding transition fires and clears `blocked` properly.
|
||||
@@ -267,7 +269,7 @@ mod tests {
|
||||
story_id,
|
||||
stage,
|
||||
body,
|
||||
crate::db::ItemMeta::from_yaml(body),
|
||||
crate::db::ItemMeta::named("Stuck Story"),
|
||||
);
|
||||
// Seed CRDT registers: blocked=true, retry_count=5, with a name so the
|
||||
// response can echo it back instead of falling through to the raw id.
|
||||
@@ -312,14 +314,15 @@ mod tests {
|
||||
#[test]
|
||||
fn unblock_command_finds_story_in_any_stage() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
// Use a high story number (9901) to avoid collisions with other tests in the
|
||||
// global content store.
|
||||
write_story_file(
|
||||
tmp.path(),
|
||||
"3_qa",
|
||||
"9901_story_in_qa.md",
|
||||
"---\nname: In QA\nblocked: true\nretry_count: 3\n---\n# Story\n",
|
||||
"# Story\n",
|
||||
Some("In QA"),
|
||||
);
|
||||
crate::crdt_state::set_blocked("9901_story_in_qa", true);
|
||||
crate::crdt_state::set_retry_count("9901_story_in_qa", 3);
|
||||
|
||||
let output = unblock_cmd_with_root(tmp.path(), "9901").unwrap();
|
||||
assert!(
|
||||
@@ -338,6 +341,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9902_story_blocked_one.md",
|
||||
"---\nname: Blocked One\nblocked: true\nretry_count: 2\n---\n",
|
||||
None,
|
||||
);
|
||||
|
||||
let output = unblock_cmd_with_root(tmp.path(), "9902").unwrap();
|
||||
|
||||
@@ -99,6 +99,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9970_story_some_feature.md",
|
||||
"---\nname: Some Feature\n---\n\n# Story 9970\n",
|
||||
None,
|
||||
);
|
||||
let (story_id, _stage_dir, path, content) =
|
||||
find_story_by_number(tmp.path(), "9970").expect("should find story 9970");
|
||||
@@ -121,6 +122,7 @@ mod tests {
|
||||
"2_current",
|
||||
"7_bug_crash_on_login.md",
|
||||
"---\nname: Crash on login\n---\n",
|
||||
None,
|
||||
);
|
||||
let (story_id, _stage_dir, _, _) =
|
||||
find_story_by_number(tmp.path(), "7").expect("should find bug 7");
|
||||
@@ -136,6 +138,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9971_story_foo.md",
|
||||
"---\nname: Foo\n---\n",
|
||||
None,
|
||||
);
|
||||
let result = find_story_by_number(tmp.path(), "99710");
|
||||
assert!(result.is_none(), "number 99710 should not match story 9971");
|
||||
@@ -149,6 +152,7 @@ mod tests {
|
||||
"4_merge",
|
||||
"503_story_migration.md",
|
||||
"---\nname: Migration\n---\n",
|
||||
None,
|
||||
);
|
||||
let (_, _, path, _) =
|
||||
find_story_by_number(tmp.path(), "503").expect("should find story 503");
|
||||
|
||||
@@ -10,15 +10,26 @@ use std::path::Path;
|
||||
/// which still verify filesystem state (e.g. assign tests that check the
|
||||
/// physical file) continue to work.
|
||||
///
|
||||
/// Uses `write_item_with_content` to populate both the in-memory content
|
||||
/// store and the CRDT, matching the production write path.
|
||||
pub(crate) fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
|
||||
/// Story 929: callers pass the typed `name` explicitly — `content` is now
|
||||
/// just the markdown body and is no longer parsed for metadata. Other
|
||||
/// typed fields (depends_on, agent, qa_mode, blocked, …) should be set
|
||||
/// via the CRDT typed setters after this call.
|
||||
pub(crate) fn write_story_file(
|
||||
root: &Path,
|
||||
stage: &str,
|
||||
filename: &str,
|
||||
content: &str,
|
||||
name: Option<&str>,
|
||||
) {
|
||||
let dir = root.join(".huskies/work").join(stage);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join(filename), content).unwrap();
|
||||
|
||||
let story_id = filename.trim_end_matches(".md");
|
||||
crate::db::ensure_content_store();
|
||||
let meta = crate::db::ItemMeta::from_yaml(content);
|
||||
let meta = crate::db::ItemMeta {
|
||||
name: name.map(str::to_string),
|
||||
..Default::default()
|
||||
};
|
||||
crate::db::write_item_with_content(story_id, stage, content, meta);
|
||||
}
|
||||
|
||||
@@ -310,6 +310,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9972_story_test.md",
|
||||
"---\nname: Test Feature\n---\n\n# Story 9972\n",
|
||||
None,
|
||||
);
|
||||
// Seed CRDT so set_agent can write to the item.
|
||||
crate::crdt_state::write_item(
|
||||
@@ -366,6 +367,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9973_story_small.md",
|
||||
"---\nname: Small Story\n---\n",
|
||||
None,
|
||||
);
|
||||
crate::crdt_state::write_item(
|
||||
"9973_story_small",
|
||||
@@ -416,6 +418,7 @@ mod tests {
|
||||
"1_backlog",
|
||||
"9974_story_existing.md",
|
||||
"---\nname: Existing\nagent: coder-sonnet\n---\n",
|
||||
None,
|
||||
);
|
||||
crate::crdt_state::write_item(
|
||||
"9974_story_existing",
|
||||
@@ -456,6 +459,7 @@ mod tests {
|
||||
"3_qa",
|
||||
"99_story_in_qa.md",
|
||||
"---\nname: In QA\n---\n",
|
||||
None,
|
||||
);
|
||||
|
||||
let agents = std::sync::Arc::new(AgentPool::new_test(3000));
|
||||
@@ -476,6 +480,7 @@ mod tests {
|
||||
"2_current",
|
||||
"10_story_current.md",
|
||||
"---\nname: Current Story\nagent: coder-sonnet\n---\n",
|
||||
None,
|
||||
);
|
||||
|
||||
let agents = std::sync::Arc::new(AgentPool::new_test(3000));
|
||||
|
||||
@@ -258,9 +258,7 @@ mod tests {
|
||||
story_id,
|
||||
"1_backlog",
|
||||
"---\nname: CRDT Tombstone Check\n---\n\n# Story 9977\n",
|
||||
crate::db::ItemMeta::from_yaml(
|
||||
"---\nname: CRDT Tombstone Check\n---\n\n# Story 9977\n",
|
||||
),
|
||||
crate::db::ItemMeta::named("CRDT Tombstone Check"),
|
||||
);
|
||||
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
@@ -291,7 +289,7 @@ mod tests {
|
||||
"9975_story_some_feature",
|
||||
"1_backlog",
|
||||
"---\nname: Some Feature\n---\n\n# Story 9975\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Some Feature\n---\n\n# Story 9975\n"),
|
||||
crate::db::ItemMeta::named("Some Feature"),
|
||||
);
|
||||
|
||||
let agents = std::sync::Arc::new(crate::agents::AgentPool::new_test(3000));
|
||||
|
||||
@@ -272,7 +272,7 @@ mod tests {
|
||||
"9976_story_test",
|
||||
"1_backlog",
|
||||
"---\nname: Test Story\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Test Story\n---\n"),
|
||||
crate::db::ItemMeta::named("Test Story"),
|
||||
);
|
||||
|
||||
let agents = Arc::new(AgentPool::new_test(3000));
|
||||
|
||||
Reference in New Issue
Block a user