Repository navigation
fix: share managed Gateway startup readiness across setup - #130682
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 2:43 AM ET / 06:43 UTC. ClawSweeper reviewWhat this changesThe PR centralizes managed Gateway startup timing and applies it after successful local setup actions across Configure and onboarding flows. Merge readinessNo 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 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherConfigure 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -16, Tests +180, Docs +1. Total +165 across 13 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
8436905 to
17baa65
Compare
|
Ready for native preparation at 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 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. |
|
Merged via squash.
|
…30682) * fix: wait for Gateway startup after configure daemon setup * fix: share managed Gateway startup timing across setup
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:
After rebuilding the initial configure repair and repeating the same real flow:
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 healthcompleted authenticated health and reportedGateway: reachablefollowed byHealth check completed.Reinstall replaced the actual service process. A daemon-only Skip reportedDaemon setup skipped.and preserved the same running process. A separatehealth --jsonreturnedok: 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.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):
AI-assisted with Codex. No transcript included.