Repository navigation
fix(macos): remote-mode profile reports a Gateway uninstall failure when it has no local service - #164069
Conversation
Remote and unconfigured connection modes call GatewayProcessManager.stop() on every launch. With service hosting and no LaunchAgent plist for the current profile, stop() still dispatched `openclaw gateway uninstall`. The CLI target was profile-scoped, but the no-op uninstall still took the service-operation lock and read the shared install-scoped handoff lease store; a row it could not decode made the uninstall fail and marked the remote profile's Gateway as failed. GatewayLaunchAgentManager.set(enabled: false) now returns without dispatching when the captured custody has no plist for this profile. Stop/enable/disable logs name the profile and LaunchAgent label, the PeekabooBridge shared per-user socket refusal logs at info level, and PortGuardian names its host-global ledger and the blocking legacy app.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 2:08 AM ET / 06:08 UTC. ClawSweeper reviewWhat this changesThe macOS app skips Gateway uninstall when the current profile has no LaunchAgent plist, clarifies shared-resource diagnostics, and updates lifecycle regression tests. Merge readiness✅ Ready for maintainer review Keep open: current main still has the reported failure path, and this focused repair has no actionable correctness finding. The author’s verified repository-admin role also excludes automatic cleanup. Priority: P2 Review scores
Verification
How this fits togetherThe macOS app translates connection and hosting choices into local Gateway lifecycle operations. Its LaunchAgent manager dispatches profile-scoped CLI commands and reports their results back to the app. flowchart TD
A[Connection mode] --> B[Gateway lifecycle manager]
B --> C[Capture profile service files]
C --> D{LaunchAgent plist present?}
D -->|No| E[Remain stopped without uninstall]
D -->|Yes| F[Validate custody and dispatch uninstall]
F --> G[Publish stopped or failure status]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceOther +118. Total +118 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep service teardown conditional on current profile service custody while preserving installed-service pause/resume and shared-resource ownership checks. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that stopping a service-hosted profile without a plist still dispatches uninstall and publishes any CLI refusal as failure. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes, the guard belongs in the existing LaunchAgent owner and preserves validation and installed-service teardown without adding another lifecycle path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0c96fd043ab3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…penclaw#164069) Remote and unconfigured connection modes call GatewayProcessManager.stop() on every launch. With service hosting and no LaunchAgent plist for the current profile, stop() still dispatched `openclaw gateway uninstall`. The CLI target was profile-scoped, but the no-op uninstall still took the service-operation lock and read the shared install-scoped handoff lease store; a row it could not decode made the uninstall fail and marked the remote profile's Gateway as failed. GatewayLaunchAgentManager.set(enabled: false) now returns without dispatching when the captured custody has no plist for this profile. Stop/enable/disable logs name the profile and LaunchAgent label, the PeekabooBridge shared per-user socket refusal logs at info level, and PortGuardian names its host-global ledger and the blocking legacy app.
What Problem This Solves
Fixes: launching the macOS app in remote connection mode under a named profile runs
openclaw gateway uninstallfor a local service that profile never installed, and reports a Gateway failure when that no-op uninstall is refused.User Impact
User impact: a remote-mode (or unconfigured) profile with no local Gateway LaunchAgent no longer spawns service teardown on launch or shows a spurious "Gateway daemon command failed" status. Profiles that do own an installed LaunchAgent still have it paused/removed exactly as before. No config, migration, or user action.
Why This Change Was Made
Root cause
ConnectionModeCoordinator.applycallsGatewayProcessManager.stop()on every remote/unconfigured launch. With service hosting,stop()captures this profile's service authority; when~/Library/LaunchAgents/ai.openclaw.<profile>.plistdoes not exist,retainManagedServiceForResumereturns it unchanged, andGatewayLaunchAgentManager.set(enabled: false)still dispatchedopenclaw --profile <name> gateway uninstall --json. The CLI target itself was correctly profile-scoped (the app stripsOPENCLAW_LAUNCHD_LABELand pinsOPENCLAW_PROFILE), but with nothing to boot out it still took the service-operation lock and read the shared, install-scopedmanaged-update-handoffs.sqliteguard. A row there that this build cannot decode made the uninstall fail, andstop()then marked the remote profile's Gateway as failed.Audit of what each launch path touches under a named profile (2026-10-02 field logs):
[gateway.process] gateway stop requested→[gateway.launchd] launchd disable requested via CLIai.openclaw.<profile>LaunchAgent, its service-lifecycle lockGateway uninstall failed: existing managed handoff lease is incompatiblemanaged-update-handoffs.sqlite(read-only guard, keyed by install root)[PeekabooBridge] Failed to start PeekabooBridge host: ... already owned by another host~/Library/Application Support/OpenClaw/bridge.sock[portguard] PortGuardian persistence unavailable; orphan reap skipped~/Library/Application Support/OpenClaw/state/openclaw.sqlitetunnel ledgerThe global node service (
ai.openclaw.node) is already skipped under named profiles.Fix
GatewayLaunchAgentManager.set(enabled: false)returns without dispatching when the captured custody has no plist for this profile (after the existing currency, custody, and disable-marker checks).stop()is its only caller. The only state no longer booted out by stop is a loaded job whose plist was deleted out of band; the CLI's own install/uninstall never leaves that state.Evidence
AppStateIsolationTests/named remote profile stop leaves other profiles' Gateway services alone(runs in CI's named partition): remote config, a default-profile LaunchAgent present, every CLI command failing with the field error. Asserts no service command, status.stopped, no failure reason, default plist bytes unchanged.pause preserves unretainable services and distinguishes absencenow asserts nouninstallfor theabsentcase. Lifecycle tests that relied on uninstall-without-plist now write a managed LaunchAgent for the current profile, keeping their original assertions.scripts/macos-health-render.sb(no network, no reads of the real home, no writes outside a throwaway root and the per-user Darwin temp dir, cfprefsd/securityd denied):.failed, lease error as failure reason);absentcase fails; the 9 re-fixtured lifecycle tests pass.GatewayProcessManagerTestspass.swift build --package-path apps/macos --build-system native --build-testsand--product OpenClaw: pass.swiftlint --strict --config config/swiftlint.yml(sources): clean. Changed-fileswiftformat --lint --config config/swiftformat: 0/6.git diff --check: clean.macos-swiftCI job (default + named partitions).