Skip to content

fix(daemon): skip unreadable foreign LaunchDaemon plists in ownership scan - #120481

Merged
steipete merged 4 commits into
mainfrom
steipete/dreamy-swanson-f278fd
Aug 8, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/dreamy-swanson-f278fd

Conversation

@steipete

@steipete steipete commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Ownership verification in src/daemon/launchd-system.ts failed closed on any unreadable plist in /Library/LaunchDaemons (observed: /Library/LaunchDaemons/com.nordvpn.macos.helper.plist, EACCES). That aborted the whole scan and caused writeLaunchAgentPlist / installLaunchAgent to throw SystemLaunchDaemonOwnershipError, breaking all 6 launchd.integration.e2e tests on affected development Macs and real openclaw gateway install/repair on end-user machines with third-party VPN or security software.

The root cause was that readLaunchDaemonPlistLabel fell back to fs.access(..., F_OK)—existence only—after plutil failed, so unreadable files were classified as unverifiable. The rendered shell probe in renderSystemLaunchDaemonOwnershipShellProbe had the symmetric bug. This behavior was introduced in #97285.

Why This Change Was Made

An unreadable plist cannot be actionably ours; a loaded same-label daemon is still caught by the launchctl print system/<label> probes bracketing the filesystem scan. The Node path now checks R_OK, returns a distinct unreadable status, and skips that status in findInstalledSystemLaunchDaemon. The rendered shell probe likewise skips [ ! -r ] entries. Malformed-readable plists and other filesystem errors still fail closed.

The sibling ownership check in inspect.ts already skips unreadable files through readUtf8File. launchd-restart-handoff.ts embeds the canonical renderer, so there is no duplicate implementation to update.

User Impact

Gateway service install and repair no longer hard-fail on Macs with locked-down third-party LaunchDaemon plists. Loaded, installed, and malformed-readable conflicts retain their existing behavior.

Evidence

Regression coverage verifies that an unreadable foreign plist resolves to absent without throwing, while an unreadable foreign plist followed by a readable same-label plist still reports the installed conflict. The rendered-probe harness also runs a real chmod 000 fixture under sh.

  • node scripts/run-vitest.mjs src/daemon/launchd-system.test.ts — 15/15 passed
  • launchd-system + launchd focused suite — 151/151 passed
  • pnpm plugin-sdk:api:gen — regenerated docs/.generated/plugin-sdk-api-baseline.sha256 after culprit 267268f646c (+1/-1)
  • pnpm plugin-sdk:surface:check — passed
  • node scripts/run-vitest.mjs src/commands/doctor-config-flow.gateway-bind-persistence.test.ts — 2/2 passed; Vitest 5.42s, wall 11.40s after scoping the localhost case to the canonical migration/writer seam introduced by culprit 267268f646c
  • git diff --check — clean
  • autoreview (Codex gpt-5.6-sol, high) — clean
  • Production LOC: +16/-1 (net +15); tests: +53/-36 (net +17); generated baseline: +1/-1

Accepted tradeoff: unreadable plists are treated as foreign. Loaded same-label daemons are caught by the bracketing launchctl print probes; an unloaded unreadable same-label plist is an accepted operator-created edge, consistent with #119091's precedent of skipping plists that cannot be shown to own the label.

@steipete
steipete marked this pull request as ready for review August 8, 2026 05:17
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

CI blocker evidence for exact head faa612cb0ce3a3b21a6ae8271bd1a5be13fcfc29:

The patch remains unchanged. openclaw/ci-gate is red solely because of those current-main failures, so native prepare/merge cannot proceed until the base failures are repaired.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR changes macOS gateway ownership scans to skip unreadable foreign LaunchDaemon plist files while continuing to reject loaded or readable same-label system daemons.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary and is correct under the recorded maintainer ruling: it removes a real macOS gateway install/repair blocker while deliberately accepting the narrow unloaded unreadable same-label daemon edge. No actionable review finding remains.

