Repository navigation
fix(sessions): wait for subagent restoration before restart recovery - #174134
Conversation
Join restored Gateway bindings before admitting requester continuations. Filter archived, tombstoned, and custody-free recovery rows in the session worker while retaining pending terminal settlements. Split startup recovery timings and cover both consumed delivery representations.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR delays main-session recovery until subagent restoration settles and filters unnecessary recovery rows inside the session worker. Example: Gateway restarts while agent:main:main has an interrupted requester continuation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a concrete startup-ordering defect still present on main. No actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup coordinates subagent restoration and main-session recovery; the session reader worker supplies durable recovery candidates to the existing admission and dispatch owners. flowchart TD
A[Gateway startup] --> B[Post-ready recovery observers]
B --> C[Subagent restoration settles]
C --> D[Main-session recovery scheduler]
D --> E[Session worker selects obligations]
E --> F[Existing admission and dispatch]
Technical reviewBest possible solution: Join the existing restoration lifetime before startup recovery while preserving current authorization, cancellation, and pending-delivery ownership. Do we have a high-confidence way to reproduce the issue? Current-main source permits recovery after post-ready release while subagent restoration is still pending; the supplied ordering regressions reportedly fail on that behavior, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch fixes ordering at the startup owner and reuses the existing worker and claim predicate, avoiding a competing recovery scheduler or authorization fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 890370dba59d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +57, Tests +78, Docs +7. Total +142 across 12 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 7:22 AM ET / 11:22 UTC. |
Reconcile orphaned receiver custody through the existing recovery owner before agent admission touches the session row. Retain exact-session, live-writer, worker-placement and command-claim checks, plus the restored registry gate. Main 9215eac reproduces all five lost deliveries; the parent of #174134 passes the unchanged cold-restart regression. All 66 focused tests pass with maxWorkers=1 (227.07s wrapper, including runtime build; native case 40.20s). Core types, targeted lint/format and independent P2 review pass. Release-note context: accepted peer updates recover across startup ordering without manual resend; cancelled/reset/revoked sources remain blocked.
…penclaw#174134) * fix(sessions): wait for subagent restoration before restart recovery Join restored Gateway bindings before admitting requester continuations. Filter archived, tombstoned, and custody-free recovery rows in the session worker while retaining pending terminal settlements. Split startup recovery timings and cover both consumed delivery representations. * test(sessions): align startup counts with worker recovery filtering
…w#174203) Reconcile orphaned receiver custody through the existing recovery owner before agent admission touches the session row. Retain exact-session, live-writer, worker-placement and command-claim checks, plus the restored registry gate. Main 78c0e92 reproduces all five lost deliveries; the parent of openclaw#174134 passes the unchanged cold-restart regression. All 66 focused tests pass with maxWorkers=1 (227.07s wrapper, including runtime build; native case 40.20s). Core types, targeted lint/format and independent P2 review pass. Release-note context: accepted peer updates recover across startup ordering without manual resend; cancelled/reset/revoked sources remain blocked.
What Problem This Solves
Main-session restart recovery could attempt a requester continuation before the subagent registry installed its current Gateway binding and restored completion authority. Startup also materialized archived and settled session rows before deciding to skip them.
User Impact
Requester recovery now waits for subagent restoration to settle. Discovery excludes archived sessions, recovery tombstones, and rows without remaining obligations before target preparation; completed sessions with pending delivery or recovery custody still settle. Existing authority and exact-target retry checks remain intact.
Historical records without restorable original operator evidence still require a fresh authenticated continuation. Restarting again cannot manufacture that evidence. There is no schema, retention, configuration, or permission change.
Why This Change Was Made
The startup owner retains its original cutoff and cancellation handle, then joins the existing subagent recovery operation before its first scan. The session worker selects potential recovery owners and applies the existing claim predicate before transferring rows to the Gateway. Separate reader, delivery, and registry startup spans make the previous umbrella timing diagnosable.
Related: #173873, #173878.
Evidence
Metadata-only restart investigation, counting the initial three startup passes:
Every failed requester cohort has execution sightings before the deployment that introduced durable operator evidence. Exact original admission timestamps and the precise missing/mismatched stored field are not available from the journal.
Measurement: recovery umbrella 13.562 s before versus 24.360 s after the investigated deployment, not before/after this patch. It includes history preparation, saved deliveries, and registry activation. A 16.201 s gap before an inactive recovery observation is not partitioned by existing logs; repeat candidate passes took 823 ms and 733 ms. No elapsed-time speedup is claimed. The synthetic worker regression reduces transferred rows from 10 to 5 while retaining every pending-obligation variant.
Focused validation: 157 distinct tests passed across seven files:
session-entry-recovery.worker.test.tsandmain-session-restart-recovery-admission.test.ts: 25/25, 67.16 s including 20.05 s cold worker compilation. The new selection case took 571 ms; the old reader fails with 10 rows instead of 5.server-startup-post-attach.test.tsandserver-startup-observers.test.ts: 91/91, 27.18 s. Both restoration-order cases fail with the oldwaitForStartgate and pass after the fix; restoration failure and shutdown remain covered.session-send-recovery.test.ts: 21/21, 23.28 s, including removed and retained consumed inputs. An initial run stopped before collection because a source file changed during worker compilation; the frozen-source rerun passed.Final reader simplification: the five worker cases and four existing memory-reader cases passed (9/9, 30.88 s including 18.61 s cold compilation); the unchanged disk-admission and startup proof above is reused.
Production delta: +57 lines (+83/-26). This correctness repair adds schema-free worker selection, excludes non-durable incognito recovery, and joins the existing startup recovery lifetime; the main-thread claim filter is removed. Timing spans expose the unresolved startup cost. No cache, fallback authority, new scheduler, or speculative speedup is introduced.
Broad gates belong to PR CI; no Testbox/Crabbox lease, heavy benchmark, production restart, or live-state mutation was performed. No full process-restart or live deployment proof was run locally.
Changed-file formatting and lint passed. Fresh independent autoreview is scoped-clean at P0–P2 on the final diff; no actionable findings remain. The reader simplification was re-reviewed after resolving the existing file line limit.
CI follow-up
The initial exact-head CI run found two stale skipped-count expectations in
main-session-startup-recovery.test.ts: archived rows now disappear during worker discovery, so they no longer count as skipped candidates or emit archived-candidate diagnostics. Those expectations are corrected; stored-entry, transcript, live-owner, newer-turn, and dispatch assertions remain intact. The single failing file passes all 16 cases locally (18.16 s), with changed-file lint and fresh independent P0–P2 review clean. The correction is test-only; no manual CI rerun was requested.Final validation: PR CI run 38891592916 and the required CI/security gate passed on
a3e307f4101f355a7db11fb01b2267e71911f54e. Merged asb4ce369de7e8d0047365e7410145321d654eaf51after both required gate records reported success.