Skip to content

fix(update): allow launcher symlink backups across macOS umasks - #145288

Closed
RileyJJY wants to merge 1 commit into
openclaw:mainfrom
RileyJJY:sunlit/fix/issue-145072
Closed

RileyJJY wants to merge 1 commit into
openclaw:mainfrom
RileyJJY:sunlit/fix/issue-145072

Conversation

@RileyJJY

@RileyJJY RileyJJY commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users running openclaw update on macOS would see Package rollback launcher backup changed during the global npm install swap when the installed launcher symlink and its backup were created under different umasks.

Fixes #145072

Why This Change Was Made

Launcher symlink modes on macOS reflect the process umask, so they are not stable identity data across the update copy boundary. The launcher fingerprint now preserves the symlink type, owner, group, and target while ignoring only symlink mode; regular-file permission fingerprints and changed-target checks remain unchanged.

User Impact

Global npm updates on macOS no longer abort for an equivalent launcher symlink whose mode changed during backup. Actual launcher target changes and regular-file integrity changes continue to be rejected.

Evidence

  • Focused test: pnpm test src/infra/package-update-swap.integrity.test.ts — 38 tests passed.
  • Real production module proof at the pinned validation base d781c156cb7738ce64eba162178bef85e715a989: source mode 0700, backup mode 0755, same target, fingerprintEqual=false, and the changed-target negative control was rejected.
  • The same proof at the exact head SHA 4cdbf2fcb1b8a707e5db5205235d4a8b9719f663 reports fingerprintEqual=true for the equivalent symlink and still rejects the changed-target negative control.
  • The proof exercises the production copyPackagePathEntry and createPackageIntegrityReader().launcher call chain at the local filesystem/npm-swap boundary.
  • This reuses the existing launcher integrity contract: symlink type, owner, group, and target remain protected while regular-file mode remains fingerprinted.
  • Published-updater × candidate proof on Darwin arm64 (Node v24.18.0, npm 11.17.0): the candidate tarball was built from exact head 4cdbf2fcb1b8a707e5db5205235d4a8b9719f663 (SHA-256 d6ffd22ec8e79311f1263de3c8432217d8a287df3123d5c8d013dba5fb9553d6) and exercised through the real global npm update pipeline under isolated state/config paths.
$ production-module proof runner (same invocation and local filesystem boundary on base and head)
entrypoint: copyPackagePathEntry -> createPackageIntegrityReader().launcher
base: d781c156cb7738ce64eba162178bef85e715a989 => before-fix fingerprintEqual=false; negativeControlRejected=true
head: 4cdbf2fcb1b8a707e5db5205235d4a8b9719f663 => after-fix fingerprintEqual=true; negativeControlRejected=true

$ published-updater x candidate (launcher installed at umask 022 => 0755; update run at umask 077 => 0700)
result: published [email protected] (1391f7c) -> candidate: candidate install/migration/doctor/config/plugin/gateway checks passed; global install swap failed only with "Package rollback launcher backup changed"; version remained 2026.9.3 and recovery remained safe
result: candidate [email protected] (4cdbf2f) -> same candidate: global install swap passed ("replaced openclaw"); doctor and post-update verification passed; version remained 2026.9.4 and resulting launcher was 0700

The first row is intentional: an already-installed pre-fix updater cannot repair its own fingerprint comparison on the first hop. The second row proves the repaired updater tolerates the macOS umask-only symlink-mode difference while preserving symlink type, owner, group, and target. Service management was skipped because the proof used isolated state/config paths; package swap and recovery were exercised directly.

Testing proof
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";

const { createPackageIntegrityReader } = await import("./src/infra/package-update-integrity.ts");
const { copyPackagePathEntry } = await import("./src/infra/package-update-filesystem.ts");

const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-145072-proof-"));
const source = path.join(root, "openclaw");
const backup = path.join(root, "backup", "openclaw");
const negative = path.join(root, "negative");
const originalUmask = process.umask();
try {
  await fs.mkdir(path.dirname(backup), { recursive: true });
  process.umask(0o077);
  await fs.symlink("../lib/node_modules/openclaw/openclaw.mjs", source);
  const sourceMode = (await fs.lstat(source)).mode & 0o777;
  process.umask(0o022);
  await copyPackagePathEntry(source, backup);
  const backupMode = (await fs.lstat(backup)).mode & 0o777;
  const reader = createPackageIntegrityReader();
  const sourceFingerprint = await reader.launcher(source);
  const backupFingerprint = await reader.launcher(backup);
  await fs.symlink("../lib/node_modules/openclaw/other.mjs", negative);
  const negativeFingerprint = await reader.launcher(negative);
  console.log(JSON.stringify({
    platform: process.platform,
    sourceMode,
    backupMode,
    sourceAndBackupHaveSameTarget: (await fs.readlink(source)) === (await fs.readlink(backup)),
    fingerprintEqual: sourceFingerprint === backupFingerprint,
    negativeControlRejected: sourceFingerprint !== negativeFingerprint,
  }));
} finally {
  process.umask(originalUmask);
  await fs.rm(root, { recursive: true, force: true });
}
Published updater proof runner

