huskies: merge 866
This commit is contained in:
@@ -44,8 +44,13 @@ pub(crate) fn unblock_by_number(project_root: &Path, story_number: &str) -> Stri
|
||||
unblock_by_story_id(&story_id)
|
||||
}
|
||||
|
||||
/// Unblock a story using the content store (DB-backed).
|
||||
/// Unblock a story via the typed state machine.
|
||||
///
|
||||
/// Checks whether the story is in `Stage::Blocked` (new path) or has legacy
|
||||
/// `blocked: true` / `merge_failure` front-matter, then routes through
|
||||
/// [`crate::agents::lifecycle::transition_to_unblocked`].
|
||||
fn unblock_by_story_id(story_id: &str) -> String {
|
||||
// Read content for the story name and legacy field checks.
|
||||
let contents = match crate::db::read_content(story_id) {
|
||||
Some(c) => c,
|
||||
None => return format!("Failed to read story content for **{story_id}**"),
|
||||
@@ -57,34 +62,51 @@ fn unblock_by_story_id(story_id: &str) -> String {
|
||||
};
|
||||
|
||||
let story_name = meta.name.as_deref().unwrap_or(story_id).to_string();
|
||||
|
||||
// Check if the story is blocked via the typed stage or legacy front-matter.
|
||||
let typed_blocked = crate::pipeline_state::read_typed(story_id)
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_some_and(|item| item.stage.is_blocked());
|
||||
let has_blocked = meta.blocked == Some(true);
|
||||
let has_merge_failure = meta.merge_failure.is_some();
|
||||
|
||||
if !has_blocked && !has_merge_failure {
|
||||
if !typed_blocked && !has_blocked && !has_merge_failure {
|
||||
return format!("**{story_name}** ({story_id}) is not blocked. Nothing to unblock.");
|
||||
}
|
||||
|
||||
let mut updated = contents;
|
||||
if has_blocked {
|
||||
updated = clear_front_matter_field_in_content(&updated, "blocked");
|
||||
}
|
||||
if has_merge_failure {
|
||||
updated = clear_front_matter_field_in_content(&updated, "merge_failure");
|
||||
}
|
||||
// retry_count lives in the CRDT; clear any stale copy from front-matter.
|
||||
updated = clear_front_matter_field_in_content(&updated, "retry_count");
|
||||
// Route through the state machine.
|
||||
match crate::agents::lifecycle::transition_to_unblocked(story_id) {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
// If the typed transition fails (e.g. legacy Archived item),
|
||||
// fall back to clearing front-matter fields directly.
|
||||
crate::slog_warn!(
|
||||
"[unblock] State-machine transition failed for '{story_id}': {e}. \
|
||||
Falling back to front-matter cleanup."
|
||||
);
|
||||
let mut updated = contents;
|
||||
if has_blocked {
|
||||
updated = clear_front_matter_field_in_content(&updated, "blocked");
|
||||
}
|
||||
if has_merge_failure {
|
||||
updated = clear_front_matter_field_in_content(&updated, "merge_failure");
|
||||
}
|
||||
updated = clear_front_matter_field_in_content(&updated, "retry_count");
|
||||
|
||||
crate::db::write_content(story_id, &updated);
|
||||
let stage = crate::pipeline_state::read_typed(story_id)
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|i| i.stage.dir_name().to_string())
|
||||
.unwrap_or_else(|| "2_current".to_string());
|
||||
crate::db::write_item_with_content(story_id, &stage, &updated);
|
||||
crate::crdt_state::set_retry_count(story_id, 0);
|
||||
crate::db::write_content(story_id, &updated);
|
||||
let stage = crate::pipeline_state::read_typed(story_id)
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|i| i.stage.dir_name().to_string())
|
||||
.unwrap_or_else(|| "2_current".to_string());
|
||||
crate::db::write_item_with_content(story_id, &stage, &updated);
|
||||
crate::crdt_state::set_retry_count(story_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
let mut cleared = Vec::new();
|
||||
if has_blocked {
|
||||
if typed_blocked || has_blocked {
|
||||
cleared.push("blocked");
|
||||
}
|
||||
if has_merge_failure {
|
||||
|
||||
@@ -109,6 +109,7 @@ fn stage_display_name(stage: &str) -> &str {
|
||||
Some(Stage::Upcoming) => "upcoming",
|
||||
Some(Stage::Backlog) => "backlog",
|
||||
Some(Stage::Coding) => "in-progress",
|
||||
Some(Stage::Blocked { .. }) => "blocked",
|
||||
Some(Stage::Qa) => "QA",
|
||||
Some(Stage::Merge { .. }) => "merge",
|
||||
Some(Stage::Done { .. }) => "done",
|
||||
|
||||
Reference in New Issue
Block a user