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
+8 -12
View File
@@ -4,24 +4,20 @@
use std::path::Path;
/// Write a work-item file into the standard pipeline directory structure.
/// Write a work-item into the content store and CRDT for testing.
///
/// Creates `.huskies/work/{stage}/{filename}` under `root`, creating any
/// missing parent directories. Also writes to the global content store so
/// that code paths that prefer the content store over the filesystem (e.g.
/// `unblock_by_number`) see this test's content rather than a stale entry
/// left by a parallel test with the same numeric prefix.
/// Also creates the filesystem directory structure and file so that tests
/// which still verify filesystem state (e.g. assign tests that check the
/// physical file) continue to work.
///
/// Uses `write_item_with_content` to populate both the in-memory content
/// store and the CRDT, matching the production write path.
pub(crate) fn write_story_file(root: &Path, stage: &str, filename: &str, content: &str) {
let dir = root.join(".huskies/work").join(stage);
std::fs::create_dir_all(&dir).unwrap();
std::fs::write(dir.join(filename), content).unwrap();
// Seed the in-memory content store so lifecycle functions that read from
// the content store (instead of the filesystem) see this entry. Use
// write_content (not write_item_with_content) to avoid writing to the
// CRDT — tests must not initialise the global CRDT OnceLock because that
// would pollute every subsequent test in the same process.
let story_id = filename.trim_end_matches(".md");
crate::db::ensure_content_store();
crate::db::write_content(story_id, content);
crate::db::write_item_with_content(story_id, stage, content);
}