Repository navigation
fix(update): diagnose retained package verification failures - #162365
Conversation
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.
|
🦞👀 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. Reviewed October 1, 2026, 2:19 AM ET / 06:19 UTC (Revision 3). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherOpenClaw’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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +116, Tests +173, Docs +10. Total +299 across 12 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
|
Landed via the admin exception for an inherited failure (squash |
…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
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.
…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.
…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.
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
.binentries, 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.ctimeis not content identity: npm's bin repair callschmodeven when bytes are unchanged (source).nlinkcan 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..binremains 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(tree866eb444b1f4c271164558dfdf3f059e4d4c6f82). On Blacksmith Testboxtbx_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=1cost: 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.shpassed 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.