Skip to content

fix(scripts): stabilize Vitest shard timing keys - #120105

Merged
steipete merged 3 commits into
openclaw:mainfrom
qingminglong:fix/scripts-stable-shard-timing-key
Sep 1, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
qingminglong:fix/scripts-stable-shard-timing-key

Conversation

@qingminglong

@qingminglong qingminglong commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Reordering the same selected Vitest test files split their local timing history into separate keys. Later scheduling could not reuse the prior measurements for that selection.

Why This Change Was Made

Canonicalize the selection at the shared timing-key owner using a nonmutating, locale-independent sort. Current main moved this owner into scripts/lib/vitest-shard-metadata.mts; the branch now preserves that extraction and its dependency-free scheduling boundary. Whole-config and named CI shard keys retain their existing contracts. No new storage format, version, option, dependency, or compatibility reader is introduced; old advisory timing entries can be rebuilt.

The regression replaces a same-input self-comparison with actual timing-file write/read aggregation for reversed ASCII and Unicode selections. Frozen caller arrays also catch accidental in-place sorting. The existing whole-config and named-shard cases remain covered. Production LOC: +2/-2 (net 0); tests: +28/-13 (net +15).

User Impact

Repeated selections reuse timing history regardless of discovery or CLI argument order, while keeping the caller's execution order unchanged. Thanks @qingminglong and @vincentkoc.

Evidence

  • Before the fix, the actual node --import tsx scripts/test-projects.mts command ran test/scripts/vitest-local-scheduling.test.ts test/scripts/package-root-args.test.ts and then the reversed target order. Both runs passed 2 files and 14 tests, but the artifact contained separate a10cb960b779 and 6f5eadc5858f keys with sample count 1 each.
  • After the fix, the same two commands passed 2 files and 14 tests each. Both used test/vitest/vitest.unit-fast.config.ts#include-2-6f5eadc5858f, and the second run advanced its sample count from 1 to 2.
  • node scripts/run-vitest.mjs test/scripts/vitest-shard-timings.test.ts: two aggregation cases failed before the fix; all 5 cases passed afterward, including whole-config and named CI controls.
  • node scripts/check-changed.mjs -- scripts/lib/vitest-shard-metadata.mts test/scripts/vitest-shard-timings.test.ts: all 18 selected gates passed, including script/test-root types, script lint, formatting, dependency guards, and erasability. The temporary-directory report emitted existing-main advisory findings; the gate exited successfully.
  • Fresh independent Codex autoreview of the complete integrated two-file candidate passed with no P0 findings. Native source hashes match the independently authored trusted-main proof. Node 24.20.0 was used locally.

Provenance: the order-dependent hash was added in commit 496d90c3b5e, whose raw parent 1531123d3547f9ff8ee8094590fc773305f018f2 and parent-relative patch were inspected. The current-main owner extraction carried that behavior forward. No whole-suite scheduling speedup is claimed; the observed proof is real CLI execution and persisted sample reuse.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 7, 2026
@vincentkoc vincentkoc self-assigned this Aug 7, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 4:28 AM ET / 08:28 UTC.

ClawSweeper review

What this changes

The branch canonicalizes locally selected Vitest file patterns before deriving timing-history keys, and adds persisted aggregation coverage for reversed selections.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR remains necessary: current main still hashes local include patterns in their supplied order, while the branch correctly hashes a sorted copy and proves persisted timing reuse for reversed selections. No actionable correctness or security finding was identified.

Priority: P3
Reviewed head: a1a6ea81325f1d7d8c383747a08fda8a9c06f938

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused real CLI proof, persistence-level regression coverage, and a net-neutral shared-owner repair make this a strong PR.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed production owner is the shared timing-key builder, exercised by the real test-project CLI path that writes and later reads timing samples; supplied before/after terminal evidence records the expected single-key reuse and increased sample count on the exact head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner is the shared timing-key builder, exercised by the real test-project CLI path that writes and later reads timing samples; supplied before/after terminal evidence records the expected single-key reuse and increased sample count on the exact head.
Evidence reviewed 6 items Current-main behavior: Current main serializes include patterns in their original order before hashing, so equivalent reversed selections receive different timing keys.
Introduced repair: The verified merge-base-to-head patch sorts a copy before hashing, preserving caller order while making the metadata key order-independent.
Scheduling consumer: The local parallel scheduler reads persisted timings and looks them up through the shared timing-key owner; completed test runs write new samples through the corresponding persistence owner.
Findings None None.
Security None None.

How this fits together

The test-project runner stores duration samples keyed by each Vitest configuration and its selected files. Later parallel scheduling reads those samples to start expensive selections earlier.

flowchart LR
A[Selected test files] --> B[Timing-key builder]
B --> C[Persisted timing metadata]
C --> D[Parallel shard scheduler]
D --> E[Vitest processes]
Loading

Before merge

  • Complete next step (P2) - No mechanical follow-up is indicated; this complete, proof-backed contributor PR needs normal exact-head landing checks.
Agent review details

Security

None.

PR surface

Tests +15, Other 0. Total +15 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 28 13 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 2 0
Total 2 30 15 +15

