Skip to content

fix: preserve standalone CLI commands across startup respawns - #174545

Merged
steipete merged 3 commits into
mainfrom
fix/standalone-respawn-invocation
Oct 16, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/standalone-respawn-invocation

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes standalone/desktop agent turns, Doctor, and plugin installation exiting before command dispatch when normal startup respawns the CLI.

Related: #174268

User Impact

Standalone artifacts incorporating 75d827b are affected, including the reported signed desktop qualification artifact. This confirms current main/desktop candidate impact; the public stable desktop release provenance was not audited here. Default agent turns, live doctor, upgrade doctor --fix, and Teams installation encounter the parent preload URL as an unknown command. The workaround OPENCLAW_NO_RESPAWN=1 bypasses the failing path; normal startup must work without it.

Why This Change Was Made

The spawn transports added Node runtime arguments after cli-invocation.mjs had selected the compiled <executable> <CLI args> shape. The invocation owner now resolves parent-bound respawns, places the existing preload before the loose entry script, and supplies compiled children with a one-use parent-PID environment marker instead. The child consumes that marker before detached workers can inherit it. Both spawn transports pass the resolved argv through unchanged; exec replacement and independent worker lifetimes retain their existing contracts.

Evidence

  • Before: a real default Codex turn on the signed bytecode desktop artifact exited 1 with no model payload and the preload URL reported as an unknown command. Live Doctor, offline Doctor repair, and npm:@openclaw/[email protected] installation each reproduced exit 1. The isolated Gateway stayed healthy around the live Doctor check.
  • Focused tests cover standalone startup, compile-cache and launcher respawns; unchanged loose preload bytes/order; actual child cancellation and marker consumption; maintenance rollback, successor ownership, and independent detached workers. Nine focused files passed in 2.2–4.2 seconds wall each; the three-case SQLite lifetime file passed under Node in 33.50 seconds including initial graph compilation (about 1.2 seconds of test execution).
  • Full pnpm build, core typecheck, touched-file lint and formatting passed. Independent Codex P0/P1 review is clean.
  • The default pinned-Bun lifetime test's independent-worker case times out identically on unchanged main. The Node run passes. The broad changed-file check also reproduces unchanged-main max-lines, deprecated-API and dead-export guard failures; its typechecks, full lint, format and import-cycle checks pass.
  • Developer ID-signed JIT desktop set (77 embedded plugins, Bun c45839085e): real Codex text and tool turns exit 0 (31.916s / 29.686s), with a real standalone hooks relay and verified tool output; live Doctor exits 0 (28.590s); upgrade doctor --fix exits 0 (42.253s); Teams install exits 0 (26.395s), then runtime inspection exits 0 (24.576s). No OPENCLAW_NO_RESPAWN was used. State and Gateway were isolated; native Codex auth was reused without copies.
  • Compiled parent-loss proof: argv contains no runtime flags, the maintenance owner records the launcher PID, the child retires 0.505s after launcher death, and successor Doctor exits 0. The signed artifact records production commit 0ae517f; subsequent commits only refine tests and copied fixture dependencies. Candidate bytecode was not rebuilt; JIT exercises the same invocation and lifetime owner.
  • First CI exposed missing copied bootstrap dependencies in isolated worker/prewarm fixtures. Fixed the inventories, then reran the failed files: smoke tests passed in 98.97s, the remaining selection in 156.63s, and pinned-Bun skills verification in 24.69s. Exact-head CI https://github.com/openclaw/openclaw/actions/runs/38952010972 finished with 54 successful jobs and two Bun subprocess deadlocks (fork recovery at 100s, Doctor disposal at 60s), plus the downstream gate. Both tests disable respawn. All three local candidate Bun cases pass in 46.01s; unchanged refreshed main reproduces the same two cases in 252.87s. Their test/helper/supervisor inputs are unchanged in the actual tested merge. These are the only CI failures proposed for the native inherited-failure exception; the earlier fixture failures were repaired.

Resolve launcher-bound runtime arguments at the CLI invocation owner. Consume a one-child parent PID signal in compiled runtimes while preserving the loose preload and detached worker lifetimes.
@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@steipete
steipete marked this pull request as ready for review October 16, 2026 18:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T19:05:59.173081Z 3961ca7 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Resolve parent-bound CLI respawns centrally so standalone executables receive command arguments without Node preload flags.

Example: Run standalone openclaw doctor --fix with normal startup respawning enabled.

  • Before: The child interprets the parent-lifetime preload URL as a command and exits 1 before Doctor dispatch.
  • After: The child receives doctor --fix and consumes its parent-lifetime marker separately.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The useful boundary repair has focused process coverage, but a verified dependency-inventory omission breaks exact-head CI.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; reported process tests exercise lifetime handling, while actual compiled after-fix qualification is explicitly pending.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Standalone commands exit before doing useful work when normal startup respawns them.
Reason: The maintainer-authored direction restores working default startup through the existing invocation owner without adding user configuration.

Regression provenance

