huskies: merge 530_story_eliminate_filesystem_markdown_shadows_entirely_crdt_db_is_the_only_story_store

This commit is contained in:
dave
2026-04-10 14:56:13 +00:00
parent 1dd675796b
commit 11d19d8902
26 changed files with 966 additions and 1668 deletions
+15 -14
View File
@@ -157,17 +157,23 @@ pub(super) async fn tool_status(args: &Value, ctx: &AppContext) -> Result<String
.ok_or("Missing required argument: story_id")?;
let root = ctx.state.get_project_root()?;
let current_dir = root.join(".huskies").join("work").join("2_current");
let filepath = current_dir.join(format!("{story_id}.md"));
if !filepath.exists() {
// Read from CRDT/DB content store — verify the item is in 2_current.
let typed_item = crate::pipeline_state::read_typed(story_id)
.map_err(|e| format!("Failed to read pipeline state: {e}"))?
.ok_or_else(|| format!(
"Story '{story_id}' not found in work/2_current/. Check the story_id and ensure it is in the current stage."
))?;
if typed_item.stage.dir_name() != "2_current" {
return Err(format!(
"Story '{story_id}' not found in work/2_current/. Check the story_id and ensure it is in the current stage."
));
}
let contents =
fs::read_to_string(&filepath).map_err(|e| format!("Failed to read story file: {e}"))?;
let contents = crate::db::read_content(story_id).ok_or_else(|| {
format!("Story '{story_id}' has no content in the content store.")
})?;
// --- Front matter ---
let mut front_matter = serde_json::Map::new();
@@ -334,23 +340,18 @@ mod tests {
#[tokio::test]
async fn tool_status_returns_story_data() {
let tmp = tempdir().unwrap();
let current_dir = tmp
.path()
.join(".huskies")
.join("work")
.join("2_current");
fs::create_dir_all(&current_dir).unwrap();
crate::db::ensure_content_store();
let story_content = "---\nname: My Test Story\nagent: coder-1\n---\n\n## Acceptance Criteria\n\n- [ ] First criterion\n- [x] Second criterion\n\n## Out of Scope\n\n- nothing\n";
fs::write(current_dir.join("42_story_test.md"), story_content).unwrap();
crate::db::write_item_with_content("9886_story_status_test", "2_current", story_content);
let ctx = crate::http::context::AppContext::new_test(tmp.path().to_path_buf());
let result = tool_status(&json!({"story_id": "42_story_test"}), &ctx)
let result = tool_status(&json!({"story_id": "9886_story_status_test"}), &ctx)
.await
.unwrap();
let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
assert_eq!(parsed["story_id"], "42_story_test");
assert_eq!(parsed["story_id"], "9886_story_status_test");
assert_eq!(parsed["front_matter"]["name"], "My Test Story");
assert_eq!(parsed["front_matter"]["agent"], "coder-1");