Skip to content

fix(test): isolate Vitest caches across linked checkouts - #132867

Merged
steipete merged 2 commits into
mainfrom
codex/frv-worktree-vitest-cache
Aug 29, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/frv-worktree-vitest-cache

Conversation

@steipete

@steipete steipete commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where focused tests stall before starting when linked worktrees share installed dependencies. A test in one checkout can invalidate and recursively delete another checkout's Vitest transforms.

Why This Change Was Made

Vitest's default filesystem cache lives beneath node_modules, which is shared by linked development checkouts. Its lockfile integrity check removes the entire selected cache on a mismatch. Move the default cache into the owning checkout's .cache/vitest directory and share that root resolver across normal, parallel-project, and plugin-batch test runners. Keep the normal leaf separate from scheduler leaves so one invocation cannot clear its siblings.

Explicit cache paths, CI restored seeds, existing Windows opt-in, and cache opt-outs are unchanged. No new options, dependencies, timeouts, or retries.

User Impact

Developers can share installed dependencies between checkouts without sharing writable default transforms. No OpenClaw product-runtime behavior changes. Independent commands using the same checkout and same cache leaf still need to be serialized or assigned separate explicit cache paths.

Evidence

The original focused Browser test spent over 13 minutes before Vitest printed RUN. A guarded diagnostic traced ensureCacheIntegrity → clearCache → recursive removal of the linked shared cache. After this repair, the same command completed in 32.79 seconds, exposing its two intended Browser regressions. This is one observed startup recovery, not a whole-suite speedup benchmark.

The new regression launches real Vitest processes in two private package workspaces sharing only private node_modules. After changing the dependency lock, the original helper deletes the first checkout's cache sentinel; the repaired helper preserves it. The same regression source failed before the fix and passed afterward.

  • All 536 focused config, scheduler, plugin-batch, and grouped-runner tests passed; the complete source-side scheduler test file adds 84 passing tests (620 total across five files).
  • Independent Codex P0–P2 review: no actionable findings.
  • Full changed-file gate passed, including scripts/root-test typechecks and script lint. The first attempt exposed a missing local UI dependency; restoring the already-pinned pako 3.0.1 package and its bundled declarations fixed that environment issue without changing repository dependencies.

Production runtime LOC: +0/-0. Tooling owner LOC: +19/-8; the growth provides one checkout-owned default and separates independently invalidated cache leaves. Test/support LOC: +88/-19.

The first hosted run, 33277503922, caught one omitted source-side scheduler test that still asserted the old default cache path. Both stale expectations are now updated; its complete 84-test file and the actual changed-file gate, including core-test typechecks and targeted lint, pass. The eight original files and cache implementation are unchanged. A fresh independent P0–P2 review of this correction found no actionable issues.

Integration refresh: the corrected scheduler leaf passed in 33278706524; its only failed leaf was the already-tracked Clipboard lifecycle error after 4,094 passing tests. After the combined Browser/Clipboard repair #132878 landed, this branch was rebased once onto containing main. All nine intended file blobs and the stable patch ID are unchanged; a fresh exact-head CI run is required before merge.

Review follow-through: the latest ClawSweeper review found no patch defect and requested finished exact-head CI plus an independent dependency check. The installed Vitest 4.1.11 FileSystemModuleCache constructor, clearCache, and ensureCacheIntegrity were directly inspected: metadata mismatch awaits recursive removal of the selected cache directories. Fresh CI remains required before landing. These are rebuildable Vitest transform artifacts; their file format is unchanged, with no OpenClaw persistent-state schema or migration change.

A separate existing case remains: callers that explicitly force one cache path across parallel plugin-batch groups can still share a live cache. The current hosted plugin-prerelease job does not combine those options; this patch preserves explicit override semantics.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 7:10 PM ET / 23:10 UTC.

ClawSweeper review

What this changes

The PR relocates Vitest’s default writable module cache to each checkout’s .cache/vitest directory and assigns separate leaves to parallel project and extension-batch runs.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-authored PR open. Current main still places default parallel-run caches under shared node_modules; the branch consistently moves writable defaults to the owning checkout and includes a real-process regression, with exact-head CI still in progress.