The following is the redacted runner used for the published-updater × candidate cell. CANDIDATE_TGZ is the candidate tarball built from the exact head SHA above.

#!/usr/bin/env bash
set -euo pipefail

: "${CANDIDATE_TGZ:?set CANDIDATE_TGZ to the candidate .tgz}"
PROOF_DIR="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-145288-proof.XXXXXX")"
OLD_PREFIX="$PROOF_DIR/old-prefix"
OLD_HOME="$PROOF_DIR/old-home"
CANDIDATE_PREFIX="$PROOF_DIR/candidate-prefix"
CANDIDATE_HOME="$PROOF_DIR/candidate-home"
mkdir -p "$OLD_PREFIX" "$OLD_HOME" "$CANDIDATE_PREFIX" "$CANDIDATE_HOME"

NPM_ARGS=(--allow-scripts=openclaw,@google/genai,koffi,tree-sitter-bash,protobufjs --no-audit --no-fund)
export PATH="$OLD_PREFIX/bin:${PATH}"

umask 022
HOME="$OLD_HOME" npm install --global --prefix "$OLD_PREFIX" [email protected] "${NPM_ARGS[@]}"
OLD_MODE="$(stat -f '%Sp' "$OLD_PREFIX/bin/openclaw")"

umask 077
set +e
OLD_JSON="$(
  NPM_CONFIG_PREFIX="$OLD_PREFIX" npm_config_prefix="$OLD_PREFIX" \
  HOME="$OLD_HOME" OPENCLAW_CONFIG_PATH="$OLD_HOME/openclaw.json" \
  OPENCLAW_STATE_DIR="$OLD_HOME/openclaw-state" \
  OPENCLAW_UPDATE_PACKAGE_SPEC="file:$CANDIDATE_TGZ" \
  "$OLD_PREFIX/bin/openclaw" update --yes --tag="file:$CANDIDATE_TGZ" --json \
  2>"$PROOF_DIR/old.stderr"
)"
OLD_STATUS=$?
set -e

umask 022
HOME="$CANDIDATE_HOME" npm install --global --prefix "$CANDIDATE_PREFIX" "file:$CANDIDATE_TGZ" "${NPM_ARGS[@]}"
umask 077
CANDIDATE_JSON="$(
  NPM_CONFIG_PREFIX="$CANDIDATE_PREFIX" npm_config_prefix="$CANDIDATE_PREFIX" \
  HOME="$CANDIDATE_HOME" OPENCLAW_CONFIG_PATH="$CANDIDATE_HOME/openclaw.json" \
  OPENCLAW_STATE_DIR="$CANDIDATE_HOME/openclaw-state" \
  OPENCLAW_UPDATE_PACKAGE_SPEC="file:$CANDIDATE_TGZ" \
  "$CANDIDATE_PREFIX/bin/openclaw" update --yes --tag="file:$CANDIDATE_TGZ" --json \
  2>"$PROOF_DIR/candidate.stderr"
)"
CANDIDATE_MODE="$(stat -f '%Sp' "$CANDIDATE_PREFIX/bin/openclaw")"

printf 'platform=%s old_mode=%s old_status=%s candidate_mode=%s\n' \
  "$(uname -s -m)" "$OLD_MODE" "$OLD_STATUS" "$CANDIDATE_MODE"
printf '%s\n' "$OLD_JSON" | tail -n 1
printf '%s\n' "$CANDIDATE_JSON" | tail -n 1

AI-assisted: built with Codex

@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, 8:05 PM ET / September 12, 2026, 00:05 UTC (Revision 2).

ClawSweeper review

What this changes

The PR excludes symlink permissions from launcher-backup comparisons while preserving other integrity checks and adds a regression test for differing macOS umasks.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix absent from current main and v2026.9.4. The updated macOS evidence satisfies the previous proof request, and source review found no blocking defect.

