Repository navigation
fix(agents): serialize subagent orphan recovery - #117283
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:52 PM ET / August 2, 2026, 02:52 UTC. ClawSweeper reviewWhat this changesSerializes delayed subagent orphan-recovery scheduling within one Gateway process, coalescing duplicate startup requests and queuing one follow-up scan while a recovery family is active. Merge readinessKeep this PR open for maintainer review. The focused scheduler change addresses the linked duplicate-resume bug at the process-wide scheduling owner, but it is behind current Priority: P1 Review scores
Verification
How this fits togetherAfter a Gateway restart, both the subagent registry and the post-startup Gateway flow can request orphan recovery for interrupted child sessions. The scheduler waits for Gateway readiness, scans the live run registry, resumes eligible child sessions, and then records the resulting session and registry state. flowchart LR
A[Gateway restart] --> B[Registry and startup recovery requests]
B --> C[Orphan recovery scheduler]
C --> D[Scan interrupted child sessions]
D --> E[Gateway resume dispatch]
E --> F[Session marker and registry update]
Decision needed
Why: This is a maintainer-owned P1 change to Gateway recovery semantics; source supports the scheduling layer, but accepting the exact coalescing and follow-up policy requires owner judgment after current-main validation. Before merge
Agent review detailsSecurityNone. PR surfaceSource +36, Tests +249. Total +285 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one process-wide orphan-recovery scheduler, then validate its active-scan, retry-backoff, and terminal-finalization paths on the current merge result before a maintainer accepts the session-state behavior. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible with high confidence: the linked report identifies separate registry and Gateway scheduling paths, and the branch adds focused tests that park recovery dispatch while another schedule request arrives. This read-only review did not execute that path. Is this the best way to solve the issue? Yes in design: process-wide serialization fixes the duplicate-scan owner boundary more directly than a second per-session guard, while retaining the live registry scan for follow-up work. The remaining requirement is proof on the current merge result, not a different product feature. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e49e9e2aa193. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
079c183 to
f00bf01
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Land-ready verification for exact head
Known gaps: none for the scoped scheduler invariant. The PR does not change registry persistence, dispatch/remap semantics, protocol, configuration, or public APIs. |
|
Merged via squash.
|
Fixes #103724
What Problem This Solves
Two independent orphan-recovery scheduler families could overlap after a Gateway restart. Each family owned private de-duplication state, so both could observe the same
abortedLastRunchild and dispatch duplicate resume turns.Why This Change Was Made
This replaces the old 118-file draft with a current-
main, scheduler-only fix.scheduleOrphanRecoverynow owns one process-wide recovery family. Calls before the first scan coalesce because that scan reads the live registry. Calls arriving after an attempt starts queue one follow-up scan, including during retry backoff, so new recovery work is not lost while the family is active.The scanner, dispatch, remap, session-marker, protocol, config, and persistence behavior are otherwise unchanged.
User Impact
One Gateway process cannot run overlapping orphan-recovery scans. This prevents the reported duplicate resume turns and avoids repeated full-registry scans during startup recovery bursts.
Evidence
f00bf01d1f1f9f5532f493b4fe26c0a3f332ca37oxfmt,oxlint, andgit diff --check: passedtbx_01kyye5erdthnmyh9k35b61neh(run 30695937637)