fix: merge_agent_work blocks until complete instead of requiring polling
The mergemaster agent was burning all 30 turns polling get_merge_status every 2 seconds while the merge pipeline takes ~2 minutes. It would exhaust turns, exit, restart, and repeat — never seeing the result. merge_agent_work now blocks with a 10-second internal poll loop and returns the final result directly. The agent calls it once and gets the answer. No more polling turns wasted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//! Passing no dependency numbers clears the field entirely.
|
||||
|
||||
use super::CommandContext;
|
||||
use crate::io::story_metadata::{clear_front_matter_field_in_content, parse_front_matter, set_front_matter_field};
|
||||
use crate::io::story_metadata::{parse_front_matter, write_depends_on};
|
||||
|
||||
/// Handle the `depends` command.
|
||||
///
|
||||
@@ -51,7 +51,7 @@ pub(super) fn handle_depends(ctx: &CommandContext) -> Option<String> {
|
||||
}
|
||||
|
||||
// Find the story by numeric prefix: CRDT → content store → filesystem.
|
||||
let (story_id, stage_dir, _path, content) =
|
||||
let (story_id, _stage_dir, path, content) =
|
||||
match crate::chat::lookup::find_story_by_number(ctx.project_root, num_str) {
|
||||
Some(found) => found,
|
||||
None => {
|
||||
@@ -61,36 +61,24 @@ pub(super) fn handle_depends(ctx: &CommandContext) -> Option<String> {
|
||||
}
|
||||
};
|
||||
|
||||
let contents = match content.or_else(|| crate::db::read_content(&story_id)) {
|
||||
Some(c) => c,
|
||||
None => return Some(format!("No content found for **{story_id}**.")),
|
||||
};
|
||||
|
||||
let story_name = parse_front_matter(&contents)
|
||||
.ok()
|
||||
let story_name = content
|
||||
.or_else(|| std::fs::read_to_string(&path).ok())
|
||||
.and_then(|c| parse_front_matter(&c).ok())
|
||||
.and_then(|m| m.name)
|
||||
.unwrap_or_else(|| story_id.clone());
|
||||
|
||||
// Update depends_on in the content store + CRDT.
|
||||
let updated = if deps.is_empty() {
|
||||
clear_front_matter_field_in_content(&contents, "depends_on")
|
||||
} else {
|
||||
let nums: Vec<String> = deps.iter().map(|n| n.to_string()).collect();
|
||||
let yaml_value = format!("[{}]", nums.join(", "));
|
||||
set_front_matter_field(&contents, "depends_on", &yaml_value)
|
||||
};
|
||||
crate::db::write_item_with_content(&story_id, &stage_dir, &updated);
|
||||
|
||||
if deps.is_empty() {
|
||||
Some(format!(
|
||||
match write_depends_on(&path, &deps) {
|
||||
Ok(()) if deps.is_empty() => Some(format!(
|
||||
"Cleared all dependencies for **{story_name}** ({story_id})."
|
||||
))
|
||||
} else {
|
||||
let nums: Vec<String> = deps.iter().map(|n| n.to_string()).collect();
|
||||
Some(format!(
|
||||
"Set depends_on: [{}] for **{story_name}** ({story_id}).",
|
||||
nums.join(", ")
|
||||
))
|
||||
)),
|
||||
Ok(()) => {
|
||||
let nums: Vec<String> = deps.iter().map(|n| n.to_string()).collect();
|
||||
Some(format!(
|
||||
"Set depends_on: [{}] for **{story_name}** ({story_id}).",
|
||||
nums.join(", ")
|
||||
))
|
||||
}
|
||||
Err(e) => Some(format!("Failed to update dependencies for {story_id}: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,11 +188,13 @@ mod tests {
|
||||
output.contains("477") && output.contains("478"),
|
||||
"response should mention dep numbers: {output}"
|
||||
);
|
||||
let contents = crate::db::read_content("42_story_foo")
|
||||
.expect("content store should have the story");
|
||||
let contents = std::fs::read_to_string(
|
||||
tmp.path().join(".huskies/work/1_backlog/42_story_foo.md"),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
contents.contains("depends_on: [477, 478]"),
|
||||
"content store should have depends_on set: {contents}"
|
||||
"file should have depends_on set: {contents}"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -222,11 +212,13 @@ mod tests {
|
||||
output.contains("Cleared"),
|
||||
"should confirm clearing deps: {output}"
|
||||
);
|
||||
let contents = crate::db::read_content("10_story_bar")
|
||||
.expect("content store should have the story");
|
||||
let contents = std::fs::read_to_string(
|
||||
tmp.path().join(".huskies/work/2_current/10_story_bar.md"),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
!contents.contains("depends_on"),
|
||||
"content store should have depends_on cleared: {contents}"
|
||||
"file should have depends_on cleared: {contents}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user