Priority: P0
Reviewed head: 4cdbf2fcb1b8a707e5db5205235d4a8b9719f663

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow repair with relevant macOS production-path proof and no blocking correctness findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied exact-head Darwin filesystem and npm-update transcripts exercise the changed launcher reader through real copying and swapping, show successful repaired-driver activation and changed-target rejection, and satisfy the prior published-driver request while explicitly recording safe first-hop failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied exact-head Darwin filesystem and npm-update transcripts exercise the changed launcher reader through real copying and swapping, show successful repaired-driver activation and changed-target rejection, and satisfy the prior published-driver request while explicitly recording safe first-hop failure.
Evidence reviewed 8 items Verified introduced change: The merge-base-to-head diff changes only launcher fingerprint comparison and its regression test; unrelated base-branch changes are excluded.
Current main still has the defect: Current main includes stat.mode in both symlink and regular-file launcher fingerprints. The copying owner recreates symlinks without preserving their mode, establishing the reported mismatch mechanism.
Latest release remains affected: The v2026.9.4 source also fingerprints symlink mode. Local retrieval of that historical blob failed; the GitHub contents API supplied the release source successfully.
Findings None None.
Security None None.

How this fits together

The npm updater backs up the installed launcher before replacing OpenClaw. Launcher fingerprints verify those backups and later restoration, so an irrelevant metadata difference can prevent an otherwise valid update.

flowchart TD
  A[Installed launcher] --> B[Copy launcher backup]
  A --> C[Capture stable fingerprint]
  B --> D[Compare backup fingerprint]
  C --> D
  D -->|Match| E[Activate staged package]
  D -->|Mismatch| F[Preserve existing installation]
  E --> G[Verify restoration if needed]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +28. Total +30 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 5 +2
Tests 1 28 0 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 5 +30

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145072
Summary: This PR addresses the canonical launcher's umask mismatch; nearby update-budget work has a different mechanism.

Members:

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

Technical review

Best possible solution:

Use copy-stable launcher identity and keep guided recovery available for installations still running an affected older updater.

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

Yes: current source compares umask-dependent symlink modes after recreating the backup, and supplied macOS traces demonstrate the mismatch. This reviewer did not execute the reproduction.

Is this the best way to solve the issue?

Yes: excluding only symlink mode repairs the existing comparison owner without changing target, ownership, regular-file integrity, or recovery authorization.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P0: Affected macOS installations cannot complete updates, and the reported workaround requires manual permission changes rather than an in-product recovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied exact-head Darwin filesystem and npm-update transcripts exercise the changed launcher reader through real copying and swapping, show successful repaired-driver activation and changed-target rejection, and satisfy the prior published-driver request while explicitly recording safe first-hop failure.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head Darwin filesystem and npm-update transcripts exercise the changed launcher reader through real copying and swapping, show successful repaired-driver activation and changed-target rejection, and satisfy the prior published-driver request while explicitly recording safe first-hop failure.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff changes only launcher fingerprint comparison and its regression test; unrelated base-branch changes are excluded. (src/infra/package-update-integrity.ts:344, 4cdbf2fcb1b8)
  • Current main still has the defect: Current main includes stat.mode in both symlink and regular-file launcher fingerprints. The copying owner recreates symlinks without preserving their mode, establishing the reported mismatch mechanism. (src/infra/package-update-integrity.ts:342, c38897f55440)
  • Latest release remains affected: The v2026.9.4 source also fingerprints symlink mode. Local retrieval of that historical blob failed; the GitHub contents API supplied the release source successfully. (src/infra/package-update-integrity.ts, 3a9d69db306c)
  • Integrity and recovery boundary: Backup comparison precedes service preparation and live replacement. Recovery uses the same launcher reader; type, uid, gid, target, regular-file permissions, and within-read mutation checks remain intact. Fingerprints are runtime observations, not newly persisted authority. (src/infra/package-update-swap.ts:360, 4cdbf2fcb1b8)
  • Updated real macOS proof: The supplied complete PR body at sourceRevision cb1fa77d63715c858438e98c45e1233d89107ebe6a8855f3f9a825065f904e3e records Darwin arm64 production-copy/fingerprint before-and-after results, including changed-target rejection. Its exact-head candidate update succeeds across differing umasks; the published 2026.9.3 updater fails safely before replacement. This fulfills the prior request to distinguish first-hop limitations from repaired-driver behavior. Service management was explicitly outside the isolated proof. (4cdbf2fcb1b8)
  • Regression coverage and execution isolation: The new test exercises the actual swap with a real launcher symlink, asserts committed activation, and restores the original umask in finally. The infra project uses isolated fork processes with file parallelism disabled. Tests were inspected, not executed during this read-only review. (src/infra/package-update-swap.integrity.test.ts:84, 4cdbf2fcb1b8)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: 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 (1 earlier review cycle)
  • reviewed 2026-09-11T21:15:40.178Z sha 4cdbf2f :: needs real behavior proof before merge. :: none

@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. 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. labels Sep 12, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #145282, now landed as the canonical fix because it preserves the symlink's observable mode rather than ignoring it in the fingerprint; thank you @RileyJJY for the analysis and alternative approach.

@steipete steipete closed this Sep 12, 2026
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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants