Skip to content

fix(update): preserve macOS launcher permissions during updates - #145282

Merged
steipete merged 4 commits into
openclaw:mainfrom
PollyBot13:fix/macos-upgrade-launcher-mode
Sep 12, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
PollyBot13:fix/macos-upgrade-launcher-mode

Conversation

@PollyBot13

@PollyBot13 PollyBot13 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #145072

What Problem This Solves

Fixes an issue where macOS users retrying an npm update receive Package rollback launcher backup changed when the updater's umask differs from the installed launcher symlink's permissions.

Why This Change Was Made

Preserve the symlink's mode with macOS lchmod before the existing atomic publication. Keep launcher fingerprints, ownership checks, and failure cleanup unchanged; never follow the link or change its target's permissions. The same copy owner serves backup and retained rollback.

User Impact

An updater containing this fix can copy and restore launchers created under either restrictive or ordinary umasks. Linux and Windows behavior is unchanged.

First-upgrade limitation: this is prevention in the fixed driver, not a rescue for an already-running 2026.9.3/9.4 updater. The published 2026.9.3 driver owns the faulty copy and rejects its backup before activation; putting this fix only in its candidate does not replace that driver. This PR therefore references rather than closes #145072. Existing-install recovery/release delivery remains separate.

Evidence

  • macOS arm64, Node 26.8.1. Five new regressions fail on the original implementation; all 66 tests pass across package-update-filesystem.test.ts, package-update-swap.integrity.test.ts, package-update-swap.ownership.test.ts, and package-update-swap.bounds.test.ts using node scripts/run-vitest.mjs.
  • Separate unmocked native filesystem execution of the actual copy and swap owners against disposable npm-layout fixtures (no real Gateway or npm install):
    • source umask 077, updater 022: original 0700, bare copy 0755, fixed copy/restored launcher 0700.
    • source umask 022, updater 077: original 0755, bare copy 0700, fixed copy/restored launcher 0755.
    • Both activate, then retained rollback returns exit 0. Link target, mode, uid/gid, target contents and target permissions remain unchanged.
  • Regression coverage also includes dangling links and metadata failure leaving the live launcher intact with no staging residue.
  • After integration with main, all 97 tests pass across the four launcher/filesystem/swap suites (66) and the first-hop fixture suite (31). Formatting and git diff --check pass. Fresh native autoreview of the combined diff is scoped-clean at P1, with no actionable findings.
  • The initial local changed-file check passed its preceding guards and stopped at an unrelated mainline shard-cap failure: config-cli: 721 test roots exceeds the 720 limit. This patch changes neither test-file membership nor the shard configuration. The standalone type-aware lint command also stops before linting because declaration preparation rejects dependency lookup into an ancestor checkout installation; this is a local worktree isolation limitation. No baseline, timeout, dependency, or lockfile was weakened or changed for this repair.

Published-driver × candidate proof and macOS comparison

Real APFS execution of the exact source revisions:

Variant Installed 0700, updater umask 022 Installed 0755, updater umask 077
Main 6a971911e062 Launcher-backup mismatch on both attempts Launcher-backup mismatch on both attempts
#145282 07fbc34a71a7 Update and rollback pass; restores 0700 Update and rollback pass; restores 0755
#145288 4cdbf2fcb1b8 Update and rollback pass; changes mode to 0755 Update and rollback pass; changes mode to 0700

macOS 27.0, APFS, Node 26.8.2, npm 11.19.1; isolated synthetic prefix and state. The exact 07fbc34a71a7385abb6b889d0899c2e5c88ee625 candidate passed the canonical Linux package build and integrity check (tarball SHA-256 5b76430dbe5f6e23b8295b299d433a096c51af01dd305d28875ecfa46a361f14). Commands used the installed launcher:

