Repository navigation
fix(onboarding): harden fresh local startup and activation - #108764
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d77816469a
ℹ️ 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".
f205202 to
22673c7
Compare
|
Codex review: found issues before merge. Reviewed July 16, 2026, 5:10 PM ET / 21:10 UTC. Summary PR surface: Source +2, Tests -3, Docs +1, Other +1285. Total +1285 across 8 files. Reproducibility: yes. at source and supplied-proof level: the PR documents pristine-machine baseline failures and successful after-fix macOS and Ubuntu runs, although this read-only review did not independently execute the current-main reproduction. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Preserve the serialized macOS startup work, but separate restart-required plugin-install adoption from the hot-reloadable model, agent, and plugin-entry publication—or explicitly complete and prove the restart before reporting activation success. Do we have a high-confidence way to reproduce the issue? Yes at source and supplied-proof level: the PR documents pristine-machine baseline failures and successful after-fix macOS and Ubuntu runs, although this read-only review did not independently execute the current-main reproduction. Is this the best way to solve the issue? No, not yet: the macOS process-owner design is a strong bounded fix, but using automatic publication for a transaction that may also adopt Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7496f4d988ab. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +2, Tests -3, Docs +1, Other +1285. Total +1285 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
22673c7 to
b7d6192
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29616d8801
ℹ️ 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".
| while let request = self.launchAgentEnablePendingRequest { | ||
| self.launchAgentEnablePendingRequest = nil | ||
| self.launchAgentEnableCurrentRequest = request | ||
| result = await self.performLaunchAgentEnable(request) |
There was a problem hiding this comment.
Return per-request results for queued enables
When a second enable request with a different port is queued while the first enableLaunchdGateway() is still waiting, the drain processes the newer request and then returns that final result to every waiter. The older caller then resumes with nil even though the service has just been reinstalled for the newer port, so it continues the readiness loop using its stale captured port and reports Gateway did not start in time while the newest service may be running correctly. The queued drain needs to tell stale callers they were superseded, or the caller needs to restart its readiness check with the latest request.
Useful? React with 👍 / 👎.
29616d8 to
a793d92
Compare
53400e3 to
1d4f3b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5af4d097db
ℹ️ 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".
|
|
||
| let attemptAttach = { | ||
| try await self.connection.requestRaw(method: .health, timeoutMs: 2000) | ||
| try await self.probeGatewayHealth(timeoutMs: 2000) |
There was a problem hiding this comment.
Route managed listener failures into repair path
When the listener already exists but the health probe times out or fails, this attach path still takes the hasListener failure branch and exits before enableLaunchdGateway can run. If that listener is the reusable launchd PID (running, matching port, clean audit) but its RPC is wedged, no launchAgentReadinessFailure is recorded; the parallel or next ensureLaunchAgentEnabledIfNeeded call sees the reusable PID and skips the install, so startup remains failed instead of repairing the managed service. This path needs to distinguish managed launchd listeners from foreign listeners and route the former through the readiness/repair flow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03c2c0d967
ℹ️ 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".
| return | ||
| } | ||
|
|
||
| let readinessPID = await GatewayLaunchAgentManager.reusableLoadedGatewayPID(port: port) |
There was a problem hiding this comment.
Record late-starting launchd PIDs before failing
When install returns before launchd reports a running PID, readinessPID is nil; if the service then starts during the 6s readiness loop but never answers health, finishLaunchAgentReadinessFailure drops the failure because startingPID is nil. On the next start, the same running service is treated as a fresh reusable PID and performLaunchAgentEnable skips the repair install, so users hit at least another full timeout instead of repairing the wedged fresh-start service. Re-sample the reusable PID at timeout when the initial sample was nil, or otherwise record the PID that survived the failed readiness loop.
Useful? React with 👍 / 👎.
03c2c0d to
9d9d431
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d9d431100
ℹ️ 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".
| afterWrite: { mode: "none", reason: "OpenClaw activates verified inference" }, | ||
| // Setup changes only hot-reloadable model, agent, and plugin-entry surfaces. | ||
| // Publish the verified route now so the next turn cannot reuse the old harness. | ||
| afterWrite: { mode: "auto" }, |
There was a problem hiding this comment.
Avoid auto-reloading plugin install adoption
When codex-cli activation has a pendingCodexInstall, this write also adopts plugins.installs.codex into the installed-plugin index via stageCandidate, not just the hot-reloadable model/agent/plugin-entry fields described here. The Gateway reload planner treats any plugin install record delta as restart-required (plugins.installs in src/gateway/config-reload-plan.ts), so { mode: "auto" } schedules a Gateway restart after the setup RPC drains on first Codex runtime install, even though activation later manually reloads the Codex registry and reports that no restart is needed. This only hits first-time install/adoption; keep that install-index delta out of the auto reload path or explicitly handle the restart outcome.
Useful? React with 👍 / 👎.
302543b to
b63ef54
Compare
|
Merged via squash.
|
…108764) * fix(macos): preserve gateway during fresh setup * fix(macos): validate reusable gateway service * chore(macos): sync native i18n inventory * fix(macos): preserve latest gateway service request * test(macos): isolate gateway port concurrency coverage * fix(macos): recover gateways after failed readiness * fix(macos): repair wedged gateway listeners * fix(macos): bound gateway startup probes * chore(macos): sync native i18n inventory * fix(onboarding): activate verified inference immediately * fix(macos): isolate readiness failure generations * chore(macos): refresh native i18n inventory * fix(macos): serialize gateway service lifecycle * fix(macos): sequence gateway startup persistence * fix(macos): close gateway readiness races * fix(macos): publish recovered gateway state * fix(macos): make gateway readiness generation-safe * chore(macos): refresh native i18n inventory * fix(macos): preserve gateway endpoint identity * fix(macos): refresh gateway ownership after attach * fix(macos): distinguish transient gateway readiness * refactor(macos): split gateway readiness lifecycle * chore(macos): refresh native i18n inventory * chore(release): keep changelog release-owned
…108764) * fix(macos): preserve gateway during fresh setup * fix(macos): validate reusable gateway service * chore(macos): sync native i18n inventory * fix(macos): preserve latest gateway service request * test(macos): isolate gateway port concurrency coverage * fix(macos): recover gateways after failed readiness * fix(macos): repair wedged gateway listeners * fix(macos): bound gateway startup probes * chore(macos): sync native i18n inventory * fix(onboarding): activate verified inference immediately * fix(macos): isolate readiness failure generations * chore(macos): refresh native i18n inventory * fix(macos): serialize gateway service lifecycle * fix(macos): sequence gateway startup persistence * fix(macos): close gateway readiness races * fix(macos): publish recovered gateway state * fix(macos): make gateway readiness generation-safe * chore(macos): refresh native i18n inventory * fix(macos): preserve gateway endpoint identity * fix(macos): refresh gateway ownership after attach * fix(macos): distinguish transient gateway readiness * refactor(macos): split gateway readiness lifecycle * chore(macos): refresh native i18n inventory * chore(release): keep changelog release-owned
What Problem This Solves
Fixes an issue where fresh local onboarding on macOS could finish detection but still leave the product unusable in two ways:
Why This Change Was Made
The macOS process owner now serializes and coalesces managed LaunchAgent lifecycle work while preserving a result for every caller. Startup, persistence, attach, stop, and repair paths are generation- and revision-gated. Listener ownership and endpoint identity are refreshed across PID handoff, and only endpoint-reachability evidence can authorize managed-service repair; responsive errors, transient
UNAVAILABLE, and cancellations cannot inherit stale repair authority.Inference activation now publishes its verified model, agent, and plugin-entry config through the normal hot-reload path. CLI and macOS continue to use the same TypeScript detection and activation owner.
User Impact
Fresh macOS onboarding reaches local model setup without an unbounded startup stall, competing service mutation, or destructive repair of a responsive/foreign listener. Once Ollama or another supported route passes verification, the immediate next agent turn uses that route without restarting the Gateway.
AI-assisted implementation and validation. I understand the changed Gateway lifecycle, inference publication, and tests.
Evidence
2c084b4001e0569dcf1fd893b9501202a3ebb864:GatewayProcessManagerTestspassed 36/36. Coverage includes per-invocation queue results, A/B/A ordering, stop/disable sequencing, startup/persistence generations, listener ownership, PID handoff and control-channel refresh, readiness revisions, transientUNAVAILABLE, independent cancellations, permanent rejection, endpoint-evidence repair classification, and bounded stalled-connect timeouts.setup-inference.test.tspassed 108/108. Full macOS SwiftLint (279 files), SwiftFormat lint, native i18n inventory check, andgit diff --checkpassed. Final whole-branch autoreview at exact head found no accepted or actionable findings.qwen3:0.6b, activated and verified it, hot-reloaded without changing the Gateway PID, and the immediate next agent session reported providerollama, modelqwen3:0.6b, and the OpenClaw harness instead of the prior Codex route.ollama/qwen3:0.6b, and used the no-fallback Ollama route: https://crabbox.openclaw.ai/portal/runs/run_a516bee0fc1a