Repository navigation
fix(mac): preserve LaunchAgent bytes and permissions on rollback - #152195
Conversation
Capture prior plist bytes and permission bits from one open descriptor and restore them before atomic rollback publication. Failed activation no longer re-encodes binary plists or widens private plist permissions. Adapt the read-only service audit caller and cover actual filesystem restoration, staged modes, and descriptor cleanup.
|
🦞👀 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 September 18, 2026, 8:39 PM ET / September 19, 2026, 00:39 UTC (Revision 2). ClawSweeper reviewWhat this changesPreserves the original macOS LaunchAgent service definition’s bytes and permission bits when replacement fails, with filesystem regression coverage and documentation. Merge readiness✅ Ready for maintainer review The fix remains necessary: current main still loses plist permissions and converts binary rollback contents to text. No introduced blocking defect was found, and the updated published-updater evidence addresses the previous review’s upgrade-proof request. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s macOS service installer publishes LaunchAgent files and asks launchd to activate the Gateway. Failed publication or activation restores the previous files and supervision state. flowchart TD
A[Gateway service installation] --> B[Capture existing bytes and permissions]
B --> C[Publish replacement files]
C --> D{Publication and activation succeed?}
D -->|Yes| E[Gateway service running]
D -->|No| F[Restore captured files]
F --> G[Restore prior supervision or report failure]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +21, Tests +204, Docs +1. Total +226 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep byte-preserving restoration in the existing publication owner, restoring captured plist permissions before publication while retaining normal installation defaults. Do we have a high-confidence way to reproduce the issue? Yes, from source: replacing a private or binary plist and then failing publication or activation reaches current-main rollback code that resets its mode or converts its bytes to UTF-8; this review did not execute that path. Is this the best way to solve the issue? Yes. Capturing bytes and permissions together and restoring them through the existing publisher is a narrow repair, and all production consumers of the changed snapshot shape were adapted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 732f5fe0a772. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '912b21b98581c0be3baad87fe3686b64d69fffeb': (191 commits) perf(process): reduce allocation while processing command output (#152261) fix(ui): collapse duplicate previews when a page opens in multiple tabs (#152281) fix(test): run local Gateway tests behind protected exec egress (#152318) fix(node-host): avoid blocking configuration reads (#151411) fix(qa-lab): prevent Evidence Archive filters from overflowing (#152123) test: stabilize Docker scheduler signal fixtures on macOS (#152301) fix(ui): close stuck submenus when moving between menu rows (#152317) fix(ui): preserve question drafts and pending submissions (#152096) fix(release): recognize 7.34 fs-safe contract (#152326) chore: retire CLAUDE.md files fix(ui): release queued input after completed chat runs (#152299) improve(tooling): reduce commit formatting resource use (#152297) feat: show mentioned sessions in Involving me (#152083) perf(tasks): reuse prepared audit summaries (#152294) fix(daemon): preserve LaunchAgent rollback bytes and modes (#152195) fix: stop chat layout changes from loading extra history (#151726) perf(gateway): streamline config reload comparison (#152279) fix(xai): reject invalid UTF-8 OAuth responses (#111737) fix(release): accept waived advisory performance evidence for stable publication (#152290) fix: deliver watcher results while other sessions are busy (#152287) ...
…152195) Capture prior plist bytes and permission bits from one open descriptor and restore them before atomic rollback publication. Failed activation no longer re-encodes binary plists or widens private plist permissions. Adapt the read-only service audit caller and cover actual filesystem restoration, staged modes, and descriptor cleanup.
Related: #150153
What Problem This Solves
A failed macOS LaunchAgent replacement can make the previous plist more readable or corrupt its binary contents during rollback.
User Impact
Rollback restores the previous plist's exact bytes and permission bits, preserving the service definition that existed before the failed replacement.
Why This Change Was Made
Capture contents and mode from one open file, then restore both through the existing publication transaction. Set the restored mode before renaming the file into place and retain binary data without text conversion. Normal new-install permissions stay unchanged.
Evidence
Real temporary-file regressions reproduce private
0600and0640plists becoming0644, plus binary contents changing during failed install rollback. All 212 focused tests pass after the fix, including exact bytes and modes before rename and file-handle cleanup. Native commands and ownership observations were mocked in those fault-injection tests.The unmodified published 2026.9.4 updater also passed a real macOS 26.5 arm64 upgrade to the exact canonical package at
054e5f70a6895e70e89fb24e76c6abe981cd08c8. The ordinary CLI update completed in 131.408 seconds with exit 0 and statusok. Native process identity changed, HTTP readiness returned 200, the authenticated WebSocket handshake reported the candidate build, and the durable update ledger finished successfully with all verification flags true and no remaining custody rows. Processes, listeners, service definition, profile, runtime files and the verified empty control root were cleaned up. The custody backup is retained; normal launchd enable overrides remain for disposal of the task-owned clone. No operator Gateway was restarted.The live cell covers the ordinary upgrade path; rollback faults are covered by the filesystem regressions above. Optional WebSocket diagnostic reads lacked
operator.readboth before and after, so this is handshake/build evidence rather than unrestricted RPC-health coverage. Earlier transport and harness setup failures remain recorded; product assertions and timeouts were unchanged, and only one actual update ran.Full selected checks, fresh independent P0–P2 autoreview and exact-head CI pass. The canonical package build and artifact checks also passed. This isolated prerequisite adds 21 production lines; the replacement series' final production reduction remains an aggregate requirement.