Repository navigation
fix: Gateway stops report cleanup failure after an exec is refused before launch - #187137
Conversation
|
🦞👀 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 changesThis PR cancels relays refused before launch and waits for confirmed cleanup instead of permanently recording identity loss. Example: An exec launch check throws TimeoutError: request timed out before writing its launch frame.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current shutdown failure without relaxing cleanup certification, and no introduced defect was found; the previous attribution finding is resolved. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe process supervisor sends commands through a relay and anchor, retaining cleanup ownership until closing receipts, channel closure, and descendant extinction establish that resources are released. flowchart TD
A[Exec request] --> B[Process supervisor]
B --> C[Relay host]
C --> D[Launch authority check]
D --> E[Anchor command launch]
D --> F[Prelaunch refusal and cancel]
E --> G[Closing receipt and extinction join]
F --> G
G --> H[Supervisor shutdown]
Technical reviewBest possible solution: Handle proven prelaunch refusal in the existing sender and relay host while retaining the anchor's acknowledged cleanup and extinction requirements. Do we have a high-confidence way to reproduce the issue? Current-main source shows prelaunch refusal entering loseIdentity and permanently rejecting supervisor cleanup; the PR reports matching production behavior and red/green real-relay regressions, which were not executed during this read-only review. Is this the best way to solve the issue? The patch addresses the producer of the false cleanup failure, reuses existing cancellation and retirement owners, and preserves uncertain-launch fencing; the start-frame extraction is mechanical and justified by the existing file cap. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48f40fb0a2f3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +44, Tests +121. Total +165 across 6 files. Added test files: 1. View PR surface stats
LabelsLabel changes: No label 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 HistoryReview history (1 earlier review cycle)
Reviewed October 28, 2026, 9:47 PM ET / October 29, 2026, 01:47 UTC (Revision 2). |
…fore launch A launch-authority refusal thrown before the POSIX launch frame was written was classified as service-child identity loss. The anchor had not spawned anything, but the rejected cleanup stayed sticky in the process supervisor, so every later shutdown rethrew it. The control sender now reports ServiceChildLaunchNotInitiatedError only when launch() was never called. The relay host then fails startup with the original refusal, starts the cleanup deadline, and cancels the waiting anchor, whose startup-error and closing receipts retire it normally. Possible frame writes, silent anchors, and non-starting states still fail closed. Move start-frame construction into the relay preparation module to keep the relay host under its line cap.
Linux exec gives plain Gateway children an owned process tree, so they also reach the service-child relay's launch frame. Keep the proof that the retained route refuses at that frame, without asserting which adapter other routes get on a given platform.
94739f9 to
b808e28
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Pull request was converted to draft
…fore launch (openclaw#187137) * fix: Gateway stops report cleanup failure after an exec is refused before launch A launch-authority refusal thrown before the POSIX launch frame was written was classified as service-child identity loss. The anchor had not spawned anything, but the rejected cleanup stayed sticky in the process supervisor, so every later shutdown rethrew it. The control sender now reports ServiceChildLaunchNotInitiatedError only when launch() was never called. The relay host then fails startup with the original refusal, starts the cleanup deadline, and cancels the waiting anchor, whose startup-error and closing receipts retire it normally. Possible frame writes, silent anchors, and non-starting states still fail closed. Move start-frame construction into the relay preparation module to keep the relay host under its line cap. * test: assert relay launch only where exec routes through it Linux exec gives plain Gateway children an owned process tree, so they also reach the service-child relay's launch frame. Keep the proof that the retained route refuses at that frame, without asserting which adapter other routes get on a given platform.
When an owned stdio process failed to start and its cleanup also failed, the relay host rethrew the cleanup rejection instead of the anchor's startup error, and owned stdio replaced the message again with "stdio startup cleanup did not confirm closure". The Docker CLI backend lane only showed the identity-loss cleanup error, never why startup failed. Throw the startup failure first with the cleanup failure as a secondary AggregateError member, and lead the owned stdio message with the startup failure plus the next step (restart the Gateway before retrying). On main this also changes the refused-launch hard-deadline case from #187137: the refusal now leads and the hard-deadline cleanup failure follows as the secondary member; the cleanup fence itself is unchanged. Forward-port of e51fa64 from release/2026.10.10.
When an owned stdio process failed to start and its cleanup also failed, the relay host rethrew the cleanup rejection instead of the anchor's startup error, and owned stdio replaced the message again with "stdio startup cleanup did not confirm closure". The Docker CLI backend lane only showed the identity-loss cleanup error, never why startup failed. Throw the startup failure first with the cleanup failure as a secondary AggregateError member, and lead the owned stdio message with the startup failure plus the next step (restart the Gateway before retrying). On main this also changes the refused-launch hard-deadline case from #187137: the refusal now leads and the hard-deadline cleanup failure follows as the secondary member; the cleanup fence itself is unchanged. Forward-port of e51fa64 from release/2026.10.10.
…192386) * fix(process): preserve loaded startup cleanup Co-authored-by: RomneyDa <[email protected]> Forward-port of ba42adb from release/2026.10.10. * fix(process): keep stdio startup failures ahead of cleanup errors When an owned stdio process failed to start and its cleanup also failed, the relay host rethrew the cleanup rejection instead of the anchor's startup error, and owned stdio replaced the message again with "stdio startup cleanup did not confirm closure". The Docker CLI backend lane only showed the identity-loss cleanup error, never why startup failed. Throw the startup failure first with the cleanup failure as a secondary AggregateError member, and lead the owned stdio message with the startup failure plus the next step (restart the Gateway before retrying). On main this also changes the refused-launch hard-deadline case from #187137: the refusal now leads and the hard-deadline cleanup failure follows as the secondary member; the cleanup fence itself is unchanged. Forward-port of e51fa64 from release/2026.10.10. * fix(process): share inherited process lineage across module copies The CLI backend live lane runs its Gateway from source under vitest while bundled plugins load from dist. The anthropic plugin's openclaw/plugin-sdk import is natively aliased to the source SDK, so src/process/supervisor loads a second time outside vitest's graph. That copy never saw the test's bindInheritedNativeProcessOwner(dist anchor) and fell back to the source anchor. Inherited lineage fds and the native process owner are process state, so keep them in one global singleton slot that every module copy shares. Forward-port of 7dc3350 from release/2026.10.10. * test(ci): scope process forward-port regression allocation * test(process): use deterministic startup cleanup clocks --------- Co-authored-by: roboclaw-bot <[email protected]>
…penclaw#192386) * fix(process): preserve loaded startup cleanup Co-authored-by: RomneyDa <[email protected]> Forward-port of ba42adb from release/2026.10.10. * fix(process): keep stdio startup failures ahead of cleanup errors When an owned stdio process failed to start and its cleanup also failed, the relay host rethrew the cleanup rejection instead of the anchor's startup error, and owned stdio replaced the message again with "stdio startup cleanup did not confirm closure". The Docker CLI backend lane only showed the identity-loss cleanup error, never why startup failed. Throw the startup failure first with the cleanup failure as a secondary AggregateError member, and lead the owned stdio message with the startup failure plus the next step (restart the Gateway before retrying). On main this also changes the refused-launch hard-deadline case from openclaw#187137: the refusal now leads and the hard-deadline cleanup failure follows as the secondary member; the cleanup fence itself is unchanged. Forward-port of e51fa64 from release/2026.10.10. * fix(process): share inherited process lineage across module copies The CLI backend live lane runs its Gateway from source under vitest while bundled plugins load from dist. The anthropic plugin's openclaw/plugin-sdk import is natively aliased to the source SDK, so src/process/supervisor loads a second time outside vitest's graph. That copy never saw the test's bindInheritedNativeProcessOwner(dist anchor) and fell back to the source anchor. Inherited lineage fds and the native process owner are process state, so keep them in one global singleton slot that every module copy shares. Forward-port of 7dc3350 from release/2026.10.10. * test(ci): scope process forward-port regression allocation * test(process): use deterministic startup cleanup clocks --------- Co-authored-by: roboclaw-bot <[email protected]>
What Problem This Solves
Fixes: after one exec call is refused before its command starts, every later Gateway shutdown reports an owned-process cleanup failure. A typical trigger is a tool call whose signal times out while the relay waits for launch permission.
User Impact
User impact: a clean stop or restart no longer fails with "Plugin runtime still owns resources" or "service child cleanup identity lost" just because an exec was cancelled before launch earlier in the process. Real identity loss is still reported.
Why This Change Was Made
When the relay anchor sends
prepared, it has no command yet. It is waiting for the launch frame. If the launch-authority check threw before the host wrote that frame, the relay host treated the refusal as identity loss and rejected cleanup without a receipt. The process supervisor keeps that rejection for the life of the process, so every latershutdown()rethrew it.Now the POSIX control sender returns a distinct
ServiceChildLaunchNotInitiatedError, but only whenlaunch()was never called. In that case the host fails startup with the original refusal, starts the normal cleanup deadline and sendscancel. The anchor already handles that message. It reports "command startup cancelled before spawn", and its closing receipt retires the relay through the usual extinction join.Cleanup still fails closed when the frame may have been written, when the anchor never answers (the hard deadline fires), or when the relay has already left
starting. That matches the rule from #183247 that missing closing evidence rejects cleanup.bash-tools.exec-launch-policy.integration.test.tsused to require shutdown to reject after a retained-child refusal before launch. That expectation pinned the bug. The test now checks that the refusal reached the relay's launch boundary and that shutdown is clean, and its unusedexpectedCleanupFailureplumbing is gone.Start-frame construction moves into
service-child-relay-preparation.tswithout behavior changes, soservice-child-relay-host.tsstays under its 700-line cap. The WindowsBrokerChildlaunch path is unchanged.Evidence
supervisor.prelaunch-initiation.real.test.ts. A refusal before the launch frame rejects with the originalTimeoutError, the command never runs, a later spawn succeeds, andshutdown()resolves. The negative control refuses after callinglaunch(), and shutdown stays fenced.service-child-relay-host.test.ts. The revoked-at-preparedcase now plays the anchor'sstartup-errorandclosingreplies and gets the original refusal back. A new case checks that a silent anchor still hits the hard deadline.d44b7df3. With the new tests on unmodified sources, 4 of 58 fail, and they are exactly the new and changed cases. With the fix, all 58 pass across the six affected relay, supervisor and exec launch-policy files.pnpm test -- src/process/supervisor src/process/spawn-brokerpassed 356 tests with 0 failures and 77 platform skips.pnpm check:changedpassed typecheck for core and core tests, lint, format, and the line-cap and max-lines checks. Two checks failed on code outside this diff. The first-party mock export check flagssrc/gateway/server-shutdown.runtime.test.tsandsrc/gateway/server.spawn-broker.test.tsand fails the same way on cleanorigin/main. The dead-export scan lists 41 exports, none in files this PR touches.