Repository navigation
fix(gateway): resume the true root after restart through visible spawned children - #201970
Conversation
…ned children - Restart root discovery walked ancestry only while the key looked like a hidden subagent, so a visible spawned coordinator (or worker) stopped the walk and its ordinary root was never marked to resume. - Follow recorded native spawn ownership (session spawnedBy / createdVia spawn) up to the ordinary root, keeping cycle, owner and incarnation checks. - sessions_send edges (no spawn metadata) stay independent roots, as #188402 needs.
|
🦞👀 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 changes before merge. What this changesThis PR follows recorded spawn ancestry through visible children to resume their ordinary root after a Gateway restart. Example: agent:main:dashboard:root has finished its turn while its visible coordinator runs a hidden worker.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Needs changes before merge - 1 item remains This PR addresses a source-confirmed recovery bug, but a failed ancestry read can prevent unrelated healthy sessions from receiving restart markers. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherShutdown selection combines live execution owners, subagent ancestry, and parked waits into persisted restart markers; startup consumes those markers through ordinary session admission. flowchart TD
A[Live execution owners] --> C[Restart selection]
B[Registry and spawn metadata] --> C
C --> D[Root restart markers]
D --> E[Startup authority admission]
E --> F[Ordinary root continuation]
Technical reviewBest possible solution: Keep spawn-aware traversal in the existing registry owner while isolating failed ancestry candidates so healthy roots still receive restart markers. Do we have a high-confidence way to reproduce the issue? Current-main traversal stops at visible session keys while persistence rejects spawned sessions; the supplied tests exercise this combination, but no target code was run during this read-only review. Is this the best way to solve the issue? Using recorded spawn metadata is appropriate and preserves ordinary conversation independence; the new asynchronous reads must retain fault isolation between recovery candidates. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d23fd767e606. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +50, Tests +99, Docs +4. Total +153 across 5 files. Added test files: 1. 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. 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 November 19, 2026, 1:11 PM ET / 18:11 UTC. |
|
Post-merge real-Gateway proof (isolated Gateway from source, real model, natural state, graceful restart). Tree: finished true root → finished visible coordinator (spawned with
|
…ned children (openclaw#201970) Problem: after a Gateway restart, OpenClaw stops running subagents and resumes only their ordinary root, which re-instructs its children. Root discovery walked up the ancestry only while the session key looked like a hidden subagent. A visible spawned child (a dashboard session from sessions_spawn visible:true) stopped the walk, its restart marker was rejected as a spawned child, and the real root was never marked. On a live Gateway a root chat -> visible coordinator -> hidden workers tree stalled after a restart until a human wrote. Fix: follow recorded native spawn ownership (session spawnedBy, or createdVia spawn with parent/controller/requester fallback) up to the ordinary root, for visible and hidden native children, keeping the cycle guard, the recorded child-authority check and the session-incarnation match. sessions_send edges carry no spawn metadata and stay independent roots, which keeps the case openclaw#188402 protected. Selection snapshots live owners before the worker reads, keeps live-root-before-parked precedence, and stays inside the existing shutdown persistence budget. User impact: a root whose work runs through a visible spawned coordinator or worker is resumed after a restart and can re-instruct its children, instead of stalling until someone writes. Proof: new ancestry regression (hidden worker under a visible coordinator; visible worker under the root) red on unchanged main and green with the fix through a real shutdown marker and startup enqueue; 11 restart-resume and registry files (110 tests); tsgo, test types, type-aware oxlint, format and the line-cap ratchet; ocx build --dts plus a packed install smoke on the head. Co-authored-by: Ayaan Zaidi <[email protected]>
…ineage spawn records Upstream openclaw#201970 (2420b7d) changed restart root discovery: resolveRootSubagentRequester now follows recorded spawn ownership and stops unless the child's session entry carries spawnedBy or createdVia "spawn" (subagent-registry-read.ts:111-114). Before, it walked by the hidden-subagent session-key shape. The fixture wrote the delegate's child session without lineage, so graceful shutdown's marker selection stopped at the child, the parent got no restart resume input, and cases 1 and 3 of the shutdown-contract pins went red on Bun and Node 24 (matrix chunk 03, f150ea9). Production continuation delegates spawn through spawnSubagentDirect, whose createInitialSubagentSession writes spawnedBy and parentSessionKey on the child (subagent-spawn-session-patch.ts:147-160). The fixture now writes the same two fields. No assertion changed: all 16 cases (graceful items 1-3, crash pins 5 and 6, the in-process restart, inspection) pass on Bun and Node 24, so the shutdown contract's behavior is unchanged for a production-shaped delegate. Refs openclaw#129388
…child session entry is gone Upstream openclaw#201970 (2420b7d) walks the restart root by recorded spawn lineage, which lives on the child's session entry. A continuation delegate whose child session entry is missing therefore leads to no root, and shutdown marked nothing for its requester. Repro at 8ba4ee8: after a graceful restart the requester got the delegate's ordinary outcome ("any work it saved ... stays in its child session", which is false), no root resume and no word about either. With the requester's session also gone, the outcome stayed pending forever with no log at all. 🌊's ruling (msg 1573423363714715731): no root inferred from the key and no unverified root resumed; one explicit "lineage missing; election outcome unknown" notice while a durable receipt still binds the requester, idempotent on the election; otherwise a diagnosable unresolved record, with no broadcast and no guess. Gateway activation (the fork's restart-custody owner, before restart resume and before any delivery) now checks each continuation delegate that a restart ended with an outcome still owed. When its child session entry is missing, the run row records continuationLineageMissing once: - the row's recorded requester agent resolves and its session exists unarchived (what restart completion recovery admits through): the delegate's one outcome opens "lineage missing; election outcome unknown (election <record id>)", says no root was resumed for it and its saved work cannot be located, and travels its return mode. Once: delivery state and the recorded decision survive a replayed activation, a second restart and the sweeps; - otherwise: the reason is recorded (requester agent unresolved, session missing or archived), a warning names the run, election, child and requester, and the row closes as intentional non-delivery, as a delegate its requester had asked to stop does. The notice is the delegate's own outcome rather than a second message: shutdown-contract item 3 allows each delegate one outcome. The root walk is unchanged and is the only caller of resolveRootSubagentRequester (selectLiveRestartResumeSessions, directly and through listLiveSubagentRootSessions). A delegate with its lineage writes no record, and its outcome is byte-identical. Pins (restart-terminal-custody item 7, red at 8ba4ee8, green here on Bun and Node 24): a graceful restart with the entry missing, per return mode (direct, silent, silent-wake, targeted), sends one lineage-missing outcome and no root resume input; a replayed activation, a second restart and its sweeps add none; a crash-settled delegate gets the interrupted variant; with no requester session, an unresolved record, a warning, no notice and no resume. Case 1 also asserts a production lineage records nothing. The status stays under the event's 500 character cap with UUID-sized ids (445 worst case). Refs openclaw#129388
What problem this solves
After a Gateway restart, OpenClaw stops running subagents and resumes only their ordinary root session, which then re-instructs its children (#185730,
docs/gateway/restart-recovery.md). Root discovery (resolveRootSubagentRequester) walked up the ancestry only while the session key looked like a hidden subagent (agent:…:subagent:…). A VISIBLE spawned child (a dashboard session created bysessions_spawnwithvisible: true) stopped the walk. Its restart marker was then rejected because it is a spawned child, and the real root was never marked.Seen on a live Gateway: a root chat → visible coordinator → hidden workers tree stalled after a restart and needed a human message 25 minutes later.
Change
spawnedBy, orcreatedVia: "spawn"with parent, controller or requester fallback. The walk now covers visible and hidden native children alike, and keeps the cycle guard, the recorded child-authority (owner) check and the session-incarnation match.sessions_sendalso registers requester edges, but it creates no child and carries no spawn metadata. Those sessions stay independent roots, which keeps the case fix: resume running channel threads after graceful restarts #188402 narrowed the walk for: an ordinary conversation must not inherit an excluded cron requester. Run records cannot tell the two edges apart, so the walk reads the session's creation metadata in a worker, once per ancestry step. A session without a registry entry stops before any read.docs/tools/subagents/operations.mdnotes that visible spawned children resolve to their root.Evidence
Proof tier: source (
ocx test).session-restart-resume.ancestry.test.ts, with two cases: a hidden worker under a visible spawned coordinator, and a visible worker directly under the root. Both fail on unchangedmain(resumeAfterRestartundefined on the root) and pass with the fix, through a real shutdown marker into the startup enqueue.session-restart-resume.workspace.test.tstimed out under heavy host load (load above 70). An instrumented run on the fix then passed in 27 s with no root-resolver calls or ancestry reads, and its close took 244 ms. It does not touch the changed path.pnpm tsgo,pnpm check:test-types, type-aware oxlint, format and the line-cap ratchet: pass.Production +50 lines, test +99 lines, docs +4 lines.