Skip to content

fix(macos): isolate profiles and report direct Gateway failures - #127007

Merged
steipete merged 5 commits into
mainfrom
codex/mac-profile-remote-onboarding-fixes-20260820
Aug 21, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/mac-profile-remote-onboarding-fixes-20260820

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Keep named macOS app profiles inside their own managed state tree unless the operator explicitly selects a development checkout. Previously, a fresh isolated remote profile without a CLI silently discovered the default development checkout and spawned its source worker, rebuilding unrelated user files.
  • Format direct remote Gateway failures from the actual selected endpoint instead of an unrelated local port and SSH-tunnel advice. Preserve SSH/local guidance, bracket IPv6 endpoints, apply the correct default TLS port, and never expose URL userinfo or query credentials.
  • Keep recovery logs transport-neutral and cover the shared profile, command-resolution, Gateway, node-worker, remote-probe, and onboarding owner boundaries.

Root cause

CommandResolver.projectRoot inherited the default development-checkout fallback before named app profiles existed. ControlChannel.friendlyGatewayMessage likewise assumed every remote route was an SSH tunnel and repeatedly reconstructed its target from the profile's local Gateway port. Both assumptions became invalid when isolated profiles and direct ws/wss remote transport were introduced.

The fixes repair the canonical project-root and error-formatting owners. The normal default-profile checkout and explicitly selected per-profile checkout remain available. Direct endpoint display is built only from the parsed host and effective port; SSH and local routes retain their existing recovery guidance.

Verification

  • Profile regression failed before the fix because the isolated profile resolved Projects/openclaw instead of .openclaw-isolated; the default profile and explicit override remain covered.
  • Direct-route owner regressions initially recorded nine failures for the wrong endpoint, false SSH remediation, default TLS port, and malformed handshake. Independent review found an additional IPv6-bracketing failure, which was reproduced first and repaired using the existing Dashboard endpoint convention.
  • xcrun swift test --package-path apps/macos --scratch-path <isolated-cache> --skip-update --disable-automatic-resolution --manifest-cache none --disable-build-manifest-caching --filter 'ControlChannelGatewayMessageTests|ControlChannelStateDebouncerTests|CommandResolverTests|AppProfileTests|GatewayEnvironmentTests|GatewayEndpointStoreTests|RemoteGatewayProbeTests|MacNodeHostWorkerTests|OnboardingViewSmokeTests': 172 tests across 9 suites passed.
  • Real macOS app compiled, signed with the matching Developer ID, and verified with codesign --verify --deep --strict; fresh isolated background profile launched with no CLI, no checkout override, and privileged bridges disabled.
  • Signed-app runtime showed mac node gateway connect failed: OpenClaw Gateway is not installed yet. without starting a source worker or changing the existing checkout.
  • Signed-app direct-connection failure rendered Cannot reach gateway at 127.0.0.1:42675; check the Gateway URL and remote gateway. and logged control channel recovery ensured remote endpoint port=42675; the running operator app and Gateway were unchanged.
  • Independent Codex review: clean, with no accepted or actionable findings. SwiftFormat and git diff --check: clean.

Production delta: +49/-30 (net +19); tests: +158/-3. The additional production lines establish the profile ownership boundary and credential-safe transport-aware endpoint reporting across all existing error callers.

@clawsweeper

clawsweeper Bot commented Aug 21, 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: M maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 21, 2026, 1:00 AM ET / 05:00 UTC.

ClawSweeper review

What this changes

The PR prevents named macOS profiles from inheriting a development checkout and changes Gateway failure messages to identify direct remote endpoints safely.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this maintainer PR open: it fixes real profile and direct-Gateway failures, but its new error path synchronously rereads config after a connection failure, so it can report a newly edited endpoint rather than the endpoint that failed and can block the main actor on file I/O.

Priority: P2
Reviewed head: aaa2b01931e11068c2b93699a9b8e26aad17c258

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The native-runtime proof and regression coverage are meaningful, but a concrete route-consistency and main-actor I/O defect remains in the changed recovery path.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.
Evidence reviewed 6 items Changed failure path: Each changed catch path reloads the config before formatting a failure, rather than using the connection route that just failed.
Synchronous config read: The configuration loader takes a file lock and reads the config file with Data(contentsOf:), making the new main-actor error-path reread observable I/O.
Route ownership invariant: GatewayEndpointStore captures routing facts before config reads and tests cancellation when a route generation is superseded; this demonstrates why post-failure reconstruction can disagree with the attempted route.
Findings 1 actionable finding [P2] Carry the attempted endpoint into failure formatting
Security None None.

Live Verification

Command: xcrun swift test --package-path apps/macos --filter ControlChannelGatewayMessageTests

Result: FAIL (partial) — step 2 expect_output passed: expected terminal output was not visible within 30 seconds: "passed"

xcrun swift test --package-path apps/macos --filter ControlChannelGatewayMessageTests
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127007-FcbaBL/target$ xcrun swift test --package-path apps/macos --filter ControlChannelGatewayMessageTests
Command 'xcrun' not found, did you mean:
  command 'crun' from deb crun (1.12-1)
  command 'scrun' from deb slurm-client (23.02.6-1ubuntu2)
Try: apt install ‹deb name›
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127007-FcbaBL/target$ xcrun swift test --package-path apps/macos --filter ControlChannelGatewayMessageTests
Command 'xcrun' not found, did you mean:
  command 'crun' from deb crun (1.12-1)
  command 'scrun' from deb slurm-client (23.02.6-1ubuntu2)
Try: apt install ‹deb name›
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127007-FcbaBL/target$







































