huskies: merge 870
This commit is contained in:
@@ -104,41 +104,42 @@ pub(crate) fn should_block_story(
|
||||
max_retries: u32,
|
||||
stage_label: &str,
|
||||
) -> Option<String> {
|
||||
use crate::io::story_metadata::{increment_retry_count_in_content, write_blocked_in_content};
|
||||
use crate::io::story_metadata::write_blocked_in_content;
|
||||
|
||||
if max_retries == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Some(contents) = crate::db::read_content(story_id) {
|
||||
let (updated, new_count) = increment_retry_count_in_content(&contents);
|
||||
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);
|
||||
let new_count = crate::crdt_state::bump_retry_count(story_id) as u32;
|
||||
if new_count == 0 {
|
||||
slog_error!(
|
||||
"[pipeline] Failed to bump retry_count for '{story_id}': item not found in CRDT"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
|
||||
if new_count >= max_retries {
|
||||
slog_warn!(
|
||||
"[pipeline] Story '{story_id}' reached retry limit ({new_count}/{max_retries}) \
|
||||
at {stage_label} stage. Marking as blocked."
|
||||
);
|
||||
let blocked = write_blocked_in_content(&updated);
|
||||
if new_count >= max_retries {
|
||||
slog_warn!(
|
||||
"[pipeline] Story '{story_id}' reached retry limit ({new_count}/{max_retries}) \
|
||||
at {stage_label} stage. Marking as blocked."
|
||||
);
|
||||
if let Some(contents) = crate::db::read_content(story_id) {
|
||||
let blocked = write_blocked_in_content(&contents);
|
||||
crate::db::write_content(story_id, &blocked);
|
||||
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, &blocked);
|
||||
Some(format!(
|
||||
"Retry limit exceeded ({new_count}/{max_retries}) at {stage_label} stage"
|
||||
))
|
||||
} else {
|
||||
slog!(
|
||||
"[pipeline] Story '{story_id}' retry {new_count}/{max_retries} at {stage_label} stage."
|
||||
);
|
||||
None
|
||||
}
|
||||
Some(format!(
|
||||
"Retry limit exceeded ({new_count}/{max_retries}) at {stage_label} stage"
|
||||
))
|
||||
} else {
|
||||
slog_error!("[pipeline] Failed to read content for '{story_id}' to increment retry_count");
|
||||
slog!(
|
||||
"[pipeline] Story '{story_id}' retry {new_count}/{max_retries} at {stage_label} stage."
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,6 +467,7 @@ async fn no_committed_work_still_retries_and_blocks() {
|
||||
.unwrap();
|
||||
|
||||
// Set up the story with max_retries=1 so it blocks immediately.
|
||||
crate::crdt_state::init_for_test();
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_content("9946_story_nowork", "---\nname: No Work Test\n---\n");
|
||||
crate::db::write_item_with_content(
|
||||
@@ -806,6 +807,7 @@ stage = "coder"
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
crate::crdt_state::init_for_test();
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_item_with_content(
|
||||
"9950_story_warm_resume",
|
||||
@@ -848,11 +850,12 @@ stage = "coder"
|
||||
);
|
||||
drop(agents);
|
||||
|
||||
// Retry counter must have been incremented (AC 3).
|
||||
let content = crate::db::read_content("9950_story_warm_resume")
|
||||
.expect("story must exist in content store");
|
||||
// Retry counter must have been incremented (AC 3) — checked via CRDT.
|
||||
let item =
|
||||
crate::crdt_state::read_item("9950_story_warm_resume").expect("story must be in CRDT");
|
||||
assert!(
|
||||
content.contains("retry_count"),
|
||||
"retry_count must be incremented after warm-resume: {content}"
|
||||
item.retry_count.is_some_and(|rc| rc > 0),
|
||||
"retry_count must be incremented after warm-resume: got {:?}",
|
||||
item.retry_count
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user