Skip to content

feat(gateway): honor host lifetime and install ownership - #161583

Merged
steipete merged 6 commits into
mainfrom
steipete/gateway-host-contracts
Sep 30, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/gateway-host-contracts

Conversation

@steipete

@steipete steipete commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An app-hosted Gateway needs to stop when its launching app disappears and must leave replacement of its bundled package/runtime to the app updater. This is B1, the core-contract PR in the Bun-powered macOS app series; packaging and native app hosting are owned by separate PRs.

Why This Change Was Made

OPENCLAW_GATEWAY_HOST_LIFELINE=stdin opts into an inherited pipe. EOF/error requests the existing graceful stop path, joining drain/child cleanup, releasing the Gateway lock, and flushing logs. It never converts host loss into a restart. QA now keeps that pipe open and uses the same owner; the PID watchdog and its environment contract are removed. Codex child grouping follows the parent Gateway's host state, so child env/clearEnv overrides cannot change containment. Broken host output pipes also retain the same shutdown owner, so console EPIPE cannot bypass drain or log flush.

A packaging-owned openclaw-install-owner.json marker is validated by one reader before any Git probe, avoiding the macOS Command Line Tools installer stub. Host packages refuse update/repair/finalize/wizard and Gateway update.run, skip package-registry/background/node updates, and report their owner and update hint. Doctor leaves payload/runtime/service repair to the host. A separately installed CLI also respects a marked service package before redirecting an update or rebinding the service.

User Impact

App-owned payloads stay in lockstep with OpenClaw.app. Missing markers preserve package/Git/unknown behavior without read-retry delays; malformed markers warn and are ignored. Terminal Gateways and supervised services retain their current lifetime unless the lifeline variable is explicitly set. No app or packaging files, configuration options, database changes, or Gateway protocol schema changes are included.

The existing Gateway update-status protocol keeps its configured-policy display and historical records. Host installs do not publish an unsupported install kind or package target; execution is skipped and browser update requests receive the app's hint.

Update behavior

Older published updaters do not know this marker and never encounter it: it exists only in app payloads created by the subsequent packaging work. New code ignores missing markers. No migration is needed, and a host refusal happens before package changes or stopping its Gateway.

Evidence

Current landing status: refreshed onto main e2113276497f3 as 3eef870c0a772 and continuing through normal review/CI gates under the coordinator decision. The constrained result is main 8/8 and head 7/8; causality remains inconclusive. The independently valid locator contention fix is landed separately in #161822 and is now included through main. It is not claimed to resolve the pressure failure. If fresh CI repeats the pressure failure, the coordinator authorizes one evidence comment and one failed-jobs-only rerun; a second red attempt stops landing.

Constrained native-hook pressure: all 16 standalone runs

Across the original three interleaved main/head pairs and five additional pairs, main passed 8/8 and PR head passed 7/8. The retained head failure reported 0/20 matched callbacks at the assertion. This establishes an intermittent failure on the PR head; it does not establish whether the cause is PR-specific or inherited under load.

Each campaign ran main then head on the same Linux Testbox lease, with a fresh lease for the additional five pairs. Every cell verified CPU affinity/cpuset 0–1, a 200% CPU quota, 8 GiB memory, zero swap, and Node 24.19.0. Original main runs 1–3 used ed7039629fa130e3499a7479fa6707cb5649382f; additional main runs 4–8 used 7db6ea365a62ef888a2eb2e1ac34f6aaa53d5505. All eight head runs used fd83e8fdaceeef9fccef348040a52b7aeecb7a55. The combined main count therefore spans two pinned main revisions, not eight identical-baseline repetitions.

The common entry point was node --import tsx scripts/ci-run-node-test-shard.mts, selecting extensions/qa-lab/src/codex-native-hook-pressure.e2e.test.ts through OPENCLAW_NODE_TEST_TARGETS_JSON, with prebuilt private-QA runtime, OPENCLAW_VITEST_MAX_WORKERS=2, and one plan. Assertions and timeouts were unchanged. The additional pairs added identical read-only fixture diagnostics on both revisions to capture callback counts and the existing hook-event stream.

All durations below are seconds. Command wall covers the complete standalone file invocation, including the transient-unit wrapper. Matched turn is the twenty-call scenario's turnElapsedMs; it includes work outside hook execution. Slowest hook in batch is the maximum individual hook-completion durationMs among that scenario's twenty hooks, not a sum or a batch wall time. The last column is the nominal difference between that maximum and the configured 10.000 s external per-hook deadline; it is not a scheduling guarantee. Individual hook timing was not captured in the original six runs and is explicitly unrecorded.

