Repository navigation
Conversation
Retain required shutdown errors through canonical completion settlement and enroll direct completion turns in existing processing receipts so transient pre-consumption failures can retry. Preserve intentional Stop and completed-receipt replay protection. Real-Gateway restart regressions fail on the parent and pass with the fix.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review Summary: ✅ CompletedThis 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. |
|
@clawsweeper review Please review the final head 93d4c44, focusing on shutdown completion custody and safe retries of direct completion inputs. All 18 real-Gateway restart cases, 318 focused owner tests, and pnpm check:changed pass; isolated Codex review is clean through P2. The source-owner guards changed separately by #195275 are untouched. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesPreserves interrupted subagent outcomes for delivery after restart and enables safe retries of direct completion inputs. Example: A requester finishes its turn while its child is running, then the Gateway restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR narrowly repairs two completion-delivery defects still present on current main; review found no actionable introduced bug. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe subagent registry settles child execution and retains completion obligations; Gateway turn admission persists and reconciles the inputs that deliver those outcomes to requester sessions. flowchart TD
A[Gateway shutdown] --> B[Subagent terminal owner]
B --> C[Persisted completion obligation]
C --> D[Startup completion recovery]
D --> E[Requester turn admission]
E --> F[Processing receipt]
F --> G[Requester conversation]
Technical reviewBest possible solution: Use the existing terminal completion and processing-receipt owners to preserve delivery obligations while retaining Stop, consumption, and completed-receipt finality. Do we have a high-confidence way to reproduce the issue? Source inspection establishes both failure paths on fetched main, and the maintainer reports base-red/head-green Gateway regressions; this review did not independently execute them. Is this the best way to solve the issue? The patch is the smallest complete repair supported by the inspected paths: it corrects shutdown settlement and extends the existing receipt classification without adding a retry mechanism or competing state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 24cb73462fe3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests +13, Docs +4, Other +187. Total +211 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:
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 18, 2026, 7:47 PM ET / November 19, 2026, 00:47 UTC. |
|
Exact-head CI run 44431185416 has one inherited failure: |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…w#201544) Retain required shutdown errors through canonical completion settlement and enroll direct completion turns in existing processing receipts so transient pre-consumption failures can retry. Preserve intentional Stop and completed-receipt replay protection. Real-Gateway restart regressions fail on the parent and pass with the fix.
…estart-custody pin Upstream openclaw#200533 (703c82d) moved queued-input custody from the graceful shutdown marker to the pending-input rows, so the marker is `{}` rather than `{ queuedInputIds: [] }`. Case 3 of subagent-registry.restart-terminal-custody (the root's resume input does not stand in for a delegate's receipt) pinned the old shape: green at chain head fa212db, red at ead2225, 11/11 here. The custody assertions that follow are unchanged. Carried to the pure candidate (stage 2): openclaw#200533 arrives with the 41bdde2 merge. On the merged head case 3 fails at the marker ({} vs { queuedInputIds: [] }); with this change it passes the marker and stops at the separate upstream openclaw#201544 shutdown-outcome change (subagent-error vs subagent-killed), which is held for 🌊's ruling and not changed here. (cherry picked from commit 525e98d) Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… H1 custody against the sweeper (O3) 🌊's O3 ruling pins, carried to the pure candidate (stage 2): upstream's restart sweeper settle (openclaw#200807/openclaw#200873) arrives with the 41bdde2 merge, and the fork's activation settle (subagent-registry-restart-custody.ts) is the same code here, so the precedence is kept only with its restart test. - 0019d35 (verbatim): activation settles an earlier process's delegate before the sweeper, and its requester gets no second outcome; a plain sibling is the live-sweeper control. - decc47c: the T3d H1 rows, inserted without the staging-only T3b/T3c chain pins that preceded them there. On this tree: the new restart case passes; with the activation settle call removed it is red at the post-activation receipt (expected terminal, got running). The H1 file is 24/24 solo twice; T9/T9b showed the documented 1-of-2 load-timing flake in one paired run and were green on the rerun. Cases 1 and 3 of the restart-custody file stay red on the separate upstream openclaw#201544 shutdown-outcome change, held for 🌊's ruling. (cherry picked from commit 0019d35) (cherry picked from commit decc47c) Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Retain required shutdown errors through canonical completion settlement and enroll direct completion turns in existing processing receipts so transient pre-consumption failures can retry. Preserve intentional Stop and completed-receipt replay protection. Real-Gateway restart regressions fail on the parent and pass with the fix. (cherry picked from commit 82e52b6) Co-authored-by: RomneyDa <[email protected]>
Retain required shutdown errors through canonical completion settlement and enroll direct completion turns in existing processing receipts so transient pre-consumption failures can retry. Preserve intentional Stop and completed-receipt replay protection. Real-Gateway restart regressions fail on the parent and pass with the fix. Backport fixture correction: register live execution custody in the restart collector fixture; production unchanged. (cherry picked from commit 82e52b6) Co-authored-by: RomneyDa <[email protected]>
…resume 🌊's ruling on upstream openclaw#201544 keeps its delivery path: a graceful shutdown completes a live child with the error "Gateway stopped", and the requester receives that outcome after startup. Restart-terminal-custody cases 1 and 3 still asserted the fork's earlier quiet kill (subagent-killed, intentional_non_delivery) and were red at e7de8c3 on that assertion. Both cases now run startup end to end through the real announce flow: the shutdown, a new lifecycle, the root resume, and three sweeps. They record what each requester receives at the delivery seam. Case 1 has one live delegate. The root gets exactly one input, GATEWAY_RESTART_RESUME_TEXT, which names no child and claims no completion. The requester gets exactly one outcome for that child, and its rendered text is pinned in full ("status: failed: Gateway stopped", "session_id: unknown", "(no output)"). The row ends delivered, never as a success. Case 3 adds an unreached sibling. It still gets no notice in this commit, and both custody receipts stay inspectable. O3's no-second-outcome case is unchanged and green. The delegate rows now carry requesterAgentId, as spawn always records it. Restart completion recovery admits a pending child only by that field. Without it the stopped child's outcome was never re-admitted in this fixture. Negative control: with the pre-openclaw#201544 quiet-kill shutdown restored (markSubagentRunTerminated with suppressTaskDelivery), case 1 is red ("expected 'subagent-killed' to be 'subagent-error'"). Case 3 stays green there because upstream openclaw#201706's restore repair re-owes the quiet-kill row on boot. Item 4 of this lane handles that repair. Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
🌊's ruling on upstream openclaw#201544, item 2: a sibling silently settled by intentional_non_delivery must not disappear from the prince's account. Show which children were stopped or not reached in the root resume, or give each a mode-preserving terminal outcome, never both, and keep O3's no-second-outcome guard. This takes the second route. At e7de8c3 Gateway activation settled a delegate the previous lifecycle left running as interrupted, then closed it with suppressCompletionDelivery and intentional_non_delivery. A delegate the bounded shutdown kill never reached, or one a crash stranded, therefore produced no notice. The requester saw only the root's generic resume input after a graceful stop, and nothing at all after a crash. The interruption is now the delegate's one outcome, owed to its requester like the shutdown's own. The settle freezes no result text, as the canonical error completion does, and leaves delivery pending. Startup's restart completion recovery admits it under current authority and resumes it. The registry announce flow then routes it by the delegate's own return mode: direct, silent, silent-wake or targeted. Under an in-process restart the custody is still live, so the outcome goes out at activation. A row that owes nothing still finishes cleanup at once. The root resume input is unchanged: it names no child, and no child gets two outcomes. Why not the root-resume list: GATEWAY_RESTART_RESUME_TEXT is upstream-owned and constant, a crash has no root resume to carry a list, and a list reaches only the root. A targeted or nested delegate returns elsewhere, so a list could not honour its mode. Per-child outcomes take the route the reached sibling already takes under openclaw#201544, and stay in the continuation-owned restart custody. Pins (restart-terminal-custody, rendered text at the delivery seams): - Two siblings in one restart, one reached by the shutdown and one not. Each is accounted for once, alongside the root's one resume input. The direct case keeps both custody receipts inspectable. silent, silent-wake and targeted each carry both outcomes on their own route: no wake for silent, one silent-wake per outcome, and the target session, woken, for targeted. - A crash-restored delegate owes one interrupted outcome, gets no root resume, and is never relaunched. The plain child keeps upstream's history and gets none. - In-process restart: one outcome at activation. - O3: the activation-settled delegate gets exactly one announce flow and one outcome, never the sweeper's "did not survive the restart". The plain child gets the sweeper's notice. Every child is accounted for once. - The parent's inspection while the outcome is owed: the list and snapshot report the delivery as pending, and runtime facts list the row under "Child results awaiting delivery". Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
🌊's ruling on upstream openclaw#201544, item 3: "failed: Gateway stopped", "(no output)" and "session_id: unknown" cannot distinguish a graceful shutdown from a task failure or support reasoning about recovery. Give the outcome an explicit graceful-stop reason, the delegate's identity, and any retained partial state, or say plainly that none was retained. Never fabricate a child id. At db74f92 the requester's status line read "failed: Gateway stopped" for a graceful stop and "failed: subagent run interrupted: the Gateway restarted before it ended" for a restart interruption. The task label and session key were the only identity, and "(no output)" did not say whether anything had been kept. The status label now names each case and stays within the event's 500-character status bound: - graceful stop: "stopped by a graceful Gateway shutdown before run <runId> finished (recorded error: Gateway stopped). Not a task failure; the run was not resumed. ..." - restart interruption (an unreached or crash-stranded delegate): "interrupted: the Gateway restarted before run <runId> ended, and no graceful shutdown reached it. Not a task failure; the run was not resumed. ..." With no result: "No result or partial result was retained; any work it saved before then stays in its child session. Inspect it before re-dispatching or abandoning the task." A suppressed-effects child's session is never cleaned up, so that holds on either cleanup mode. With a captured result: "Its last output before then follows as a partial result." The run id comes from the registry row. session_id stays "unknown": with child-session effects suppressed the announce does not read the session, and nothing invents an id. The recorded "Gateway stopped" error stays verbatim, so upstream's restart e2e cases that match on it still find it. Every other outcome renders as before. The label lives in the continuation-owned message builder. The one upstream-owned file touched is subagent-announce.ts, a one-line fork hunk that passes childRunId. The restart interruption error is exported from the restart custody that records it. Pins: restart-terminal-custody pins the full rendered requester text for direct delivery and for silent, silent-wake and targeted returns, for both reasons, through the real announce flow. Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e a deploy 🌊's ruling on upstream openclaw#201544, item 4: before any deploy, audit the target's older pending quiet-kill rows and prevent a surprise late delivery from restore. Verify the migration on fixtures first. The hazard: before openclaw#201544 a graceful shutdown ended a live child with markSubagentRunTerminated(reason "Gateway stopped", suppressTaskDelivery). That left delivery pending as a quiet kill. On its first boot, upstream openclaw#201706's restore (subagent-registry-restore- metadata.ts) re-owes every such row that is still pending, whenever the restart that wrote it happened. A probe of the pre-merge fork head bc7e568 confirms that those rows match the predicate as its shutdown writes them and still match after its next activation. What later boots do to them depends on the seat, so each owner has to count their own. The predicate restore uses is now exported as isUnrepairedShutdownQuietKill, unchanged; restore itself calls it. It is the one definition, so the audit cannot drift from restore. This is the only upstream-owned change in this commit and is a candidate upstream contribution. Operator surface, offline, beside fence-status and interrupt-fenced: - openclaw continuations shutdown-notices [--json]: read-only. It is refused while a Gateway owns the state and reads through an artifact-preserving snapshot. It lists every row restore would re-owe (the predicate, minus rows whose child authority restore skips) with runId, child, requester, delegate or plain, and endedAt. It prints no task text. - openclaw continuations settle-shutdown-notices --ended-before <time>: runs under exclusive local state ownership. First it writes a backup with each row exactly as stored plus what the settle will write (<stateDir>/backups/subagent-shutdown-notices/, 0600, fsynced). Then it closes each row that ended before the cutoff as an intentional non-delivery: delivery not_required, disposition intentional_non_delivery, suppressCompletionDelivery. It compares and swaps on the stored payload, never deletes a row, and starts no turn. Rows at or after the cutoff are kept, so the deploy's own stop is still delivered. - settle-shutdown-notices --undo <backup>: puts back each row that is still exactly as the settle wrote it. Pins, on fixtures written by the pre-openclaw#201544 shutdown call itself, booted through this build's real restore, root resume and announce flow (subagent-registry.shutdown-notices): 1. The count names the three re-owed rows, not the explicit Stop. On an unsettled seat the week-old rows are delivered late: the hazard. 2. After a settle with a cutoff between them, the requester receives only the root resume input and the deploy restart's one stopped delegate. The settled runs are neither deleted nor delivered. Each stays reachable by run id as ended by "Gateway stopped" with delivery not_required. 3. The undo restores the rows byte for byte, and restore then re-owes them as before. The CLI case pins the receipts, the untouched store bytes for the count, and the refusals (no instruction, an unparseable time). The restart custody suites share their registry world through subagent-registry.restart-custody.test-support.ts. The worker inventory classifies the settle as a CLI one-shot (T3) and is regenerated. Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…esented CLI 🌊's ruling (msg 1573159410027733043): move `shutdown-notices` and `settle-shutdown-notices` out of the CLI presented upstream and into fleet-only deploy tooling. Item 4 stays a required pre-deploy audit and settle gate, with its fixture proof and an exact-build receipt. The gate now lives in karmaterminal/openclaw-bootstrap, deploy/tools/subagent-shutdown-notices (8368a13629). It runs from the target build's checkout and imports that build's own state paths, snapshot, subagent_runs store and codec, child-authority check and offline owner gate. So this tree exposes no command or export for it. Its fixture proof moved with it. prove.sh runs the proof against an exact product SHA: fixtures written by the pre-openclaw#201544 shutdown, the tool in cold processes, this build's real restore and announce flow. Removed from this tree, each restored to its e7de8c3 bytes: - register.continuations.ts and its test: the two commands, their receipts and refusals. fence-status and interrupt-fenced are unchanged; - subagent-registry-restore-metadata.ts: the predicate is inline again, so the file equals upstream 41bdde2 byte for byte; - the worker inventory's T3 classification and the regenerated inventory; - docs/cli/index.md's section and command tree entries. Deleted: subagent-registry-shutdown-notices.ts and its suite. RFC §5.4.4 boundary 5 drops the sentence naming the commands. The restart custody test-support no longer takes the older shutdown's kill as a parameter, because only the moved suite passed one. The test-lines record is re-measured: +428 over e7de8c3, down from +575. Refs openclaw#129388 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…w#201544) Retain required shutdown errors through canonical completion settlement and enroll direct completion turns in existing processing receipts so transient pre-consumption failures can retry. Preserve intentional Stop and completed-receipt replay protection. Real-Gateway restart regressions fail on the parent and pass with the fix. Release adaptation: Reviewed canonical shutdown error and processing receipt custody; owns real restart test error assertion and collector regression. (cherry picked from commit 82e52b6) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
A Gateway restart can interrupt a completion-required subagent and silently retire its outcome, especially when the requester has already finished its turn. Separately, a transient failure before a direct completion is consumed can leave its input cancelled, making the scheduled retry fail permanently against the same input.
User Impact
User impact: requesters receive the interrupted child's “Gateway stopped” outcome after startup, and direct completions can retry transient failures before consumption. Intentional Stop and already-completed work retain their existing replay protection. No configuration or schema changes are required.
Why This Change Was Made
Shutdown now uses the existing terminal completion owner instead of intentional quiet-kill settlement. It captures the error and defers cleanup, preserving the required delivery obligation through restart. Direct completion turns now use the same processing receipts and safe cancelled-input retry as private and batched completions.
The production change is seven net lines: an explicit error outcome with deferred cleanup, and inclusion of direct completions in the existing receipt classification. No new retry loop, cache, or state owner. Requester-run turnover and source-owner guards are handled separately in #195275 and are untouched here.
Related: #198905, #199488, #199868, #201460, #195275.
Evidence
Real-Gateway restart regressions fail on the exact base and pass with this change: a running child reports its shutdown error to both a yielded requester and an already-finished requester; a recovered completion survives a transient access-policy failure and reaches the requester on retry. The assertions require the actual child outcome, so a generic restart prompt cannot satisfy them.
244 lifecycle/worker/restart-collector tests and 74 Gateway receipt, queued-registration and swarm-close tests pass. All 18 real-Gateway restart and completion-custody cases pass, including announcement crashes, private completions, busy requesters and stale settle wake recovery.
pnpm check:changedpasses, and isolated Codex review is clean through P2. Synthetic scale proof uses a 43.35 GiB database, 10,800 sessions, 4,300 runs and 62,000 files (1.116 GB), on APFS. Five interleaved A/A/B timing groups give shutdown-owner wall medians of 628/652/650 ms and CPU medians of 970/981/1002 ms; the unchanged A/A controls include a 1767 ms outlier, so no speedup is claimed. Three separate allocation-sampling groups show main-isolate allocation of 14.54/14.56/18.00 MB, about 24% extra for preserving canonical completion custody. Every candidate run retains 16/16 required outcomes; both base controls retain 0/16. Imports, fixture setup and hydration are outside timing. Allocation excludes worker heaps; CPU includes workers. This measures terminal settlement, not total restart downtime or btrfs behavior. The committed probe reproduces the measurement.The generic historical “agent run aborted” message alone does not identify its aborting predicate. This change fixes the independently reproduced obligation and retry defects; it does not claim to establish that historical predicate.
CI attribution
Exact-head CI run 44431185416 has one inherited failure:
src/gateway/chat-goal-created-authority.e2e.test.tstimes out waiting for provider cancellation afterusers.setRole. It reproduces on CI’s exact main parentb7bf9150fa20bfe93cfe6a64b79c4f0f5ec4ce4e. The unchanged test passes onb400e8deed133ac0fa084072424fe1285f162952and fails on its immediate successorad550e953a9bcd81a424de087afed5823454ec97(#201377). That change fixes authority for an admitted recovered continuation but leaves this test expecting mid-request role revocation. This is a main test-contract regression requiring follow-up, not dismissed as noise. This PR changes neither the failing test nor its recovery-authority owner. All other CI jobs pass or skip, including security-fast; all 18 restart cases also pass in CI. Local focused proof andpnpm check:changedare green. ClawSweeper’s final-head review has zero findings and zero open items. Landing uses the explicitly authorized inherited-failure exception; CI is not described as fully green.