Skip to content

fix(update): diagnose retained package verification failures - #162365

Merged
steipete merged 2 commits into
mainfrom
upd/upd-rollback-verify-npm-bookkeeping
Oct 1, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-rollback-verify-npm-bookkeeping

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Refs #162063

What Problem This Solves

Managed npm updates can refuse rollback with a package-tree mismatch that does not identify the changed entry. The reporter's original 2026.9.4 failure remains unexplained; this change does not claim to reproduce or close it.

User Impact

The installed updater compares retained file hashes and reports up to five changed relative entries and field names in failure facts and the sanitized report. npm's regular hidden lockfile cache and non-content link-count/change-time drift no longer invalidate an otherwise identical retained tree. JavaScript changes, inode replacement, permissions, ownership, executable .bin entries, and symlink changes remain strict.

This belongs to the installed driver: an old updater cannot gain the verifier from the candidate during its first swap. Entry diagnostics survive the original process's journaled activation and rollback; standalone recovery after a process restart retains its compact saved digest and cannot reconstruct entry observations. Recovery continues to use the recorded original sealed helper, preserving the fingerprint interpretation for older recovery records. No SQLite schema, dependency, CLI option, or config option changes.

Why This Change Was Made

The package-integrity reader already hashes bytes, but it also included incidental inode metadata and discarded all entry observations. Keep bounded in-process observations at that owner, propagate mismatch facts through both swap paths, and allow only their bounded relative-path/closed-field format through public report redaction. Full within-scan race checks remain enabled, including rechecking an ignored cache entry's type.

The only path excluded is a regular node_modules/.package-lock.json, including nested dependency trees. npm documents it as a disposable derived cache and recommends deleting it after manual edits (npm 11.19 docs); its writer also deletes it on cache-write failure (source). Parent directory size/timestamps can change during that replacement, while inventory, inode identity, modes, and owners remain verified. File size, mtime, inode identity, and SHA-256 remain verified.

ctime is not content identity: npm's bin repair calls chmod even when bytes are unchanged (source). nlink can change when another link to a package-store inode is removed; pnpm documents this storage layout (docs). Retained inode identities still protect the in-tree hardlink relationships. .bin remains runtime content (npm folders).

npm 11.19 explicitly does not save the hidden lockfile during a global install (source), so cache exclusion is not evidence of the reporter's cause. Thanks @nessim-liamani for the detailed reproduction evidence.

Evidence

Original-code controls on Linux: cache rewrite, cache removal, and external hardlink-count change all fail with the old retained-tree refusal (3 expected failures). The candidate preserves the requested rejection of changed JavaScript and diagnoses its path/fields through the real swap and public-report boundary.

Final integrated head: 46a212ec573a35318ca4ec6aff9299592c96207c (tree 866eb444b1f4c271164558dfdf3f059e4d4c6f82). On Blacksmith Testbox tbx_01m3txtp14mxf87s91wxh4kjaz, node scripts/check-changed.mjs --base 9680e57a9631b6a7060b9d4642bffb9f9fbc3000 -- <changed files> passed in 1,425 s, including core and all core-test type graphs, lint, schema guards, and import-cycle checks. Ten focused owner suites passed three times (262 tests each; 43/42/44 s wall). The seven new regression cases totaled 286 ms in the first prepared-host run.

All 43 import-dependent files passed (1,008 tests, 10 shards, 817 s including shared E2E preparation). The shared runtime build took 513 s; the longest individual test took 20.325 s and the largest file total was 108.187 s of test time. No test crossed the lane’s slow-test thresholds in this final Testbox run. The seven new cases cover bookkeeping acceptance, changed-content refusal, a cache entry replaced during scanning, bounded journaled diagnostics, and public reporting; the redaction suite covers private scopes, traversal, and arbitrary prose.

Measured local pnpm test <file> --maxWorkers=1 cost: the new diagnostics file passed 7 tests in 333.75 s wall / 44.43 s test time on the loaded Mac; shared compiler/transform preparation dominated, and the journal case exercises real filesystem and ownership transitions. The redaction file passed 41 tests in 20.81 s wall / about 3.8 s test time. Linux focused runs provide the lower-cost prepared-host measurement above. CI timings are not yet available.

Fresh independent direct-route Codex P1 review: scoped clean, no accepted/actionable findings. Production +175/-59 lines, tests +173/-0, docs +11/-1. Growth is the bounded in-process entry observations and failure-fact/report propagation. An actual merge conflict was resolved by adopting main’s package-swap target owner, preserving its Windows retries and recovery warnings, and combining the pre-compensation integrity checks. No suppressions or baseline changes.