Priority: P1
Reviewed head: 6078d092515bb69117370b4e5a5087c4a211713f

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, policy-documented repair with exact-head regression coverage and no remaining actionable correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; focused ownership tests, a chmod-000 rendered-probe fixture, and successful exact-head CI provide supplemental evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; focused ownership tests, a chmod-000 rendered-probe fixture, and successful exact-head CI provide supplemental evidence.
Evidence reviewed 5 items Current ownership boundary: Current main treats a plist that cannot be parsed but still exists as unverifiable, so the reported EACCES condition blocks lifecycle operations today; the PR changes that narrow classification after an R_OK check.
Exact-head canonical implementation: The PR returns unreadable only for EACCES or EPERM after plutil fails, skips only that result, and retains fail-closed handling for malformed and other unverifiable files; the renderer shares the same policy with detached restart paths.
Regression coverage: Exact-head tests cover an unreadable foreign plist resolving absent, a later readable same-label plist still producing a conflict, and the rendered shell probe against a chmod-000 fixture.
Findings None None.
Security None None.

How this fits together

Before OpenClaw installs or repairs its user LaunchAgent, it checks whether a system LaunchDaemon already owns the gateway. The scan’s decision either permits the user service lifecycle or prevents two gateway managers from running together.

flowchart LR
A[Gateway install or repair] --> B[System daemon ownership scan]
B --> C[Loaded daemon probe]
C --> D[Readable plist scan]
D --> E{Ownership result}
E -->|No conflict| F[Write or restart user LaunchAgent]
E -->|Same-label conflict| G[Refuse duplicate manager]
Loading

Before merge

  • Resolve merge risk (P1) - Merging intentionally permits an unloaded unreadable same-label system daemon to be missed; the recorded maintainer ruling accepts this operator-created edge while loaded same-label daemons remain caught by the bracketing launchctl probes.
  • Complete next step (P2) - No mechanical repair remains; this protected maintainer PR should proceed through normal exact-head maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +15, Tests +17, Generated 0. Total +32 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 1 +15
Tests 2 53 36 +17
Docs 0 0 0 0
Config 0 0 0 0
Generated 1 1 1 0
Other 0 0 0 0
Total 4 70 38 +32

Review metrics

Metric Value Why it matters
Production versus test delta production +16/-1; tests +53/-36; generated baseline +1/-1 The production growth implements one explicit ownership classification and its mirrored shell policy; focused tests cover both direct and rendered paths.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-config-flow.gateway-bind-persistence.test.ts, unknown-data-model-change: src/commands/doctor-config-flow.gateway-bind-persistence.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #120481
Summary: This PR is the canonical current repair for unreadable foreign plist handling in the system-daemon ownership scan.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented ownership tradeoff (recommended)
    Merge the exact head with the explicit policy that unreadable foreign plists are skipped while loaded and readable same-label conflicts still refuse activation.
  2. Restore fail-closed scanning
    Do not merge if maintainers withdraw the ruling and require unreadable installed plists to remain ownership conflicts.

Technical review

Best possible solution:

Land the focused canonical Node-and-shell ownership change with the documented accepted tradeoff, preserving the existing loaded and readable same-label conflict protections.

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

Yes, source reproducible: current main converts a plutil failure plus an existing unreadable plist into an ownership failure, while the exact-head tests exercise the new EACCES and chmod-000 paths.

Is this the best way to solve the issue?

Yes: under the explicit maintainer ruling, updating the canonical classifier and its shared shell renderer is the narrowest maintainable fix; a separate fallback or lifecycle-specific exemption would duplicate policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The patch repairs gateway install and recovery failures on macOS systems containing unreadable third-party LaunchDaemon plists.
  • merge-risk: 🚨 compatibility: It deliberately changes how an existing system LaunchDaemon configuration is classified during gateway repair and install.
  • merge-risk: 🚨 availability: An incorrect ownership classification can either block recovery or allow competing gateway managers.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; focused ownership tests, a chmod-000 rendered-probe fixture, and successful exact-head CI provide supplemental evidence.

Evidence

