Repository navigation
fix: unblock Gateway after a killed Doctor launcher - #174268
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 SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7528c0cd84
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| parentPid: process.ppid, | ||
| ...(parentStartTime === null ? {} : { parentStartTime }), |
There was a problem hiding this comment.
Record parent custody only for actual respawns
When maintenance runs without a CLI respawn—for example, OPENCLAW_NO_RESPAWN=1 openclaw doctor --fix or an invocation that already has the required Node flags—process.ppid is the shell or embedding process, not an OpenClaw launcher. Recording it unconditionally causes the heartbeat to send SIGKILL to the maintenance process if that caller exits, so a deliberately backgrounded/no-respawn Doctor or update can be terminated mid-repair. Populate these fields only when the process was launched through the new owned IPC respawn path, or pass the launcher identity explicitly.
AGENTS.md reference: AGENTS.md:L81-L82
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesBind CLI respawns and maintenance heartbeats to their parent process so killing a Doctor launcher does not leave maintenance ownership alive indefinitely. Example: Kill the launcher running
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this maintainer-authored PR addresses a concrete Gateway outage, but two focused corrections are needed before merge. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherCLI launchers supervise respawned commands, while the state-owner heartbeat maintains exclusive database custody until its owning process exits. flowchart TD
A[CLI launcher] --> B[Respawned Doctor]
B --> C[Maintenance state owner]
C --> D[Heartbeat worker]
D --> E[Ownership lock files]
E --> F[Gateway admission]
Technical reviewBest possible solution: Attach parent-loss termination only to owned launcher respawns while preserving ordinary maintenance callers and live-owner exclusion. Do we have a high-confidence way to reproduce the issue? Current-main source permits a respawned Doctor to outlive a killed launcher, and the PR reports a matching isolated macOS reproduction; this read-only review ran no target code. Is this the best way to solve the issue? Using existing respawn and heartbeat owners addresses the orphan's cause, but parent-loss termination must distinguish an owned launcher from an ordinary caller. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 01e659317b7f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +39, Tests +113, Docs +1, Other +19. Total +172 across 20 files. Added test files: 0. View PR surface stats
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 October 16, 2026, 10:07 AM ET / 14:07 UTC. |
Bind CLI respawns to launcher IPC and let the existing maintenance heartbeat worker terminate its owner after parent loss, even when its main thread is blocked. Preserve foreign live custody until process exit before recovery. Cover parent loss and natural respawn completion, and keep platform-simulated fixtures consistent with their real host workers. Fixes #174219
Bind CLI respawns to their launcher explicitly and consume that private preload before it can reach detached update and finalization workers. Request normal cancellation before force termination, and keep renewing custody while rollback, service restoration, and lease release settle. Preserve live-writer exclusion until the owner actually exits. Ship the lifetime helper in package and trusted wrapper inventories, and cover detached commits, graceful rollback, and subsequent ownership.
8145dab to
74576be
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74576be415
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| params.detachForProcessTree === true && process.platform !== "win32" && !stdioIsTerminal; | ||
| const child = runtime.spawn(command, args, { | ||
| stdio: "inherit", | ||
| const child = runtime.spawn(command, ["--import", CLI_PARENT_BOUND_PRELOAD, ...args], { |
There was a problem hiding this comment.
Avoid passing preload flags to standalone executables
When a compiled standalone Bun executable needs the normal startup respawn for warning suppression or CA setup, this unconditional prefix becomes application argv rather than a runtime preload, so OpenClaw receives --import <data URL> as a root CLI option and rejects or misroutes the command. buildCliRespawnPlan explicitly supports this standalone path, and Bun's executable documentation confirms that compiled executables do not interpret their command line as Bun flags. Use a standalone-compatible preload mechanism or add these arguments only when spawning Node.
AGENTS.md reference: AGENTS.md:L64-L64
Useful? React with 👍 / 👎.
#174268 added the root cli-parent-lifetime.mjs launcher helper without listing it in the duplicate-scan targets, so the target-coverage guard in dup:check fails on every PR and on the next main run. List it beside the other root launcher modules. Proof: pnpm dup:check on current main a0ac309 fails only on the coverage guard; with the target added it passes (target coverage ok, existing clone findings unchanged).
…74480) node-runtime-recovery.mjs imports cli-parent-lifetime.mjs after #174268. Ship that dependency in both Docker launcher stages, cleanup smoke, and the remote-node bootstrap artifact, and keep copied runtime fixtures in sync. Require the module in the bootstrap archive regression. Preserve existing launcher and detached update lifetimes. No new closure framework, dependency, configuration, or timeout changes.
Keep Discord processing at its live owner while replacing namespace spies with the named module spy and deleting the preflight re-export used only by tests. Preserve every assertion and exercise all importers of the changed helper. Expose existing memory CLI registration through the public runtime barrel for the PostgreSQL core test, retaining the plugin boundary. Add shipped cli-parent-lifetime.mjs to both focused guard commands. Causes: d49ea0f (#174322), 8955750 (#174374), and 75d827b (#174268). No runtime policy or timeout changes. Proof: 165 focused tests passed with --maxWorkers=1 (444.35s), 12 plugin boundary tests passed (19.14s) after the old-import negative control, core/extension/test types, source contracts, focused guard, and P2 review. Remaining independent audit finding: ORIGINAL_REVISION in an unchanged Gateway fixture. Standalone package types report unchanged memory-core connection/tableHasColumn errors; canonical source/type lanes pass.
…eir launcher dies (openclaw#174268) Killing a hung openclaw doctor --fix left its respawned child alive (reparented to PID 1) and renewing sqlite-maintenance ownership, so every later Gateway start failed with 'undergoing offline maintenance' and stale-owner recovery never fired because the recorded owner was still alive. CLI respawns now carry an explicit launcher-bound lifetime marker; when the launcher disappears the owner is asked to cancel, rolls back and releases its lease while keeping custody during cleanup, and is escalated only after ten seconds. Detached update and handoff drivers stay independent by default and are never terminated because their launcher exited. Live on macOS: launcher killed → owner exits in 0.22 s, lock released, zero orphans, next Gateway HTTP 200, SQLite integrity ok. The separate zero-output Doctor hang is addressed by the bounded SQLite admission wait (openclaw#174060). Fixes openclaw#174219
openclaw#174268 added the root cli-parent-lifetime.mjs launcher helper without listing it in the duplicate-scan targets, so the target-coverage guard in dup:check fails on every PR and on the next main run. List it beside the other root launcher modules. Proof: pnpm dup:check on current main 8be8fd6 fails only on the coverage guard; with the target added it passes (target coverage ok, existing clone findings unchanged).
…enclaw#174480) node-runtime-recovery.mjs imports cli-parent-lifetime.mjs after openclaw#174268. Ship that dependency in both Docker launcher stages, cleanup smoke, and the remote-node bootstrap artifact, and keep copied runtime fixtures in sync. Require the module in the bootstrap archive regression. Preserve existing launcher and detached update lifetimes. No new closure framework, dependency, configuration, or timeout changes.
…74482) Keep Discord processing at its live owner while replacing namespace spies with the named module spy and deleting the preflight re-export used only by tests. Preserve every assertion and exercise all importers of the changed helper. Expose existing memory CLI registration through the public runtime barrel for the PostgreSQL core test, retaining the plugin boundary. Add shipped cli-parent-lifetime.mjs to both focused guard commands. Causes: b5c5a99 (openclaw#174322), 9409878 (openclaw#174374), and 963fbbd (openclaw#174268). No runtime policy or timeout changes. Proof: 165 focused tests passed with --maxWorkers=1 (444.35s), 12 plugin boundary tests passed (19.14s) after the old-import negative control, core/extension/test types, source contracts, focused guard, and P2 review. Remaining independent audit finding: ORIGINAL_REVISION in an unchanged Gateway fixture. Standalone package types report unchanged memory-core connection/tableHasColumn errors; canonical source/type lanes pass.
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.
…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.
…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.
…1695) After publication-complete, a delegated maintenance worker could keep renewing the state database's offline-maintenance claim after its update executor died, so every CLI command and Gateway start was refused ('undergoing offline maintenance') until manual recovery; reported as a ~53-minute outage on a Raspberry Pi after a Control UI update from 2026.10.5 to 2026.10.6. The worker now watches its recorded parent process identities and exits through the existing bounded shutdown path when they are dead or replaced; normal startup then reclaims the dead claim through canonical recovery, and live-owner messages point to update progress. Fixes #181649, reported by @PonySlayer28. Release adaptation: stable lacks requestCliParentTermination (cli-parent-lifetime.mjs, #174268), so the parent watch calls a local equivalent built on the stable gateway-shutdown-budget reserve: emit SIGTERM to the process's own signal owners (or self-signal when none listen) and escalate to SIGKILL after GATEWAY_SHUTDOWN_RESERVE_MS. Stable's delegated executor has no terminal-preparation wrapper or finally-time identity flush, so only the interval cleanup was added there. The refusal message now carries role/PID plus the update-status hint. The orphaned-worker integration test was ported onto stable's createInterruptedPackagePublication/preparePreview fixtures. (cherry picked from commit 3a1d3dd)
What Problem This Solves
Fixes Gateway startup remaining blocked by offline maintenance after the launcher of
doctor --fixis killed, while preserving update drivers that intentionally outlive their launchers.Fixes #174219
User Impact
Launcher-bound Doctor work cancels and releases maintenance ownership when its launcher dies. Detached update, managed-handoff, and finalization drivers retain independent lifetimes. No new configuration, CLI/environment options, dependencies, or SQLite schema changes are required.
Why This Change Was Made
The launcher forwards ordinary signals but cannot forward SIGKILL, leaving its respawned CLI alive and renewing ownership indefinitely. Detached update drivers intentionally outlive their launchers, so parent-loss cancellation must be an explicit producer contract rather than a default for maintenance ownership.
Only CLI respawn producers install a private preload that records the launcher PID. The preload removes itself from
process.execArgv, so later detached workers cannot inherit the contract. Independent owners record no launcher dependency. The existing maintenance heartbeat worker detects loss only for a recorded launcher.Parent loss now requests the main thread's normal SIGTERM cancellation path. Ownership continues renewing while rollback, lease release, and service restoration settle. A ten-second backstop terminates a process that remains stuck. Merely losing a launcher does not let another process reclaim a still-live writer: that would permit overlapping native work. Peers recover the claim after the owner exits.
Evidence
quick_checkreturnedok. No lock or database deletion was needed. An earlier admission-phase kill also released its lock and started the next Gateway.check:changedSQLite inventory remains omitted under the campaign's local time budget; PR CI supplies broad proof.910b54b1ffa9(fix(update): return partial status when inspections stall #174060) already bounds stalled SQLite admission waits. The original pristine-main orphan reproduction and failing parent-loss regressions remain applicable to the initial defect.Live commands and isolation
Each process received a separate
HOME,OPENCLAW_HOME,OPENCLAW_STATE_DIR,OPENCLAW_CONFIG_PATH, and profile in a task-local artifact directory. The proof waited for Doctor's pre-repair backup, killed only its task-owned launcher, inspected descendants and lock release, and started the Gateway on an available loopback port.The task-owned Gateway was stopped after proof.