fix: kill stale cargo processes before running acceptance gates
The completion handler now pgrep+kills any cargo processes targeting the worktree's Cargo.toml before running gates. This prevents the run_tests MCP child from holding the build lock and blocking gates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -199,6 +199,25 @@ pub(in crate::agents::pool) async fn run_server_owned_completion(
|
|||||||
.and_then(|a| a.worktree_info.as_ref().map(|wt| wt.path.clone()))
|
.and_then(|a| a.worktree_info.as_ref().map(|wt| wt.path.clone()))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Kill any in-flight cargo test processes for this worktree so they don't
|
||||||
|
// hold the build lock while gates try to run.
|
||||||
|
if let Some(wt_path) = worktree_path.as_ref() {
|
||||||
|
if let Ok(output) = std::process::Command::new("pgrep")
|
||||||
|
.args(["-f", &format!("--manifest-path {}/Cargo.toml", wt_path.display())])
|
||||||
|
.output()
|
||||||
|
{
|
||||||
|
let pids = String::from_utf8_lossy(&output.stdout);
|
||||||
|
for pid_str in pids.lines() {
|
||||||
|
if let Ok(pid) = pid_str.trim().parse::<i32>() {
|
||||||
|
crate::slog!(
|
||||||
|
"[agents] Killing stale cargo process (pid {pid}) for '{story_id}' before running gates"
|
||||||
|
);
|
||||||
|
unsafe { libc::kill(pid, libc::SIGKILL); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Run acceptance gates.
|
// Run acceptance gates.
|
||||||
let (gates_passed, gate_output) = if let Some(wt_path) = worktree_path {
|
let (gates_passed, gate_output) = if let Some(wt_path) = worktree_path {
|
||||||
let path = wt_path;
|
let path = wt_path;
|
||||||
|
|||||||
Reference in New Issue
Block a user