Priority: P3
Reviewed head: b8f9db6224ef903ae49dfa78854e0a1653304e7f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has coherent owner-boundary coverage and strong reported real-process evidence; exact-head CI and independent local dependency-source confirmation remain outstanding in this review environment.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The captured PR body nevertheless describes a real two-workspace Vitest process test that preserves the first cache sentinel after the second workspace sees a changed lockfile.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The captured PR body nevertheless describes a real two-workspace Vitest process test that preserves the first cache sentinel after the second workspace sees a changed lockfile.
Evidence reviewed 7 items Current-main baseline: Current main only sets a filesystem-cache path when the environment explicitly supplies one, while the parallel scheduler’s fallback remains beneath node_modules/.experimental-vitest-cache; the central behavior is not already implemented on main.
Canonical default and shared-config caller: The branch centralizes the checkout-owned cache root, preserves an explicitly configured path, and passes the repository root from the shared Vitest configuration so normal configurations use the checkout rather than an incidental process directory.
Parallel and extension callers: Both parallel project scheduling and extension-batch grouping use the same resolver while retaining explicit cache-path overrides, so the three runner entry paths agree on ownership and leaf separation.
Findings None None.
Security None None.

How this fits together

OpenClaw test launchers pass filesystem-cache paths into Vitest for normal runs, parallel project plans, and extension batches. Vitest stores rebuildable transforms at those paths, so cache ownership determines whether linked checkouts can invalidate each other.

flowchart LR
  A[Linked checkouts] --> B[Test launchers]
  B --> C[Checkout cache resolver]
  C --> D[Default and parallel cache leaves]
  D --> E[Vitest module cache]
  E --> F[Test execution]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head hosted CI is still in progress, so its final required-gate result remains unverified.
  • Resolve merge risk (P1) - The PR body reports direct inspection of Vitest’s recursive cache clearing, but this read-only checkout lacks installed Vitest sources and upstream access was unavailable for an independent repeat; that is a reviewer limitation, not missing contributor proof.
Agent review details

Security

None.

PR surface

Tests +81, Other -1. Total +80 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 7 103 22 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 5 -1
Total 9 107 27 +80

Review metrics

Metric Value Why it matters
Runtime versus test-tooling delta production runtime +0/-0; tooling +19/-8; tests +88/-19 The added tooling code establishes one checkout-owned cache root and distinct invalidation leaves; no OpenClaw product-runtime code changes.

Stored data model

Persistent data-model change detected: persistent cache schema: scripts/test-extension-batch.mts, persistent cache schema: scripts/test-projects.test-support.mts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the checkout-owned resolver and distinct cache leaves, then complete exact-head CI and retain the recorded Vitest-contract verification with the merge evidence.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the checkout-owned resolver and distinct cache leaves, then complete exact-head CI and retain the recorded Vitest-contract verification with the merge evidence.

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

Source-reproducible, with medium confidence: current main’s fallback resolves beneath shared node_modules, and the branch contains a two-workspace real-Vitest regression. The local dependency source needed to independently confirm Vitest’s clearing trigger is unavailable.

Is this the best way to solve the issue?

Yes, subject to the stated Vitest-contract check: one checkout-root resolver used by normal, parallel, and extension-batch paths removes the shared writable owner while preserving explicit overrides.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9e86e084e155.

Labels

Label justifications:

  • P3: This repairs developer test-cache isolation without changing product runtime behavior.
  • 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. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply. The captured PR body nevertheless describes a real two-workspace Vitest process test that preserves the first cache sentinel after the second workspace sees a changed lockfile.

Evidence

What I checked:

  • Current-main baseline: Current main only sets a filesystem-cache path when the environment explicitly supplies one, while the parallel scheduler’s fallback remains beneath node_modules/.experimental-vitest-cache; the central behavior is not already implemented on main. (test/vitest/vitest.performance-config.ts:49, 9e86e084e155)
  • Canonical default and shared-config caller: The branch centralizes the checkout-owned cache root, preserves an explicitly configured path, and passes the repository root from the shared Vitest configuration so normal configurations use the checkout rather than an incidental process directory. (test/vitest/vitest.performance-config.ts:34, b8f9db6224ef)
  • Parallel and extension callers: Both parallel project scheduling and extension-batch grouping use the same resolver while retaining explicit cache-path overrides, so the three runner entry paths agree on ownership and leaf separation. (scripts/test-projects.test-support.mts:4141, b8f9db6224ef)
  • Boundary regression: The added regression launches real Vitest processes in two temporary package workspaces that share only node_modules, changes the dependency lockfile between runs, and verifies that the first checkout’s cache sentinel remains present. (test/vitest-performance-config.test.ts:110, b8f9db6224ef)
  • Dependency signal and inspection limitation: The branch configures Vitest’s fsModuleCachePath and the lockfile pins Vitest 4.1.11, making its invalidation behavior relevant. This checkout has no installed dependencies and the upstream remote could not resolve, so the claimed Vitest source inspection could not be independently repeated here. (pnpm-lock.yaml:150, b8f9db6224ef)
  • History and routing: The cache-root implementation was introduced on this branch by commit bb60b41; the pre-existing cache helper and scheduler baseline were recently maintained by the same area contributor in current-main history. (test/vitest/vitest.performance-config.ts:34, bb60b41c1f97)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the exact-head hosted CI run before merge.

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-08-29T22:05:23.743Z sha 525b7a3 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T22:41:52.283Z sha 9691877 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/frv-worktree-vitest-cache branch from 9691877 to b8f9db6 Compare August 29, 2026 23:04
@steipete steipete self-assigned this Aug 29, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The cache-owner repair is ready to land at b8f9db6. Exact-head CI 33280098801 completed successfully. The latest ClawSweeper review has no actionable findings; its request to complete exact-head CI is satisfied.

The real two-checkout Vitest regression fails with the original helper and passes with this repair. Focused proof passed all 536 original config/runner tests plus all 84 source-side scheduler tests, with both selected changed-file gates and independent P0–P2 reviews clean. The first CI run exposed the omitted source-side path assertions, which were corrected; the next run’s sole failed leaf was the existing Clipboard lifecycle bug, and one integration rebase after its fix retained all nine intended file blobs and the stable patch ID.

Commands: node scripts/run-vitest.mjs run test/vitest-performance-config.test.ts test/scripts/test-projects.test.ts test/scripts/test-extension.test.ts test/scripts/test-group-report.test.ts; node scripts/run-vitest.mjs run src/scripts/test-projects.test.ts; node scripts/check-changed.mjs -- scripts/test-extension-batch.mts scripts/test-projects.test-support.mts test/scripts/test-extension.test.ts test/scripts/test-group-report.test.ts test/scripts/test-projects.test.ts test/vitest-performance-config.test.ts test/vitest/vitest.performance-config.ts test/vitest/vitest.shared.config.ts; and node scripts/check-changed.mjs -- src/scripts/test-projects.test.ts. Vitest 4.1.11’s installed FileSystemModuleCache constructor, clearCache, and ensureCacheIntegrity were directly inspected, and the live startup diagnostic confirmed the recursive shared-cache invalidation. These remain rebuildable Vitest artifacts with unchanged format; no OpenClaw persistent-state schema or migration changes.

The observed recovery was one focused startup from over 13 minutes without RUN to a completed 32.79-second diagnostic run, not a full-suite benchmark. Explicit cache overrides and CI seed behavior remain unchanged; explicitly sharing one cache leaf across independent commands remains the documented limitation. Product runtime LOC +0/-0; tooling owner +19/-8; test/support +88/-19.

@steipete
steipete merged commit ac22c96 into main Aug 29, 2026
184 of 186 checks passed
@steipete
steipete deleted the codex/frv-worktree-vitest-cache branch August 29, 2026 23:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 30, 2026
…2867)

* fix(test): isolate Vitest caches across linked checkouts

* test: align scheduler cache expectations with checkout ownership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S 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