What I checked:

  • Current ownership boundary: Current main treats a plist that cannot be parsed but still exists as unverifiable, so the reported EACCES condition blocks lifecycle operations today; the PR changes that narrow classification after an R_OK check. (src/daemon/launchd-system.ts:121, bf0aadbc40c2)
  • Exact-head canonical implementation: The PR returns unreadable only for EACCES or EPERM after plutil fails, skips only that result, and retains fail-closed handling for malformed and other unverifiable files; the renderer shares the same policy with detached restart paths. (src/daemon/launchd-system.ts:147, 6078d092515b)
  • Regression coverage: Exact-head tests cover an unreadable foreign plist resolving absent, a later readable same-label plist still producing a conflict, and the rendered shell probe against a chmod-000 fixture. (src/daemon/launchd-system.test.ts:276, 6078d092515b)
  • Prior policy and maintainer decision: The earlier duplicate-manager guard explicitly chose fail-closed unreadable scans; the PR discussion now records the maintainer decision to accept the unloaded unreadable same-label edge rather than restore that behavior. (src/daemon/launchd-system.ts:74, 895b691c55cf)
  • Release and current-main status: Neither the earlier ownership guard nor its unlabeled-plist follow-up is contained by the latest release tag; current main also lacks this PR’s unreadable classification, so this branch is not obsolete. (src/daemon/launchd-system.ts:121, 0790d9f593ad)

Likely related people:

  • steipete: Authored the exact-head repair and recorded the maintainer-approved ownership tradeoff; also has substantial recent daemon-area history. (role: recent area contributor and decision owner; confidence: high; commits: de58251b7822, 6078d092515b; files: src/daemon/launchd-system.ts, src/daemon/launchd-system.test.ts)
  • harjothkhara: Authored the merged duplicate-manager guard whose unreadable-plist policy this PR revises. (role: original ownership-guard contributor; confidence: medium; commits: 895b691c55cf; files: src/daemon/launchd-system.ts, src/daemon/launchd.ts)
  • fuller-stack-dev: Authored the merged readable-unlabeled plist refinement in the same ownership classifier. (role: adjacent classifier contributor; confidence: medium; commits: ae21f3c00c78; files: src/daemon/launchd-system.ts, src/daemon/inspect.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-08T05:43:36.705Z sha faa612c :: found issues before merge. :: [P1] Do not treat an unreadable plist as foreign | [P1] Keep the detached restart probe fail-closed

… scan

inspectSystemLaunchDaemonOwnership raised SystemLaunchDaemonOwnershipError when any /Library/LaunchDaemons plist was unreadable, such as third-party VPN helper plists with mode 600. This broke gateway install/repair and launchd.integration.e2e on affected Macs. Unreadable plists are foreign by contract, while loaded same-label daemons remain caught by the bracketing launchctl probes.
@steipete
steipete force-pushed the steipete/dreamy-swanson-f278fd branch from faa612c to 6078d09 Compare August 8, 2026 06:02
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations labels Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer ruling for #120481: the unreadable-plist skip is the intended product behavior. Loaded same-label daemons are caught by the bracketing launchctl print probes; OpenClaw never creates system LaunchDaemons, so an installed-but-unloaded unreadable same-label plist requires deliberate third-party/root action and is an accepted operator-created edge.

The PR body’s Evidence section and both Node/shell skip-site comments now record this accepted tradeoff, following #119091’s precedent of skipping plists that cannot be shown to own the label. Accordingly, the findings and Before-merge moves requesting fail-closed restoration, privileged inspection, or an operator override are intentionally declined under the frozen maintainer decision; no other actionable move remains from this review.

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review exact head 6078d092515bb69117370b4e5a5087c4a211713f with the maintainer ruling and Accepted tradeoff recorded above and in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 8, 2026
@steipete
steipete merged commit fb61ae1 into main Aug 8, 2026
136 checks passed
@steipete
steipete deleted the steipete/dreamy-swanson-f278fd branch August 8, 2026 07:49
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
… scan (openclaw#120481)

* fix(daemon): skip unreadable foreign LaunchDaemon plists in ownership scan

inspectSystemLaunchDaemonOwnership raised SystemLaunchDaemonOwnershipError when any /Library/LaunchDaemons plist was unreadable, such as third-party VPN helper plists with mode 600. This broke gateway install/repair and launchd.integration.e2e on affected Macs. Unreadable plists are foreign by contract, while loaded same-label daemons remain caught by the bracketing launchctl probes.

* fix(ci): regenerate plugin-sdk api baseline after b1707c1

* test(doctor): scope gateway-bind persistence test to its writer seam

Culprit: b1707c1.

* docs(daemon): document unreadable plist tradeoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime 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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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