Review metrics

Metric Value Why it matters
Production versus test delta production +2/-2 (net 0); tests +28/-13 (net +15) The repair is absorbed into the shared key owner; added test lines exercise the persisted behavior rather than a duplicate direct comparison.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/vitest-shard-metadata.mts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the shared order-insensitive key repair with its persistence-level regression coverage so equivalent local selections reuse their advisory scheduling history.

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

Yes. The supplied current-head CLI trace runs the same selected tests in opposite orders and observes one persisted key advancing from sample count 1 to 2; source confirms that this key is consumed by parallel scheduling.

Is this the best way to solve the issue?

Yes. Canonicalizing only the metadata key at its shared owner fixes the order-dependent lookup without altering the caller’s selected execution order or adding a storage migration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded local test-scheduling reliability fix with no user-facing runtime or data-loss impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owner is the shared timing-key builder, exercised by the real test-project CLI path that writes and later reads timing samples; supplied before/after terminal evidence records the expected single-key reuse and increased sample count on the exact head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the shared timing-key builder, exercised by the real test-project CLI path that writes and later reads timing samples; supplied before/after terminal evidence records the expected single-key reuse and increased sample count on the exact head.

Evidence

What I checked:

  • Current-main behavior: Current main serializes include patterns in their original order before hashing, so equivalent reversed selections receive different timing keys. (scripts/lib/vitest-shard-metadata.mts:28, 9c3d3fc65a89)
  • Introduced repair: The verified merge-base-to-head patch sorts a copy before hashing, preserving caller order while making the metadata key order-independent. (scripts/lib/vitest-shard-metadata.mts:28, a1a6ea81325f)
  • Scheduling consumer: The local parallel scheduler reads persisted timings and looks them up through the shared timing-key owner; completed test runs write new samples through the corresponding persistence owner. (scripts/test-projects.mts:409, a1a6ea81325f)
  • Regression coverage: The changed test writes an initial sample, writes a reversed selection, then verifies one aggregate timing record with sampleCount 2; it also uses frozen input to detect accidental in-place sorting. (test/scripts/vitest-shard-timings.test.ts:42, a1a6ea81325f)
  • Real behavior proof: The PR body and current-head maintainer comment report before/after production CLI runs: reversed targets previously created two one-sample keys and now reuse one key whose sample count advances to 2. (a1a6ea81325f)
  • Current area history: Recent current-main history includes Vincent Koc and Peter Steinberger commits touching the timing-metadata owner; unavailable promisor objects prevented a complete older introduction trace, so no source-line introduction attribution is asserted. (scripts/lib/vitest-shard-metadata.mts:1, d22146e1035e)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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 (17 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-27T12:35:59.248Z sha 4a33cb5ddcb9de6e35d1560b4716a2453f8c3275 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-27T13:01:23.743Z sha 4a33cb5ddcb9de6e35d1560b4716a2453f8c3275 :: needs historical verification review before merge. :: none
  • reviewed 2026-08-31T10:18:08.854Z sha 8e9632b33da4c6d35f605dafd184e8f5c1557e12 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T11:31:09.202Z sha 8e9632b33da4c6d35f605dafd184e8f5c1557e12 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T11:38:47.394Z sha 8e9632b33da4c6d35f605dafd184e8f5c1557e12 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T16:05:50.994Z sha de1a6a1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T16:20:05.645Z sha de1a6a1 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T16:27:12.936Z sha de1a6a1 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 7, 2026
@qingminglong
qingminglong force-pushed the fix/scripts-stable-shard-timing-key branch from bbf3323 to 9161dfc Compare August 7, 2026 05:26
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 7, 2026
@qingminglong
qingminglong force-pushed the fix/scripts-stable-shard-timing-key branch from 9161dfc to c7dd134 Compare August 12, 2026 13:06
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
@qingminglong
qingminglong force-pushed the fix/scripts-stable-shard-timing-key branch from 8e9632b to de1a6a1 Compare August 31, 2026 15:47
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 31, 2026
Merge current main to move canonicalization into the shared timing metadata owner. Replace duplicate key comparisons with persisted sample aggregation coverage.

Co-authored-by: qingminlong <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Updated a1a6ea81325f1d7d8c383747a08fda8a9c06f938, preserving the contributor stack and merging current main to use the extracted metadata owner. The timing key now sorts a copy, preserving the caller’s execution order.

Four actual node --import tsx scripts/test-projects.mts runs of the same two files passed 14 tests each. Before: reversed order produced two keys with sampleCount 1. After: one key with sampleCount 2. Five focused timing tests and all 18 selected changed gates pass; complete integrated candidate Codex P0 review is clean. Production net 0, tests net +15. No timing-file schema change or measured whole-suite speedup is claimed. Thanks @qingminglong and @vincentkoc.

The prior ClawSweeper review is older than 12 hours: @clawsweeper re-review. Exact-head CI remains the landing gate.

@steipete
steipete merged commit ce87244 into openclaw:main Sep 1, 2026
201 checks passed
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

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

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XS 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.

3 participants