Regression provenance — verified: source commit 75d827b3b607 by Peter Steinberger; canonical PR #174268 (blame-to-merge-commit).

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR addresses a current standalone startup regression, but its new bootstrap dependency breaks compiled CLI test artifacts.

Priority: P1
Reviewed head: 10cbaf4f2ad11556830271058ba3b14607b954ff

Before merge

  • Include the new dependency in copied CLI runtime artifacts (P2) - This import makes every disk copy of cli-invocation.mjs require cli-parent-lifetime.mjs, which also imports gateway-shutdown-budget.mjs. scripts/lib/vitest-worker-declarations.mts still copies only cli-invocation.mjs and node-host-launcher.mjs, and prepareCandidateAuthorityRuntime repeats that incomplete inventory. Exact-head CI now reports ERR_MODULE_NOT_FOUND before agent, Gateway-backed CLI, and plugin-resource test commands can dispatch. Extend the copied runtime inventories with the transitive dependencies and update affected bootstrap fixtures rather than weakening the failing assertions.

Findings

  • [P2] Include the new dependency in copied CLI runtime artifacts — cli-invocation.mjs:5

Tests

  • Missing end-to-end proof: Compiled-artifact after-fix command dispatch, launcher-loss cancellation, and stable-to-candidate upgrade results are still pending in the supplied evidence.
Agent review details

How this fits together

CLI bootstrap prepares executable identity, arguments, and environment; spawn transports launch the prepared invocation, while the child lifecycle owner handles launcher loss.

flowchart TD
  A[CLI startup] --> B[Invocation owner]
  B --> C[Loose runtime preload]
  B --> D[Standalone parent marker]
  C --> E[Spawn transport]
  D --> E
  E --> F[CLI command and lifecycle]
Loading

Technical review

Best possible solution:

Keep invocation planning centralized and include its complete bootstrap dependency closure wherever CLI artifacts are copied.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the standalone argument corruption, matching the maintainer's signed-artifact report; this read-only review executed no target code.

Is this the best way to solve the issue?

Moving runtime argument construction into the existing invocation owner fixes the responsible boundary, but copied test runtimes must include the newly required modules.

Full review comments:

  • [P2] Include the new dependency in copied CLI runtime artifacts — cli-invocation.mjs:5
    This import makes every disk copy of cli-invocation.mjs require cli-parent-lifetime.mjs, which also imports gateway-shutdown-budget.mjs. scripts/lib/vitest-worker-declarations.mts still copies only cli-invocation.mjs and node-host-launcher.mjs, and prepareCandidateAuthorityRuntime repeats that incomplete inventory. Exact-head CI now reports ERR_MODULE_NOT_FOUND before agent, Gateway-backed CLI, and plugin-resource test commands can dispatch. Extend the copied runtime inventories with the transitive dependencies and update affected bootstrap fixtures rather than weakening the failing assertions.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 956dd5d98995.

Provenance checked

  • Parent-bound respawn supervision keeps the original intent (75d827b: Cancel owned CLI maintenance when its launcher dies while preserving independent detached workers.)
  • Standalone CLI argument shape keeps the original intent (3bfccdb: Give compiled executables CLI arguments directly and retain interpreter flags plus entry scripts only for loose runtimes.)
  • Compile-cache and prewarm respawns keeps the original intent (8cf0d21: Warm the immutable release's Gateway graph at its final path using the existing build-scoped cache owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test test/scripts/vitest-worker-cache.test.ts --maxWorkers=1
  • pnpm test src/cli/agent-session-affinity.process.test.ts src/cli/gateway-backed-exit.process.test.ts src/cli/plugin-invocation-resources.test.ts --maxWorkers=1
  • pnpm test src/entry.respawn.test.ts src/infra/node-runtime-recovery.shutdown.test.ts src/process/respawn-child-runner.process.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3bfccdb adds cli-invocation.mjs:82 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3bfccdb9bd3d; files: cli-invocation.mjs)
  • Vincent Koc: Raw commit 0d48284 adds src/process/respawn-child-runner.ts:5 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 0d4828497e26; files: src/process/respawn-child-runner.ts)

PR surface

Source +8, Tests +172, Docs +3, Other +48. Total +231 across 21 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 20 12 +8
Tests 8 199 27 +172
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 8 69 21 +48
Total 21 292 61 +231

Labels

Label changes:

  • add P1: Normal standalone startup prevents agent turns, Doctor, and plugin installation from reaching command dispatch in affected artifacts.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: Normal standalone startup prevents agent turns, Doctor, and plugin installation from reaching command dispatch in affected artifacts.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 16, 2026, 3:01 PM ET / 19:01 UTC.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 16, 2026
@steipete
steipete merged commit 71fac53 into main Oct 16, 2026
161 of 165 checks passed
@steipete
steipete deleted the fix/standalone-respawn-invocation branch October 16, 2026 19:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 16, 2026
Reuse the Vitest runtime asset owner for copied update candidates. Replace
empty parent-lifetime and shutdown-budget stubs beside the real invocation
module in bootstrap fixtures. Derive the paired-node upgrade fixture's
launcher files from its existing entrypoint seeds and eager import closure.