Assertions:

  • FAIL expect_output: passed

How this fits together

The macOS app selects a project root before it can launch local worker processes, and ControlChannel reports Gateway connection failures to the app UI. Profile state and Gateway routing feed those owners, which determine worker startup and recovery guidance.

flowchart LR
A[Profile selection] --> B[Project-root resolver]
B --> C[Local worker launch]
D[Gateway route snapshot] --> E[Gateway connection]
E --> F[Failure formatter]
F --> G[Recovery message]
Loading

Before merge

  • Carry the attempted endpoint into failure formatting (P2) - The changed catches reread openclaw.json after the Gateway operation has failed. That can block the @MainActor UI path and, more importantly, can format a newly saved direct URL even though the failed socket was created from the previous route snapshot. Pass the endpoint/route that the operation used into this formatter instead; the endpoint store already treats a routing-generation change as a reason to reject stale work.
  • Resolve merge risk (P1) - The new main-actor config reread can block recovery handling and, if routing changes while a request is in flight, display the new configured endpoint instead of the endpoint that actually failed.
  • Complete next step (P2) - A narrow mechanical repair can preserve the PR's owner-level fixes while removing the stale-route and main-actor I/O failure path.

Findings

  • [P2] Carry the attempted endpoint into failure formatting — apps/macos/Sources/OpenClaw/ControlChannel.swift:217
Agent review details

Security

None.

PR surface

Other +174. Total +174 across 4 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 4 207 33 +174
Total 4 207 33 +174

Review metrics

Metric Value Why it matters
Production versus test delta production +49/-30 (net +19), tests +158/-3 The positive production growth is mostly owner-boundary and formatting logic, but the new catch-path I/O should be removed rather than retained.

Merge-risk options

Maintainer options:

  1. Format from the captured route (recommended)
    Pass the selected endpoint or route snapshot into the formatter and add a route-change regression test before merging.
  2. Accept stale recovery text
    Merge knowing that a simultaneous Gateway route change can make a failure message point at the wrong endpoint and can synchronously read config on the UI actor.

Technical review

Best possible solution:

Carry the route or endpoint snapshot used by the failed connection into error formatting, and remove the catch-path config-file reread so recovery text stays route-consistent and non-blocking.

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

Yes in source: trigger a Gateway failure while the configured route changes; the request uses an endpoint snapshot, but the changed catch path rereads the current config and formats that later state.

Is this the best way to solve the issue?

No: repairing the two stated owners is right, but formatting must receive the attempted endpoint rather than reconstructing it from a post-failure config read.

Full review comments:

  • [P2] Carry the attempted endpoint into failure formatting — apps/macos/Sources/OpenClaw/ControlChannel.swift:217
    The changed catches reread openclaw.json after the Gateway operation has failed. That can block the @MainActor UI path and, more importantly, can format a newly saved direct URL even though the failed socket was created from the previous route snapshot. Pass the endpoint/route that the operation used into this formatter instead; the endpoint store already treats a routing-generation change as a reason to reject stale work.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The PR repairs bounded macOS startup and recovery behavior, but the remaining defect affects operator-facing failure handling rather than core runtime availability.
  • add merge-risk: 🚨 availability: The changed error path performs synchronous configuration file I/O on the main actor whenever Gateway operations fail.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.

Label justifications:

  • P2: The PR repairs bounded macOS startup and recovery behavior, but the remaining defect affects operator-facing failure handling rather than core runtime availability.
  • merge-risk: 🚨 availability: The changed error path performs synchronous configuration file I/O on the main actor whenever Gateway operations fail.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (logs): The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix signed-app runtime output for both isolated-profile startup and direct Gateway failure text, alongside focused Swift regression coverage.

Evidence

Acceptance criteria:

  • [P1] xcrun swift test --package-path apps/macos --filter 'ControlChannelGatewayMessageTests|GatewayEndpointStoreTests|CommandResolverTests'.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: The named-profile feature, subsequent profile follow-up, and this PR's macOS routing repairs are all authored by steipete/Peter Steinberger in local history. (role: feature owner and recent area contributor; confidence: high; commits: 0dbdf994b38e, 87bb2e5af0cf, aaa2b01931e1; files: apps/macos/Sources/OpenClaw/AppProfile.swift, apps/macos/Sources/OpenClaw/CommandResolver.swift, apps/macos/Sources/OpenClaw/ControlChannel.swift)
  • haruai: Local history shows haruai authored the recent macOS remote-URL validation alignment that shares GatewayRemoteConfig behavior. (role: adjacent remote-routing contributor; confidence: medium; commits: b168e4b5ed59; files: apps/macos/Sources/OpenClaw/GatewayRemoteConfig.swift)

Rank-up moves

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

  • Pass the attempted route or endpoint snapshot to the failure formatter and remove its config reread.
  • Add a focused route-change regression proving a failed old endpoint cannot be reported as a newly saved endpoint.
  • Rerun the signed-app direct-connection failure proof with redacted output after the repair.

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 df8fedc into main Aug 21, 2026
69 checks passed
@steipete
steipete deleted the codex/mac-profile-remote-onboarding-fixes-20260820 branch August 21, 2026 05:08
@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 22, 2026
…claw#127007)

* fix(macos): isolate named-profile development project roots

* fix(macos): report actual direct gateway connection failures

* fix(macos): satisfy SwiftLint remote recovery line limit

* fix(macos): sync native IPv6 endpoint localization inventory

* fix(macos): keep IPv6 endpoint formatting out of localization inventory
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. 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. 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.

1 participant