Skip to content

improve: speed up cold Node test planning - #156234

Merged
steipete merged 2 commits into
mainfrom
codex/planner-glob-cost460
Sep 23, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/planner-glob-cost460

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold Node test planning repeatedly recompiles globs when canonical test inventories exceed the runtime's 250-entry compiled-pattern cache. File-major matching cycles through the exclusion patterns for every candidate, evicting patterns before the next file reuses them.

User Impact

This is an internal tooling performance improvement. Selected tests, their ordering and duplicates, and shard ownership remain unchanged.

Why This Change Was Made

Batch inventories through the existing vitest.include-patterns owner, finishing each pattern across candidate files before advancing. Callers supply their original native matcher; the helper adds no matcher, dependency, or persistent cache. Bulk unit discovery, coverage discovery, and canonical shard inventories use the operation, while single-file CLI routing retains its contract and planning remains dependency-free before installation.

An additional Bun probe caught a hidden-file difference in the first candidate: Bun's native matcher accepts a path that the normalized Vitest matcher excludes. The corrected implementation retains each caller's native semantics. A regression fails on that first candidate and passes on the final head.

Evidence

  • Node 24.20.0, same first-signin planner entry: 26.064s → 3.608s cold (7.2× faster); warm calls 209ms → 172ms. The complete emitted plan is byte-identical, including exclusive Gateway admission.
  • Available Bun 1.4.2, same entry: 2.400s → 1.966s cold; warm calls 148ms → 122ms. Every before/after plan has SHA-256 c22db9fc94f4e365937acfa1683427e06babaf2373c42742ddf55915e518636e. These are bounded local measurements, not a whole-suite or hosted-CI speedup claim.
  • Final original-versus-candidate inventory comparison covers 17,927 paths, including hidden and normalized path variants: exact ordered equality on Node (1,238 selected) and Bun (1,239 selected), with no additions or removals.
  • The deterministic cache-budget regression fails with the original file-major algorithm: 3,132 modeled cache misses against a 261-pattern budget. Batched selection passes without a wall-clock assertion. Semantic cases cover extglobs, overlapping and empty include/exclude lists, literal negative/comment prefixes, path variants, order/duplicates, shared exclusions, and dependency-free loading.
  • Final corrected head: 47 Node cases passed in 4.46s wrapper wall; Bun passed 46 cases in 3.14s, with only the Node-cache-policy regression intentionally skipped. These three files cover pattern selection, unit ownership, and unit coverage configuration.
  • The earlier batching candidate also passed 2,061 owner cases across six files in 185.78s wall, covering canonical/changed shard planning and CLI routing. That broader run preceded the native-matcher correction; final focused tests, full inventory comparison, and identical planner output validate the correction. It is not presented as a final-head 2,061-case rerun.
  • Final changed gates passed: formatting, structural guards, script erasability, scripts and test-root typechecking, coercion declarations, all three Knip scans, and scoped typed lint. Fresh independent P0–P2 review found no actionable issues.
  • Exact-head hosted CI passed. The changed pattern-selector file ran 27 tests in 0.108s, and unit ownership ran 4 tests in 0.104s; the new cache-budget and hidden-file cases took 0.034s and 0.004s respectively. No Windows/macOS device run is claimed.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 23, 2026 05:46
@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 Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 2:04 AM ET / 06:04 UTC (Revision 2).

ClawSweeper review

What this changes

Batch test-file pattern matching to shorten cold planning while preserving selected files, ordering, duplicates, and shard ownership.

Merge readiness

✅ Ready for maintainer review

This remains a useful optimization: current main still performs file-by-file filtering. The corrected patch preserves native matcher semantics, and the reported planner measurements and inventory comparisons support the improvement. No actionable defect was found.

Priority: P2
Reviewed head: 9916ac9571f8b123f77dba875c91becfb6156f37

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with convincing bounded runtime evidence and useful semantic regressions; no blocking defect remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body reports after-fix runs through the actual planner on Node and Bun, faster cold planning, identical complete plans, and exact ordered inventory equality after the native-matcher correction. These observations exercise the changed selection owner; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports after-fix runs through the actual planner on Node and Bun, faster cold planning, identical complete plans, and exact ordered inventory equality after the native-matcher correction. These observations exercise the changed selection owner; no stored-data contract changes.
Evidence reviewed 9 items Introduced patch boundary: Reviewed the pinned merge-base-to-head diff. Its changes concern test selection and associated tests; the provider, plugin, and dependency changes in endpoint drift are base-branch work.
Selection semantics: The helper evaluates each pattern across candidates, removes excluded matches, and filters the original input to preserve ordering and duplicates. Unit selection retains path normalization, native path.matchesGlob, and shared exclusions; scoped planner selection also supplies its original native matcher.
Runtime cache contract: Node v24.20.0 implements a pattern cache with a 250-entry eviction threshold. This directly supports the patch’s cache-churn mechanism; the dependency signal is the changed callers’ use of node:path.matchesGlob.
Findings None None.
Security None None.

How this fits together

OpenClaw’s test planner turns repository file inventories and inclusion rules into test shards and coverage targets. This change optimizes file selection before those plans are emitted.

flowchart TD
  A[Repository test files] --> C[Batch pattern selection]
  B[Include and exclude rules] --> C
  D[Caller native matcher] --> C
  C --> E[Ordered selected files]
  E --> F[Test shards]
  E --> G[Coverage targets]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +132, Other +2. Total +134 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 7 152 20 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 14 12 +2
