Skip to content

fix: Gateway stops report cleanup failure after an exec is refused before launch - #187137

Merged
fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/service-child-prelaunch-refusal
Oct 29, 2026
Merged

fuller-stack-dev merged 2 commits into
openclaw:mainfrom
fuller-stack-dev:fix/service-child-prelaunch-refusal

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

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 later shutdown() rethrew it.

Now the POSIX control sender returns a distinct ServiceChildLaunchNotInitiatedError, but only when launch() was never called. In that case the host fails startup with the original refusal, starts the normal cleanup deadline and sends cancel. 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.ts used 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 unused expectedCleanupFailure plumbing is gone.

Start-frame construction moves into service-child-relay-preparation.ts without behavior changes, so service-child-relay-host.ts stays under its 700-line cap. The Windows BrokerChild launch path is unchanged.

Evidence

  • New real-relay test supervisor.prelaunch-initiation.real.test.ts. A refusal before the launch frame rejects with the original TimeoutError, the command never runs, a later spawn succeeds, and shutdown() resolves. The negative control refuses after calling launch(), and shutdown stays fenced.
  • service-child-relay-host.test.ts. The revoked-at-prepared case now plays the anchor's startup-error and closing replies and gets the original refusal back. A new case checks that a silent anchor still hits the hard deadline.
  • Red/green on 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-broker passed 356 tests with 0 failures and 77 platform skips.
  • pnpm check:changed passed 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 flags src/gateway/server-shutdown.runtime.test.ts and src/gateway/server.spawn-broker.test.ts and fails the same way on clean origin/main. The dead-export scan lists 41 exports, none in files this PR touches.
  • Seen in production. A refusal at 19:58Z showed up at a 20:23Z Gateway stop as "Failed to reset global singleton lifecycle state", wrapping "service child cleanup identity lost: TimeoutError: request timed out".

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Oct 29, 2026
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) October 29, 2026 00:48
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The command never starts, but subsequent Gateway shutdowns fail with service child cleanup identity lost.
  • After: The original timeout is returned, the waiting anchor completes acknowledged cleanup, and subsequent shutdown succeeds.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful lifecycle regressions and no actionable finding; available behavioral evidence is harness-based and current-head CI remains pending.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supplied evidence covers real relay and supervisor tests for prelaunch refusal, absent command effects, later work, clean shutdown, and post-launch fencing, rather than a shipped Gateway run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A command refused before launch causes later Gateway stops and restarts to report retained resources despite no command having started.
Reason: The maintainer-authored direction repairs a concrete lifecycle failure without new settings, persisted formats, public APIs, or a competing cleanup owner.

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
Reviewed head: b808e28a66a6f3d08264131933888d56c1d6b0ab

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show an isolated Gateway refusing an exec before launch and then stopping or restarting successfully through the shipped entry point.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Prepared-launch refusal and cleanup settlement changes intended behavior with a stated reason (843a24c: Launch initiation was moved to the final IPC boundary so live authority and cleanup custody survive preparation and broker queues.)
  • Closing receipts and admitted-command retirement keeps the original intent (fix: preserve relay cleanup after authority rejection #183247: Keep lifecycle transport available after admission so authority rejection cannot interrupt acknowledged descendant cleanup.)
  • Exec launch-policy shutdown expectation changes intended behavior with a stated reason (2d8051e: Linux command memory protection routes exec through owned-tree supervision; the PR explains why its inherited expectation of permanent shutdown failure pinned the prelaunch bug.)
  • Start-frame construction keeps the original intent (ffc94d0: The relay carries command and ownership facts to its anchor; extraction preserves the complete frame and existing platform contracts.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8277325 adds src/process/supervisor/service-child-relay-host.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8277325ccf1b; files: src/process/supervisor/service-child-relay-host.ts)
  • Shakker: Raw commit 5d20423 adds src/process/supervisor/service-child-relay-host.ts:655 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5d204234f2d2; files: src/process/supervisor/service-child-relay-host.ts)
  • Josh Avant: Raw commit ffc94d0 adds src/process/supervisor/service-child-relay-host.ts:12 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ffc94d0ff056; files: src/process/supervisor/service-child-relay-host.ts)

PR surface

Source +44, Tests +121. Total +165 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 73 29 +44
Tests 3 133 12 +121
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 206 41 +165

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A reported exec timeout can poison every subsequent Gateway stop or restart for the process lifetime.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-29T01:19:55.983Z sha 94739f995b454c075bb6d794e01d4cae3dcde752 :: needs changes before merge. :: [P3] Remove generated-agent attribution from the public PR text

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.
@fuller-stack-dev
fuller-stack-dev force-pushed the fix/service-child-prelaunch-refusal branch from 94739f9 to b808e28 Compare October 29, 2026 01:42
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@fuller-stack-dev
fuller-stack-dev marked this pull request as draft October 29, 2026 18:02
auto-merge was automatically disabled October 29, 2026 18:02

Pull request was converted to draft

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review October 29, 2026 18:02
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) October 29, 2026 18:02
@fuller-stack-dev
fuller-stack-dev merged commit b4b499a into openclaw:main Oct 29, 2026
279 of 290 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…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.
RomneyDa added a commit that referenced this pull request Nov 3, 2026
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.
RomneyDa added a commit that referenced this pull request Nov 5, 2026
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.
RomneyDa added a commit that referenced this pull request Nov 5, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant