Skip to content

fix: share managed Gateway startup readiness across setup - #130682

Merged
steipete merged 2 commits into
mainfrom
codex/configure-gateway-readiness
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/configure-gateway-readiness

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130679
Related: #130617

What Problem This Solves

Fixes an issue where users reinstalling the Gateway through configure could see Gateway: not detected (connect ECONNREFUSED ...) even though the newly installed service was simply starting and then became reachable without further changes.

Why This Change Was Made

Supervisor installation registers and activates a service; the setup caller owns the subsequent authenticated reachability observation. Configure previously made one immediate observation. Its first repair selected the generic 15-second wait, but review and an observed slow cold start exposed a second gap: non-interactive managed onboarding already uses 45-second startup / 10-second probe timing, or 90 seconds / 15 seconds on Windows.

Move that existing platform policy into one small shared startup owner and use it from configure, classic onboarding, conversational setup, and non-interactive onboarding. Configure applies it both to the final summary and to a health section after a successful daemon action. Health-before-daemon still starts with the existing attach budget. Reused services, failed/skipped actions, config-only runs, auth-resolution warnings, and standalone/remote health retain their existing policies. Service outcome remains distinct from reachability, and a scheduled restart is not relabeled as a completed replacement.

The canonical polling helper is reused; no new retry loop, timeout values, backend behavior, flag, config key, credential fallback, or persistence surface is added. Remove the non-interactive-only timing resolver/constants and its test-only access path. The separate non-interactive Windows health-RPC timeout remains unchanged. Production LOC: +38/-43 (net -5), tests/test support: +205/-36, docs: +1. Moving observation into platform installers would incorrectly change their activation contract.

Provenance: #127669 (992948356f23, author and merger @steipete) carried forward the one-shot summary while fixing SecretRef handling; it did not introduce this timing gap. Original introduction is unknown in the available shallow history. This is not a regression from #130617.

User Impact

After successful daemon setup, configure and the sibling setup flows give the newly activated Gateway the established platform-specific startup allowance before presenting reachability. A Gateway that remains unavailable still reports that result; successful service registration is not relabeled as failed installation. Ordinary configuration and failed/skipped installation do not gain the managed-startup delay.

Release note: Avoid premature Gateway-not-detected and health-failed results after setup installs or restarts the managed Gateway; share platform-specific startup timing across configure and onboarding.

Evidence

Real macOS 27.0 launchd flow, source build at 73b98c4b50160a1f57f6a0f9197ae6c6b53c22b4, dedicated profile/loopback port43219, token auth, plugins disabled, no channels or model calls. The operator Gateway and existing config were not touched.

Before, using the unmodified build:

configure --section daemon -> Local -> port43219 -> Reinstall -> Node
Installed LaunchAgent: <isolated profile service>
Gateway: not detected (connect ECONNREFUSED 127.0.0.1:43219)
Subsequent openclaw --profile <profile> health --json: {"ok":true}

After rebuilding the initial configure repair and repeating the same real flow:

Installed LaunchAgent: <isolated profile service>
Gateway: reachable
Daemon setup completed.
openclaw --profile <profile> health --json: {"ok":true}

These are authenticated WebSocket checks, not HTTP-liveness substitutes. The test service uses generated task-only credentials; none are included here. Cross-platform installer semantics were source-inspected, but live execution was macOS only. This change does not claim that a scheduled deferred restart has completed merely because the current Gateway answers.

Additional initial live boundary checks: Skip preserved the running Gateway and reported Daemon setup skipped. A cold install under concurrent validation exceeded the generic 15-second allowance and passed authenticated health afterward, approximately three seconds after the summary. This observation supports the review finding addressed by the final shared managed-startup policy. Startup remains bounded; no guarantee is made that every broken or slow service will become reachable.

