huskies: merge 626_refactor_introduce_services_bundle_and_migrate_appcontext_matrix_transport
This commit is contained in:
@@ -32,15 +32,17 @@ pub(super) async fn tool_merge_agent_work(
|
||||
.map_err(|e| format!("Serialization error: {e}"));
|
||||
}
|
||||
|
||||
let project_root = ctx.agents.get_project_root(&ctx.state)?;
|
||||
ctx.agents.start_merge_agent_work(&project_root, story_id)?;
|
||||
let project_root = ctx.services.agents.get_project_root(&ctx.state)?;
|
||||
ctx.services
|
||||
.agents
|
||||
.start_merge_agent_work(&project_root, story_id)?;
|
||||
|
||||
// Block until the merge completes instead of returning immediately.
|
||||
// Uses tokio::time::sleep so the async executor is not blocked.
|
||||
// This prevents the mergemaster from burning all its turns polling
|
||||
// get_merge_status in a tight loop.
|
||||
let sid = story_id.to_string();
|
||||
let agents = ctx.agents.clone();
|
||||
let agents = ctx.services.agents.clone();
|
||||
loop {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
|
||||
if let Some(job) = agents.get_merge_status(&sid) {
|
||||
@@ -64,9 +66,13 @@ pub(super) fn tool_get_merge_status(args: &Value, ctx: &AppContext) -> Result<St
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: story_id")?;
|
||||
|
||||
let job = ctx.agents.get_merge_status(story_id).ok_or_else(|| {
|
||||
format!("No merge job found for story '{story_id}'. Call merge_agent_work first.")
|
||||
})?;
|
||||
let job = ctx
|
||||
.services
|
||||
.agents
|
||||
.get_merge_status(story_id)
|
||||
.ok_or_else(|| {
|
||||
format!("No merge job found for story '{story_id}'. Call merge_agent_work first.")
|
||||
})?;
|
||||
|
||||
match &job.status {
|
||||
crate::agents::merge::MergeJobStatus::Running => {
|
||||
@@ -130,13 +136,14 @@ pub(super) async fn tool_move_story_to_merge(
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("mergemaster");
|
||||
|
||||
let project_root = ctx.agents.get_project_root(&ctx.state)?;
|
||||
let project_root = ctx.services.agents.get_project_root(&ctx.state)?;
|
||||
|
||||
// Move story from work/2_current/ to work/4_merge/
|
||||
move_story_to_merge(&project_root, story_id)?;
|
||||
|
||||
// Start the mergemaster agent on the story worktree
|
||||
let info = ctx
|
||||
.services
|
||||
.agents
|
||||
.start_agent(&project_root, story_id, Some(agent_name), None, None)
|
||||
.await?;
|
||||
@@ -165,7 +172,7 @@ pub(super) fn tool_report_merge_failure(args: &Value, ctx: &AppContext) -> Resul
|
||||
.ok_or("Missing required argument: reason")?;
|
||||
|
||||
slog!("[mergemaster] Merge failure reported for '{story_id}': {reason}");
|
||||
ctx.agents.set_merge_failure_reported(story_id);
|
||||
ctx.services.agents.set_merge_failure_reported(story_id);
|
||||
|
||||
// Broadcast the failure so the Matrix notification listener can post an
|
||||
// error message to configured rooms without coupling this tool to the bot.
|
||||
|
||||
Reference in New Issue
Block a user