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
+9 -15
View File
@@ -3,7 +3,7 @@ use serde_json::Value;
use std::collections::HashMap;
use std::path::Path;
use super::{create_section_content, next_item_number, read_story_content, replace_section_content, slugify_name, story_stage, write_story_content_with_fs};
use super::{create_section_content, next_item_number, read_story_content, replace_section_content, slugify_name, story_stage, write_story_content};
/// Shared create-story logic used by both the OpenApi and MCP handlers.
///
@@ -66,14 +66,8 @@ pub fn create_story_file(
content.push_str("## Out of Scope\n\n");
content.push_str("- TBD\n");
// Write to database content store.
write_story_content_with_fs(root, &story_id, "1_backlog", &content);
// Also write to filesystem for backwards compatibility during migration.
let backlog_dir = root.join(".huskies").join("work").join("1_backlog");
if let Ok(()) = std::fs::create_dir_all(&backlog_dir) {
let _ = std::fs::write(backlog_dir.join(format!("{story_id}.md")), &content);
}
// Write to database content store and CRDT.
write_story_content(root, &story_id, "1_backlog", &content);
Ok(story_id)
}
@@ -123,7 +117,7 @@ pub fn check_criterion_in_file(
// Write back to content store.
let stage = story_stage(story_id).unwrap_or_else(|| "2_current".to_string());
write_story_content_with_fs(project_root, story_id, &stage, &new_str);
write_story_content(project_root, story_id, &stage, &new_str);
Ok(())
}
@@ -177,7 +171,7 @@ pub fn add_criterion_to_file(
// Write back to content store.
let stage = story_stage(story_id).unwrap_or_else(|| "2_current".to_string());
write_story_content_with_fs(project_root, story_id, &stage, &new_str);
write_story_content(project_root, story_id, &stage, &new_str);
Ok(())
}
@@ -263,7 +257,7 @@ pub fn update_story_in_file(
// Write back to content store.
let stage = story_stage(story_id).unwrap_or_else(|| "2_current".to_string());
write_story_content_with_fs(project_root, story_id, &stage, &contents);
write_story_content(project_root, story_id, &stage, &contents);
Ok(())
}
@@ -732,13 +726,13 @@ mod tests {
#[test]
fn update_story_native_integer_written_unquoted() {
let tmp = tempfile::tempdir().unwrap();
setup_story_in_fs(tmp.path(), "33_test", "---\nname: T\n---\n\nNo sections.\n");
setup_story_in_fs(tmp.path(), "33b_test", "---\nname: T\n---\n\nNo sections.\n");
let mut fields = HashMap::new();
fields.insert("retry_count".to_string(), serde_json::json!(3));
update_story_in_file(tmp.path(), "33_test", None, None, Some(&fields)).unwrap();
update_story_in_file(tmp.path(), "33b_test", None, None, Some(&fields)).unwrap();
let result = read_story_content(tmp.path(), "33_test").unwrap();
let result = read_story_content(tmp.path(), "33b_test").unwrap();
assert!(result.contains("retry_count: 3"), "native integer should be unquoted: {result}");
assert!(!result.contains("retry_count: \"3\""), "must not be quoted: {result}");
}