Repository navigation
fix(gateway): resume a root whose yield source was lost instead of failing it - #202044
Conversation
…iling it - Startup failed every yielded session whose wake source could not survive the restart. For a root that ended its work: nothing could wake it, so it needed a new human message. - The registry read owner now reports a root as waiting while a child still owes it a settlement or delivery (that completion is its only wake); a root with nothing owed gets the ordinary restart input to inspect and reconcile. - Sub-agents keep the lost-source failure plus registry settlement (#202000).
|
🦞👀 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. What this changesResume yielded root sessions after restart when no child completion remains capable of waking them. Example: agent:main:dashboard:parked-root restarts after its awaited child registry entry disappears.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a current root-recovery defect, and no introduced correctness or security defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway startup classifies persisted session waits using the subagent registry, then preserves a reachable wait, settles an unreachable child, or admits ordinary root recovery. flowchart TD
A[Gateway startup] --> B[Registry wait classification]
B --> C[Child completion still owed]
C --> D[Registry wakes requester]
B --> E[Root has no remaining wake]
E --> F[Authority checked restart input]
B --> G[Unreachable child settlement]
Technical reviewBest possible solution: Keep registry completion as the wake owner while an obligation remains, otherwise resume the eligible root through ordinary restart admission. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the unreachable-root failure path, and the supplied regressions report the matching base failure; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch is a small, complete repair using existing classification, completion, and admission owners, with distinct regressions for direct recovery and child-settlement wake ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d5f3e4d7b75a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +19, Tests +30, Docs +2. Total +51 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 November 19, 2026, 3:26 PM ET / 20:26 UTC. |
|
Real-Gateway restart proof (isolated Gateway from source, real model, natural source loss by SIGKILL; no state injection). A root yields in
Case (a) ran with background-process exit notices disabled after the crash, on both sides, so the comparison differs only in code. Known, pre-existing, not changed here: with exit notices on, an interrupted root also receives the background process's lost-exit notice, so it replies twice. A non-yielded interrupted root on unchanged |
…iling it (openclaw#202044) Problem: at Gateway startup, every yielded session whose wake source could not survive the restart was closed with a visible failure. A sub-agent is then settled by the registry and its requester wakes (openclaw#202000), but an ordinary root has no registry row, so its work stayed failed until a human wrote to it. Fix: resolveSessionYieldWait (the registry read owner) reports a root as waiting while a child still owes it a settlement wake, an unfinished completion, a yield or a pending/in-progress delivery; that registry completion is the root's only wake. A root still unreachable (nothing will wake it) is admitted through the ordinary restart-resume input instead of failed. Sub-agents keep the lost-source failure plus registry settlement. No ordering or handshake: the registry is shared across physical agents and hydrated before restart resume. A failed delivery is terminal and does not count as owed. Proof: source tier (ocx test): red on unchanged main for both roots (marked failed); green with one restart input across two boots, or one subagent_settle wake with no restart input. 230 tests across 19 files; tsgo, test types, oxlint, format, lifetime-check, line-cap and session-identity ratchets; clean exact-head local ClawSweeper review; ocx build --dts plus packed install smoke on the head. Real-Gateway restart proof (isolated Gateway, real model, natural SIGKILL source loss): root without owed child gets restart x1 and ends done; root with settled lost-source child gets subagent_settle x1, restart x0, ends done; unchanged main ends failed. Co-authored-by: Ayaan Zaidi <[email protected]>
What problem this solves
At Gateway startup, a session parked in
sessions_yieldwhose wake source could not survive the restart was always closed with a visible failure (recordRestartYieldFailure). For a sub-agent that is correct: since #202000, the registry also settles it and its requester wakes. For an ordinary root session, nothing settles:completeSubagentRunWithRecoveryreturns at once when there is no registry row. So the root's work just failed and stayed failed until a human wrote to it. The restart contract says an interrupted root gets one ordinary input to inspect current state and continue.Seen live: a root failed at startup and was only rescued by an unrelated child-settlement turn nine seconds later.
Change
resolveSessionYieldWait(the registry read owner,subagent-registry-read.ts): at the root branch, when no waiting child resolves but a child still owes this requester a completion, it returnswaiting. "Owes" means a pending settle wake, or an owed completion that is not yet terminal, is still yielded, or has a delivery pending or in progress. That registry completion is then the root's only wake.session-restart-resume.ts: a root that is stillunreachable(nothing will ever wake it) is admitted through the ordinary restart-resume input instead of being failed. Sub-agents keep the lost-source failure plus registry settlement (fix(gateway): settle a lost yielded child after restart so its parent wakes #202000).server-startup-observers.ts:63, then:74).subagent-registry-lifecycle-finalize-cleanup.ts:234-244), so counting it would park the root forever.docs/gateway/restart-recovery.md: corrected the lost-source row and paragraph.Follows #201970 and #202000.
User impact
After a restart, a root session waiting on work that cannot continue resumes on its own to inspect and reconcile, or wakes on its child's settlement. It is not left failed until someone writes to it.
Evidence
Proof tier: source (
ocx test).resumeMarkedSessionsstartup path. On unchangedmain, both roots are markedfailed. With the fix:subagent_settle, with no restart input and no failed status.pnpm tsgo,pnpm check:test-types, oxlint, format, and the lifetime-check, line-cap and session-identity ratchets: pass.subagent-registry-worker.test.ts"releases serialized payloads while their immutable registry rows remain resident" also fails on cleanmain(d9e2d8a).Production +24 −5 lines, tests +47 −17, docs +4 −2.