Skip to content

fix(update): keep restored npm packages readable by non-root services - #193272

Merged
RomneyDa merged 3 commits into
mainfrom
fix/retained-package-readable
Nov 12, 2026
Merged

RomneyDa merged 3 commits into
mainfrom
fix/retained-package-readable

Conversation

@obviyus

@obviyus obviyus commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #175423, #175449, #170032. cc @steipete for information.

What Problem This Solves

Fixes: a failed update makes a root-owned global npm installation unreadable to a non-root systemd service, preventing the old version from starting after rollback.

User Impact

Rollback preserves npm package read/execute permissions (0755 directories and executables, 0644 regular files), so a service running as another OS user can still launch the restored package. Private activation anchors, controls, helpers, and journals remain owner-only. This does not change service lifecycle or state ownership.

Why This Change Was Made

#175423 targeted private activation objects affected by recursive POSIX ACLs. #175449 extended permission repair to retained package trees; its body explicitly notes that the copy path preserves npm's original public modes. The #170032 diagnosis also explicitly preserves another account's read access to the installed package. Applying the private-object 0o077 rule to package content turned normal 0755/0644 npm files into 0700/0600.

The integrity owner now repairs only group/other WRITE (0o022), including write grants controlled by POSIX ACL masks, preserving read/execute. Package fingerprint encoding and historical receipt matching are unchanged: permission-only drift still permits recovery; changed bytes, identity, ownership, owner permissions, and symlink targets still refuse it. The existing no-follow, descriptor-checked repair and private-object permission rule are unchanged. Old full-mode-only receipts retain their existing compatibility behavior.

Evidence

  • Focused retain → restore regression is red with main's original permission policy: observed [0700,0700,0600,0700] instead of [0755,0755,0644,0755] on the retained package. It passes with this fix (846 ms test time).

  • Focused permission/publication/private-object tests: 16 passed, one Linux ACL test platform-skipped on macOS (19 unrelated boundary cases deselected). Private anchors/controls repair to 0700; journals/helpers to 0600. Includes write-only drift, shared-inode deduplication, old public-mode receipts, changed-content refusal, and filesystem-repair warnings. Wrapper wall time 36.34 s, mostly existing worker preparation; CI seconds not yet available.

  • Targeted oxfmt and oxlint passed. Test growth is 38 lines, allocated for the retain/restore regression and revised write-only permission assertions. Production growth is two lines; no new permission owner or repair path.

  • Initial CI found one stale legacy-consumer expectation that ordinary public package modes emit a repair warning. That expectation is corrected; its focused three-case link-count run passed (213 ms test time; 46.72 s wrapper wall time including compilation).

  • Retained real-systemd baseline: main predecessor d755a99495e79c0b98ae1ad612511889097b259f → frozen target c84048f70d1deea59736c030584708e38ea57b10, root-owned global npm install, umask 022, User=openclaw. Natural post-activation Doctor failure rolled back the old package; all five sampled objects changed 755 → 700 root:root. runuser -u openclaw -- node .../openclaw.mjs --version exited 1, and an actual systemd restart ended ActiveState=failed, MainPID=0, Result=exit-code, /readyz=false. This is retained production-path evidence, not a new execution of today's main.

  • Fixed real-systemd run: built this branch's fixed source on main base b99ed97b8f8f with pnpm build:package and the canonical self-contained Docker packer through pueue. The build began before the commit, so embedded build metadata names that base; the source is the production patch in this PR. Package SHA-256: 521332c51f5c51e9b14ab08c4665bbe2de5b9ba02964792fb653ea1b74351d9e. Reused the same frozen target and existing systemd harness, umask 022, a root-owned global install, and User=openclaw; no product tracing or permission intervention.

    • A real openclaw update --tag /inputs/target.tgz --yes --json --timeout 600 staged and swapped successfully, then returned doctor-failed because the existing Gateway lease prevented post-activation maintenance. package-rollback exited 0 and restored 2026.10.10.
    • Post-rollback runuser -u openclaw -- node .../openclaw.mjs --version exited 0. An actual systemd restart became active/running, Result=success, /readyz=true. Readiness was false before that explicit restart: this proves restartability, not a service-lifecycle fix or automatic recovery.
    • One task-owned container ran, then was removed. No daemon restart or unrelated container changes.