Run File result Matched callbacks Command wall (s) Matched turn (s) Slowest hook in batch (s) Below 10 s by (s)
main-1 pass 20/20 276.78 7.313 unrecorded unrecorded
head-1 pass 20/20 245.75 8.025 unrecorded unrecorded
main-2 pass 20/20 255.76 5.853 unrecorded unrecorded
head-2 pass 20/20 302.13 7.012 unrecorded unrecorded
main-3 pass 20/20 245.08 5.631 unrecorded unrecorded
head-3 fail 0/20 296.26 unrecorded unrecorded unrecorded
main-4 pass 20/20 305.60 7.228 5.304 4.696
head-4 pass 20/20 280.51 6.220 4.808 5.192
main-5 pass 20/20 275.84 6.416 5.505 4.495
head-5 pass 20/20 294.89 6.149 4.910 5.090
main-6 pass 20/20 251.57 7.287 5.795 4.205
head-6 pass 20/20 231.27 5.268 3.936 6.064
main-7 pass 20/20 239.11 9.921 7.876 2.124
head-7 pass 20/20 213.20 5.605 4.657 5.343
main-8 pass 20/20 235.64 6.100 4.718 5.282
head-8 pass 20/20 237.85 4.772 4.017 5.983

All ten instrumented runs recorded twenty completed hook events for the twenty-call scenario and no failed hook-completion event. Their slowest hooks ranged from 3.936–7.876 s, all below the 10 s deadline. These passing observations do not explain the earlier failure. On head-3, the assertion saw zero new callbacks. Its diagnostic registry contained six cumulative calls, already accounted for by the preceding one-call and five-call scenarios; those are not six completions of the failed twenty-call batch. The successful-scenario metric was never emitted, so neither its matched-turn duration nor its individual hook durations are available. The file's 296.26 s wall and the duration of the whole matched-policy test must not be substituted for a failing hook's duration. External timeout, startup delay, and lifecycle behavior remain unresolved alternatives; no captured failing hook event distinguishes them.

The independently fixed SQLite locator contention issue landed in #161822 as 71156a00c9ddc6838489c1f5d07a959281a8c85b. It was not present in these sixteen historical runs. Its separate constrained passing runs and reduced locator overhead are useful evidence for that fix, but are not causal proof that it resolves the 0/20 pressure failure. CI-prefix replays and locator-candidate runs are excluded from the 8/8 and 7/8 totals. These historical measurements also do not replace current-head CI after refreshing this branch.

A separate bounded replay of the original first-three-file CI prefix, with CI's Node/Vitest cache environment, also passed on both revisions: main 310.30 s, head 270.08 s; 20/20 callbacks; slowest hooks 3.561 s and 3.248 s. This checks the remaining ordering/cache difference without adding those runs to the 8-run standalone counts. The test lease is stopped. Provisioning run 36704384209; test results come from retained remote-command receipts, not the provisioning workflow's cleanup conclusion.

The earlier 7.884–9.282 s successful diagnostic hook batch was on the PR head, not main, and is separate from the sixteen standalone cells. It is not included in their totals. The original failed/cancelled CI run 36689169374 remains historical evidence; all five Windows jobs passed in that attempt. The refresh completed without conflicts. Range-diff preserves all six patches; only surrounding context changed in the macOS docs and update command. Prior Codex reviews remain applicable to that unchanged patch. Fresh exact-head CI and ClawSweeper review are required after this refresh.

Inherited Windows runtime-preparation failure: native head/main comparison reproduces the same refusal without this PR. On one native Windows Testbox, Node 24.21.0 and Git Bash, head 33df06335464 and captured origin/main f3672acef8623 both reject \Microsoft\Windows\Hotpatch\Monitoring during strict managed-Gateway inventory, then throw the same discovery error and return the fence refusal. Imports succeed and the invoking Gateway service is absent. The two valid native JSON records match; failed direct PowerShell launcher attempts are excluded. Eight targeted local discovery/Startup/fence files pass (207 tests, one existing skip). The original CI log did not retain its task inventory, so the historical runner's exact offending task is not claimed known. The coordinator accepted this independent-main proof for the native inherited-failure exception and authorized a separate Windows owner fix after landing.