Total 8 166 32 +134

Review metrics

Metric Value Why it matters
Reported cold planning 26.064s → 3.608s on Node 24.20.0 The bounded real-planner comparison reports a 7.2× improvement with identical emitted plans.
Production versus test growth Production/tooling +35; tests and test support +99 net lines The tooling growth supplies shared batch selection, while most growth protects selection semantics and the cache-budget regression.

Technical review

Best possible solution:

Keep batch selection in the existing pattern owner and preserve each caller’s native matching contract without adding a persistent cache.

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

Yes, the file-major selection path and Node’s bounded pattern cache establish the mechanism, supported by reported before/after planner measurements; this review did not execute it.

Is this the best way to solve the issue?

Yes, batching through the existing pattern owner preserves native semantics and avoids a competing matcher or cache.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8f531df7080d.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a measured internal planning improvement with bounded scope and no product-runtime behavior change.
  • 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 body reports after-fix runs through the actual planner on Node and Bun, faster cold planning, identical complete plans, and exact ordered inventory equality after the native-matcher correction. These observations exercise the changed selection owner; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports after-fix runs through the actual planner on Node and Bun, faster cold planning, identical complete plans, and exact ordered inventory equality after the native-matcher correction. These observations exercise the changed selection owner; no stored-data contract changes.

Evidence

What I checked:

  • Introduced patch boundary: Reviewed the pinned merge-base-to-head diff. Its changes concern test selection and associated tests; the provider, plugin, and dependency changes in endpoint drift are base-branch work. (9916ac9571f8)
  • Selection semantics: The helper evaluates each pattern across candidates, removes excluded matches, and filters the original input to preserve ordering and duplicates. Unit selection retains path normalization, native path.matchesGlob, and shared exclusions; scoped planner selection also supplies its original native matcher. (test/vitest/vitest.include-patterns.ts:5, 9916ac9571f8)
  • Runtime cache contract: Node v24.20.0 implements a pattern cache with a 250-entry eviction threshold. This directly supports the patch’s cache-churn mechanism; the dependency signal is the changed callers’ use of node:path.matchesGlob. (lib/internal/fs/glob.js:925, 71b8b174857e)
  • After-fix planner evidence: The captured PR body reports the same first-signin planner scenario on Node 24.20.0 improving from 26.064s to 3.608s cold, with byte-identical plans. Bun 1.4.2 also improves. Final inventory comparisons cover 17,927 paths and preserve exact ordered selections on both runtimes. Final focused validation reports 47 Node cases and 46 Bun cases; the broader 2,061-case run is explicitly identified as preceding the matcher correction. Source snapshot identity: 1806d87fcf35f511e4b0b4ffb7766dda953d6b094b02c9615cd4751b1aa99778. (9916ac9571f8)
  • Current main still needs the optimization: Fetched main retains the singleton file-major unit selector and lacks the new batch helper. The latest release’s unit-path owner likewise uses singleton filtering, so neither inspected revision supersedes this work. (test/vitest/vitest.unit-paths.mjs:87, 8f531df7080d)
  • Latest release comparison: Read the unit selector at the supplied v2026.9.5 release commit through GitHub; it does not contain this batch selection operation. (test/vitest/vitest.unit-paths.mjs, ec9c1a13db89)

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-09-23T05:53:51.590Z sha 6de15fd :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 23, 2026
@steipete
steipete enabled auto-merge (squash) September 23, 2026 06:13
@steipete
steipete merged commit f2521d6 into main Sep 23, 2026
157 checks passed
@steipete
steipete deleted the codex/planner-glob-cost460 branch September 23, 2026 06:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

vincentkoc added a commit to ycmjbot-bot/openclaw that referenced this pull request Sep 23, 2026
* commit '3ab93b4ea59804b34d02a696382db16dc95189bb': (80 commits)
  fix(gateway): keep session refreshes moving during unrelated writes (openclaw#156286)
  chore(deps): update fs-safe to 0.18.2 (openclaw#156262)
  refactor(plugins): extract ClawHub plugin archives once (openclaw#156246)
  improve(llm-core): avoid unnecessary tool validation sets (openclaw#152066)
  fix(backup): verification accepts archives missing captured databases (openclaw#156211)
  fix: cancel Guest work when its original access is revoked (openclaw#156106)
  fix(test): classify drained legacy migration refusals
  fix(anthropic): finish Opus 5.5 defaults and thinking display (openclaw#156093)
  refactor(agents): share native harness tool execution (openclaw#154217)
  fix(ui): carry typed ownership through short-route resolution
  test(worktrees): accept additive gc result fields (openclaw#156127)
  test(tasks): close sqlite borrowers before registry reload (openclaw#156131)
  chore(autoreview): sync Astra high defaults (openclaw#156175)
  refactor(node-host): await prepared workspace storage (openclaw#149519)
  improve: speed up cold Node test planning (openclaw#156234)
  fix(doctor): avoid slow legacy ownership repair in source checkouts (openclaw#156238)
  improve: speed up native build artifact validation (openclaw#156219)
  fix(ui): preserve short-route resolution ownership
  fix(doctor): name retained session metadata conflicts (openclaw#156162)
  perf(tasks): bound creation selection to matching runs (openclaw#156183)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
* perf(test): avoid glob cache churn during cold planning

* fix(test): retain native matcher semantics in batched selectors
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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