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:
@@ -66,7 +66,7 @@ pub fn create_story_file(
|
||||
content.push_str("- TBD\n");
|
||||
|
||||
// Write to database content store and CRDT.
|
||||
write_story_content(root, &story_id, "1_backlog", &content);
|
||||
write_story_content(root, &story_id, "1_backlog", &content, Some(name));
|
||||
|
||||
// Sync depends_on to the typed CRDT register.
|
||||
crate::crdt_state::set_depends_on(&story_id, depends_on.unwrap_or(&[]));
|
||||
@@ -83,7 +83,6 @@ pub fn create_story_file(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::db::yaml_legacy::parse_front_matter;
|
||||
use std::fs;
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -146,7 +145,7 @@ mod tests {
|
||||
"36_story_existing",
|
||||
"1_backlog",
|
||||
"---\nname: Existing\n---\n",
|
||||
crate::db::ItemMeta::from_yaml("---\nname: Existing\n---\n"),
|
||||
crate::db::ItemMeta::named("Existing"),
|
||||
);
|
||||
|
||||
let number = super::super::super::next_item_number(tmp.path()).unwrap();
|
||||
@@ -184,29 +183,24 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_story_with_colon_in_name_produces_valid_yaml() {
|
||||
fn create_story_with_colon_in_name_persists_to_crdt() {
|
||||
crate::crdt_state::init_for_test();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let name = "Server-owned agent completion: remove report_completion dependency";
|
||||
let result = create_story_file(tmp.path(), name, None, None, None, None, false);
|
||||
assert!(result.is_ok(), "create_story_file failed: {result:?}");
|
||||
|
||||
let story_id = result.unwrap();
|
||||
// Read from content store or filesystem.
|
||||
let content = crate::db::read_content(&story_id)
|
||||
.or_else(|| {
|
||||
let backlog = tmp.path().join(".huskies/work/1_backlog");
|
||||
fs::read_to_string(backlog.join(format!("{story_id}.md"))).ok()
|
||||
})
|
||||
.expect("story content should exist");
|
||||
|
||||
let meta = parse_front_matter(&content).expect("front matter should be valid YAML");
|
||||
assert_eq!(meta.name.as_deref(), Some(name));
|
||||
let view =
|
||||
crate::crdt_state::read_item(&story_id).expect("CRDT entry should exist after create");
|
||||
assert_eq!(view.name(), Some(name));
|
||||
}
|
||||
|
||||
// ── check_criterion_in_file tests ─────────────────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn create_story_with_depends_on_writes_front_matter_array() {
|
||||
fn create_story_with_depends_on_persists_to_crdt() {
|
||||
crate::crdt_state::init_for_test();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let story_id = create_story_file(
|
||||
tmp.path(),
|
||||
@@ -219,24 +213,9 @@ mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let contents = crate::db::read_content(&story_id)
|
||||
.or_else(|| {
|
||||
let backlog = tmp.path().join(".huskies/work/1_backlog");
|
||||
fs::read_to_string(backlog.join(format!("{story_id}.md"))).ok()
|
||||
})
|
||||
.expect("story content should exist");
|
||||
|
||||
assert!(
|
||||
contents.contains("depends_on: [489]"),
|
||||
"missing front matter: {contents}"
|
||||
);
|
||||
assert!(
|
||||
!contents.contains("- [ ] depends_on"),
|
||||
"must not appear as checkbox: {contents}"
|
||||
);
|
||||
|
||||
let meta = parse_front_matter(&contents).expect("front matter should parse");
|
||||
assert_eq!(meta.depends_on, Some(vec![489]));
|
||||
let view =
|
||||
crate::crdt_state::read_item(&story_id).expect("CRDT entry should exist after create");
|
||||
assert_eq!(view.depends_on(), &[489]);
|
||||
}
|
||||
|
||||
// ── Story 730: numeric-only story IDs ─────────────────────────────────────
|
||||
@@ -258,19 +237,18 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_story_file_writes_type_field_in_front_matter() {
|
||||
fn create_story_file_sets_item_type_register() {
|
||||
crate::crdt_state::init_for_test();
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let story_id =
|
||||
create_story_file(tmp.path(), "Type Test Story", None, None, None, None, false)
|
||||
.unwrap();
|
||||
let content = crate::db::read_content(&story_id).expect("content must exist");
|
||||
let meta = crate::db::yaml_legacy::parse_front_matter(&content)
|
||||
.expect("front matter should be valid");
|
||||
let view = crate::crdt_state::read_item(&story_id).expect("CRDT entry must exist");
|
||||
assert_eq!(
|
||||
meta.item_type.as_deref(),
|
||||
view.item_type(),
|
||||
Some("story"),
|
||||
"front matter must contain type: story"
|
||||
"CRDT register must be set to story"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user