The previous attempt also exposed a PR-caused update.run regression when the launch directory had disappeared: the new ownership lookup evaluated bare process.cwd() and threw before managed handoff. Follow-up fd83e8fdaceee reuses tryProcessCwd() so the package-root owner keeps its module/argv hints with an absent cwd. A full-PR diff audit found no other new bare cwd lookup in production Gateway code (the other occurrence is a QA test fixture). The existing regression failed before this fix (exit 1, 113.20 s). All 48 update.test.ts tests now pass (104.46 s), including the unavailable-cwd case, and the host-owned RPC refusal test passes (21.99 s). Core types (11.13 s), targeted core lint (16.07 s), formatting and whitespace checks pass. Codex review of the correction is scoped-clean through P2. No test assertions or timeouts changed. Fresh exact-head CI is run 36689169374; its new QA failure is recorded below. Prior failed attempts are historical evidence, not current-head clearance.

The required evidence comment preceded the one gh run rerun 36681218454 --failed invocation. It records the first attempt's unrelated native-declaration timeout and both passing local reproductions (67.73 s and 57.55 s). Those passing reproductions were not represented as a source fix.

ClawSweeper revision 17 completed on exact head 3eef870c0a772369c5b8530b33ce7b25ed9d8b4c at 2026-09-30T12:37:16.863Z: ready for maintainer review, sufficient terminal proof, no source/security findings, and no before-merge items. It accepts the native-service smoke and records the historical pressure uncertainty under normal current-head gates. Fresh CI is 36715201857.

Fresh CI attempt 1 failed a separate requester-wake cleanup observation in job 109886872609; the pressure job was cancelled. The evidence comment records unchanged source-path independence and two passing local reproductions (original eight-file cohort: 235 pass/one existing skip, 302.55 s; isolated file: 25 pass, 162.23 s). No source/assertion/timeout change was made. The single coordinator-authorized failed-jobs rerun completed successfully: run 36715201857 attempt 2, exact head 3eef870c0a772, Actions gate job 109908553967. The pressure, requester-wake and Windows jobs passed. These passing results clear the test gate; no causal fix for either historical flake is claimed.

Refreshed-head focused proof passed all 57 tests: lifeline 6/6 (4.94 s), Codex stdio 21/21 (30.64 s), pending recovery 21/21 (42.73 s), registered host CLI 4/4 (10.79 s), locator admission 4/4 (12.11 s), and host-owned RPC refusal 1/1 (21.29 s). Each used node scripts/run-vitest.mjs <file> --maxWorkers=1. Core types (15.82 s), root-test types (56.21 s), formatting (0.68 s), targeted update-command lint (70.58 s), docs sanity (0.61 s), and whitespace (0.50 s) passed. Gateway-profile setup/build completed; build phases totaled 47.3 s. Unchanged-owner proof above remains retained; fresh CI is not substituted by those historical results.

Separate CLI → marked native service: passed

A real macOS LaunchAgent smoke on exact head fd83e8fdacee closes the service-custody proof requested by ClawSweeper revision 16. Two independent package roots used current built runtime/launcher/AI bytes and dependencies copied from the earlier installed first-hop fixture. This proves real CLI/native-service behavior from copied packages; it is not fresh npm installation or macOS packaging proof. Git and launchd discovery used real subprocesses.

The fixture started its own uniquely named profile/service from the app package, then wrote the marker only into that package. The invoking CLI package remained unmarked. Its real node "$CLI/openclaw.mjs" --profile "$PROFILE" update --yes --json refused in 1.973 s, exit 1:

{"status":"error","reason":"managed-service-preflight","failureFact":{"check":"managed-service","code":"service-mutation-refused","message":"Managed by OpenClaw.app. Update OpenClaw.app to update this Gateway."}}

Before/after complete file-content, mode and symlink snapshots matched for both packages (44,334 CLI entries; 44,335 app entries). LaunchAgent definition, generated environment/wrapper, and profile config hashes matched. Native PID, run count (1), running state, program/arguments and working directory remained identical; real health checks passed before (10.213 s) and after (1.966 s). Service installation took 3.641 s. The fixture used an isolated named profile, npm prefix/cache, workspace and port; the default profile/operator Gateway were untouched. One exact bootout cleaned up its service; PID, package processes, plist/profile and listening port were verified absent, and a fresh port bind succeeded. Temporary package copies were removed.