openclaw update --yes --json --no-restart --tag <fixture.tgz>
  • Published 2026.9.4, two initial attempts: both hit its existing 30-second package-fingerprint limit before launcher comparison. Version, inode, target, and 0700 mode remained unchanged. These do not establish the exact published-CLI mode refusal; that refusal is reproduced in the main owner matrix.
  • After a manual corrective install of the fixed candidate as a valid .3 version fixture, fixed normal update .3 → .4 returned CLI exit 0, changed the package inode, and published the staged launcher as 0755.
  • Injected rollback .4 → .5 under umask 077: post-activation Doctor exited 97. CLI exited 1 with doctor-failed; global install rollback exited 0, and packageRollbackVerified was true.
  • Rollback restored .4, the original package inode, symlink target, launcher mode 0755, and target mode 0755. The launcher executed afterward and no transaction residue remained.

Full hashing exceeded its budget, so recovery explicitly used retained directory identity/version and launcher fingerprints. Service restart was not tested. Fixture suffixes describe synthetic package versions, not upgrades between published releases. The published driver attempts and the successful subsequent fixed-driver runs are distinct evidence cells.

Linux launcher regression proof · Exact candidate package builder

Maintainer additions

Maintainer commits 3b276ae6515 (test(update): verify launcher targets and permissions through rollback) and 0b1ba898db3 (test(update): refresh content inventories in first-hop fixtures) add distinct old/new targets, staged permissions, Linux coverage, hardlinked executable launchers, and valid packaged fixture transformations. Main subsequently gained the narrower fixture-inventory repair in aa0ad4c7804; integration keeps that implementation, including its corruption-detection behavior, and retains the additional five transformation cases. Thanks to @PollyBot13 for the fix and @RileyJJY for the analysis and alternative comparison.

node scripts/run-vitest.mjs src/infra/package-update-swap.integrity.test.ts -t 'preserves distinct launcher targets|accepts a hardlinked launcher'
# Before copier fix: 2 failed, 1 passed. After: 3 passed. Linux: 2 passed.
node scripts/run-vitest.mjs test/scripts/update-first-hop-package-fixtures.test.ts -t 'keeps modern content inventories valid'
# Before fixture repair: 5 failed — content-inventory mismatch.
node scripts/run-vitest.mjs test/scripts/update-first-hop-package-fixtures.test.ts
# After fixture repair: 28 passed.

The packaged proof and first-upgrade limitation above address ClawSweeper's requested behavior evidence and Rank-up move. Existing-install recovery remains separate under Related #145072.

Scope: five production lines plus regression tests, no dependency or schema changes. Reverting the launcher patch restores prior behavior.

Maintainer disposition and current CI

The refreshed review of 9fe875b3d2d159ef12ba8160d11a6aeb1ee6fef3 accepts the behavior proof and reports no correctness or security findings. The earlier Rank-up request is addressed by the published-driver versus fixed-driver evidence above. The remaining merge-risk note is an accepted scope boundary: this repair prevents recurrence once the fixed updater is installed; affected older-driver recovery stays in the separately tracked work under #145072. The landing decision for this focused copier repair does not claim first-upgrade rescue or service restart coverage.

Exact-head CI run 34667406704 completed successfully across 162 jobs (including conditional skips), with openclaw/ci-gate successful and no reruns. The refreshed merge ref includes the mainline repairs from #145415 and #145431.

The earlier run 34661178456 failed on unrelated mainline shard-cap and Control UI lint/deadcode/cursor-policy checks. Those failures were repaired upstream; this PR's head and four-file repair diff remain unchanged. No checks or assertions were weakened.

ClawSweeper's latest completed exact-head review reports Before merge: None, no correctness or security findings, and sufficient behavior proof. No Rank-up move remains outstanding.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 10:52 PM ET / September 12, 2026, 02:52 UTC (Revision 5).

ClawSweeper review

What this changes

The PR preserves macOS launcher symlink permissions during package backup, activation, and rollback, and adds launcher and update-fixture regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, narrowly scoped repair: current main and v2026.9.4 still contain the mismatch. Native update-and-rollback evidence supports the implementation, and no actionable correctness or security findings remain.

Priority: P0
Reviewed head: 9fe875b3d2d159ef12ba8160d11a6aeb1ee6fef3

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small owner-level repair with strong native before/after evidence, meaningful regression coverage, and no remaining findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured PR body documents real macOS/APFS copy, update, and injected-failure rollback through the production owners and installed CLI, with preserved launcher metadata and successful recovery. The exercised copier is unchanged at this head. Published-driver attempts establish the separately documented first-upgrade limitation, not successful rescue; service restart is outside this repair’s proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured PR body documents real macOS/APFS copy, update, and injected-failure rollback through the production owners and installed CLI, with preserved launcher metadata and successful recovery. The exercised copier is unchanged at this head. Published-driver attempts establish the separately documented first-upgrade limitation, not successful rescue; service restart is outside this repair’s proof.
Evidence reviewed 10 items Introduced production change: The pinned introduced delta adds Darwin-only lchmod on the staged symlink before atomic rename. Existing assertion checks, regular-file handling, and staging cleanup remain intact.
Shared backup and restoration owner: The swap calls the copier for baseline launcher backups, candidate publication, and rollback. Backup fingerprint comparison occurs before service preparation and live package mutation; launcher fingerprints retain mode, ownership, and target checks.
Current main still needs the repair: Fetched main recreates symlinks without restoring their mode; only regular files receive chmod.
Findings None None.
Security None None.

How this fits together

OpenClaw’s package updater copies command launchers while replacing an installed npm package. The same filesystem owner prepares backups, publishes candidate launchers, and restores previous launchers when activation fails.

