Repository navigation
fix(update): keep restored npm packages readable by non-root services - #193272
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Tests +38, Docs +2, Other +2. Total +44 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment 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]>
…#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]>
…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]>
…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
…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
…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)
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
0o077rule 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 targetc84048f70d1deea59736c030584708e38ea57b10, 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 --versionexited 1, and an actual systemd restart endedActiveState=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
b99ed97b8f8fwithpnpm build:packageand 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, andUser=openclaw; no product tracing or permission intervention.openclaw update --tag /inputs/target.tgz --yes --json --timeout 600staged and swapped successfully, then returneddoctor-failedbecause the existing Gateway lease prevented post-activation maintenance.package-rollbackexited 0 and restored 2026.10.10.runuser -u openclaw -- node .../openclaw.mjs --versionexited 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.stat -c '%a %U:%G %n'at the package boundaries:/usr/local/lib/node_modules/openclaw.dist/openclaw.mjsnode_modules/dist/index.jsThe 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
0facc928run, the branch baseb99ed97brun, 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 beforeb99ed97b8f8f(#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 (1db0343a0c0dandc6a601f68e74) leave 29. Earlier notable unallocated growth was +19 inf594cf68afaa, +20 ine747944b4722, +4 incc51325e10fa, +13 in75c3b134cbea, and +1 in8880686545b6, 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
b753bbe38a118c28906ce5b7cacc773946878510preserves the original PR ancestry and integrates tested main baseline4947e40db109a28c1fbdcf692eb431db19d46720. 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.