Skip to content

fix(macos): preserve externally owned Gateways in attach-only mode - #128134

Merged
steipete merged 1 commit into
mainfrom
codex/mac-attach-only-launchagent-ownership-20260822
Aug 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/mac-attach-only-launchagent-ownership-20260822

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators running the macOS app in documented attach-only mode could have their externally owned Gateway uninstalled when the app paused, stopped, or switched connection modes.

Why This Change Was Made

The launch-agent lifecycle owner honored the persistent attach-only marker for installation and restart, but accidentally allowed its destructive uninstall branch through. Apply the existing ownership fence to every launch-agent mutation so an external Gateway remains outside the app's lifecycle authority.

User Impact

Attach-only mode now preserves externally managed Gateways across app shutdown, pauses, and local-to-remote transitions. Regular app-managed Gateway installation, removal, restart, and profile ownership continue to behave as before.

Evidence

  • Existing native owner-boundary regression extended to exercise install, uninstall, and restart with the attach-only marker enabled.
  • Before the fix, the real lifecycle owner issued the forbidden intercepted command [["uninstall"]] and the regression failed.
  • After the fix, 60 tests across GatewayLaunchAgentManagerTests, GatewayProcessManagerTests, and GatewayAutostartPolicyTests pass, including remote-mode removal for normally managed Gateways.
  • Production change: +2/-2 lines; regression coverage: +10 lines; no new configuration, compatibility path, dependency, or test-only seam.
  • Independent Codex review reported no actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 23, 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 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 3:44 AM ET / 07:44 UTC.

ClawSweeper review

What this changes

The PR makes macOS attach-only mode suppress launch-agent installation and removal so an externally managed local Gateway remains outside app lifecycle control.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

The patch is the correct owner-boundary repair: current main still lets attach-only shutdown reach launchd uninstall, while the branch prevents every mutation. It remains open for maintainer proof judgment because it is maintainer-labeled and the supplied evidence lacks an after-fix real macOS launchd trace.

Priority: P2
Reviewed head: effa54bc5f1f60c8cd904d08c807fa5bd86d3af1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is a clean, covered owner-boundary repair, but real launchd preservation remains unobserved.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its final-command interception test is strong regression evidence, while a real macOS launchd trace remains the recommended rank-up proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its final-command interception test is strong regression evidence, while a real macOS launchd trace remains the recommended rank-up proof.
Evidence reviewed 6 items Current-main defect: Current main applies the disable marker only when enabling; the false branch then issues uninstall, so attach-only shutdown can mutate an externally owned Gateway.
Lifecycle caller: GatewayProcessManager.stop invokes the false branch after lifecycle shutdown, establishing the concrete route to uninstall.
Repair and regression coverage: The branch makes the marker guard unconditional and extends the owner-boundary regression to install, uninstall, and restart, asserting no daemon command is emitted.
Findings None None.
Security None None.

Live Verification

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

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

swift test --package-path apps/macos --filter GatewayLaunchAgentManagerTests
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128134-o2yL6e/target$ swift test --package-path apps/macos --filter GatewayLaunchAgentManagerTests
swift test --package-path apps/macos --filter GatewayLaunchAgentManagerTests
















































Assertions:

  • FAIL expect_output: Test run with

How this fits together

The macOS app maps startup, pause, shutdown, and connection-mode changes to launchd Gateway commands. Attach-only mode records that the Gateway is externally owned, so the launch-agent manager must avoid install, uninstall, and restart mutations.

flowchart LR
A[Mac app lifecycle] --> B[Launch-agent manager]
C[Attach-only ownership marker] --> B
B --> D{App owns Gateway?}
D -->|yes| E[Install remove restart]
D -->|no| F[Skip launchd mutation]
E --> G[Local Gateway service]
Loading

Decision needed

Question Recommendation
Should merge require an after-fix macOS launchd preservation trace, or is the final-command interception regression sufficient for this attach-only ownership repair? Capture a real launchd trace: Run the app in attach-only mode against an externally installed Gateway and show that shutdown or remote transition leaves its launch agent intact.

Why: The patch is source-correct, but repository policy treats native user-visible lifecycle proof as the stronger pre-merge evidence and the persistent marker changes removal semantics.

Before merge

  • Resolve merge risk (P1) - The persistent attach-only marker previously skipped installation but now also preserves an existing launch agent on removal; that documented ownership semantic should be confirmed against upgrade expectations.
  • Resolve merge risk (P1) - The supplied regression intercepts the final daemon-command owner but does not show an after-fix macOS launchd trace preserving an actual externally managed Gateway.
  • Complete next step (P2) - Maintainer proof-sufficiency judgment is required before merge because this maintainer-labeled PR changes persistent attach-only removal behavior.
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 12 2 +10
Total 2 12 2 +10

Review metrics

Metric Value Why it matters
Production versus regression coverage production +2/-2 (net 0), tests +10 The repair is net-neutral production code and adds focused coverage for the previously unguarded uninstall path.
Persistent ownership behavior 1 existing marker changed from install-only to all launch-agent mutations Existing attach-only users will retain their launch agent on removal as well as installation.

Merge-risk options

Maintainer options:

  1. Prove attach-only upgrade semantics (recommended)
    Capture the real launchd preservation trace before merge so the persistent marker's expanded no-removal meaning is demonstrated.
  2. Accept the documented ownership change
    Maintain the merge with the explicit decision that attach-only means the app never mutates that launch agent, including on shutdown.

Technical review

Best possible solution:

Land the manager-level fence after a real macOS attach-only trace confirms shutdown or remote transition leaves the external launch agent intact while unmarked remote cleanup still removes an app-managed agent.

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

Yes—current main's marker guard excludes only enabled calls, and shutdown calls the false branch that reaches uninstall; the branch regression would fail before the guard becomes unconditional.

Is this the best way to solve the issue?

Yes—the launch-agent manager owns every relevant mutation, and the existing remote-mode test confirms the repair does not suppress normal app-managed cleanup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 87d49a3dcaf0.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The existing persistent attach-only marker gains no-removal behavior, changing lifecycle semantics for users who already rely on it.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This fixes a bounded macOS Gateway lifecycle bug for attach-only operators.
  • merge-risk: 🚨 compatibility: The existing persistent attach-only marker gains no-removal behavior, changing lifecycle semantics for users who already rely on it.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is maintainer-authored, so the external-contributor proof gate does not apply; its final-command interception test is strong regression evidence, while a real macOS launchd trace remains the recommended rank-up proof.

Evidence

What I checked:

Likely related people:

  • steipete: History ties the original attach-only lifecycle work to this author, and the current repair is from the same area owner. (role: introduced lifecycle behavior and authored repair; confidence: high; commits: a3c007fb45d3, effa54bc5f1f; files: apps/macos/Sources/OpenClaw/GatewayLaunchAgentManager.swift, apps/macos/Sources/OpenClaw/GatewayProcessManager.swift)

Rank-up moves

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

  • Capture a redacted macOS trace showing attach-only shutdown or remote transition leaves an external launch agent installed.
  • Rebase or refresh exact-head validation before merge because GitHub reports the branch behind main.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-23T07:01:08.266Z sha effa54b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T07:21:00.449Z sha effa54b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 23, 2026
@steipete
steipete merged commit 3cb52f4 into main Aug 23, 2026
76 checks passed
@steipete
steipete deleted the codex/mac-attach-only-launchagent-ownership-20260822 branch August 23, 2026 09:00
@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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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