This closes the separate-service final-effect coverage gap. Pressure attribution remains inconclusive as recorded above.

Data-model compatibility proof

The two compatibility cells below cover the published 2026.9.7 updater completing an ordinary unmarked candidate upgrade and the installed candidate refusing after the app marker is added. Configuration and synthetic workspace state were preserved; the marked refusal launched no subprocesses and left package/state hashes unchanged. The marker is an opt-in packaging contract; no database/configuration/protocol schema or existing stored user data is changed. The coordinator accepted this evidence for the generic compatibility checkbox; no additional proof is required.

Published updater × candidate: passed

A real macOS/Node 26.10.0 first-hop cell used npm's current latest, pinned to openclaw 2026.9.7 (published build c074824a27c9), installed into a fresh canonical /private/tmp prefix. The candidate package was built from d1de10a203f5; canonical build, package inventory, dist import graph, and tarball integrity checks passed. Candidate archive SHA-256: 20f06fc73f41638cbc147c328512be2e3fd7f0c8e6fa946181f80e3c284d35d9.

The repository's first-hop fixture helper stamped 2026.9.99-first-hop.0 to force an actual update. It changed only package.json, dist/build-info.json, and dist/postinstall-content-inventory.json; all candidate code and compatibility chunks were retained. HOME, state, npm prefix/cache, temp files, and the service label were isolated. No managed service was installed; --no-restart and the updater's isolated-state service skip preserve that absence. This cell covers package upgrade and state preservation; managed-service restart remains outside its scope.

The child environment set HOME=$PROOF/home, OPENCLAW_STATE_DIR=$PROOF/state, OPENCLAW_CONFIG_PATH=$PROOF/state/openclaw.json, NPM_CONFIG_PREFIX=$PREFIX, an isolated npm cache, and the unique b1-first-hop-canonical-20260930 profile/service label.

Commands (paths shortened to the recorded proof variables):

npm view [email protected] version dist --json --prefer-online
npm install --global --prefix "$PREFIX" [email protected] --no-audit --no-fund --min-release-age=0
node scripts/package-openclaw-for-docker.mjs --output-dir "$ARTIFACTS/candidate" --output-name openclaw-b1-candidate.tgz
node scripts/e2e/lib/update-first-hop-package-fixtures.mjs first-hop-tarball "$ARTIFACTS/candidate/openclaw-b1-candidate.tgz" "$ARTIFACTS/first-hop.tgz" 0
node "$PREFIX/lib/node_modules/openclaw/openclaw.mjs" config set gateway.mode local
node "$PREFIX/lib/node_modules/openclaw/openclaw.mjs" config validate --json
node "$PREFIX/lib/node_modules/openclaw/openclaw.mjs" update --yes --tag "$ARTIFACTS/first-hop.tgz" --json --no-restart

The installed published CLI performed the update:

{"exit":0,"status":"ok","mode":"npm","before":"2026.9.7","after":"2026.9.99-first-hop.0","markerPresent":false,"installedBuildMatches":true,"configValid":true,"gatewayModePreserved":true,"syntheticWorkspacePreserved":true}

Candidate admission's config, database-schema, node-runtime, and plugin-availability checks all returned ok. Candidate Doctor, config validation, plugin discovery, recovery check, Gateway startup canary, package swap, post-core Doctor, and post-plugin lint all exited 0. Build/pack wall: 1263.01 s; fixture generation: 25.07 s; published updater: 507.14 s; installed candidate config validation: 2.74 s.

Second cell: write the required app marker into that installed candidate and run its real update --json entry. All child-process launch APIs were instrumented to record and throw, so any Git/npm/service subprocess would fail the probe:

node --import "$PROOF/no-subprocess.mjs" "$PREFIX/lib/node_modules/openclaw/openclaw.mjs" update --json
{"exit":1,"status":"host-managed","reason":"host-owned-install","installKind":"host","message":"Managed by OpenClaw.app. Update OpenClaw.app to update this Gateway.","steps":[],"subprocessAttempts":0,"packageUnchanged":true,"stateFilesUnchanged":true}

Marked-cell wall: 0.97 s. An initial fixture attempt used macOS's /tmp alias and failed the updater's canonical publication-directory guard before replacing the old package (219.30 s). A fresh prefix using /private/tmp throughout corrected that fixture input; no updater guard or source code was changed to obtain the passing cell.