The candidate built and passed package-tarball integrity checks in 446 s. SHA-256: 68f96035fe5bf2aae360b8cf71f2f86287b410da1cc8a0ea988cf1a86d8eabab. The UI build reported a startup CSS advisory (50,674 B gzip versus the 46,080 B target, below the 51,200 B hard ceiling); build/pack exited 0, and this PR changes no UI code. The Linux upgrade image verifies npm 11.19.0.

Published-driver × candidate proof through scripts/e2e/upgrade-survivor-docker.sh passed with npm 11.19.0: 2026.9.4 → 2026.9.7 candidate in 250 s, and 2026.9.6 → the same candidate in 324 s. Both completed the swap, installed-package identity checks, automatic migration/Doctor assertions, seeded-state survival, and isolated Gateway health/readiness. The combined final-head Testbox command exited 0 (3,467 s).

The live cells use the isolated stopped-Gateway/manual restart path, not native systemd-user service proof. The installed drivers are unpatched: their success proves candidate compatibility; the real swap regressions exercise the new verifier. The original-head cells already passed, but the refreshed results above are for the integrated head.

An earlier lease ended with transport exit 255; the unfinished proof passed on a fresh lease. ClawSweeper found no code defects on the original head; its remaining items were conflict integration, validation, and marking ready. No PR CI reruns were requested.

Final-head Testbox provisioning run. Testbox command results, rather than the provisioning run’s eventual cleanup/cancellation state, establish the proof. Crabbox reported an external runner-portal sync timeout after the command succeeded; this was telemetry, and the completion receipt recorded exit 0 with the exact source tree. Auto-merge is off.

Refs #162063. Preserve strict file hashes and ownership while excluding npm hidden-lockfile cache bytes and incidental link-count/change-time drift. Carry bounded entry diagnostics through rollback and public reporting without changing durable journal fingerprints.
@clawsweeper

clawsweeper Bot commented Oct 1, 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: M labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 2:19 AM ET / 06:19 UTC (Revision 3).

ClawSweeper review

What this changes

The updater reports bounded package-entry differences during failed rollback and tolerates disposable npm cache changes and incidental metadata drift while preserving content checks.

Merge readiness

✅ Ready for maintainer review

This remains useful work absent from current main and the latest release. The prior draft blocker is resolved, and no blocking introduced defect was found; the original reporter’s failure remains unexplained.

Priority: P2
Reviewed head: 46a212ec573a35318ca4ec6aff9299592c96207c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, sound patch with relevant boundary coverage and recorded upgrade proof; no material contributor follow-up remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Recorded final-head Linux published-driver upgrade cells exercise real package activation, state survival, Doctor, and Gateway readiness; filesystem fault cases cover the changed verifier and report boundary. Native systemd service behavior and the original host’s cause are not claimed. Journal shape is unchanged, and older records retain their original sealed helper, preserving existing-state compatibility.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded final-head Linux published-driver upgrade cells exercise real package activation, state survival, Doctor, and Gateway readiness; filesystem fault cases cover the changed verifier and report boundary. Native systemd service behavior and the original host’s cause are not claimed. Journal shape is unchanged, and older records retain their original sealed helper, preserving existing-state compatibility.
Evidence reviewed 10 items Pinned introduced change: Reviewed the merge-base-to-head delta at the supplied identities. The stale test merge was not used to infer removal of current-main behavior.
Integrity boundary: Only regular hidden npm lockfiles are excluded. Retained entries still include inode identity, modes, ownership, file size/mtime, hashes, and symlink targets; all observed entries, including excluded cache files, undergo strict within-scan rechecks.
Public redaction: Existing secret/path redaction runs before the new allowlist, which accepts bounded relative paths and closed field names and rejects traversal, private scopes, absolute paths, and arbitrary prose.
Findings None None.
Security None None.

How this fits together

OpenClaw’s package updater retains the previous installation while activating a candidate. Its integrity reader determines whether rollback material is unchanged, and its reporting layer turns failures into sanitized diagnostics.

flowchart TD
  A[Installed package] --> C[Integrity baseline]
  B[Candidate package] --> D[Package activation]
  C --> E[Rollback verification]
  D --> E
  E --> F[Restore verified package]
  E --> G[Retain changed recovery material]
  G --> H[Sanitized failure report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +116, Tests +173, Docs +10. Total +299 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 9 175 59 +116
Tests 2 173 0 +173
Docs 1 11 1 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 359 60 +299

Review metrics

Metric Value Why it matters
Diagnostic bounds 5 differing entries; 90 characters per path; 0 new journal fields The added detail remains bounded and does not expand durable recovery records.
Production versus test growth production +175/-59; tests +173/-0 Production growth is justified by entry observations and failure propagation within the existing integrity and reporting owners.

Technical review

Best possible solution:

Keep rollback strict for changed runtime content while providing bounded, sanitized explanations and preserving each recovery record’s original helper.

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

Yes for the narrow bookkeeping refusal: current source includes hidden-cache bytes and incidental metadata in the retained digest, and the PR records original-code failure controls. The linked host’s original failure has not been reproduced.

Is this the best way to solve the issue?

Yes. The patch extends the existing integrity and reporting owners, keeps runtime content strict, and avoids adding durable diagnostic state or configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Recorded final-head Linux published-driver upgrade cells exercise real package activation, state survival, Doctor, and Gateway readiness; filesystem fault cases cover the changed verifier and report boundary. Native systemd service behavior and the original host’s cause are not claimed. Journal shape is unchanged, and older records retain their original sealed helper, preserving existing-state compatibility.

Label justifications:

  • P2: This improves rollback reliability and diagnosis without claiming to repair the linked host’s unresolved update blocker.
  • 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 (live_output): Recorded final-head Linux published-driver upgrade cells exercise real package activation, state survival, Doctor, and Gateway readiness; filesystem fault cases cover the changed verifier and report boundary. Native systemd service behavior and the original host’s cause are not claimed. Journal shape is unchanged, and older records retain their original sealed helper, preserving existing-state compatibility.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded final-head Linux published-driver upgrade cells exercise real package activation, state survival, Doctor, and Gateway readiness; filesystem fault cases cover the changed verifier and report boundary. Native systemd service behavior and the original host’s cause are not claimed. Journal shape is unchanged, and older records retain their original sealed helper, preserving existing-state compatibility.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head delta at the supplied identities. The stale test merge was not used to infer removal of current-main behavior. (src/infra/package-update-integrity.ts:21, 46a212ec573a)
  • Integrity boundary: Only regular hidden npm lockfiles are excluded. Retained entries still include inode identity, modes, ownership, file size/mtime, hashes, and symlink targets; all observed entries, including excluded cache files, undergo strict within-scan rechecks. (src/infra/package-update-integrity.ts:317, 46a212ec573a)
  • Public redaction: Existing secret/path redaction runs before the new allowlist, which accepts bounded relative paths and closed field names and rejects traversal, private scopes, absolute paths, and arbitrary prose. (src/logging/diagnostic-support-redaction.ts:455, 46a212ec573a)
  • Recovery compatibility: Entry observations remain in a WeakMap rather than serialized journal fields. Recovery commands use the recorded sealed helper, whose identity and digest are checked before recovery, preserving older fingerprint interpretation. (src/infra/package-update-activation-sealed.ts:53, 46a212ec573a)
  • After-fix and upgrade evidence: The captured PR body identifies final head 46a212e and reports Linux npm 11.19.0 published-driver cells from 2026.9.4 and 2026.9.6 completing swap, migration/Doctor assertions, seeded-state survival, and Gateway readiness in 250 and 324 seconds. Real-filesystem swap regressions cover cache acceptance, content rejection, bounded journaled diagnostics, and public reporting. These observations establish scoped compatibility, not reproduction of the reporter’s original cause; this review executed no tests. (src/infra/package-update-swap.diagnostics.test.ts:15, 46a212ec573a)
  • Dependency contract: The cache exclusion explicitly depends on npm’s hidden-lockfile contract. Inspected npm 11.19.0 documentation describing the cache and recommending deletion after manual edits, plus its writer’s removal on cache-write failure and its global-install comment that no hidden lockfile is saved. The verified tag points to bfacd33ccbcd908480610703b60455d2da5b57a9. (docs/lib/content/configuring-npm/package-lock-json.md:37, bfacd33ccbcd)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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 (2 earlier review cycles)
  • reviewed 2026-10-01T04:04:51.471Z sha 62bbd5e :: blocked before merge. :: none
  • reviewed 2026-10-01T06:08:33.049Z sha 46a212e :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 1, 2026
@steipete
steipete marked this pull request as ready for review October 1, 2026 06:13
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 46a212ec573a35318ca4ec6aff9299592c96207c
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/logging/diagnostic-support-redaction.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 1, 2026
@steipete
steipete merged commit 5cf24af into main Oct 1, 2026
234 of 306 checks passed
@steipete

steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed via the admin exception for an inherited failure (squash 5cf24affb0c1c78e400426490c03956f21649f12, head 46a212ec573a). Only red: checks-ui-e2e (4/9) (ui/src/e2e/session-management.group-defaults.e2e.test.ts ), a comment-UI e2e first sighting the CI-status session is watching; this PR touches only package-update integrity. Remaining jobs were fail-fast cancellations. Lead review scoped-clean (0.87); no CI re-spent.

@steipete
steipete deleted the upd/upd-rollback-verify-npm-bookkeeping branch October 1, 2026 06:35
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…lback verification (openclaw#162365)

The rollback verifier compared an exact per-entry metadata digest over the whole retained package tree and failed with the bare "retained package tree changed" for any drift, including a missing baseline, without saying which entry or field differed, so a host that always failed at the global install swap could not be diagnosed. The package-integrity owner now reports up to five changed entries with their differing fields in the failure fact and the update report, tolerates proven npm bookkeeping and incidental metadata changes while keeping SHA-256 content checks for non-cache files, inode identity, permissions, ownership and symlink targets for both retained and restored trees.

Refs openclaw#162063
steipete added a commit that referenced this pull request Oct 2, 2026
Published updaters 2026.9.3 through 2026.9.7 add every regular file's
bytes to the 1 GiB rollback-verification cap, including npm's hidden
node_modules/.package-lock.json. Only main (#162365, unreleased) skips
those bytes, and the guard had copied main's more lenient rule, so it
could pass a tree that every shipped updater refuses. Count every
regular file so the guard never undercounts relative to any shipped
driver. Entry counting is identical across all shipped tags.

Real global installs write no hidden lockfiles: published 2026.9.7
still measures 44,098 entries / 630.3 MiB, matching an all-files find.
steipete added a commit that referenced this pull request Oct 2, 2026
…grows shipped updaters (#163612)

* ci(release): guard installed package tree against shipped updater caps

Published updaters (2026.9.7 and current main) fingerprint the whole
npm-installed package tree with createPackageIntegrityReader().tree(),
capped at 50,000 entries (root included) and 1 GiB. The staged-candidate
walk in preparePackageActivation does not tolerate the limit error, and
installed updaters cannot be patched, so a candidate whose installed tree
crosses the cap cannot be installed by those drivers. The tarball check
only sees the ~13.9k tarball entries, not the installed dependency tree.

Package Acceptance's npm_12_install_sh job already installs the exact
candidate globally; a new step measures that install with the reader's
counting rules (root plus every dirent, no symlink following, regular-file
bytes excluding npm's hidden lockfile) and fails above 47,500 entries or
900 MiB, while every shipped updater can still install the candidate.
It runs wherever Package Acceptance runs (release checks, the 3-hourly
main Full Release Validation, weekly Update Migration) at the cost of one
directory walk; no new job or install.

Measured: main candidate 44,074 entries / 562.0 MiB; published 2026.9.7
44,098 / 630.3 MiB, both matching an independent find oracle. The real
reader accepts a 50,000-entry tree the guard counts as 50,000 and refuses
the 50,001-entry tree.

* fix(release): charge hidden lockfile bytes like published updaters

Published updaters 2026.9.3 through 2026.9.7 add every regular file's
bytes to the 1 GiB rollback-verification cap, including npm's hidden
node_modules/.package-lock.json. Only main (#162365, unreleased) skips
those bytes, and the guard had copied main's more lenient rule, so it
could pass a tree that every shipped updater refuses. Count every
regular file so the guard never undercounts relative to any shipped
driver. Entry counting is identical across all shipped tags.

Real global installs write no hidden lockfiles: published 2026.9.7
still measures 44,098 entries / 630.3 MiB, matching an all-files find.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…grows shipped updaters (openclaw#163612)

* ci(release): guard installed package tree against shipped updater caps

Published updaters (2026.9.7 and current main) fingerprint the whole
npm-installed package tree with createPackageIntegrityReader().tree(),
capped at 50,000 entries (root included) and 1 GiB. The staged-candidate
walk in preparePackageActivation does not tolerate the limit error, and
installed updaters cannot be patched, so a candidate whose installed tree
crosses the cap cannot be installed by those drivers. The tarball check
only sees the ~13.9k tarball entries, not the installed dependency tree.

Package Acceptance's npm_12_install_sh job already installs the exact
candidate globally; a new step measures that install with the reader's
counting rules (root plus every dirent, no symlink following, regular-file
bytes excluding npm's hidden lockfile) and fails above 47,500 entries or
900 MiB, while every shipped updater can still install the candidate.
It runs wherever Package Acceptance runs (release checks, the 3-hourly
main Full Release Validation, weekly Update Migration) at the cost of one
directory walk; no new job or install.

Measured: main candidate 44,074 entries / 562.0 MiB; published 2026.9.7
44,098 / 630.3 MiB, both matching an independent find oracle. The real
reader accepts a 50,000-entry tree the guard counts as 50,000 and refuses
the 50,001-entry tree.

* fix(release): charge hidden lockfile bytes like published updaters

Published updaters 2026.9.3 through 2026.9.7 add every regular file's
bytes to the 1 GiB rollback-verification cap, including npm's hidden
node_modules/.package-lock.json. Only main (openclaw#162365, unreleased) skips
those bytes, and the guard had copied main's more lenient rule, so it
could pass a tree that every shipped updater refuses. Count every
regular file so the guard never undercounts relative to any shipped
driver. Entry counting is identical across all shipped tags.

Real global installs write no hidden lockfiles: published 2026.9.7
still measures 44,098 entries / 630.3 MiB, matching an all-files find.
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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.

1 participant