Skip to content

fix(macos): fail promptly after terminal gateway startup errors - #126697

Merged
steipete merged 1 commit into
mainfrom
codex/mac-onboarding-terminal-failure
Aug 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/mac-onboarding-terminal-failure

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Prevent macOS onboarding and other local Gateway activation callers from stalling after startup has already reached a terminal failure with no process to recover.

GatewayProcessManager.waitForGatewayReady intentionally keeps probing after some owner failures because a launchd-managed process can become healthy after its initial readiness deadline. That recovery is correct when there is an installed LaunchAgent, a current-generation install, a pending readiness candidate, or a retained process-backed readiness failure. It is incorrect for terminal states such as attach-only/launchd-disabled startup, failed launchd installation, or configuration repair failure when no Gateway process exists. The CLI installer gives this readiness wait a 120-second migration budget, so first-run onboarding could keep spinning long after the actionable failure reason was known.

Teach the lifecycle owner to return immediately only when it is already failed and none of those recovery facts exists. Preserve the generation/cancellation guard and every legitimate delayed-start recovery path. Strengthen the existing owner regression to assert that a terminal failure does not create a Gateway WebSocket probe.

This is deliberately distinct from the healthy-Gateway reconciliation in #119850: this change handles only a terminal failure with no launched/recoverable process and does not change onboarding views or install-row ownership.

Validation

  • Demonstrated RED on the unmodified owner: the strengthened existing regression failed because session.snapshotMakeCount() was 1, proving an unnecessary Gateway probe after the terminal startup failure.
  • Demonstrated GREEN with the owner repair: all 43 GatewayProcessManagerTests passed, including delayed owner recovery, pending readiness candidates, retained process-backed failures, launchd installation/replacement, cancellation, and foreign-listener coverage. The terminal-failure regression completed in 0.001 seconds.
  • Ran 50 additional CLIInstallerTests and OnboardingViewSmokeTests successfully, including successful Gateway activation, failure-reason binding, local/remote first-run flow, and onboarding handoff.
  • Built a real native macOS app from the repaired source, signed and deeply verified it with the installed application's matching Developer ID, and launched a fresh isolated named profile with private state, a compatible CLI, a unique unused Gateway port, and --attach-only.
  • PID-scoped unified logs showed the real launchd-disabled owner failure at 07:53:51.321174, followed by downstream control-channel configuration at 07:53:51.325855: 4.681 ms from terminal failure to completion of the shared readiness wait. The test profile never started a Gateway; the original app and operator Gateway stayed untouched.
  • SwiftFormat lint passed for both changed files; independent structured autoreview reported no actionable findings.

Production LOC: +9/-0 (net +9); tests: +2/-1 (net +1). The production growth records the lifecycle-owner distinction between terminal no-process failure and four independent, existing sources of legitimate recovery evidence.

Release note: macOS onboarding now reports terminal local Gateway startup failures promptly instead of potentially waiting through the full startup migration timeout.

@clawsweeper

clawsweeper Bot commented Aug 20, 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 app: macos App: macos size: XS maintainer Maintainer-authored PR labels Aug 20, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 11:01 AM ET / 15:01 UTC.

ClawSweeper review

What this changes

The PR makes macOS Gateway activation return the recorded terminal startup failure instead of probing for up to the migration timeout when no recovery evidence exists.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. This is a focused, source-backed macOS lifecycle repair; no blocking correctness or security finding was identified, but the active maintainer-labeled PR should remain open through exact-head native validation.

Priority: P1
Reviewed head: 1cd9d909a0da009cba1c4b6044130874f08024ad

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with a credible regression test; exact-head native validation remains the material merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports an isolated signed-app run and PID-scoped logs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports an isolated signed-app run and PID-scoped logs.
Evidence reviewed 7 items Current-main behavior: The current-main version proceeds from the generation guard directly into the audit probe; it has no terminal-failure short circuit.
Owner-boundary repair: The branch returns only for failed status without a fresh install, readiness candidate, retained process-backed failure, or same-generation install evidence.
Caller and recovery sibling: CLI onboarding gives this wait the 120-second migration tolerance, while the connection-mode coordinator preserves an explicit post-install recovery path via launchAgentInstalled.
Findings None None.
Security None None.

Live Verification

Command: swift test --package-path apps/macos --filter GatewayProcessManagerTests

Result: FAIL (failed) — step 1 run swift test --package-path apps/macos --filter GatewayProcessManagerTests: terminal command did not produce output within 20 seconds: "swift test --package-path apps/macos --filter GatewayProcessManagerTests"

swift test --package-path apps/macos --filter GatewayProcessManagerTests
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126697-89NG28/target$ swift test --package-path apps/macos --filter GatewayProcessManagerTests
swift test --package-path apps/macos --filter GatewayProcessManagerTests
















































Assertions:

  • FAIL expect_output: Test run with

How this fits together

macOS onboarding and local-mode setup activate a launchd-managed local Gateway, then wait for readiness before continuing. The Gateway lifecycle owner records whether a launch attempt, candidate process, or retained failure can still recover and reports the resulting state to the installer and onboarding UI.

flowchart LR
A[Onboarding or local setup] --> B[Gateway lifecycle owner]
B --> C[Attach or launchd startup]
C --> D{Recovery evidence?}
D -->|Yes| E[Bounded readiness probe]
D -->|No, terminal failure| F[Return recorded failure]
E --> G[Ready or recorded timeout]
F --> H[Installer and onboarding outcome]
G --> H
Loading

Before merge

  • Resolve merge risk (P2) - This intentionally removes a fallback probe after failed startup; if a valid recovery state is not represented by the install, candidate, or retained-failure facts, an existing setup would fail promptly rather than wait for a late Gateway.
  • Complete next step (P2) - No repair dispatch is appropriate: this is an active maintainer-owned PR with no concrete automated repair finding.
Agent review details

Security

None.

PR surface

Other +10. Total +10 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 11 1 +10
Total 2 11 1 +10

Review metrics

Metric Value Why it matters
Production vs test LOC production +9/-0; tests +2/-1 The positive production delta is the explicit lifecycle-owner distinction between terminal failure and four existing recovery facts.
Recovery policy surface 1 readiness decision changed; 0 config options added The change alters startup fallback behavior without expanding the operator configuration surface.

Merge-risk options

Maintainer options:

  1. Complete exact-head macOS validation (recommended)
    Merge after the queued macOS native lane confirms terminal failures fail promptly while fresh installs, retained process failures, and readiness candidates still recover.

Technical review

Best possible solution:

Keep the lifecycle decision in GatewayProcessManager, retain the zero-probe regression, and merge only after exact-head macOS validation confirms all recoverable launch paths remain intact.

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

Yes, source reproducible: current main enters the audit probe after a failed owner state, and the focused fixture can observe that session creation; the read-only review did not execute the native test.

Is this the best way to solve the issue?

Yes. The lifecycle owner already holds the precise recovery facts, so deciding before the consumer-facing audit avoids masking a terminal failure in onboarding or the installer.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A first-run local Gateway failure can otherwise hold macOS onboarding through its 120-second readiness budget.
  • add merge-risk: 🚨 compatibility: Existing local setup flows change from a fallback readiness probe to an immediate recorded failure when no recovery evidence exists.
  • add merge-risk: 🚨 availability: An omitted recovery fact would make the app stop waiting for a Gateway that could otherwise become ready.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports an isolated signed-app run and PID-scoped logs.

Label justifications:

  • P1: A first-run local Gateway failure can otherwise hold macOS onboarding through its 120-second readiness budget.
  • merge-risk: 🚨 compatibility: Existing local setup flows change from a fallback readiness probe to an immediate recorded failure when no recovery evidence exists.
  • merge-risk: 🚨 availability: An omitted recovery fact would make the app stop waiting for a Gateway that could otherwise become ready.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports an isolated signed-app run and PID-scoped logs.

Evidence

What I checked:

Likely related people:

  • steipete: Repository state identifies this author as a member, and git blame attributes the exact lifecycle predicate and regression update to the PR head. (role: current lifecycle repair author and likely decision owner; confidence: medium; commits: 1cd9d909a0da; files: apps/macos/Sources/OpenClaw/GatewayProcessManager.swift, apps/macos/Tests/OpenClawIPCTests/GatewayProcessManagerTests.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the queued macOS native checks complete on the reviewed head.

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.

@steipete
steipete merged commit eb84b56 into main Aug 20, 2026
74 checks passed
@steipete
steipete deleted the codex/mac-onboarding-terminal-failure branch August 20, 2026 15:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos maintainer Maintainer-authored PR 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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