Skip to content

fix(update): ignore permission-only drift in retained package trees - #175449

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1670
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1670

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #170032

What Problem This Solves

Recovery rejects an otherwise unchanged private retained package after recursive ACL or chmod changes widen its group/other mode bits, reporting Package publication object changed.

User Impact

Recovery accepts permission-only drift, tightens the verified owned files and directories through the existing no-follow repair helper, and emits one aggregated warning. Permission-denied or read-only-filesystem failures while tightening become warnings; changed contents, identity, ownership, owner permissions, or symlink targets still refuse recovery.

Why This Change Was Made

The integrity owner masks group/other bits in the retained-tree digest while keeping raw observations for file hashing and within-read stability. Publication and copy/recovery comparisons share one compatibility helper. No receipt fields, receipt format, schema, or link-count policy changes.

The copy path preserves npm's original modes, so old receipts can contain public-mode trees. Those receipts may match their original full-mode digest; their modes are preserved with a warning so the unchanged receipt remains usable on the next recovery attempt. Symlinks keep their platform mode and are never followed by permission repair.

Evidence

  • Regression against the pre-fix encoding: permission-only drift failed with Package publication object changed; unchanged public-mode receipts and the other controls passed (1 failed, 5 passed; 31.24 s wrapper time, dominated by compilation).
  • Local focused tests: 3 files, 20 passed and 1 Linux-only skip; 36.13 s wrapper time. Includes the real publication recovery owner, no-follow repair, pre-fix receipt compatibility, content/owner-mode/inode/link-target refusal, and read-only-filesystem warnings.
  • Linux live filesystem proof: setfacl -R -m u:65534:rX on an isolated retained tree; production publication-tree verification succeeded, all four file/directory modes returned to owner-only, ACL masks became ---, and exactly one warning was recorded. 8 tests passed; 22.98 s wrapper time. Blacksmith Testbox lease tbx_01m54qvb7z6kga8axvfny2g6h6, run, stopped after proof. The source-only sync initially lacked dependencies; installing the frozen lockfile in that same isolated lease resolved the setup failure.
  • Targeted TypeScript check passed; Madge reported 0 cycles. The lint wrapper waited on its own nested artifact lock, so only its owned processes were stopped and direct oxlint was used.
  • All 32 directly importing sibling files were exercised (existing platform skips unchanged), plus the remount suite. After the fixture/oracle corrections, the targeted rerun passed 146 tests in 11 files (466.13 s wrapper time); the additional remount suite passed all 37 tests (89.29 s wrapper time).
  • The full check:changed SQLite inventory was omitted under the campaign's local time-budget rule; PR CI provides broad proof.
  • Final isolated Codex review: no actionable P0–P2 findings.
  • The sibling run found and fixed a stale full-mode digest oracle and a historical-fixture bug under the Bun runner: the frozen Node helper hash did not include Bun's per-install SQLite-library header. Those historical fixtures now explicitly select Node; ordinary Bun coverage remains unchanged. All 39 affected infra tests pass after the correction.
  • Existing slow proof: managed-handoff-build-config.test.ts / loads the staged production package runtime without neighboring assets took 38.36 s. It builds/stages an isolated production helper and exercises two recovery generations through repeated real child commands; retained under the campaign's pre-existing-slow-proof allowance. Initial shared runtime preparation took 84.6 s separately from test time.

Production delta: +146/-34 lines. Tests and test helpers: +183/-8 lines. Documentation: +9 lines. The existing activation permission repair is shared, with no second chmod path.

Mask group/other bits for private retained-tree fingerprints, then tighten
verified owned objects through the shared no-follow permission repair.
Preserve full-mode historical receipts without changing their persisted shape.

Cover pre-fix receipts, recursive POSIX ACLs, recovery, and strict content and
owner-mode refusals. Pin frozen legacy-helper fixtures to their Node runtime.

Fixes #170032
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review October 17, 2026 11:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T11:11:32.929469Z 899eb02 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Oct 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 899eb02eaf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to +67
for (const { file, stat } of entries) {
assertCurrent();
try {
repairPackagePermissions(file, stat, Number(stat.mode & 0o7700n));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Deduplicate permission repairs for hard-linked files

When two paths in the retained tree reference the same widened hard-linked inode, both observations enter permissionRepairs; repairing the first path changes that inode's mode and ctime, so the second call compares against its stale stat and throws object changed before permission repair. Because that custom error is not among the tolerated filesystem errors, recovery fails instead of ignoring permission-only drift. Deduplicate repairs by device/inode or recognize an already-repaired alias.

Useful? React with 👍 / 👎.

Comment on lines +144 to +146
if (
!("digest" in expectedTree) ||
!packageIntegrityMatches({ ...expectedTree, identity: installedIdentity }, tree)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tighten permissions before settling remounted recovery

For a non-legacy operation recovered through the remount settlement path, packageIntegrityMatches now accepts widened group/other mode bits, but this path never calls repairPackageIntegrityPermissions. The operation can therefore be durably settled and its recovery custody archived while the installed package or retained previous tree remains accessible through the widened permissions, unlike the ordinary publication matcher path that tightens them. The mutating settlement path should repair or explicitly report failed repairs before committing settlement; dry-run can remain read-only.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 4b791ee into main Oct 17, 2026
198 of 199 checks passed
@steipete
steipete deleted the upd/upd-l1670 branch October 17, 2026 11:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…penclaw#175449)

After a recursive setfacl (e.g. granting a second account read access to ~/.npm-global), files inside the updater's private retained package trees carried an ACL mask in their group bits, and recovery refused with 'Package publication object changed' even though identity and content matched; only 'openclaw update repair' recovered. Integrity verification of private retained trees now ignores group/other permission bits (content, type, identity, ownership, owner bits and symlink targets still must match; legacy full-mode receipts still need an exact digest match), and verified objects with widened bits are tightened back through the shared no-follow repair helper with one aggregated warning. No receipt format change.

Fixes openclaw#170032
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node4 npm-global update blocked: unsafe publication-recovery permissions and retained lease database identity refusal

1 participant