Skip to content

fix(update): reduce slow prevalidation for large plugin trees - #166317

Merged
hannesrudolph merged 2 commits into
mainfrom
fix/update-validation-copy-20261006
Oct 7, 2026
Merged

hannesrudolph merged 2 commits into
mainfrom
fix/update-validation-copy-20261006

Conversation

@hannesrudolph

@hannesrudolph hannesrudolph commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes prolonged update prevalidation when configured plugin paths refer to the installed bundled plugins or large dependency trees.

User Impact

Updates can prepare and validate their private candidate state substantially faster without skipping database snapshots, integrity checks, plugin checks, or test startup. In one local, production-shaped rehearsal, complete prevalidation including cleanup fell from 12m49s to 5m42s (55% less time).

The full improvement requires both the updated installed driver and candidate worker. Older driver/worker combinations remain compatible but can retain the previous copying and progress-probe overhead. This does not change configuration, schemas, or live-state activation behavior.

Why This Change Was Made

  • Capture the serving updater's actual bundled-plugin selection before entering the staged worker. Validate its package ownership and containment before matching candidate entries, instead of rediscovering the candidate itself as the source and copying the old installation unnecessarily.
  • Send opt-in, throttled receipts for completed filesystem work to the existing I/O watchdog. Keep quiet-period probes, deadlines, diagnostic limits, and legacy-worker behavior; do not write a ledger entry for every file.
  • Run large guarded file-copy phases through the existing four-worker pool, retaining the parent's original destination identity, source fingerprints, byte hashes, create-only publication, native-operation fencing, and stop/drain/join ordering.

Evidence

Rebased-head verification (2026-10-07)

The candidate was rebased onto eb1b48c58b61dec3cc273587d44e4f9a7eaa29f9 as 9c985fa8888558925e31f98a8dfe1514d9d38ce4. The only conflict was additive diagnostics tests; both main's signal-error cases and this PR's progress cases were retained.

  • Native macOS 27.0 arm64, Node 26.7.0: published updater → candidate PASS. The unmodified npm 2026.9.8 updater (published build fc23bc864e45) ran update --yes --no-restart --tag <candidate.tgz> --json in an isolated installation with synthetic state: exit 0, status ok, 503.442 s wall time.
  • An ordinary custom plugin verified 1,024 payload files / 256 MiB, every payload hash, a read-only 0444 file, and a relative symlink from its actual private-canary root. The canary was removed afterward. Explicit installed bundled llm-task and the custom plugin loaded before and after; post-ready health reported no plugin errors. The running candidate's WebSocket hello attested the exact rebased build, and a regular synthetic chat's ID and complete message array were preserved.
  • Native snapshot 2.117 s; candidate startup 15.177 s. These are synthetic-cell observations, not a comparison against the original production-shaped benchmark.
  • 182 focused tests passed, 26 Linux-only cases skipped, in 96.85 s including preparation. Full scoped check-changed passed: formatting, core/core-test type checks, lint, dead exports, and applicable guards. Full package build took 4m06.7s; canonical tarball integrity passed. Independent review found no P0/P1 findings.
  • Candidate package SHA-256: 719bc969dc833a5da9e666eb88357d70cdba27dd56f45260426cd1f08f9fa5c4.
  • An earlier published-2026.9.8 Linux Docker cell passed on incoming head 6fdf4f3a7fe5, including copied-plugin bytes, restart/readiness, regular history and incognito behavior. That is prior-head evidence, not rebased-head CI.

Limits and disclosed warnings: native service management was intentionally skipped through the normal account-home fence; this verifies native package update/copy/startup with owned foreground Gateways, not LaunchAgent activation. No serving installation or operator state was changed. The first native attempt stopped at Doctor because the long test TMPDIR exceeded Darwin's Unix-socket path bound and the write fence rejected the shared-/tmp fallback. The retry used a 90-byte socket path in a short private temp root with all fences retained and no product patch. The passing run still logged a 5-second shared-state CLI cleanup warning and a sandbox process-inspection warning; a premature pre-ready health probe timed out, then all post-ready runtime checks passed. These warnings are not presented as fixed defects.

Hosted CI fixture correction

The first rebased-head hosted run exposed two existing probe-uncertainty fixture failures. Both were reproduced locally before repair: the missing dummy worker exited before the new reported-progress quiet period could reach its probe.

Follow-up 5f33ee23ca18047ab2bcdb0b7f459b55a0e66e67 changes only src/infra/update-candidate-state.budget.test.ts. It holds admitted worker work until the probe runs under a controlled clock, then settles it. Existing rejection and retained-scratch assertions remain; no test cases were skipped or removed. The changed fixture is not shipped in the verified package.

28 related tests passed in 21.03 s, plus the infra test typecheck, scoped lint, formatting and applicable line/assertion/timeout guards. Independent review found no P0/P1 findings. Production sources are unchanged from the native-tested 9c985fa88885 build; the native proof remains explicitly bound to that build. The earlier hosted failure is retained as a failure, not relabeled green; the updated head has its own required CI.

Original performance and author validation

A same-configuration private rehearsal exercised database snapshots, Doctor, lint/config/plugin/recovery checks, candidate startup/readiness, and cleanup. All seven phases succeeded; the serving gateway processes and source configuration remained unchanged.

Measurement Before After
State preparation 638.258 s 238.465 s
Complete prevalidation, including cleanup 769.178 s 342.377 s
Inventoried plugin allocation 4.73 GB 1.56 GB

These are single-host measurements, not a whole production-upgrade benchmark or a universal timing guarantee. The earlier four-worker copy component alone improved an identical frozen inventory by 18.8%; the larger result above includes the provenance and progress fixes.

  • 179 focused tests passed across two commands (82.264 s and 19.538 s wall time, including test preparation).
  • Scoped lint, pnpm tsgo:core, and pnpm tsgo:core:test passed.
  • The native updater build path, OPENCLAW_UPDATE_IN_PROGRESS=1 pnpm build, passed in 63.66 s.
  • Independent review passed. Tests cover cross-root provenance, disabled/missing selections, escaping paths, multi-entry matching, progress opt-in, deadline/cancellation behavior, source/root replacement, diagnostic preservation, and worker drainage.
  • CI runtime has not yet been measured. No production deployment was performed for this PR.
Focused test commands
pnpm test \
  src/infra/update-candidate-bundled-provenance.test.ts \
  src/infra/update-candidate-state.diagnostics.test.ts \
  src/infra/update-candidate-snapshot.progress.test.ts \
  src/infra/update-candidate-io.process.test.ts \
  src/infra/update-candidate-canary.test.ts \
  --maxWorkers=1

pnpm test \
  src/infra/update-candidate-io.test.ts \
  src/infra/update-candidate-plugin-tree.test.ts \
  src/infra/update-candidate-plugin-file.worker.test.ts \
  src/infra/update-candidate-plugin-copy-scheduling.test.ts \
  src/infra/update-candidate-snapshot.plugin-inspection.test.ts \
  src/infra/update-immutable-activation.test.ts \
  --maxWorkers=1

View the OpenClaw team session

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L labels Oct 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 3:14 AM ET / 07:14 UTC (Revision 3).

ClawSweeper review

What this changes

The PR speeds private update validation by carrying installed bundled-plugin selections into the candidate, reporting completed filesystem work, and copying large plugin inventories through four workers.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main lacks the optimizations, and the exact-head published-updater evidence resolves the previous compatibility-proof blocker. No actionable introduced defect was found.

Priority: P2
Reviewed head: 9c985fa8888558925e31f98a8dfe1514d9d38ce4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with strong exact-head upgrade evidence and meaningful failure coverage; no blocking correctness finding remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured exact-head native run exercises the published 2026.9.8 updater through candidate snapshot preparation, real plugin copying, startup/readiness, state preservation, and cleanup. It resolves the prior proof request; LaunchAgent activation is outside the demonstrated scope. Stored schemas and serialization contracts are unchanged, and existing-state preservation is explicitly observed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured exact-head native run exercises the published 2026.9.8 updater through candidate snapshot preparation, real plugin copying, startup/readiness, state preservation, and cleanup. It resolves the prior proof request; LaunchAgent activation is outside the demonstrated scope. Stored schemas and serialization contracts are unchanged, and existing-state preservation is explicitly observed.
Evidence reviewed 9 items Pinned introduction and merge ownership: Reviewed the merge-base-to-head delta. Raw test-merge parent records match the pinned base followed by the exact PR head; its result contains the same introduced paths, without attributing unrelated base changes to this PR.
Guarded filesystem copying: The extracted copy owner retains source metadata checks, destination identity revalidation immediately before mutation, create-only publication, and copied-byte hashing. Large inventories use four workers without independent task replay or timeouts, and pool retirement is awaited before returning.
Legacy progress compatibility: Entry receipts require explicit parent opt-in. Released parents retain their previous stderr limits and stdout JSON contract; updated parents feed completed work into the existing watchdog while keeping quiet-period probes, deadlines, and diagnostic limits.
Findings None None.
Security None None.

How this fits together

The updater rehearses a staged OpenClaw package against private copies of existing state and configured plugins before activation. Snapshot preparation feeds plugin checks, Doctor, and candidate startup while preserving the serving installation.

