Repository navigation
fix(agents): preserve restart-interrupted parent continuation ownership - #165496
Conversation
Keep the active parent source when shutdown also records queued child announcements. Join its recovery claim and final receipt on announcement retries, and refuse execution when recovery completed that exact source while admission waited. Other child completions wait for the recovery owner. Report each skipped recovery candidate and keep skip reasons in mixed startup summaries. Existing session fields and batch ownership are retained. Co-authored-by: Oldrich333 <[email protected]>
|
🦞👀 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, 7:22 AM ET / 11:22 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR preserves interrupted parent-turn identity across Gateway restarts, prevents completion retries from replaying recovered work, and improves recovery diagnostics. Merge readiness✅ Ready for maintainer review This remains a useful, bounded fix absent from current main. No introduced correctness or security blocker was found, and exact-head CI passed; the related work does not supersede the full repair. Priority: P1 Review scores
Verification
How this fits togetherGateway restart recovery resumes interrupted agent conversations from persisted session state. Subagent completion notices pass through session admission and delivery reconciliation so parent conversations continue without duplicate execution. flowchart TD
A[Parent turn and child notices] --> B[Gateway restart]
B --> C[Persist interrupted source]
C --> D[Session recovery owner]
E[Completion retry] --> F[Check source and receipt]
D --> F
F --> G[Reuse recovered result]
F --> H[Wait or admit unrelated notice]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +22, Tests +263, Docs +5. Total +290 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep source identity and receipt consumption with the existing recovery owner so each interrupted parent continues once while unrelated notices retain normal admission. Do we have a high-confidence way to reproduce the issue? Yes: current source clears lifecycle identity while multiple run fences defeat the single-fence source fallback, and announcement retries lack the matching recovery guards. Reported negative controls support this path; this read-only review did not execute it. Is this the best way to solve the issue? Yes: the patch repairs source capture at its producer and reuses existing admission and receipt reconciliation without creating a competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2d3a5c7bbced. 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 (4 earlier review cycles)
|
|
Merged via squash.
|
…ip (openclaw#165496) Keep the active parent source when shutdown also records queued child announcements. Join its recovery claim and final receipt on announcement retries, and refuse execution when recovery completed that exact source while admission waited. Other child completions wait for the recovery owner. Report each skipped recovery candidate and keep skip reasons in mixed startup summaries. Existing session fields and batch ownership are retained. Co-authored-by: Oldrich333 <[email protected]>
…166030) Consolidate claim fixtures and equivalent recovery, media, and receipt cases while retaining distinct race inputs and durable-state assertions. Preserve the requester recovery regression coverage from #165496. Test-only scope: 2,567 to 2,276 lines; the target exception and Testbox proof are recorded in the PR.
…penclaw#166030) Consolidate claim fixtures and equivalent recovery, media, and receipt cases while retaining distinct race inputs and durable-state assertions. Preserve the requester recovery regression coverage from openclaw#165496. Test-only scope: 2,567 to 2,276 lines; the target exception and Testbox proof are recorded in the PR.
What Problem This Solves
Fixes: an interrupted parent continuation loses its source identity when a Gateway restart also drains queued child announcements, allowing the original completion to run again or fail behind the recovery owner.
User Impact
Parent turns started by subagent pause notices or completion announcements retain the same recovery source across restart. Retries join the existing recovery and consume its final receipt. Unrelated child completions wait for the recovery owner; stopping, resetting, replacing, or rerouting a session still revokes pending work.
No schema, configuration, or migration changes. Existing session recovery fields and terminal receipts retain ownership; waiting yielded parents remain with the child-batch owner. Previously persisted source-less recovery rows retain the existing single-fence correlation fallback until they settle.
Why This Change Was Made
Shutdown previously saved the active and queued run fences, then cleared the active lifecycle ID. Startup could identify a source only when exactly one fence remained. Preserve the already-recorded source before releasing lifecycle ownership, and apply the existing receipt reconciliation to announcements as well as settle turns. Refuse execution if that exact source completed while waiting for recovery, without blocking a different sibling source.
Includes the announce admission wait from #161788, with credit to @Oldrich333. This complements #165335: restoring unrelated registry work after a superseded transfer does not preserve a parent continuation's own interrupted source. Recovery logs now identify skipped sessions and reasons even when other sessions start successfully.
Net production LOC: +22 (29 added, 7 removed), required to preserve the exact interrupted source, refuse execution after a matching terminal receipt, and report skipped sessions. The existing schedulers and store remain the only owners.
Evidence
tbx_01m45h4bqcf9jgpqm2rbdzg2nw, pinned basee78e965a55e2d2b121c61d0a93e571c26f6f50f8.tbx_01m45s0zsbpq7rnmx74vxv3apw:node scripts/check-changed.mjs --base e78e965a55e2d2b121c61d0a93e571c26f6f50f8 --head HEAD. Formatting, boundary/ratchet guards, production types, and all 27 core-test typecheck groups pass. The command exits 1 at the broad dead-export scan on two inherited exports:GoogleMeetJoinResultinextensions/google-meet/src/transports/types.tsandMeetingRuntimeOwnerinsrc/meeting-bot/runtime-facade-types.ts. Replacing all ten changed files with their exact base bytes, verifying a zero diff against the base, and rerunningnode --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mtsreproduces the same failures. The candidate was restored and verified clean afterward. No scanner exception or unrelated source change was added.tbx_01m45fy33h1wbhv6b1qym5ksaapassed 21 baseline tests, then hit two full-sync timeouts and was stopped. No local test suite, build, or typecheck ran.tbx_01m45n39k3zxc9syet3fh9cw2r:node scripts/run-vitest.mjs <file> --maxWorkers=1— command recovery owner: 41 tests, 27.72 s wall; direct announce delivery: 32 tests, 15.41 s; parent restart integration: 19 tests, 35.00 s. All pass. The integration file exercises real SQLite/registry shutdown and startup ownership; its existing shared fixture and asynchronous persistence make this cost materially higher than the pure admission/delivery files.22c1990af349c76169cded0fb117a6f58158a20f.Limits: the standalone changed-file aggregate remains red only on the reproduced base dead-export failures; exact-head CI is green. Behavioral proof uses synthetic SQLite/registry state and mocked dispatch, not a production deployment or live provider restart. The source-loss regression proves source correlation and replay suppression; it does not claim that the historical production incident's entire lifecycle-publication ordering was reproduced. User-input preservation and transcript-conflict classification are outside this change.