The coordinator's main fix b872697936000 supplies the missing route resolver in the unrelated scenario-flow fixture. This branch was then rebased onto 79fded8bf552; the update consumers and all four repair patches are unchanged. The one mechanical run-loop conflict preserves main's direct synchronous lifecycle-owner calls with this PR's host-aware formatter. After rebase, all 6 host-lifeline tests passed (2.61 s), all 227 run-loop tests passed (78.20 s), and all 46 scenario-flow tests passed (43.67 s). Core types passed (13.16 s), targeted run-loop lint passed (10.73 s), formatting/whitespace passed, and fresh full-branch Codex review was scoped-clean through P2. Current-head CI and completed ClawSweeper review remain required before landing.

Follow-up d1de10a203f5 applies the same read-only retained-recovery admission to update repair before install-root discovery and host-owner refusal, preserving the later pre-write check. The new repair regression failed on the previous ordering (20.06 s). Recovery, registered host CLI, repair command, and repair history tests then passed 100/100, with command walls of 67.75 s, 16.14 s, 39.94 s, and 70.26 s respectively. Targeted lint, formatting, whitespace checks, and Codex review through P2 passed.

CI run 36671428988 hit EADDRINUSE in the unchanged legacy-listener fixture. Inspection confirms it already claims the full [0, 1, 2] block, and the allocator's probes honor those claims. No unreserved-neighbor defect or competing socket owner was established, so no speculative allocation change is included. The observed 43-file Node slice passed locally (1,182 tests, 81.63 s), followed by the listener file (13 tests, 10.67 s); three further requested one-worker listener runs passed in 18.10 s, 42.60 s, and 51.30 s. These passing runs do not prove that collision is fixed. No assertions, timeouts, or CI jobs were weakened or rerun.

All three full type-aware extension lint jobs passed in run 36671428988, closing the earlier local declaration-preparation gap. Superseded-head CI remains historical evidence; landing requires the new head's CI gate and completed ClawSweeper review.

Follow-up 39de352d173f5 restores read-only pending-recovery admission before install discovery in finalization, while retaining the later pre-write recheck and the no-subprocess host refusal. The unchanged recovery regression failed before the fix. Afterward, pending-recovery tests passed 20/20 (249.41 s command wall), registered host-owned CLI tests passed 4/4 (68.42 s), and finalization-refusal tests passed 5/5 (74.95 s). Targeted lint/format and fresh Codex review passed; compiler/setup work dominates these cold command walls.

Follow-up f7c5ee89fc901 moves the unchanged install-kind union to a dependency-free type module, removing two reverse type imports found by CI. Both cycle checks now report zero cycles. The full pnpm check:architecture passed (508.59 s), core typecheck passed (22.53 s), targeted lint passed (18.42 s), and fresh Codex review was clean through P2. No runtime behavior, tests, or baselines changed in this correction.

Refreshed onto df2a29cac9ad3 after main's CI repair; the rebase was conflict-free and range-diff preserved the original feature patch. Follow-up 6067c6dce1091 fixes the ClawSweeper parent/child-environment finding. Both new override cases failed before the fix; all 21 stdio transport tests now pass (3.01 s command wall), along with 13 real process-group cleanup tests (12.20 s). Targeted formatting/lint and fresh Codex review passed for the correction. Current-head CI and ClawSweeper gates are required before landing.

825 tests passed across 29 focused files, with one existing skip. Each source test command used node scripts/run-vitest.mjs <file> --maxWorkers=1; the QA child/env files shared one invocation. The new EOF/restart/EPIPE run-loop cases each took 49–52 ms and use no sleeps. The inherited QA recovery fixture took 90.06 s and exercised a real mock-provider Gateway, queued follow-up, and cleanup.

pnpm tsgo:core (11.69 s), pnpm tsgo:test:root (31.20 s), targeted core and extension lint, oxfmt, line/environment ratchets (476/476), git diff --check, and pnpm docs:list passed. The final pnpm build qaRuntime passed in 70.04 s. Full SDK declaration preparation for an earlier type-aware extension lint attempt timed out; focused extension syntax lint passed, and the later native E2E build completed its declaration stages.

Real built-entry smokes used isolated HOME/state and free ports. Closing the stdin pipe produced exit 0 in 776 ms on Node 26.10.0 and 779 ms on Bun 1.4.2, within the shutdown budget, with no restart. A copied package containing the marker returned exit 1 with status: "host-managed", the app hint, and no attempted subprocesses, stderr, or state entries. Child-process APIs were instrumented to fail any Git/npm or other subprocess launch.

Codex review found no actionable P0–P2 findings on the final source. The requested committed-branch review also returned scoped-clean through P2, with its verdict line verified. Historical CI failures and their resolutions are recorded above; no workflow was dispatched or rerun to manufacture this proof.

Focused tests and measured command walls
Test file Passed Command wall (s)
extensions/codex/src/app-server/transport-stdio.test.ts 19 4.10
src/cli/gateway-cli/host-lifeline.test.ts 6 4.59
src/cli/gateway-cli/run-loop.test.ts 227 62.26
src/cli/signal-exit-barrier.test.ts 10 3.43
src/cli/update-cli.host-owned.test.ts 4 191.83
src/cli/update-cli/update-command-service-root-plan.test.ts 9 129.01
src/commands/doctor-gateway-daemon-flow.test.ts 49 12.99
src/commands/doctor-gateway-services.test.ts 78 15.14
src/commands/doctor-host-runtime.test.ts 8 429.26
src/commands/doctor-install.test.ts 31 3.51
src/commands/doctor-stale-runtime-build.test.ts 8 8.78
src/commands/doctor-ui.repair.test.ts 12 2.59
src/commands/doctor-ui.test.ts 11 8.54
src/commands/doctor-update.test.ts 23 8.50
src/commands/doctor/shared/plugin-runtime-symlinks.test.ts 5 2.46
src/commands/node-runtime-diagnostics.test.ts 8 17.21
src/commands/status-overview-surface.test.ts 5 48.20
src/flows/doctor-core-checks.runtime.test.ts 50 25.94
src/gateway/server-methods/update-host-owned.test.ts 1 417.67
src/gateway/server-methods/update-status-schedule.test.ts 16 288.22
src/gateway/server-qa-diagnostic-timings.test.ts 7 5.18
src/infra/install-owner.test.ts 7 62.08
src/infra/update-check-install-kind.test.ts 10 22.59
src/infra/update-startup-host-owned.test.ts 4 185.14
src/infra/update-startup.test.ts 109 58.62
src/node-host/auto-update.test.ts 28 10.20
extensions/qa-lab/src/gateway-child.test.ts + gateway-child-env.test.ts 79 (1 existing skip) 561.97 combined
test/e2e/qa-lab/runtime/gateway-repeated-request-recovery.e2e.test.ts 1 2030.36 including runtime preparation

Cold command walls include compiler/setup work, which dominated the initial entry-point files (up to 16,746 compiled inputs). The QA E2E wall includes native runtime preparation of 29m 56.8s plus a 21.5s declaration invocation. The QA spawn assertion extends an existing fixture; the E2E only changes its environment-contract assertion. The larger run-loop file retains its existing process-lifecycle cases. These timings do not represent new sleeps or per-case Gateway boots.

Earlier failed attempts exposed a missing-marker ENOENT retry delay and fake-clock coordination; both were corrected and their regressions pass. A separate compiler-namespace failure occurred before tests because runtime preparation was replacing artifacts; serializing artifact preparation resolved it. Review also caught malformed generated QA fixture imports, which were fixed before the passing QA runs.

@clawsweeper

clawsweeper Bot commented Sep 30, 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 docs Improvements or additions to documentation app: macos App: macos gateway Gateway runtime cli CLI command changes commands Command implementations extensions: qa-lab extensions: codex size: XL labels Sep 30, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Sep 30, 2026
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 30, 2026, 9:01 AM ET / 13:01 UTC (Revision 19).

ClawSweeper review

What this changes

The branch lets an app-held stdin pipe stop its Gateway gracefully and makes app-owned packages direct updates and Doctor repairs to the app updater.

Merge readiness

✅ Ready for maintainer review

This remains useful, distinct groundwork for app-hosted Gateways. Current main lacks both contracts. The recorded macOS behavior and upgrade proof are strong, and this review found no concrete patch defect. The earlier intermittent pressure-test failure remains documented without established causality.