flowchart TD
  A[Installed updater and existing state] --> B[Capture bundled plugin selection]
  B --> C[Inventory private candidate state]
  C --> D[Guarded four-worker copies]
  D --> E[Progress watchdog]
  D --> F[Plugin checks and Doctor]
  F --> G[Candidate startup and readiness]
  G --> H[Cleanup and validation result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +266, Tests +462. Total +728 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 13 323 57 +266
Tests 6 467 5 +462
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 790 62 +728

Review metrics

Metric Value Why it matters
Production versus test growth production net +266 lines; tests and test support net +462 lines Production growth is justified by guarded worker copying and progress plumbing, with focused compatibility and failure coverage.
Reported rehearsal improvement 769.178 s → 342.377 s, approximately 55% faster The same-configuration single-host benchmark measures complete prevalidation including cleanup, without claiming a universal upgrade speedup.

Technical review

Best possible solution:

Keep one guarded snapshot owner that reports actual completed work and preserves released-updater compatibility while accelerating large plugin trees.

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

Yes, source inspection identifies candidate-side bundled-selection rediscovery and synchronous guarded copying on large inventories; the body supplies a measured before/after rehearsal. This review did not execute a reproduction.

Is this the best way to solve the issue?

Yes, the patch extends the existing snapshot, watchdog, and worker owners while preserving copy safeguards and legacy output behavior rather than adding a competing update path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6acf06b1299f.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head native run exercises the published 2026.9.8 updater through candidate snapshot preparation, real plugin copying, startup/readiness, state preservation, and cleanup. It resolves the prior proof request; LaunchAgent activation is outside the demonstrated scope. Stored schemas and serialization contracts are unchanged, and existing-state preservation is explicitly observed.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded update-performance improvement for large configured plugin trees, with no demonstrated emergency regression.
  • 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. Sufficient (live_output): The captured exact-head native run exercises the published 2026.9.8 updater through candidate snapshot preparation, real plugin copying, startup/readiness, state preservation, and cleanup. It resolves the prior proof request; LaunchAgent activation is outside the demonstrated scope. Stored schemas and serialization contracts are unchanged, and existing-state preservation is explicitly observed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head native run exercises the published 2026.9.8 updater through candidate snapshot preparation, real plugin copying, startup/readiness, state preservation, and cleanup. It resolves the prior proof request; LaunchAgent activation is outside the demonstrated scope. Stored schemas and serialization contracts are unchanged, and existing-state preservation is explicitly observed.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the merge-base-to-head delta. Raw test-merge parent records match the pinned base followed by the exact PR head; its result contains the same introduced paths, without attributing unrelated base changes to this PR. (65617415c240)
  • Guarded filesystem copying: The extracted copy owner retains source metadata checks, destination identity revalidation immediately before mutation, create-only publication, and copied-byte hashing. Large inventories use four workers without independent task replay or timeouts, and pool retirement is awaited before returning. (src/infra/update-candidate-plugin-file.ts:43, 9c985fa88885)
  • Legacy progress compatibility: Entry receipts require explicit parent opt-in. Released parents retain their previous stderr limits and stdout JSON contract; updated parents feed completed work into the existing watchdog while keeping quiet-period probes, deadlines, and diagnostic limits. (src/infra/update-candidate-state.diagnostics.ts:101, 9c985fa88885)
  • Bundled-plugin provenance: Serving-package selection is passed through candidate inventory. Redirects require matching canonical package ownership and bundled-root containment; disabled, missing, mismatched, or escaping selections retain private-copy behavior. (src/infra/update-candidate-plugins.ts:68, 9c985fa88885)
  • Published-driver proof resolves prior review: The captured PR body reports unmodified npm 2026.9.8 updating to this exact head on native macOS: exit 0 and status ok in 503.442 seconds. It records verification of 1,024 plugin payload files totaling 256 MiB, all payload hashes, read-only mode, a relative symlink from the actual private-canary root, bundled and custom plugin loading, post-ready health, exact build attestation, preserved synthetic chat contents, and canary removal. This directly addresses the previous review's published-driver preparation/readiness/cleanup request. LaunchAgent activation was expressly excluded, and warnings were disclosed. (9c985fa88885)
  • Focused regression coverage: Inspected actual-worker cases for copied bytes and modes, source mutation, replaced root or ancestor, and create-only diagnostics; scheduling coverage verifies failure drainage and worker retirement before link publication. Progress tests exercise opt-in subprocess output and watchdog receipts. The body reports 182 passing focused tests and scoped checks; no tests were executed during this read-only review. (src/infra/update-candidate-plugin-file.worker.test.ts:95, 9c985fa88885)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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-06T22:30:05.393Z sha 6fdf4f3 :: blocked before merge. :: none
  • reviewed 2026-10-07T06:28:49.964Z sha 6fdf4f3 :: blocked before merge. :: none

@hannesrudolph
hannesrudolph marked this pull request as ready for review October 7, 2026 06:23
@clawsweeper

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

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 7, 2026
@hannesrudolph
hannesrudolph force-pushed the fix/update-validation-copy-20261006 branch from 6fdf4f3 to 9c985fa Compare October 7, 2026 07:07
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Oct 7, 2026
@hannesrudolph
hannesrudolph merged commit a2e44be into main Oct 7, 2026
129 checks passed
@hannesrudolph
hannesrudolph deleted the fix/update-validation-copy-20261006 branch October 7, 2026 07:33
@hannesrudolph

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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. size: L 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