huskies: merge 1178 bug MergeFailureFinal is a trap state: successful re-merge cannot mark the story done

This commit is contained in:
Huskies Agent
2026-07-16 14:19:55 +00:00
parent 61acf98909
commit e5df6232cf
6 changed files with 226 additions and 34 deletions
+29 -1
View File
@@ -121,7 +121,7 @@ pub fn move_story_to_done(story_id: &str) -> Result<(), String> {
Stage::Merge { .. } => PipelineEvent::MergeSucceeded {
merge_commit: GitSha("accepted".to_string()),
},
Stage::MergeFailure { .. } => PipelineEvent::Accepted,
Stage::MergeFailure { .. } | Stage::MergeFailureFinal { .. } => PipelineEvent::Accepted,
Stage::Coding { .. } | Stage::Qa | Stage::Backlog => PipelineEvent::Close,
_ => {
return Err(format!(
@@ -627,6 +627,34 @@ mod tests {
);
}
/// Regression test (story 1178): a story in `Stage::MergeFailureFinal`
/// whose merge is later retried and succeeds must be movable to Done.
/// Before this fix, `move_story_to_done` had no arm for
/// `MergeFailureFinal`, so it always returned an error even after a
/// real, successful re-merge — the exact "trap state" this story fixes.
#[test]
fn move_story_to_done_from_merge_failure_final_succeeds() {
crate::db::ensure_content_store();
crate::db::write_item_with_content(
"99952_story_merge_failure_final",
"merge_failure_final",
"---\nname: Merge Failure Final Test\n---\n# Story\n",
crate::db::ItemMeta::named("Merge Failure Final Test"),
);
move_story_to_done("99952_story_merge_failure_final")
.expect("move_story_to_done should succeed from MergeFailureFinal");
let item = crate::pipeline_state::read_typed("99952_story_merge_failure_final")
.expect("CRDT read should succeed")
.expect("item should exist in CRDT");
assert_eq!(
item.stage.dir_name(),
"done",
"item should be in done after move from MergeFailureFinal"
);
}
// ── item_type_from_id tests ────────────────────────────────────────────────
#[test]