Priority: P2
Reviewed head: 3eef870c0a772369c5b8530b33ce7b25ed9d8b4c

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Direct macOS and built-runtime proof, upgrade coverage, and coherent owner-level changes support a strong rating despite the documented unattributed pressure observation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Terminal traces exercise the built Gateway on Node and Bun after host-pipe closure, the published updater against an unmarked candidate, and marked package and native LaunchAgent refusal with unchanged state. Those runs cover the changed shutdown and update owners; focused current-head tests supplement the earlier patch-equivalent runtime runs. The opt-in marker changes no existing user-state format, and the published-driver cell verifies existing-state upgrade compatibility.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Terminal traces exercise the built Gateway on Node and Bun after host-pipe closure, the published updater against an unmarked candidate, and marked package and native LaunchAgent refusal with unchanged state. Those runs cover the changed shutdown and update owners; focused current-head tests supplement the earlier patch-equivalent runtime runs. The opt-in marker changes no existing user-state format, and the published-driver cell verifies existing-state upgrade compatibility.
Evidence reviewed 9 items Current main: Current main still classifies Git, package, and unknown installs and has no install-owner reader; the branch's host contract remains unique.
Package ownership: The introduced reader validates the packaging marker and leaves absent or invalid markers on the existing discovery path.
Update boundary: Installation discovery checks the marker before a Git subprocess; the Gateway update request refuses a marked package before starting an update.
Findings None None.
Security None None.

How this fits together

The Gateway run loop controls server shutdown, while update and Doctor classify who owns an installed package before changing it. A host pipe and a package marker enter those owners and produce either graceful shutdown or app-directed update guidance.

flowchart LR
 A[App launcher] --> B[Stdin lifeline]
 B --> C[Gateway lifecycle]
 C --> D[Graceful stop]
 E[Package marker] --> F[Install ownership]
 F --> G[Update and Doctor]
 G --> H[App updater guidance]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +373, Tests +1022, Docs +24, Other -1. Total +1418 across 70 files.

View PR surface stats
Area Files Added Removed Net
Source 39 670 297 +373
Tests 27 1205 183 +1022
Docs 3 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 70 1899 481 +1418

Review metrics

Metric Value Why it matters
New host contracts 1 environment mode, 1 package-marker schema The follow-up macOS packaging and launcher work must supply both contracts correctly.
Code growth production net +373 lines; tests net +1022 lines The production growth implements the two stated ownership contracts and their update, Doctor, and shutdown consumers.

Stored data model

Persistent data-model change detected: database schema: src/infra/install-owner.ts, migration/backfill/repair: src/commands/doctor-gateway-daemon-flow.ts, migration/backfill/repair: src/commands/doctor-gateway-legacy-services.ts, migration/backfill/repair: src/commands/doctor-gateway-services.ts, migration/backfill/repair: src/commands/doctor-ui.ts, migration/backfill/repair: src/commands/doctor-update.ts, and 5 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Use the packaging-written marker and launcher-held pipe as the shared app-hosting contract, then let the separate macOS integration consume them while preserving standalone installs.

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

Not applicable: this adds opt-in host behavior. The PR records direct after-change runs for shutdown, update, and native-service refusal.

Is this the best way to solve the issue?

