Skip to content

fix: orphan reconciliation never killed a still-alive subprocess, letting two agents race the same worktree - #582

Merged
getappz merged 2 commits into
masterfrom
fix/orphan-reconcile-kill-live-process
Aug 21, 2026
Merged

fix: orphan reconciliation never killed a still-alive subprocess, letting two agents race the same worktree#582
getappz merged 2 commits into
masterfrom
fix/orphan-reconcile-kill-live-process

Conversation

@getappz

@getappz getappz commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

Opened by claude for item #172 via agentflare.

A daemon restart doesn't kill an already-spawned agent subprocess tree — it's deliberately placed in its own process group (cmd.process_group(0) in agent_launch::run_captured, needed so kill_tree's targeted kill works during normal timeouts), so it survives as a genuine orphan invisible to the new daemon. reconcile_orphaned_running only updated the DB row and released the claim, then immediately restored ready-for-work — letting a fresh dispatch race the still-running orphan into editing the same files concurrently.

Hit in production 2026-08-21 (item #164): a claude-code process and an opencode process both ended up bound to the same worktree simultaneously, corrupting it.

src/dashboard/orphan_reconcile.rs now kills anything still touching the item's worktree (pgrep -f against the worktree path, robust to any process-tree shape) before releasing the claim or relabeling ready-for-work.

Test plan

  • New test spawns a real orphaned process whose argv embeds the worktree path, confirms reconcile_orphaned_jobs actually terminates it
  • All 12 existing orphan_reconcile tests still pass
  • cargo check --workspace clean
  • cargo fmt applied

…ting two agents race the same worktree

A daemon restart doesn't kill an already-spawned agent subprocess tree —
it's deliberately placed in its own process group (cmd.process_group(0),
needed so kill_tree's targeted kill works during normal timeouts), so it
survives as a genuine orphan invisible to the new daemon. reconcile_orphaned_running
only updated the DB row and released the claim, then immediately restored
ready-for-work — letting a fresh dispatch race the still-running orphan
into editing the same files concurrently. Hit in production 2026-08-21
(item #164): a claude-code and an opencode process both ended up bound to
the same worktree, corrupting it.

Kill anything still touching the item's worktree (pgrep -f against the
worktree path, robust to any process-tree shape) before releasing the
claim or relabeling ready-for-work.

Agentflare-Agent: claude-code
Agentflare-Branch: docs/opencode-model-mapping-fallback
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your current included review allowance is based on your included PR review attempts over the past 7 days.

Next review available in: 36 minutes

Limit details: You’ve used the included review currently available. Your 61 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e0f8c8f5-74a0-4c18-93f6-93d759be4a24

📥 Commits

Reviewing files that changed from the base of the PR and between fc2a0e7 and 1880312.

📒 Files selected for processing (1)
  • src/dashboard/orphan_reconcile.rs

Comment @coderabbitai help to get the list of available commands.

…had no pgrep)

The original fix used pgrep -f directly, which doesn't exist on Windows
(caught by CI: build (windows-latest) failed). Split into #[cfg(unix)]
(pgrep, unchanged) and #[cfg(windows)] (Get-CimInstance Win32_Process
CommandLine match via PowerShell) implementations. Gated the new test
#[cfg(unix)] since its yes-based orphan simulation isn't portable.
Trimmed comments to stay under the LOC gate.

Agentflare-Agent: claude-code
Agentflare-Branch: fix/orphan-reconcile-kill-live-process
@getappz
getappz merged commit b072f41 into master Aug 21, 2026
16 checks passed
@getappz
getappz deleted the fix/orphan-reconcile-kill-live-process branch August 21, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant