fix: move_item must not overwrite advanced CRDT stage when missing_ok=true (bug 524)
When a story is found in the CRDT but not in the expected source stages, and missing_ok is true, return Ok(None) instead of proceeding with the move. This prevents promote_ready_backlog_stories from demoting a story that has already advanced to merge/done via a stale filesystem shadow in 1_backlog. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,15 +44,23 @@ fn move_item<'a>(
|
|||||||
|
|
||||||
// Verify it's in one of the expected source stages.
|
// Verify it's in one of the expected source stages.
|
||||||
let src_dir = sources.iter().find(|&&s| current_dir == s).copied();
|
let src_dir = sources.iter().find(|&&s| current_dir == s).copied();
|
||||||
if src_dir.is_none() && !missing_ok {
|
let src_dir = match src_dir {
|
||||||
let locs = sources
|
Some(s) => s,
|
||||||
.iter()
|
None if missing_ok => {
|
||||||
.map(|s| format!("work/{s}/"))
|
// Item is in CRDT but not in an expected source stage — do not
|
||||||
.collect::<Vec<_>>()
|
// overwrite its current stage. This prevents promote_ready_backlog_stories
|
||||||
.join(" or ");
|
// from demoting a story that has already advanced to merge/done (bug 524).
|
||||||
return Err(format!("Work item '{story_id}' not found in {locs}."));
|
return Ok(None);
|
||||||
}
|
}
|
||||||
let src_dir = src_dir.unwrap_or(sources[0]);
|
None => {
|
||||||
|
let locs = sources
|
||||||
|
.iter()
|
||||||
|
.map(|s| format!("work/{s}/"))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(" or ");
|
||||||
|
return Err(format!("Work item '{story_id}' not found in {locs}."));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Optionally clear front-matter fields from the stored content.
|
// Optionally clear front-matter fields from the stored content.
|
||||||
let transform: ContentTransform = if fields_to_clear.is_empty() {
|
let transform: ContentTransform = if fields_to_clear.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user