Skip to content

fix(update): shorten package rollback verification - #179797

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1777
Oct 21, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1777

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large npm installations spend one filesystem round trip per entry in the final package-integrity drift sweep. That unnecessarily extends update and rollback verification and can consume the verifier's deadline.

Supersedes #169599, thanks @Tsuki-hash.

User Impact

Package update and rollback verification complete sooner while checking the same entries and producing the same fingerprint. Existing timeouts, resource-error fallback, and integrity refusals remain intact. This improves the installed updater; staging a candidate cannot change the updater already running.

Why This Change Was Made

Batch up to 32 final stat reads inside the existing integrity reader and inspect settled results in traversal order. A later timeout cannot hide an earlier integrity failure. No new exported helper, cache, configuration, dependency, or persistent state is needed. The rollback mutation fixture now targets the entry's own final observation, independent of sibling I/O order.

Runtime production delta: +4 lines (12 added / 8 removed); the small growth preserves deterministic error precedence rather than adding a separate sweep owner. Tests: +74 net lines. Rerunnable benchmark tooling: 77 lines.

Release-note context: faster package update/rollback integrity verification, preserving drift detection and resource fallback; contributor credit for #169599 belongs to @Tsuki-hash (Aaron08140).

Evidence

Acceptance: preserve fingerprints and stat counts, reduce drift-sweep time, and avoid a material full-scan regression. The committed scripts/bench-package-integrity.ts scanned the same synthetic package (2,048 4-KiB files, a symlink and a hardlink) with separately bundled baseline and candidate readers, alternating A/B six times. The first pair is cold; the remaining five pairs are warm. Local macOS APFS, Node 26.12.0.

Warm metric Baseline median / p95 Candidate median / p95
Full scan 93.12 / 103.53 ms 81.75 / 86.15 ms
Final sweep 25.21 / 28.30 ms 10.46 / 11.06 ms
Process CPU 245.66 / 259.56 ms 249.10 / 269.95 ms
Stat calls 4,107 4,107
Peak in-flight stats 1 32

All 12 fingerprints matched. Cold full scan: 109.12 → 87.28 ms. CPU did not improve; process-wide RSS rose during both readers' repeated scans, so this is a latency claim, not a memory improvement claim. This small local fixture does not establish a full real-world upgrade speedup.

  • New slow-storage regression failed on unchanged main with Package rollback verification timed out, then passed after the fix. A second regression preserves earlier drift over a faster later timeout.
  • Focused Node tests: 4 files, 52 passed, 31.80 s wall (3.95 s tests; shared compilation dominated). Focused pinned Bun tests: 4 files, 52 passed, 35.46 s wall (about 4.4 s tests).
  • Real filesystem smoke with isolated HOME/state: swapStagedPackageInstall committed a synthetic staged npm package, then rolled back successfully (exit 0), restoring the original version, exact bytes, and launcher. No filesystem mocks or operator state. A full installed-CLI/Gateway upgrade was not exercised.
  • All 9 additional consumer files passed on Node: 144 tests, including built-runtime handoff, durable publication, migrated finalization, and repair. Total Node proof: 13 files / 196 tests. The consumer command took 362.38 s wall including runtime build and shared compiler preparation; the slowest individual test was 25.03 s. Scoped services and scripts typechecks, touched-file oxlint, and oxfmt pass.
  • Madge: 0 cycles. Independent Codex review: no actionable P0–P2 findings. git diff --check clean.
  • Per the campaign's local gate budget, the full check:changed SQLite inventory is skipped; scoped types/lint/format/tests and Madge substitute, with PR CI owning broad proof.

Commands used an isolated HOME and OPENCLAW_STATE_DIR under .artifacts/:

node scripts/run-vitest.mjs src/infra/package-update-integrity.test.ts src/infra/package-update-swap.bounds.test.ts src/infra/package-update-swap.integrity.test.ts src/infra/package-update-integrity-hasher.test.ts --maxWorkers=1
# Run with OPENCLAW_VITEST_RUNTIME=node, then OPENCLAW_VITEST_RUNTIME=bun.
node --import ./scripts/tsx.mjs scripts/bench-package-integrity.ts .artifacts/baseline.mjs .artifacts/candidate.mjs
# Baseline: e18310f1ba35ab426c8a798b3cf93f363bdd803f; candidate: this PR's head.
# Both bundles use esbuild with platform=node, format=esm, packages=external.
node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts

Additional consumer command:

node scripts/run-vitest.mjs src/infra/package-update-activation-lifetime.test.ts src/infra/package-update-publication-boundary.test.ts src/infra/package-update-publication-legacy.test.ts src/infra/package-update-activation-durability.test.ts src/infra/package-update-publication-durability.test.ts src/cli/update-cli/update-command-migrated.test.ts src/cli/update-cli/update-command-post-core-admission.process.test.ts src/cli/update-cli/update-repair-package-activation.test.ts test/scripts/managed-handoff-build-config.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.services.json --incremental
node scripts/run-tsgo.mjs -p tsconfig.scripts.json --incremental
node scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.core.test.services.json src/infra/package-update-integrity.ts src/infra/package-update-integrity.test.ts src/infra/package-update-swap.bounds.test.ts
node scripts/run-oxlint.mjs --tsconfig tsconfig.scripts.json scripts/bench-package-integrity.ts

Current-main recheck before publication: origin/main at 2a597857a055 has no newer changes to either touched runtime/test owner; #169599 remains open and unmerged.

Batch final package stat reads without changing fingerprint observations or
traversal-order failure precedence. Preserve timeout fallback and prove the
slow-storage deadline, rollback, and real-filesystem scan behavior.

Co-authored-by: Aaron08140 <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 21, 2026 18:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T18:45:22.500540Z ada8e83 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 scripts Repository scripts size: S labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 21, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing despite one red job: checks-ui-e2e (1/2). It fails the Control UI boot-module-boundaries e2e test, which this PR doesn't touch; the PR changes no ui/ files. All non-UI checks are green.

@steipete
steipete merged commit 3fc6f44 into main Oct 21, 2026
197 of 201 checks passed
@steipete
steipete deleted the upd/upd-l1777 branch October 21, 2026 19:26
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
The integrity reader's final drift sweep read files one at a time. It now batches 32 reads while preserving traversal-order errors; fingerprints are identical and measured sweep latency fell 59%. Supersedes openclaw#169599, thanks @Tsuki-hash.

Co-authored-by: Aaron08140 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant