huskies: merge 946

This commit is contained in:
dave
2026-05-13 07:54:50 +00:00
parent 4a0fbcaa95
commit a7840ea4b0
49 changed files with 378 additions and 314 deletions
+19 -10
View File
@@ -61,7 +61,8 @@ pub(crate) fn tool_list_epics(_ctx: &AppContext) -> Result<String, String> {
continue;
};
if view.item_type() == Some("epic") {
use crate::io::story_metadata::ItemType;
if view.item_type() == Some(ItemType::Epic) {
epics.push((sid.clone(), item.name.clone()));
}
@@ -110,13 +111,17 @@ pub(crate) fn tool_show_epic(args: &Value, _ctx: &AppContext) -> Result<String,
let epic_view = crate::crdt_state::read_item(epic_id)
.ok_or_else(|| format!("Epic '{epic_id}' not found in CRDT"))?;
if epic_view.item_type() != Some("epic") {
use crate::io::story_metadata::ItemType;
if epic_view.item_type() != Some(ItemType::Epic) {
return Err(format!(
"'{epic_id}' is not an epic (item_type: {:?})",
epic_view.item_type()
));
}
// Parse the epic_id argument to a numeric EpicId for comparison.
let epic_numeric = crate::crdt_state::EpicId::from_crdt_str(epic_id);
// Find member items.
let all_items = crate::pipeline_state::read_all_typed();
let mut member_items: Vec<Value> = Vec::new();
@@ -126,7 +131,7 @@ pub(crate) fn tool_show_epic(args: &Value, _ctx: &AppContext) -> Result<String,
let Some(member_view) = crate::crdt_state::read_item(sid) else {
continue;
};
if member_view.epic() == Some(epic_id) {
if member_view.epic() == epic_numeric {
// Story 945: Frozen / ReviewHold / MergeFailureFinal are first-class
// Stage variants — no more orthogonal boolean flags.
let stage_name = match &item.stage {
@@ -238,14 +243,18 @@ mod tests {
crate::crdt_state::init_for_test();
crate::db::ensure_content_store();
use crate::crdt_state::EpicId;
use crate::io::story_metadata::ItemType;
// Write a fake epic with the typed CRDT registers (story 933).
// Epics use numeric-only story_ids (see create_epic_file).
crate::db::write_item_with_content(
"9990_epic_rollup",
"9990",
"1_backlog",
"# Rollup Epic\n\n## Goal\n\nTest\n",
crate::db::ItemMeta::named("Rollup Epic"),
);
crate::crdt_state::set_item_type("9990_epic_rollup", Some("epic"));
crate::crdt_state::set_item_type("9990", Some(ItemType::Epic));
// Write two member items: one done, one current.
crate::db::write_item_with_content(
@@ -254,8 +263,8 @@ mod tests {
"# Done Member\n",
crate::db::ItemMeta::named("Done Member"),
);
crate::crdt_state::set_item_type("9991_story_member_done", Some("story"));
crate::crdt_state::set_epic("9991_story_member_done", Some("9990_epic_rollup"));
crate::crdt_state::set_item_type("9991_story_member_done", Some(ItemType::Story));
crate::crdt_state::set_epic("9991_story_member_done", Some(EpicId(9990)));
crate::db::write_item_with_content(
"9992_story_member_current",
@@ -263,8 +272,8 @@ mod tests {
"# Current Member\n",
crate::db::ItemMeta::named("Current Member"),
);
crate::crdt_state::set_item_type("9992_story_member_current", Some("story"));
crate::crdt_state::set_epic("9992_story_member_current", Some("9990_epic_rollup"));
crate::crdt_state::set_item_type("9992_story_member_current", Some(ItemType::Story));
crate::crdt_state::set_epic("9992_story_member_current", Some(EpicId(9990)));
let tmp = tempfile::tempdir().unwrap();
let ctx = crate::http::test_helpers::test_ctx(tmp.path());
@@ -272,7 +281,7 @@ mod tests {
let parsed: Vec<Value> = serde_json::from_str(&result).unwrap();
let epic = parsed
.iter()
.find(|e| e["epic_id"] == "9990_epic_rollup")
.find(|e| e["epic_id"] == "9990")
.expect("expected rollup epic in list");
assert_eq!(epic["members_total"], 2, "two members expected");
assert_eq!(epic["members_done"], 1, "one done member expected");