flowchart TD
  A[Installed launcher] --> C[Atomic launcher copy]
  B[Candidate launcher] --> C
  C --> D[Preserve macOS link permissions]
  D --> E[Verify backup fingerprint]
  E --> F[Activate candidate]
  F --> G[Restore retained launcher on failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +132. Total +137 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
Tests 3 132 0 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 137 0 +137

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145072
Summary: This PR repairs the canonical report’s launcher-copy mechanism; older-driver recovery remains outside its demonstrated scope.

Members:

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

Technical review

Best possible solution:

Preserve launcher metadata in the existing copy owner, while tracking a visible Fix path for affected older updaters in #145072.

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

Yes: current source recreates macOS symlinks under the updater’s umask and then compares their modes strictly. Independent reports and the supplied native matrix establish both mismatch directions; this review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes: correcting the shared copier preserves the existing integrity contract and covers backup, activation, and restoration without adding another implementation path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against af135e068540.

Labels

Label justifications:

  • P0: The linked reports establish a blocked normal macOS update flow, including Control UI updates, with recovery currently requiring terminal intervention.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured PR body documents real macOS/APFS copy, update, and injected-failure rollback through the production owners and installed CLI, with preserved launcher metadata and successful recovery. The exercised copier is unchanged at this head. Published-driver attempts establish the separately documented first-upgrade limitation, not successful rescue; service restart is outside this repair’s proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body documents real macOS/APFS copy, update, and injected-failure rollback through the production owners and installed CLI, with preserved launcher metadata and successful recovery. The exercised copier is unchanged at this head. Published-driver attempts establish the separately documented first-upgrade limitation, not successful rescue; service restart is outside this repair’s proof.

Evidence

What I checked:

  • Introduced production change: The pinned introduced delta adds Darwin-only lchmod on the staged symlink before atomic rename. Existing assertion checks, regular-file handling, and staging cleanup remain intact. (src/infra/package-update-filesystem.ts:109, 9fe875b3d2d1)
  • Shared backup and restoration owner: The swap calls the copier for baseline launcher backups, candidate publication, and rollback. Backup fingerprint comparison occurs before service preparation and live package mutation; launcher fingerprints retain mode, ownership, and target checks. (src/infra/package-update-swap.ts:363, 9fe875b3d2d1)
  • Current main still needs the repair: Fetched main recreates symlinks without restoring their mode; only regular files receive chmod. (src/infra/package-update-filesystem.ts:105, af135e068540)
  • Latest supplied release retains the defect: GitHub’s v2026.9.4 source also lacks symlink-mode preservation. No shipped implementation of this repair was established. (src/infra/package-update-filesystem.ts:105, 3a9d69db306c)
  • Native behavior proof and its boundary: The supplied PR body records real APFS execution on macOS 27.0 with Node 26.8.2: both opposing mode/umask cases preserve link permissions through copy and rollback. Installed-launcher CLI execution subsequently completes a fixed-driver update and an injected Doctor-failure rollback, restoring package identity, launcher target and permissions, with no transaction residue. Published 2026.9.4 attempts stopped earlier at the fingerprint budget; they do not prove first-upgrade rescue. Service restart was explicitly excluded. Prepared images belong to the unrelated package-icon PR and were not counted as launcher proof. (07fbc34a71a7)
  • Proof remains applicable to the reviewed production code: The production copier is unchanged between the natively exercised initial head and the reviewed head. Later introduced changes add regression coverage. (src/infra/package-update-filesystem.ts:109, 9fe875b3d2d1)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-11T21:04:52.778Z sha 07fbc34 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-12T00:25:18.512Z sha 9fe875b :: blocked before merge. :: none
  • reviewed 2026-09-12T00:35:08.836Z sha 9fe875b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T02:26:41.510Z sha 9fe875b :: needs maintainer review before merge. :: none

Extend the retained launcher regression from openclaw#145282 (@PollyBot13) to use
separate old and candidate symlink targets on macOS and Linux. Verify the
staged launcher mode, restored mode and ownership, target executable bits,
and executable permissions on hardlinked launchers.

Refs openclaw#145072. Thanks to @yuxiao345 and @alexph-dev for the reproduction.
Version stamping changed build-info.json without regenerating its packaged
content hash. Modern updaters rejected those targets before installation,
and removed compatibility chunks also left stale inventory entries.

Regenerate through the existing inventory writer for modern artifacts while
preserving the capability set of older frozen packages. Cover all five
version and compatibility transform entry points with the real validator.

Refs openclaw#145072 and openclaw#145282.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 12, 2026
Keep the mainline fixture inventory updater from aa0ad4c and retain the five additional fixture transformation cases. This preserves corruption detection and removes the superseded full inventory regeneration helper.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 12, 2026
@steipete steipete closed this Sep 12, 2026
@steipete steipete reopened this Sep 12, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Sep 12, 2026
@steipete
steipete merged commit 884b0ee into openclaw:main Sep 12, 2026
445 of 451 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
…claw#145282)

macOS: npm updates no longer fail with `Package rollback launcher backup changed` when the updater's umask differs from the installed launcher symlink's permissions; the symlink mode is preserved through backup, activation and rollback.

Keep launcher fingerprints strict and preserve link metadata at the shared copy owner before atomic publication. Regression coverage verifies old/new targets, staged permissions, retained rollback, dangling links, metadata failures, hardlinked launchers, and modern package fixture inventories.

Native macOS owner comparisons pass in both umask directions. Packaged fixed-driver update exits 0; injected Doctor failure restores the previous package and launcher with packageRollbackVerified=true. Published 2026.9.4 initial attempts reached its earlier fingerprint timeout, so this does not claim rescue of the already-running old updater.

Related openclaw#145072. Thanks to @RileyJJY for the analysis and comparison.

Co-authored-by: PollyBot13 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
This was referenced Oct 27, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
)

The global-install-failed reason-code entry still claimed no published release contained both openclaw#145282 and openclaw#144758. Both landed in v2026.9.5 (f19a973, cdb8e14), so users stuck on the 2026.9.3/2026.9.4 updater need the manual hop only once.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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

2 participants