stat -c '%a %U:%G %n' at the package boundaries:

Object under /usr/local/lib/node_modules/openclaw Main predecessor: before → rollback Fixed source: before → rollback
. 755 → 700 root:root 755 → 755 root:root
dist/ 755 → 700 root:root 755 → 755 root:root
openclaw.mjs 755 → 700 root:root 755 → 755 root:root
node_modules/ 755 → 700 root:root 755 → 755 root:root
dist/index.js 755 → 700 root:root 755 → 755 root:root

The retained main baseline failed later at Client credential directory is unsafe; today's fixed-source run refused the still-live owner lease earlier in Doctor. Both executed real publication and successful package rollback. These are intentionally not claims that the lifecycle/ownership defects are fixed here.

CI baseline limitation

The initial exact-head CI run failed its test-lines ratchet: total 6,481,936, ceiling 6,481,907, net +42. The PR allocated precisely those 42 lines; removing the PR delta and allocation gives base total 6,481,894 versus base ceiling 6,481,865, an inherited 29-line deficit. The corrected consumer test reduces this PR's net growth and allocation together to +38; it does not pay unrelated baseline debt or raise the shared scalar.

Main's ratchet job is skipped, not proven passing or failing: the exact CI base 0facc928 run, the branch base b99ed97b run, and the newer completed main run. No main failure is claimed from those skipped jobs.

