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:
@@ -3,7 +3,6 @@
|
||||
use super::bug::{create_bug_file, extract_bug_name_from_content, list_bug_files};
|
||||
use super::refactor::{create_refactor_file, list_refactor_files};
|
||||
use super::spike::create_spike_file;
|
||||
use crate::db::yaml_legacy::parse_front_matter;
|
||||
use std::fs;
|
||||
|
||||
fn setup_git_repo(root: &std::path::Path) {
|
||||
@@ -50,13 +49,13 @@ fn next_item_number_increments_from_existing_bugs() {
|
||||
"1_bug_crash",
|
||||
"1_backlog",
|
||||
"---\nname: Crash\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Crash\n---\n"),
|
||||
crate::db::ItemMeta::named("Crash"),
|
||||
);
|
||||
crate::db::write_item_with_content(
|
||||
"3_bug_another",
|
||||
"1_backlog",
|
||||
"---\nname: Another\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Another\n---\n"),
|
||||
crate::db::ItemMeta::named("Another"),
|
||||
);
|
||||
assert!(super::super::next_item_number(tmp.path()).unwrap() >= 4);
|
||||
}
|
||||
@@ -75,7 +74,7 @@ fn next_item_number_scans_archived_too() {
|
||||
"5_bug_old",
|
||||
"5_done",
|
||||
"---\nname: Old Bug\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Old Bug\n---\n"),
|
||||
crate::db::ItemMeta::named("Old Bug"),
|
||||
);
|
||||
assert!(super::super::next_item_number(tmp.path()).unwrap() >= 6);
|
||||
}
|
||||
@@ -98,14 +97,14 @@ fn list_bug_files_excludes_archive_subdir() {
|
||||
"7001_bug_open",
|
||||
"1_backlog",
|
||||
"---\nname: Open Bug\n---\n# Bug 7001: Open Bug\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Open Bug\n---\n# Bug 7001: Open Bug\n"),
|
||||
crate::db::ItemMeta::named("Open Bug"),
|
||||
);
|
||||
// Bug in done (should NOT appear — list_bug_files only returns Backlog).
|
||||
crate::db::write_item_with_content(
|
||||
"7002_bug_closed",
|
||||
"5_done",
|
||||
"---\nname: Closed Bug\n---\n# Bug 7002: Closed Bug\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Closed Bug\n---\n# Bug 7002: Closed Bug\n"),
|
||||
crate::db::ItemMeta::named("Closed Bug"),
|
||||
);
|
||||
|
||||
let result = list_bug_files(tmp.path()).unwrap();
|
||||
@@ -125,19 +124,19 @@ fn list_bug_files_sorted_by_id() {
|
||||
"7013_bug_third",
|
||||
"1_backlog",
|
||||
"---\nname: Third\n---\n# Bug 7013: Third\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Third\n---\n# Bug 7013: Third\n"),
|
||||
crate::db::ItemMeta::named("Third"),
|
||||
);
|
||||
crate::db::write_item_with_content(
|
||||
"7011_bug_first",
|
||||
"1_backlog",
|
||||
"---\nname: First\n---\n# Bug 7011: First\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: First\n---\n# Bug 7011: First\n"),
|
||||
crate::db::ItemMeta::named("First"),
|
||||
);
|
||||
crate::db::write_item_with_content(
|
||||
"7012_bug_second",
|
||||
"1_backlog",
|
||||
"---\nname: Second\n---\n# Bug 7012: Second\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Second\n---\n# Bug 7012: Second\n"),
|
||||
crate::db::ItemMeta::named("Second"),
|
||||
);
|
||||
|
||||
let result = list_bug_files(tmp.path()).unwrap();
|
||||
@@ -349,15 +348,8 @@ fn create_spike_file_with_special_chars_in_name_produces_valid_yaml() {
|
||||
assert!(result.is_ok(), "create_spike_file failed: {result:?}");
|
||||
|
||||
let spike_id = result.unwrap();
|
||||
let contents = crate::db::read_content(&spike_id)
|
||||
.or_else(|| {
|
||||
let backlog = tmp.path().join(".huskies/work/1_backlog");
|
||||
fs::read_to_string(backlog.join(format!("{spike_id}.md"))).ok()
|
||||
})
|
||||
.expect("spike content should exist");
|
||||
|
||||
let meta = parse_front_matter(&contents).expect("front matter should be valid YAML");
|
||||
assert_eq!(meta.name.as_deref(), Some(name));
|
||||
let view = crate::crdt_state::read_item(&spike_id).expect("CRDT entry should exist");
|
||||
assert_eq!(view.name(), Some(name));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -369,7 +361,7 @@ fn create_spike_file_increments_from_existing_items() {
|
||||
"7050_story_existing",
|
||||
"1_backlog",
|
||||
"---\nname: Existing\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Existing\n---\n"),
|
||||
crate::db::ItemMeta::named("Existing"),
|
||||
);
|
||||
|
||||
let spike_id = create_spike_file(tmp.path(), "My Spike", None, &[], None).unwrap();
|
||||
@@ -387,7 +379,8 @@ fn create_spike_file_increments_from_existing_items() {
|
||||
// ── Bug 640: create_bug_file / create_refactor_file depends_on tests ────────
|
||||
|
||||
#[test]
|
||||
fn create_bug_file_with_depends_on_writes_front_matter_array() {
|
||||
fn create_bug_file_with_depends_on_persists_to_crdt() {
|
||||
crate::crdt_state::init_for_test();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_git_repo(tmp.path());
|
||||
|
||||
@@ -403,26 +396,8 @@ fn create_bug_file_with_depends_on_writes_front_matter_array() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&bug_id)
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
.join(format!(".huskies/work/1_backlog/{bug_id}.md"));
|
||||
fs::read_to_string(filepath).ok()
|
||||
})
|
||||
.expect("bug content should exist");
|
||||
|
||||
assert!(
|
||||
contents.contains("depends_on: [42, 43]"),
|
||||
"front matter should contain depends_on array: {contents}"
|
||||
);
|
||||
assert!(
|
||||
!contents.contains("depends_on: \"["),
|
||||
"depends_on must not be quoted string: {contents}"
|
||||
);
|
||||
|
||||
let meta = parse_front_matter(&contents).expect("front matter should be valid YAML");
|
||||
assert_eq!(meta.depends_on, Some(vec![42, 43]));
|
||||
let view = crate::crdt_state::read_item(&bug_id).expect("CRDT entry should exist");
|
||||
assert_eq!(view.depends_on(), &[42, 43]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -458,29 +433,16 @@ fn create_bug_file_without_depends_on_omits_field() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_refactor_file_with_depends_on_writes_front_matter_array() {
|
||||
fn create_refactor_file_with_depends_on_persists_to_crdt() {
|
||||
crate::crdt_state::init_for_test();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_git_repo(tmp.path());
|
||||
|
||||
let refactor_id =
|
||||
create_refactor_file(tmp.path(), "Dep Refactor", None, None, Some(&[99])).unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&refactor_id)
|
||||
.or_else(|| {
|
||||
let filepath = tmp
|
||||
.path()
|
||||
.join(format!(".huskies/work/1_backlog/{refactor_id}.md"));
|
||||
fs::read_to_string(filepath).ok()
|
||||
})
|
||||
.expect("refactor content should exist");
|
||||
|
||||
assert!(
|
||||
contents.contains("depends_on: [99]"),
|
||||
"front matter should contain depends_on array: {contents}"
|
||||
);
|
||||
|
||||
let meta = parse_front_matter(&contents).expect("front matter should be valid YAML");
|
||||
assert_eq!(meta.depends_on, Some(vec![99]));
|
||||
let view = crate::crdt_state::read_item(&refactor_id).expect("CRDT entry should exist");
|
||||
assert_eq!(view.depends_on(), &[99]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user