Update behavior is unchanged: migrated candidates still validate config,
prove readiness, reject replaced owners and retain unconfirmed recovery
results. This fixes fixture drift after the parent-bound CLI invocation
change in #174545, not production update authority or package contents.
The trusted Docker harness is already repaired by #174463.

Local Node 24 proof, maxWorkers=1:
- Bootstrap baseline: 16 failures / 29 passes; all five importing suites now
  pass (49 tests, 86.42s).
- Update baseline: two failures / two passes; all three importing suites
  now pass (36 tests, 342.13s). Healthy authority case: 76.20s failing before
  readiness -> 37.40s passing with every assertion retained.
- Paired-node upgrade: passes before and after (366.36s -> 271.28s Vitest
  wall; different preparation/cache conditions, not a speedup claim).
  Its existing scenario enters dist/index.js. A separate isolated root
  launcher smoke proves the old copy list exits 1 for missing parent
  lifetime while the derived closure exits 0 and prints the version.
- Existing trusted-harness case passes. Targeted CLI, gateway and E2E
  typechecks, scoped lint, boundary lint, format, import cycles and P2
  autoreview pass. Windows was not available locally; no CI dispatched.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…aw#174545)

* fix: preserve standalone CLI commands across startup respawns

Resolve launcher-bound runtime arguments at the CLI invocation owner. Consume a one-child parent PID signal in compiled runtimes while preserving the loose preload and detached worker lifetimes.

* test: keep respawn transport guard independent of local names

* test: include respawn owner dependencies in CLI fixtures
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
Reuse the Vitest runtime asset owner for copied update candidates. Replace
empty parent-lifetime and shutdown-budget stubs beside the real invocation
module in bootstrap fixtures. Derive the paired-node upgrade fixture's
launcher files from its existing entrypoint seeds and eager import closure.

Update behavior is unchanged: migrated candidates still validate config,
prove readiness, reject replaced owners and retain unconfirmed recovery
results. This fixes fixture drift after the parent-bound CLI invocation
change in openclaw#174545, not production update authority or package contents.
The trusted Docker harness is already repaired by openclaw#174463.

Local Node 24 proof, maxWorkers=1:
- Bootstrap baseline: 16 failures / 29 passes; all five importing suites now
  pass (49 tests, 86.42s).
- Update baseline: two failures / two passes; all three importing suites
  now pass (36 tests, 342.13s). Healthy authority case: 76.20s failing before
  readiness -> 37.40s passing with every assertion retained.
- Paired-node upgrade: passes before and after (366.36s -> 271.28s Vitest
  wall; different preparation/cache conditions, not a speedup claim).
  Its existing scenario enters dist/index.js. A separate isolated root
  launcher smoke proves the old copy list exits 1 for missing parent
  lifetime while the derived closure exits 0 and prints the version.
- Existing trusted-harness case passes. Targeted CLI, gateway and E2E
  typechecks, scoped lint, boundary lint, format, import cycles and P2
  autoreview pass. Windows was not available locally; no CI dispatched.
steipete added a commit that referenced this pull request Oct 19, 2026
The built-CLI runtime recovery suite only runs in CI when the shared test
instance helper changes, so two of its cases kept asserting behavior that
main retired:

- Runtime-recovery respawns now carry the launcher-bound parent-lifetime
  preload and an IPC channel (#174268, #174545); the Doctor recovery case
  still expected bare argv and plain inherited stdio.
- Compiled entries keep the build-scoped compile cache and no longer take
  the compile-cache-disable respawn, which is source-entry only (#170514);
  the compile-cache case still expected that respawn's marker.

Assert the current respawn shape and that compiled entries keep caching
while still keeping workspace roots out of the startup respawn.
steipete added a commit that referenced this pull request Oct 19, 2026
…wns (#177503)

The built-CLI runtime recovery suite only runs in CI when the shared test
instance helper changes, so two of its cases kept asserting behavior that
main retired:

- Runtime-recovery respawns now carry the launcher-bound parent-lifetime
  preload and an IPC channel (#174268, #174545); the Doctor recovery case
  still expected bare argv and plain inherited stdio.
- Compiled entries keep the build-scoped compile cache and no longer take
  the compile-cache-disable respawn, which is source-entry only (#170514);
  the compile-cache case still expected that respawn's marker.

Assert the current respawn shape and that compiled entries keep caching
while still keeping workspace roots out of the startup respawn.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…wns (openclaw#177503)

The built-CLI runtime recovery suite only runs in CI when the shared test
instance helper changes, so two of its cases kept asserting behavior that
main retired:

- Runtime-recovery respawns now carry the launcher-bound parent-lifetime
  preload and an IPC channel (openclaw#174268, openclaw#174545); the Doctor recovery case
  still expected bare argv and plain inherited stdio.
- Compiled entries keep the build-scoped compile cache and no longer take
  the compile-cache-disable respawn, which is source-entry only (openclaw#170514);
  the compile-cache case still expected that respawn's marker.

Assert the current respawn shape and that compiled entries keep caching
while still keeping workspace roots out of the startup respawn.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant