Skip to content

fix(daemon): orphan reconciliation must restore ready-for-work so items auto-resume after a crash/reboot, not require manual relabel - #465

Merged
getappz merged 3 commits into
masterfrom
task/99
Aug 12, 2026
Merged

fix(daemon): orphan reconciliation must restore ready-for-work so items auto-resume after a crash/reboot, not require manual relabel#465
getappz merged 3 commits into
masterfrom
task/99

Conversation

@getappz

@getappz getappz commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Working tree is clean with the fix committed.

Summary

Fixed item #99: reconcile_orphaned_jobs (daemon startup, on a crash/restart) released the dead job's item_claims lease but never touched the item's labels. Since dispatch_item had already swapped ready-for-workdispatched when the job was first sent out, and run_discovery_tick only ever looks for ready-for-work items, an orphaned item was claim-free but permanently invisible to auto-dispatch — stuck until a human manually relabeled it.

Fix (src/dashboard/orphan_reconcile.rs, new file): added restore_ready_for_work, called after each orphaned in-process job's claim is released. It swaps dispatched back to ready-for-work — the reverse of dispatch_item's own swap — but skips items already in a completed/cancelled state group (same exclusion item::claim's handoff-freeze check uses), so an item a human finished or cancelled out-of-band while its job was still marked running doesn't get silently resurrected onto the discovery queue.

I deliberately did not clear the stale assignee_agent — tracing resolve_agent in src/cli/work.rs showed the codebase already relies on a stale assignee_agent surviving a normal (non-crash) job failure to route retries back to the same agent; clearing it here would be an inconsistent special case for no real benefit.

Added a test, reconcile_orphaned_jobs_restores_ready_for_work_label, alongside the existing claim-release test, asserting the item ends up with ready-for-work (not dispatched) after reconciliation.

Moving reconcile_orphaned_jobs + the two tests into their own file was necessary to keep dashboard/server.rs under the repo's 1500-line LOC gate (it was already sitting exactly at the limit before this change). Verified: cargo build, targeted cargo test (dashboard/supervisor modules, 60 tests), cargo clippy, cargo fmt --check, and scripts/loc-gate.sh all pass.

…aned jobs

reconcile_orphaned_jobs released the dead job's item claim but never
touched the item's labels, so an item dispatch had already swapped from
ready-for-work to dispatched stayed stuck on dispatched forever after a
daemon crash/restart -- invisible to run_discovery_tick, which only ever
looks at ready-for-work. Swap the label back (mirroring dispatch_item's
own swap in reverse) unless the item was independently completed or
cancelled while the job was still marked running.

Split reconcile_orphaned_jobs and its tests out of dashboard/server.rs
into dashboard/orphan_reconcile.rs to stay under the repo's LOC gate.

Agentflare-Agent: claude-code
Agentflare-Branch: task/99
Agentflare-Item: 99
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 26 minutes

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?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98ab909d-6eef-4192-bcd9-70d243d20745

📥 Commits

Reviewing files that changed from the base of the PR and between 59ec6a8 and 7337938.

📒 Files selected for processing (4)
  • src/dashboard/mod.rs
  • src/dashboard/orphan_reconcile.rs
  • src/dashboard/server.rs
  • src/supervisor.rs

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

@getappz
getappz merged commit 1d7d678 into master Aug 12, 2026
16 checks passed
@getappz
getappz deleted the task/99 branch August 12, 2026 15:24
getappz added a commit that referenced this pull request Aug 14, 2026
execute_work's "claim succeeded but no worktree was created" and
"failed to chdir into <worktree>" paths were structural git-state
failures (e.g. a stale prunable worktree registration, confirmed live
for items #465/#466) that retry identically every time, but went
through the normal max_retries backoff budget before the terminal-
failure recovery hook could swap the item off `dispatched`.

Add a `fatal` flag to JobFailure/WorkOutcome that Queue::fail uses to
skip straight to terminal `state=failed` regardless of retries
remaining, and set it on those two setup-failure branches. Agent-run
failures are unaffected and keep the existing retry/cooldown behavior.
dispatch_item's ready-for-work/dispatched label-flip timing is
untouched.

Agentflare-Agent: claude-code
Agentflare-Branch: task/467-fail-fast-on-structural-worktree-setup-f
Agentflare-Item: 467
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