wip(929): stage 4 — migrate agents/pool/* + lifecycle.rs read sides off yaml_legacy

Read-side migrations:
- agents/pool/auto_assign/backlog.rs: depends_on check now reads from
  WorkItem.depends_on() instead of parse_front_matter.
- agents/pool/auto_assign/story_checks.rs: read_story_front_matter_agent
  drops its YAML fallback — post-891 the CRDT entry is reliable, and
  removing the fallback makes the contract honest. The now-unused
  read_story_contents helper goes too.
- agents/pool/start/validation.rs: same shape — YAML fallback removed,
  CRDT register is the only source for agent pinning.
- agents/pool/start/spawn.rs: epic-context injection wraps the
  parse_front_matter call in `yaml_residue(...)` since `meta.epic` has no
  CRDT analog (sub-story 933).
- agents/lifecycle.rs: item_type_from_id (numeric-only ID path) wraps its
  parse_front_matter in `yaml_residue(...)` for the same reason (933).
  The write-side `fields_to_clear_transform` calls in lifecycle.rs are
  left for stage 8, when FS-shadow writes are deleted wholesale.

Test fix:
- start_agent_returns_error_when_front_matter_agent_busy now seeds the
  CRDT entry (write_item with agent="coder-opus") instead of relying on
  parse_front_matter reading the YAML on disk.

Filed earlier:
- 932 (review_hold register) — note: this turns out to be a real class-1
  bug: write_review_hold_to_store still writes YAML but has_review_hold
  reads Stage::Frozen, so the write goes into a void. 932 is the correct
  fix.

All 2861 tests pass; fmt + clippy clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Timmy
2026-05-12 19:03:51 +01:00
parent 03a99b3cf1
commit f775f4cfb9
6 changed files with 42 additions and 39 deletions
+6 -1
View File
@@ -230,8 +230,13 @@ pub(super) async fn run_agent_spawn(
// Read the story's front matter to find the epic ID, then load the epic's
// content and prepend it to the system prompt so the agent treats it as
// authoritative context.
//
// Epic linkage has no CRDT register yet (story 933) — wrap the parse in
// `yaml_residue` so the gap is grep-findable.
if let Some(story_content) = crate::db::read_content(&sid)
&& let Ok(meta) = crate::db::yaml_legacy::parse_front_matter(&story_content)
&& let Ok(meta) = crate::db::yaml_legacy::yaml_residue(
crate::db::yaml_legacy::parse_front_matter(&story_content),
)
&& let Some(ref epic_id) = meta.epic
&& let Some(epic_content) = crate::db::read_content(epic_id)
{
@@ -281,6 +281,20 @@ stage = "coder"
std::fs::write(current.join("368_story_test.md"), story_content).unwrap();
crate::db::ensure_content_store();
crate::db::write_content("368_story_test", story_content);
// Story 929: agent pin comes from the CRDT register, not YAML. Seed it.
crate::crdt_state::init_for_test();
crate::crdt_state::write_item(
"368_story_test",
"2_current",
Some("Test Story"),
Some("coder-opus"),
None,
None,
None,
None,
None,
None,
);
let pool = AgentPool::new_test(3011);
// Preferred agent is busy — should NOT fall back to coder-sonnet.
+6 -14
View File
@@ -60,18 +60,10 @@ pub(super) fn read_front_matter_agent(story_id: &str, agent_name: Option<&str>)
if agent_name.is_some() {
return None;
}
// After story 871 the pin lives in the CRDT typed register; fall back
// to legacy YAML parsing for stories whose CRDT entry doesn't yet have
// the field populated.
if let Some(view) = crate::crdt_state::read_item(story_id)
&& let Some(agent) = view.agent()
&& !agent.is_empty()
{
return Some(agent.to_string());
}
crate::db::read_content(story_id).and_then(|contents| {
crate::db::yaml_legacy::parse_front_matter(&contents)
.ok()?
.agent
})
// Story 929: the agent pin lives in the CRDT typed register; the
// legacy YAML fallback is gone — post-891 every story has its CRDT
// entry and any story without one has no pinned agent.
crate::crdt_state::read_item(story_id)
.and_then(|w| w.agent().map(str::to_string))
.filter(|s| !s.is_empty())
}