Repository navigation
fix(subagents): keep restart recovery running past stale transfer records - #165335
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 1:58 AM ET / 05:58 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch excludes stale subagent completion claims during restart recovery, warns about skipped runs, adds recovery regressions, and extracts the existing Gateway ownership helper. Merge readiness✅ Ready for maintainer review The PR remains useful: main isolates failed recovery groups but still includes superseded records within an affected group. The resolved patch preserves that isolation and its retries, addresses the previous review request, and introduces no actionable correctness findings. Priority: P1 Review scores
Verification
How this fits togetherThe subagent registry restores saved child tasks after a Gateway restart and transfers their completion obligations back to the parent. Its recovery selector determines which retained records can participate in that transfer. flowchart TD
A[Saved subagent records] --> B[Registry hydration]
B --> C[Current completion selection]
C --> D[Skip stale claims and warn]
C --> E[Transfer current obligations]
E --> F[Owner and membership checks]
F --> G[Child settlement and parent continuation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +38, Tests +137, Docs +7. Total +182 across 8 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use one current-completion selector for restoration and live settlement while preserving historical cleanup, transfer fencing, and independent recovery retries. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a focused path: hydrate stale and current completion claims for one requester turn, then activate recovery; the existing transfer guard rejects the stale member. The reviewer did not execute this path. Is this the best way to solve the issue? Yes. Reusing the admission owner's existing currency predicate avoids competing policy and preserves main's recovery isolation and retry ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7b295df476ae. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
…episodes Select current completion owners before restoring requester transfers and use the same cohort for saved yield policy and accepted receipts. Warn for superseded claims and skip empty cohorts so retained historical rows cannot block recovery of current siblings and nested children. Extract Gateway-owner recovery unchanged to keep the restorer below its existing line cap, and migrate the production and native-worker callers. Validation: 17 restart integration cases pass locally (205.79s wall, including cold worker preparation). The all-superseded case fails without the guard. Full-diff review is scoped-clean through P2. Remote gates follow this commit under maintainer direction.
eefa38d to
75c4381
Compare
|
Merged via squash.
|
…episodes (openclaw#165335) Select current completion owners before restoring requester transfers and use the same cohort for saved yield policy and accepted receipts. Warn for superseded claims and skip empty cohorts so retained historical rows cannot block recovery of current siblings and nested children. Extract Gateway-owner recovery unchanged to keep the restorer below its existing line cap, and migrate the production and native-worker callers. Validation: 17 restart integration cases pass locally (205.79s wall, including cold worker preparation). The all-superseded case fails without the guard. Full-diff review is scoped-clean through P2. Remote gates follow this commit under maintainer direction.
What Problem This Solves
Fixes: after a Gateway restart, subagent restart recovery can fail to start entirely (
Initial requester transfer episode was superseded), so no interrupted subagent is recovered.User Impact
User impact: one stale subagent registry record no longer blocks restart recovery for every other subagent. Interrupted subagents recover, or are terminalized under the existing policy so their parent can continue. A warning names any skipped stale run. There are no config or schema changes.
Why This Change Was Made
During restart, registry hydration restored stale and current requester completion claims for the same requester turn together. The requester transfer guard correctly rejected the superseded claim, but that rejection escaped the activation await and aborted the whole subagent-registry activation.
The requester-turn selector now applies the existing completion-cohort currency check (
isRequesterCompletionCohortCurrent) to drop superseded records. Activation logs a warning per skipped run and skips a requester turn whose cohort is entirely superseded. The settlement owner already rejects zero accepted spawns. The four live callers of the selector were audited: each should only see current completion obligations, and admission revalidation still enforces membership, identity, and live authority. To stay under the restorer's line cap, the existing Gateway-owner recovery function moved unchanged intosubagent-registry-gateway-owner.ts.Observed in production alongside a main-session restart recovery bug (fixed separately):
subagent restart recovery failed to activate: SubagentRegistryWriteError: Queued subagent registry persistence failed: Initial requester transfer episode was superseded.Evidence
src/agents/subagents/registry/subagent-parent-recovery.restart-integration.test.tsreproduces the original order: children restart-aborted, then the main requester marked interrupted, then hydration restoring stale and current claims. Before: 2 failed / 14 passed with the exact production error. With the all-superseded case added and the fix applied: 17/17 pass.pnpm test <file> --maxWorkers=1took 205s locally (an existing heavy file; it was 212s before this change); an earlier Testbox run of the file took 44s.Earlier remote sibling runs passed requester-yield 43/43 and wake-commit 25/25.
Codex autoreview was scoped-clean through P2 on the final diff.
Gap: the full remote
check-changedgate did not run locally, because shared Crabbox/Testbox capacity was saturated. PR CI is the gate for it.Conflict resolution: rebased the reviewed
eefa38d0bb728b24da550a9ee76f2b08e4a4d84fcandidate onto mainb57e493c831749ac097e7f7e8f28f48bb85add3c. Main had extracted requester restoration intosettleRestoredRequesterTurns; the current-child selection, stale-run warning, and empty-cohort guard now run in that helper. Main retains failed-cohort isolation, retry custody, and one-time collector resumption. The earlier 17/17 local result remains prior-head evidence; no earlier passing PR CI run exists. After resolution,pnpm test src/agents/subagents/registry/subagent-parent-recovery.restart-integration.test.ts --maxWorkers=1passed 17/17 (415.43s wall), andpnpm test src/agents/subagents/registry/subagent-registry-queued-recovery.test.ts --maxWorkers=1passed 8/8 (167.10s wall).Fresh Codex autoreview of the full conflict-resolved candidate was scoped-clean through P2, with no actionable findings.
Release note: subagent restart recovery keeps going past stale requester transfer records instead of failing for every subagent after a Gateway restart.