Yes. The marker is read by the existing install-discovery owner, and host loss enters the existing Gateway stop path; app packaging and hosting remain in their separate integration PRs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cd59fe831ed9.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is bounded groundwork for a future app-hosted Gateway workflow rather than a current emergency.
  • merge-risk: 🚨 compatibility: A marked package deliberately stops accepting CLI updates; the recorded published-updater and native-service cells cover the intended upgrade boundary.
  • merge-risk: 🚨 availability: The new host-loss path stops a Gateway and changes Codex child containment; direct stop proof exists, while an earlier pressure-test failure remains unattributed.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Terminal traces exercise the built Gateway on Node and Bun after host-pipe closure, the published updater against an unmarked candidate, and marked package and native LaunchAgent refusal with unchanged state. Those runs cover the changed shutdown and update owners; focused current-head tests supplement the earlier patch-equivalent runtime runs. The opt-in marker changes no existing user-state format, and the published-driver cell verifies existing-state upgrade compatibility.
  • proof: sufficient: Contributor real behavior proof is sufficient. Terminal traces exercise the built Gateway on Node and Bun after host-pipe closure, the published updater against an unmarked candidate, and marked package and native LaunchAgent refusal with unchanged state. Those runs cover the changed shutdown and update owners; focused current-head tests supplement the earlier patch-equivalent runtime runs. The opt-in marker changes no existing user-state format, and the published-driver cell verifies existing-state upgrade compatibility.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Alex Markson: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Mitchell Etzel: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (18 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-30T07:38:54.109Z sha 33df063 :: blocked before merge. :: none
  • reviewed 2026-09-30T08:13:24.317Z sha 33df063 :: needs changes before merge. :: none
  • reviewed 2026-09-30T08:29:19.143Z sha fd83e8f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-30T08:41:29.727Z sha fd83e8f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-30T09:15:13.561Z sha fd83e8f :: blocked before merge. :: none
  • reviewed 2026-09-30T10:46:56.551Z sha fd83e8f :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-30T12:37:16.863Z sha 3eef870 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-30T12:47:40.310Z sha 3eef870 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/gateway-host-contracts branch from 9f758a1 to 496495d Compare September 30, 2026 04:06
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 30, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 30, 2026
@steipete
steipete force-pushed the steipete/gateway-host-contracts branch from fd83e8f to 3eef870 Compare September 30, 2026 12:30
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Refreshed to 3eef870c0a772369c5b8530b33ce7b25ed9d8b4c on current main, including the separately landed locator contention fix. The PR body records all sixteen constrained runs, distinct hook/turn timings against the 10-second deadline, main 8/8 versus head 7/8, and the unresolved causality. The locator fix is not claimed to resolve that failure.

The separate unmarked CLI → marked native LaunchAgent smoke also passed: readable ownership refusal, unchanged full package/service snapshots and native process generation, health before/after, and complete isolated-fixture cleanup. The coordinator has directed continuation through fresh normal CI and review gates with the remaining pressure uncertainty documented.

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 30, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Fresh CI attempt 1 failed checks-node-changed-2 in subagent-registry.requester-wake.e2e.test.ts → delivers the visible requester final: alpha delivery was recorded as delivered, but cleanupCompletedAt had not appeared within the fixture's 80 fake-clock/import-flush polls. The pressure job was cancelled, not failed.

Two bounded local reproductions on unchanged head 3eef870c0a772 passed:

Reproduction Result Wall
Original ordered eight-file CI cohort 235 passed, one existing package skip; target case passed 302.55 s
Requester-wake file alone, one worker 25 passed; target case passed 162.23 s

The cohort used node --import tsx scripts/ci-run-node-test-shard.mts, the exact CI target order below, OPENCLAW_VITEST_MAX_WORKERS=2, plan concurrency 1, bun-compatible runtime policy, and prebuilt private-QA runtime. The isolated command was:

node scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry.requester-wake.e2e.test.ts --maxWorkers=1
Original cohort target order
extensions/qa-lab/src/plugin-subagent-self-yield-followup.e2e.test.ts
extensions/qa-lab/src/subagent-private-completion-package.e2e.test.ts
extensions/qa-lab/src/web-runtime.lifecycle.e2e.test.ts
src/agents/subagents/registry/subagent-registry.lifecycle-retry-grace.e2e.test.ts
src/agents/subagents/registry/subagent-registry.requester-wake.e2e.test.ts
src/channels/plugins/contracts/channel-import-guardrails.test.ts
src/channels/plugins/contracts/mattermost-read-authority.contract.test.ts
src/channels/plugins/contracts/plugin-shape.contract.test.ts

These were macOS/Node 26.10 runs; CI used Linux/Node 24.19. The target case took 1.618 s and 1.753 s locally. Source inspection supports independence from B1: this case uses an in-process registry and mocked Gateway/spawn calls, without a QA Gateway or Codex stdio child. Agent, state, shared, plugin and config owners are byte-identical to the main baseline; the reached Gateway-admission change is type-only. No identical assertion was found in the recent failed-main logs checked. A fixture/native-worker scheduling race is plausible, not proven; passing replays do not establish a fix.

No source, timeout, or assertion changes were made. Under the coordinator's explicit policy, I am requesting the single permitted failed-jobs-only rerun: gh run rerun 36715201857 --failed. A second red attempt stops landing, except the separately authorized documented Windows inherited-failure path if its conditions hold.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 30, 2026
@steipete
steipete merged commit d7f8b2c into main Sep 30, 2026
424 of 443 checks passed
@steipete
steipete deleted the steipete/gateway-host-contracts branch September 30, 2026 13:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…1583)

* feat(gateway): honor host lifetime and install ownership

* fix(codex): preserve hosted child process grouping

* fix(update): keep install kinds outside update check cycles

* fix(update): check retained recovery before install discovery

* fix(update): admit retained recovery before repair discovery

* fix(gateway): tolerate unavailable cwd during update admission
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: codex extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL 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