Skip to content

fix(update): allow package-manager hardlinks in swaps - #85569

Merged
steipete merged 3 commits into
openclaw:mainfrom
ai-hpc:fix/85559-package-hardlink-swaps
May 25, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
ai-hpc:fix/85559-package-hardlink-swaps

Conversation

@ai-hpc

@ai-hpc ai-hpc commented May 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • allow the package-manager update/install swap path to move package roots that contain source-side hardlinks
  • keep the generic movePathWithCopyFallback reject guard unchanged for non-package-manager callers
  • add regression coverage with real filesystem hardlinks for both global update swaps and install-directory swaps

Fixes #85559.

Real behavior proof

Behavior or issue addressed: npm 11+/pnpm-style global OpenClaw installs can contain hardlinked files under the installed package root. Before this change, the updater/install swap path used sourceHardlinks: "reject" and could fail before replacing the package root. This patch scopes sourceHardlinks: "allow" to the package-manager-owned swap paths while preserving the generic reject guard.

Real environment tested: Docker node:24-bookworm, Node v24.16.0, npm 11.13.0, Linux container, real global npm install under /usr/local/lib/node_modules/openclaw. The proof used local OpenClaw tarballs built from this PR head: baseline 2026.5.22 and target 2026.5.23-proof.0.

Exact steps or command run after fix:

docker run --rm -v /tmp/openclaw-proof-85559-aacec68753:/proof node:24-bookworm bash -lc '
set -eu
npm install -g --omit=optional /proof/baseline.tgz
root="$(npm root -g)/openclaw"
hardlink_source="$(find "$root" -type f -path "*/dist/*" -print -quit)"
mkdir -p /tmp/openclaw-hardlink-cache
ln "$hardlink_source" /tmp/openclaw-hardlink-cache/source-hardlink
find "$root" -type f -links +1 | head -n 3
OPENCLAW_ALLOW_ROOT=1 npm_config_omit=optional NPM_CONFIG_OMIT=optional openclaw update --tag /proof/target.tgz --yes --json
openclaw --version
'

Evidence after fix:

node=v24.16.0
npm=11.13.0
baseline=OpenClaw 2026.5.22 (aacec68)
packageRoot=/usr/local/lib/node_modules/openclaw
hardlinkSource=/usr/local/lib/node_modules/openclaw/dist/setup-surface-BUJl2T9I.js
hardlinkedBefore=
/usr/local/lib/node_modules/openclaw/dist/setup-surface-BUJl2T9I.js
{
  "status": "ok",
  "mode": "npm",
  "root": "/usr/local/lib/node_modules/openclaw",
  "before": {
    "version": "2026.5.22"
  },
  "after": {
    "version": "2026.5.23-proof.0"
  },
  "steps": [
    {
      "name": "global update",
      "exitCode": 0,
      "stdoutTail": "\nadded 483 packages in 5m"
    },
    {
      "name": "global install swap",
      "exitCode": 0,
      "stdoutTail": "replaced openclaw"
    },
    {
      "name": "openclaw doctor",
      "exitCode": 0
    }
  ]
}
updated=OpenClaw 2026.5.23-proof.0 (aacec68)

Observed result after fix: The package root contained a real hardlinked file before the update, and openclaw update --tag /proof/target.tgz --yes --json completed with status: ok. The global install swap step replaced the package root successfully and the installed CLI reported OpenClaw 2026.5.23-proof.0 afterward.

What was not tested: I did not run a separate pnpm global update E2E locally. The Docker proof covers npm 11 global install/update with a real hardlinked package root in the same package-manager swap path, and the regression tests cover both update and install swap helpers with actual filesystem hardlinks.

Verification

git diff --check
pnpm test src/infra/replace-file.test.ts src/infra/package-update-steps.test.ts src/infra/install-package-dir.test.ts
node scripts/package-openclaw-for-docker.mjs --output-dir /tmp/openclaw-proof-85559-aacec68753 --output-name baseline.tgz
docker run --rm -v /tmp/openclaw-proof-85559-aacec68753:/proof node:24-bookworm bash -lc '...'

Security notes

  • This does not weaken the generic hardlink protection in movePathWithCopyFallback.
  • The allow policy is scoped to package-manager-owned package root swaps where npm/pnpm may legitimately materialize hardlinks.

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Latest ClawSweeper review: 2026-05-23 03:34 UTC / May 22, 2026, 11:34 PM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • 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.

Summary
The PR allows hardlinked package-manager swap sources in global update and dependency-install paths while preserving rejection for generic and dependency-free install moves, with hardlink regression tests.

Reproducibility: yes. Current main source still rejects hardlinked package-root swaps, and the PR body provides Docker/npm 11 live output showing the same hardlinked global package-root update succeeding after the fix.

PR rating
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Summary: Strong real behavior proof and a now-scoped patch make this normally mergeable after maintainer security-boundary review.

Rank-up moves:

  • Add or attach pnpm global-update live proof if maintainers want direct evidence for the pnpm half of the report.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Sufficient (live_output): The PR body includes after-fix Docker/npm 11 live output for a real hardlinked global package root updating successfully; contributors should still redact any private paths, tokens, phone numbers, or endpoints in future proof.

Risk before merge

  • This intentionally changes a filesystem hardlink guard: package-manager-owned swap moves with hardlinked sources will proceed instead of failing closed.
  • The live proof covers npm 11 global update; pnpm is covered by the shared source path and filesystem tests but not by a separate live pnpm global-update proof.

Maintainer options:

  1. Accept the scoped package-manager allowance (recommended)
    Maintainers can land this shape if they agree npm/pnpm-owned package roots are allowed to contain package-manager hardlinks while generic and dependency-free moves still reject them.
  2. Ask for pnpm live proof first
    If maintainers want parity for the pnpm claim, request a pnpm global-update proof before merge without changing the code shape.
  3. Pause for hardlink policy review
    If the hardlink trust boundary for package-manager roots is unsettled, pause this PR until the infra/security owner chooses the permanent policy.

Next step before merge
No narrow automated repair remains; the next action is maintainer review of the scoped hardlink security-boundary decision and any desired pnpm live proof.

Security
Cleared: No concrete security defect found after the narrowing commit; the generic hardlink guard and dependency-free install rejection remain in place.

Review details

Best possible solution:

Land the scoped package-manager hardlink allowance after maintainer security-boundary review, while keeping generic and dependency-free install moves fail-closed on hardlinked sources.

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

Yes. Current main source still rejects hardlinked package-root swaps, and the PR body provides Docker/npm 11 live output showing the same hardlinked global package-root update succeeding after the fix.

Is this the best way to solve the issue?

Yes, with maintainer security review. The second commit narrows the install helper so dependency-free installs still reject hardlinked sources, which is the maintainable shape for the reported package-manager update bug.

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix Docker/npm 11 live output for a real hardlinked global package root updating successfully; contributors should still redact any private paths, tokens, phone numbers, or endpoints in future proof.
  • add rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🦞 diamond lobster, patch quality is 🐚 platinum hermit, and Strong real behavior proof and a now-scoped patch make this normally mergeable after maintainer security-boundary review.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix Docker/npm 11 live output for a real hardlinked global package root updating successfully; contributors should still redact any private paths, tokens, phone numbers, or endpoints in future proof.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The linked bug prevents real npm 11 or pnpm-style global installs from advancing through the update path and can leave users pinned on older releases.
  • merge-risk: 🚨 security-boundary: The patch deliberately relaxes a hardlink rejection guard for package-manager-owned swap paths, which is a filesystem trust-boundary decision even when scoped.
  • rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🦞 diamond lobster, patch quality is 🐚 platinum hermit, and Strong real behavior proof and a now-scoped patch make this normally mergeable after maintainer security-boundary review.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix Docker/npm 11 live output for a real hardlinked global package root updating successfully; contributors should still redact any private paths, tokens, phone numbers, or endpoints in future proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix Docker/npm 11 live output for a real hardlinked global package root updating successfully; contributors should still redact any private paths, tokens, phone numbers, or endpoints in future proof.

What I checked:

  • Current main rejects hardlinked package-update swap sources: On current main, the staged global package swap calls movePathWithCopyFallback with sourceHardlinks: "reject" for existing package backup, staged package publish, and rollback, matching the reported failure mode for package roots containing hardlinked files. (src/infra/package-update-steps.ts:424, 679a46d01e65)
  • Current main rejects all installPackageDir hardlinked sources: On current main, installPackageDir uses sourceHardlinks: "reject" for backup restore, existing-target backup, and staged publish, so shared install helpers currently fail closed on hardlinked source files. (src/infra/install-package-dir.ts:214, 679a46d01e65)
  • PR head scopes the package-update allowance: The PR adds PACKAGE_MANAGER_SWAP_SOURCE_HARDLINKS and uses it only inside swapStagedNpmInstall for package-manager-owned backup, publish, and rollback moves. (src/infra/package-update-steps.ts:21, b3e3bf1d1e03)
  • PR head narrows installPackageDir allowance by dependency install path: The second PR commit derives installPackageDir sourceHardlinks from hasDeps, so dependency-bearing package-manager installs allow hardlinks while dependency-free skill, hook, and similar publishes still reject them. (src/infra/install-package-dir.ts:111, b3e3bf1d1e03)
  • Regression tests cover allow and reject cases: The PR adds POSIX hardlink tests for npm package-root swaps, dependency-bearing install updates, and dependency-free update/publish rejection, including real fs.link-created hardlinks. (src/infra/install-package-dir.test.ts:304, b3e3bf1d1e03)
  • Read-only formatting check passed: The PR merge diff for the four touched files has no whitespace errors under git diff --check. (684e421e9fc9)

Likely related people:

  • Sebastien Tardif: Available git history/blame attributes the current installPackageDir file, replace-file hardlink guard, and package-update swap function to commit e008bc9 in this checkout. (role: introduced current area in available history; confidence: medium; commits: e008bc92c396; files: src/infra/install-package-dir.ts, src/infra/replace-file.ts, src/infra/package-update-steps.ts)
  • Jason (Json): Commit 84f6b5c recently changed package-update-steps.ts and its tests around staged global npm update behavior, adjacent to the swap path this PR modifies. (role: recent package-update contributor; confidence: medium; commits: 84f6b5c7f8de; files: src/infra/package-update-steps.ts, src/infra/package-update-steps.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 679a46d01e65.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Brave Review Wisp

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: keeps receipts.
Image traits: location workflow harbor; accessory tiny test log scroll; palette moonlit blue and soft silver; mood sleepy but ready; pose pointing at a small proof artifact; shell glossy opal shell; lighting moonlit rim light; background small green status lights.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Brave Review Wisp in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 23, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 23, 2026
@ai-hpc

ai-hpc commented May 23, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 23, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added size: M and removed size: S proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 23, 2026
@ai-hpc

ai-hpc commented May 23, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 23, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@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: 🧂 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. labels May 23, 2026
@steipete steipete self-assigned this May 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026
@steipete
steipete force-pushed the fix/85559-package-hardlink-swaps branch from f0026ba to 8e4c61d Compare May 25, 2026 17:17
@steipete

Copy link
Copy Markdown
Contributor

Verification for maintainer fixup on 8e4c61d:

Behavior addressed: package-manager hardlinks are now an explicit install/swap policy instead of being inferred inside installPackageDir from hasDeps.
Real environment tested: local macOS checkout plus GitHub Actions CI for PR #85569.
Exact steps or command run after this patch:

  • git diff --check origin/main...HEAD
  • pnpm test src/infra/install-package-dir.test.ts src/infra/package-update-steps.test.ts src/infra/replace-file.test.ts src/plugins/install.test.ts
  • env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_REMOTE_RUN pnpm check:changed
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main
  • GitHub CI run 26411998352 on SHA 8e4c61d; failed checks-node-agentic-agents job 77748311652 was rerun as job 77749100478 and passed

Evidence after fix: focused local tests passed; changed checks passed; autoreview reported no accepted/actionable findings; GitHub CI is clean for required/pass lanes with CodeQL neutral and unrelated skipped matrix entries.
Observed result after fix: installPackageDir defaults to rejecting hardlinked sources unless a caller explicitly opts into sourceHardlinks: "package-manager"; package-manager dependency install paths and global update swaps opt in deliberately.
What was not tested: separate live pnpm global update E2E; the PR body covers npm 11 Docker live proof and tests cover shared hardlink swap behavior.

@steipete
steipete merged commit 8061d66 into openclaw:main May 25, 2026
158 of 159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

Auto-update fails on npm 11+/pnpm installs due to hardlink rejection in swap step

2 participants