Final source rebuilt after the timing refactor: a fresh isolated macOS profile, generated task-only token, loopback port 43219, plugins disabled, and no model/channel calls. Both fresh Install and Reinstall through configure --section daemon --section health completed authenticated health and reported Gateway: reachable followed by Health check completed. Reinstall replaced the actual service process. A daemon-only Skip reported Daemon setup skipped. and preserved the same running process. A separate health --json returned ok: true. These are real CLI/launchd/Gateway runs; Windows timing is covered by caller-level tests, not native Windows execution. Cleanup verified the test service absent, its listener closed and plist removed; task state and log were moved to Trash.

  • Original owner regressions failed on baseline for the intended status mismatch (2/27).
  • Shared-policy regressions then failed before the timing refactor: configure 3, classic finalizer 6, conversational setup 8. The existing non-interactive policy passed its caller-level tests. A further 3 intended failures proved the daemon-then-health ordering gap before its repair.
  • Final focused/sibling run passed 262 tests across 11 files and 3 harness shards. Coverage includes default/macOS/Windows timing, fresh versus reused service actions, scheduled restarts, failed/skipped actions, both health/daemon orders, auth and SecretRefs, persistence and concurrency, and LAN display versus loopback probing.
  • CLI startup build passed, including bootstrap import checks and 48 runtime postbuild module checks.
  • Fresh Codex autoreview completed clean; independent full-severity source/test review found no actionable findings.
  • Full final local changed gate passed: core/test types, changed lint/format, all dead-export scans, runtime import cycles, and structural guards. Final docs MDX passed across 791 files.
  • First exact-head CI 33038439760 failed only the unrelated UI startup gzip budget (343458 bytes versus 343442). The synthetic merge's UI/build closure matched its main parent; build-identity variation exposed shared near-zero headroom. Canonical repair perf(ui): defer custom theme import to settings #130710 is now merged as 42ce03e72e34, moving real theme-import code into lazy Settings with a controlled 2139-byte startup reduction and unchanged budget. This branch was refreshed onto that actual repair. No budget increase, blind retry, or failed-gate bypass.

ClawSweeper findings/rank-up moves: addressed managed startup timing, caller-level default/Windows coverage, and refresh onto the canonical UI repair. The independent follow-up also caught and verified the configure daemon-to-health ordering case.

Final exact-head CI 33046429882 passed on 17baa65d026458e2dc4b1c919fd733aa6b6f1871, including the previously failing build-artifacts job. Its actual startup payload is 341185 bytes gzip in 8 requests, below the unchanged 343442-byte ceiling. Full local gates and live proof above match the published source.

Local validation commands (task-owned source checkout; live profile was removed after proof):

node scripts/run-vitest.mjs src/commands/configure.wizard.gateway.test.ts src/commands/configure.wizard.test.ts src/commands/configure.wizard.persistence.test.ts src/commands/configure.daemon.test.ts src/commands/onboard-helpers.test.ts src/commands/configure.commands.test.ts src/commands/onboard-non-interactive.gateway.test.ts src/commands/onboard-non-interactive.gateway-health-auth.test.ts src/system-agent/setup-apply.test.ts src/system-agent/setup-apply.concurrency.test.ts src/wizard/setup.finalize.test.ts
node --import tsx scripts/build-all.mts cliStartup
env -u OPENCLAW_TESTBOX node scripts/check-changed.mjs -- src/commands/gateway-startup-timing.ts src/commands/configure.wizard.ts src/commands/configure.wizard.gateway.test.ts src/commands/configure.wizard.persistence.test.ts src/commands/onboard-non-interactive/local.ts src/commands/onboard-non-interactive/local.test-support.ts src/commands/onboard-non-interactive.gateway.test.ts src/commands/onboard-non-interactive.gateway.test-mocks.ts src/system-agent/setup-apply.ts src/system-agent/setup-apply.test.ts src/wizard/setup.finalize.ts src/wizard/setup.finalize.test.ts docs/cli/configure.md
node scripts/check-docs-mdx.mjs docs README.md

AI-assisted with Codex. No transcript included.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 04:07
@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. 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 Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 2:43 AM ET / 06:43 UTC.

ClawSweeper review

What this changes

The PR centralizes managed Gateway startup timing and applies it after successful local setup actions across Configure and onboarding flows.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking correctness findings. The prior timing finding is addressed; this active maintainer PR remains necessary because current main still uses the shorter Configure probes, while exact-head checks are incomplete.

Priority: P2
Reviewed head: 17baa65d026458e2dc4b1c919fd733aa6b6f1871

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-negative runtime refactor resolves the prior finding with useful caller-boundary coverage and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless records an isolated authenticated macOS before/after CLI and launchd run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless records an isolated authenticated macOS before/after CLI and launchd run.
Evidence reviewed 5 items Current-main behavior: Current main still gives Configure health checks the generic 15-second deadline, so the reported startup race is not already fixed.
Shared owner and callers: The PR adds one platform timing resolver and uses it only after successful managed starts, preserving short probes for failed, skipped, and reused service paths.
Canonical polling contract: The reused reachability helper is bounded and passes the supplied per-probe timeout to authenticated Gateway probes; its normal defaults remain 15 seconds and 1.5 seconds.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw configure --help

Result: PASS (completed)

$ node scripts/run-node.mjs configure --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 79.25 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.5s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 11.3s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3272ms (slowest: built plugin control-plane loads 2694ms)

OpenClaw 2026.8.1 (17baa65) — All your chats, one OpenClaw.

Usage: openclaw configure [options]

Interactive configuration for credentials, channels, gateway, and agent defaults

Options:
  -h, --help           Display help for command
  --section ‹section›  Configuration sections (repeatable). Options: workspace, model, web, gateway, daemon, channels, plugins, skills, health (default: [])

Docs: docs.openclaw.ai/cli/configure

Assertions:

  • PASS expect_output: --section

How this fits together

Configure and onboarding install or restart the local managed Gateway, then authenticate to it before reporting setup status. The shared timing policy controls how long those callers allow the listener and handshake to become reachable.

flowchart LR
  A[Configure or onboarding] --> B[Gateway service action]
  B --> C{New managed start?}
  C -->|Yes| D[Shared startup allowance]
  C -->|No or reused| E[Existing short probe]
  D --> F[Authenticated reachability check]
  E --> F
  F --> G[Setup and health status]
Loading

Before merge

  • Complete next step (P2) - The active maintainer-owned PR already supplies the bounded repair; no separate fix lane is appropriate.
Agent review details

Security

None.

PR surface

Source -16, Tests +180, Docs +1. Total +165 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 38 54 -16
Tests 5 206 26 +180
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 245 80 +165

Review metrics

Metric Value Why it matters
Production versus test LOC production +38/-43 (net -5); tests/test support +205/-36 The repair removes duplicated timing policy and its test-only access path while adding caller-boundary regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130679
Summary: This PR is the active candidate fix for the linked Configure readiness race.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one shared startup-policy owner, preserve each caller’s distinct service outcome and short attach behavior, and land once the exact-head checks complete successfully.

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

Yes, source reproducible: current main’s Configure path uses the generic 15-second wait after service setup, while the supplied isolated macOS evidence records the false status followed by successful authenticated health.

Is this the best way to solve the issue?

Yes. One shared policy reuses the canonical bounded authenticated probe and removes duplicated non-interactive timing constants rather than moving readiness observation into platform installers.

AGENTS.md: found but not applied because it conflicted with ClawSweeper's review contract.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs misleading local Gateway readiness status after setup, without evidence of data loss, a security boundary failure, or core-runtime unavailability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the contributor proof gate; its body nevertheless records an isolated authenticated macOS before/after CLI and launchd run.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the exact PR head and recent merged adjacent setup/auth work; local history also attributes the available current setup timing lines to this contributor. (role: recent setup and Gateway contributor; confidence: high; commits: 17baa65d0264, 992948356f23, 682ddcb28cbe; files: src/commands/configure.wizard.ts, src/wizard/setup.finalize.ts, src/system-agent/setup-apply.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-27T04:57:25.439Z sha 8436905 :: found issues before merge. :: [P2] Use daemon-install readiness timing for the final probe
  • reviewed 2026-08-27T05:26:18.882Z sha 8436905 :: found issues before merge. :: [P2] Pass managed-daemon readiness timing to the final probe

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 27, 2026
@steipete
steipete force-pushed the codex/configure-gateway-readiness branch from 8436905 to 17baa65 Compare August 27, 2026 06:35
@steipete steipete changed the title fix: wait for Gateway startup after configure daemon setup fix: share managed Gateway startup readiness across setup Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Ready for native preparation at 17baa65d026458e2dc4b1c919fd733aa6b6f1871.

Addressed the timing finding and all rank-up moves: one shared managed-startup policy now covers configure, classic onboarding, conversational setup, and non-interactive onboarding. Configure's explicit health check also receives the preceding daemon outcome, so daemon→health cannot fail prematurely before a successful final summary. Health→daemon, standalone/remote health, reused services, auth-warning skips, and separate health-RPC timing retain their contracts. Production is net -5 lines.

Before/after regression proof: 17 shared-timing failures and 3 additional daemon→health failures reproduced before their repairs. Final 262 tests across 11 files pass, as do the full changed gate, CLI startup build/48 postbuild module checks, docs MDX, fresh Codex autoreview, and independent full-severity review. Exact reproducible local commands and real before/after output are in the PR body.

Final real macOS proof used a new isolated token-authenticated profile: fresh Install and Reinstall followed by explicit health both reported reachable and completed health; Reinstall changed the service process, while Skip preserved it. Independent health JSON returned ok: true. The test service, listener, and plist were verified removed afterward. Native Windows live execution remains unrun; its timing is covered at the caller boundaries.

CI 33046429882 is completed/success on this exact head. After refreshing onto the substantive #130710 repair, build-artifacts measured 341185 bytes startup gzip in 8 requests, below the unchanged 343442-byte ceiling. No retry, budget increase, or failed-gate bypass was used for this head.

@steipete
steipete merged commit 2fd16c2 into main Aug 27, 2026
213 checks passed
@steipete
steipete deleted the codex/configure-gateway-readiness branch August 27, 2026 07:11
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…30682)

* fix: wait for Gateway startup after configure daemon setup

* fix: share managed Gateway startup timing across setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

configure reports Gateway not detected while reinstalled service starts

1 participant