huskies: merge 879
This commit is contained in:
@@ -41,8 +41,10 @@ pub(crate) fn tool_update_story(args: &Value, ctx: &AppContext) -> Result<String
|
||||
crate::crdt_state::set_qa_mode(story_id, mode);
|
||||
}
|
||||
|
||||
// Sync `depends_on` to the typed CRDT register when present in the update.
|
||||
if let Some(deps_val) = front_matter.get("depends_on") {
|
||||
// Route `depends_on` to the typed CRDT register and remove it from the
|
||||
// front-matter map so it is NOT written back to the YAML content store.
|
||||
// This matches the `qa` field pattern: CRDT is the single source of truth.
|
||||
if let Some(deps_val) = front_matter.remove("depends_on") {
|
||||
if let Some(arr) = deps_val.as_array() {
|
||||
let dep_nums: Vec<u32> = arr
|
||||
.iter()
|
||||
@@ -148,7 +150,7 @@ mod tests {
|
||||
fs::create_dir_all(¤t).unwrap();
|
||||
fs::write(current.join(format!("{story_id}.md")), content).unwrap();
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content(story_id, content);
|
||||
crate::db::write_item_with_content(story_id, "2_current", content);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -206,7 +208,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tool_update_story_front_matter_json_array_written_as_yaml_sequence() {
|
||||
fn tool_update_story_depends_on_routes_to_crdt_not_yaml() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
setup_story_for_update(
|
||||
tmp.path(),
|
||||
@@ -221,20 +223,19 @@ mod tests {
|
||||
);
|
||||
assert!(result.is_ok(), "Expected ok: {result:?}");
|
||||
|
||||
let content = crate::db::read_content("504_arr_test").unwrap();
|
||||
// YAML inline sequences use spaces after commas
|
||||
assert!(
|
||||
content.contains("depends_on: [490, 491]"),
|
||||
"array should be unquoted YAML: {content}"
|
||||
);
|
||||
assert!(
|
||||
!content.contains("depends_on: \""),
|
||||
"array must not be quoted: {content}"
|
||||
// CRDT register must hold the deps.
|
||||
let view = crate::crdt_state::read_item("504_arr_test").expect("CRDT must have the story");
|
||||
assert_eq!(
|
||||
view.depends_on,
|
||||
Some(vec![490, 491]),
|
||||
"CRDT register should hold [490, 491]: {view:?}"
|
||||
);
|
||||
|
||||
// The YAML must be parseable as a vec
|
||||
let meta = crate::io::story_metadata::parse_front_matter(&content)
|
||||
.expect("front matter should parse");
|
||||
assert_eq!(meta.depends_on, Some(vec![490, 491]));
|
||||
// Content store YAML must NOT contain depends_on — CRDT is sole source of truth.
|
||||
let content = crate::db::read_content("504_arr_test").unwrap();
|
||||
assert!(
|
||||
!content.contains("depends_on"),
|
||||
"depends_on must not be written to YAML content store: {content}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user