History since the last scalar update (94bea34ae991) reconciles to +29 unallocated lines, rather than one +29 commit. Immediately before b99ed97b8f8f (#190721) the net deficit was 5; that commit added 26 test lines with no allocation, bringing it to 31. Two subsequent one-line test reductions (1db0343a0c0d and c6a601f68e74) leave 29. Earlier notable unallocated growth was +19 in f594cf68afaa, +20 in e747944b4722, +4 in cc51325e10fa, +13 in 75c3b134cbea, and +1 in 8880686545b6, partly offset by other test reductions. This is an unresolved baseline issue, not a permission-fix failure.

Two-way code door: reverting restores the old repair policy; no receipt schema or package fingerprint migration. Blast radius: retained/restored npm package content permissions during update recovery; private recovery objects retain their strict permissions. Existing packages already stripped to owner-only are not reconstructed from a fingerprint that does not record their original r/x bits.

November 12 publication follow-up

Head b753bbe38a118c28906ce5b7cacc773946878510 preserves the original PR ancestry and integrates tested main baseline 4947e40db109a28c1fbdcf692eb431db19d46720. Its complete tree exactly matches that baseline plus the prepared, independently reviewed permission patch. The existing 38-line allocation is retained; no credit was added for the 29-line debt inherited by the earlier CI merge tree. The shared scalar is unchanged.

The prepared catalog/permissions validation ran in secretless rootless Podman: 229 focused tests passed (190 catalog equivalence, 2 installed-assets/sealed-worker, 37 rollback), plus the wrapper-inventory regression. The retained/restored package-mode assertion failed on the baseline and passed with the repair. Scoped types, lint, format, generation, and ratchet passed. These results are reused exact-tree evidence, not a newly executed full updater run. The original real non-root systemd rollback evidence above remains identified with its original execution. Fresh remote CI and any new-head native qualification remain pending.

@clawsweeper

clawsweeper Bot commented Nov 5, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 5, 2026
@obviyus
obviyus marked this pull request as ready for review November 5, 2026 07:14
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves npm package read/execute permissions during recovery while continuing to remove group/other write access.

Example: A root-owned global npm installation rolls back after Doctor fails, and its systemd service runs as User=openclaw.

  • Before: Package directories become 0700 and ordinary files become 0600, preventing the service account from launching the restored package.
  • After: Existing 0755 directories and executables and 0644 files retain their permissions, allowing the service to restart.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported fix with production rollback evidence and useful regression coverage; broad validation remains limited by the unresolved required ratchet gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied fixed-source systemd run exercises the real update CLI, publication, Doctor failure, and rollback on a root-owned npm installation with User=openclaw; preserved permissions allow the service account to launch the restored 2026.10.10 package and an explicit restart reaches readiness.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After rollback, a non-root service cannot read or execute the restored root-owned npm package.
Reason: The collaborator-authored direction restores an established installation contract with a narrow policy correction; reconstructing permissions already stripped by older updates is explicitly outside its scope.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a source-confirmed rollback regression still present on main, with no introduced correctness defect found; the required test-line CI gate remains unresolved.

Priority: P1
Reviewed head: 919cb61696e76c65759a899bf41897b8d54d5245

Before merge

None.

Findings

None.

Agent review details

How this fits together

The npm publication and recovery owner verifies retained package fingerprints, repairs permissions through a descriptor-checked helper, and restores the package for the service runtime.

flowchart TD
  A[Update CLI] --> B[Package publication owner]
  B --> C[Retained package verification]
  C --> D[Package permission repair]
  D --> E[Rollback restoration]
  E --> F[Non-root service runtime]
Loading

Technical review

Best possible solution:

Keep permission repair in the existing integrity owner, preserve package read/execute bits, and retain the separate owner-only policy for private recovery objects.

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

Current-main repair masks deterministically strip public package permissions, matching the supplied systemd failure trace and reported red-on-base regression; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete prospective fix: change the existing permission policy, retain integrity and no-follow checks, and update the affected consumers without adding another repair path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Retained package permission repair changes intended behavior with a stated reason (4b791ee: Accept recursive ACL permission drift after content verification and tighten retained objects through the existing no-follow helper.)
  • Legacy package receipt matching keeps the original intent (3e83272: Allow historical recovery records to settle after metadata drift while preserving stricter current-record verification.)
  • Existing publication and permission test fixtures keeps the original intent (ab5ec50: Consolidate repeated test scaffolding without changing production behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +2, Tests +38, Docs +2, Other +2. Total +44 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 3 +2
Tests 3 67 29 +38
Docs 1 5 3 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 6 79 35 +44

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +5/-3; tests +67/-29 Two net production lines refine the existing owner; 38 net test lines cover retain/restore permissions and update affected permission and legacy expectations.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A failed npm update can leave a root-owned installation unusable by its non-root service account even after successful package rollback.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 5, 2026, 2:43 AM ET / 07:43 UTC.

Integrate the tested main baseline while preserving the original permission repair, its exact 38-line allocation, and all contributor history. No extra allowance for inherited baseline debt.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
@RomneyDa
RomneyDa merged commit c63b13a into main Nov 12, 2026
121 of 122 checks passed
@RomneyDa
RomneyDa deleted the fix/retained-package-readable branch November 12, 2026 06:53
RomneyDa added a commit that referenced this pull request Nov 12, 2026
…#193272)

Backport source behavior and tests. Adapt recovery documentation context and make legacy public-mode fixtures independent of umask.

(cherry picked from commit c63b13a)

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…openclaw#193272)

* fix(update): preserve npm package readability after rollback

* test(update): preserve public modes without repair warnings

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
fuller-stack-dev added a commit that referenced this pull request Nov 17, 2026
…pdate left behind (#200550)

* fix(update): settle a killed package publication on the next update

An update killed between publishing its journal and installing the new
package left the next `openclaw update` and `openclaw update repair`
refusing with "Package publication is incomplete" until someone ran the
printed recovery command.

Settlement now first brings such a publication to rest with the recovery
that command runs, under a claim in the recorded lease store that proves
the original updater gone, then closes the aborted or published
operation through the existing settlement. It resumes only a journal
this build's own helper was sealed for, never replaces an installed
package, and never resumes under a caller-supplied claim. The update
records what it settled as a package-publication-recovery warning step.

Refusals that remain name their cause and a step that works: a lost
lease store and a changed installation now name the reinstall that
supersedes the operation.

* fix(ci): expect readable package modes in the installed recovery lane

Recovery keeps group/other read and execute access on retained package
contents and clears only write access (#193272). The installed recovery
lane still expected owner-only modes, so its first tree comparison
failed on every entry.

* test(update): keep the replaced launcher's inode distinct

Unlinking a link and creating it again can reuse the freed inode on
Linux, which leaves the launcher's recorded identity unchanged and the
publication legitimately resumable. The control now keeps the old link
under another name, so the new one always has a new identity.

* docs(update): say what repair does with a publication under its own claim
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…pdate left behind (openclaw#200550)

* fix(update): settle a killed package publication on the next update

An update killed between publishing its journal and installing the new
package left the next `openclaw update` and `openclaw update repair`
refusing with "Package publication is incomplete" until someone ran the
printed recovery command.

Settlement now first brings such a publication to rest with the recovery
that command runs, under a claim in the recorded lease store that proves
the original updater gone, then closes the aborted or published
operation through the existing settlement. It resumes only a journal
this build's own helper was sealed for, never replaces an installed
package, and never resumes under a caller-supplied claim. The update
records what it settled as a package-publication-recovery warning step.

Refusals that remain name their cause and a step that works: a lost
lease store and a changed installation now name the reinstall that
supersedes the operation.

* fix(ci): expect readable package modes in the installed recovery lane

Recovery keeps group/other read and execute access on retained package
contents and clears only write access (openclaw#193272). The installed recovery
lane still expected owner-only modes, so its first tree comparison
failed on every entry.

* test(update): keep the replaced launcher's inode distinct

Unlinking a link and creating it again can reuse the freed inode on
Linux, which leaves the launcher's recorded identity unchanged and the
publication legitimately resumable. The control now keeps the old link
under another name, so the new one always has a new identity.

* docs(update): say what repair does with a publication under its own claim
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…pdate left behind (#200550)

* fix(update): settle a killed package publication on the next update

An update killed between publishing its journal and installing the new
package left the next `openclaw update` and `openclaw update repair`
refusing with "Package publication is incomplete" until someone ran the
printed recovery command.

Settlement now first brings such a publication to rest with the recovery
that command runs, under a claim in the recorded lease store that proves
the original updater gone, then closes the aborted or published
operation through the existing settlement. It resumes only a journal
this build's own helper was sealed for, never replaces an installed
package, and never resumes under a caller-supplied claim. The update
records what it settled as a package-publication-recovery warning step.

Refusals that remain name their cause and a step that works: a lost
lease store and a changed installation now name the reinstall that
supersedes the operation.

* fix(ci): expect readable package modes in the installed recovery lane

Recovery keeps group/other read and execute access on retained package
contents and clears only write access (#193272). The installed recovery
lane still expected owner-only modes, so its first tree comparison
failed on every entry.

* test(update): keep the replaced launcher's inode distinct

Unlinking a link and creating it again can reuse the freed inode on
Linux, which leaves the launcher's recorded identity unchanged and the
publication legitimately resumable. The control now keeps the old link
under another name, so the new one always has a new identity.

* docs(update): say what repair does with a publication under its own claim

(cherry picked from commit 0ce9c77)

Release adaptation: none. Companion disposition: update publication, custody, Doctor and best-effort maintenance fixes are ported together in dependency order; #200331 supplies the owed-step owner required by #200507/#200579.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 2dd257b6ce71507101c2563df56ff6662376ace0)
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants