Skip to content

chore: speed up worktree recovery tests with Bun - #157674

Merged
steipete merged 3 commits into
mainfrom
codex/bun-test-speed-next-20260924
Sep 25, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/bun-test-speed-next-20260924

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Worktree recovery tests repeatedly pay SQLite startup and shutdown costs, and a migration fixture reopens databases before asynchronous shutdown completes.

User Impact

No product behavior changes. All 61 existing fixture cases retain their assertions. Qualified worktree-recovery selections run on Bun for PRs; mixed PR groups retain Node. Dual-runtime validation keeps the complete Node selection and adds the selected qualified Bun coverage.

Why This Change Was Made

Worktree recovery reuses a suite-owned database and deletes each case's exact registry record after operations settle. A teardown assertion detects leaked run leases, and final teardown awaits closure before directory removal. Main's prepared Git template and batched snapshot refs remain intact. The migration fixture now uses the existing scoped cleanup operation before reopening instead of synchronous helpers that start background shutdown.

The runtime selector admits the worktree-recovery file only when it is the entire exact PR selection. It preserves unsupported-argument fallbacks and the original Node coverage in release validation. Both runtimes retain Vitest's assertions, loaders, compiled subprocesses, reporters, and resource budgets.

Evidence

Matched Linux measurements on final tree 0486a62ce59adc200b2949044547d10b0332a766 (base d9a69464657d), one AWS m7i.xlarge, one worker, unchanged budgets, and separate disk-backed caches:

Runtime Before fixture reuse After fixture reuse
Node 24.18.1 102.004 s 60.383 s
Bun 1.4.3-canary.1+ddfce5d01 83.290 s 47.392 s

All four cells pass the exact same 58 cases with zero skips. Bun is 21.5% faster than optimized Node; original Node to optimized Bun is 53.5% faster. Bun uses the checksum-pinned OpenClaw fork build.

The actual ci-run-node-test-shard.mts launcher, supplied the qualified target and bun-compatible policy without an explicit runtime override, selected Bun and passed all 58 cases in 50.342 s. The test command and final source check completed successfully. The lease expired during subsequent harness cleanup, so the outer Crabbox command returned 7; the paired JSON reports and streamed launcher result were preserved.

The migration fixture reproduces three failures under Bun before the repair and passes all three afterward. The same Bun forks diagnostic group replay passes 1,485 files and 19,555 cases, with the same four skipped files and eleven skipped cases. Bun still emits its existing directory-cache and occasional worker-shutdown warnings; no broad pool or native-import change is included.

After rebasing onto d9a69464657d, all 61 fixture cases and 145 runtime-selection cases pass locally. Independent reviews are clean through P2. The final tree is 0486a62ce59adc200b2949044547d10b0332a766. The full Linux changed-file gate passed on the reviewed superset before the conflict-only rebase; focused tests and runtime qualification passed on the final tree. Hosted CI attempt 2 passed both changed-test jobs (147 s and 154 s). The recovery suite ran on the checksum-verified fixed Bun fork: all 58 cases passed in 57.69 s of Vitest time and 61.15 s including its launcher. The three migration cases also passed on Bun in 17.48 s of Vitest time and 20.65 s including the launcher. Both archive and executable checksums were verified; the runtime revision was 1.4.3-canary.1+ddfce5d01. Hosted timings include different runner/cache conditions; the matched Linux table above is the runtime comparison.

Canonical local single-worker command costs on Node 26.9.0: worktree recovery 100.82 s, migration cleanup 17.02 s, and runtime-selection tests 8.64 s. Compiler preparation varied across local fixture measurements, so the Linux paired results above carry the speed comparison. The new selection cases take about 20 ms. In hosted CI, the routing file passed all 145 cases in 2.330 s of file test time; its containing two-file envelope took 46.54 s including preparation. Full changed-file checks passed for the fixture patches; script/test type checks, lint, formatting, and independent P2 review passed for the routing change.

Earlier CI used a merge base with the UpdateStepResult import defect; this branch includes its owning fix, #157659. An overlapping session-fixture improvement landed in #157685, so this PR retains that main implementation and contains no session-recovery fixture delta. The resolved head was deferred by Full Release Validation runner priority. Once its owner cleared priority, CI attempt 2 passed on the same head. Its final aggregate waited 14 m 21 s for a hosted runner, then passed in 4 s; that allocation delay is separate from test execution time. Security Review and the exact-head ClawSweeper review are clean.

@clawsweeper

clawsweeper Bot commented Sep 24, 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 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 9:26 PM ET / September 25, 2026, 01:26 UTC (Revision 3).

ClawSweeper review

What this changes

The branch reuses a suite-owned SQLite fixture, awaits Doctor test cleanup, and runs exact worktree-recovery CI selections on Bun while retaining Node coverage.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main lacks the qualified Bun route, and the merged fixture work covers only part of this change. The reported exact-launcher run and focused review support the patch; no actionable defect was found.

Priority: P3
Reviewed head: e1e443940416210af3c503c54f92bace83d3c638

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The scoped patch has meaningful real-launcher proof and no identified correctness or security blocker.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed CI selector routes the recovery suite through Bun; the PR records an after-change Linux run through the actual shard launcher selecting Bun and passing all 58 cases, plus matched Node/Bun measurements. No production stored-data contract changes; SQLite reuse is confined to test fixtures.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed CI selector routes the recovery suite through Bun; the PR records an after-change Linux run through the actual shard launcher selecting Bun and passing all 58 cases, plus matched Node/Bun measurements. No production stored-data contract changes; SQLite reuse is confined to test fixtures.
Evidence reviewed 9 items Introduced CI route: The pinned merge-base-to-head diff adds Bun admission for the exact recovery file and retains Node for other agents-support selections.
Fixture lifecycle: The suite retains one state database, checks for a live run lease before deleting each case’s registry row, and awaits database closure at suite teardown.
Migration test cleanup: The changed test awaits the existing scoped cleanup before reopening state; that helper drains writers and closes the relevant database handles.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CI launcher receives a test selection and runtime policy, then starts the appropriate Vitest process. The recovery suite checks Git worktree removal using test-owned Git and SQLite state.

flowchart LR
A[CI test selection] --> B[Runtime policy]
B --> C{Exact recovery selection?}
C -->|Yes| D[Bun test run]
C -->|No| E[Node test run]
B -->|Dual validation| E
D --> F[Recovery assertions]
E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +83, Docs +6, Other +33. Total +122 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 104 21 +83
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 34 1 +33
Total 5 144 22 +122

Review metrics

Metric Value Why it matters
Matched recovery wall time 60.383 s Node → 47.392 s Bun; 21.5% faster The PR reports a same-host, single-worker comparison for the optimized fixture.
Measured recovery coverage 58 cases, 0 skips in all four comparison runs The measured speedup did not omit recovery cases.

Technical review

Best possible solution:

Preserve a faster, complete recovery test run on the pinned Bun build, with Node validation and case isolation maintained.

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

Not applicable: this PR optimizes test execution. The PR records matched before/after runs and an after-change run through the actual shard launcher.

Is this the best way to solve the issue?

Yes: the selector admits only the measured recovery file to Bun and keeps mixed selections on Node; the fixture changes retain the existing assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal test and CI speed improvement with no product behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed CI selector routes the recovery suite through Bun; the PR records an after-change Linux run through the actual shard launcher selecting Bun and passing all 58 cases, plus matched Node/Bun measurements. No production stored-data contract changes; SQLite reuse is confined to test fixtures.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed CI selector routes the recovery suite through Bun; the PR records an after-change Linux run through the actual shard launcher selecting Bun and passing all 58 cases, plus matched Node/Bun measurements. No production stored-data contract changes; SQLite reuse is confined to test fixtures.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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-09-24T23:14:19.190Z sha bbea013 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-25T01:16:05.351Z sha e1e4439 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Sep 24, 2026
@steipete steipete changed the title chore: speed up session recovery tests chore: speed up session and worktree recovery tests Sep 24, 2026
@steipete
steipete force-pushed the codex/bun-test-speed-next-20260924 branch from b9bf1bf to 0f58357 Compare September 25, 2026 00:18
@steipete steipete changed the title chore: speed up session and worktree recovery tests chore: speed up recovery tests with Bun Sep 25, 2026
@steipete
steipete force-pushed the codex/bun-test-speed-next-20260924 branch from 0f58357 to e1e4439 Compare September 25, 2026 00:34
@steipete steipete changed the title chore: speed up recovery tests with Bun chore: speed up worktree recovery tests with Bun Sep 25, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 25, 2026
@steipete
steipete enabled auto-merge (squash) September 25, 2026 02:01
@steipete
steipete merged commit 10bb242 into main Sep 25, 2026
187 of 192 checks passed
@steipete
steipete deleted the codex/bun-test-speed-next-20260924 branch September 25, 2026 02:15
vincentkoc added a commit that referenced this pull request Sep 25, 2026
* commit '05edd36e124dc376f63475256f45e82ec437412c': (30 commits)
  refactor(matrix): reuse bounded direct-room cache insertion (#157775)
  fix: preserve channel-owner revocation across recovery (#157709)
  fix(ci): stop blocking CI during release validation (#157757)
  refactor(tlon): remove unreachable DM summary branches (#157789)
  chore: speed up worktree recovery tests with Bun (#157674)
  fix(sessions): release PR caches when pending viewers leave (#157776)
  refactor(twitch): reuse setup account selection (#157787)
  test: skip empty task ledger resets in cron fixtures (#157767)
  perf: reduce gateway and state test startup (#157711)
  fix: preserve maintenance leases during slow heartbeat renewal (#157696)
  fix(channels): match non-TTY setup advice to registered flags (#157551)
  fix: keep failed update report uploads in the CLI (#156633)
  fix: preserve rejected settings reason when opening config (#157731)
  test(update): load real filesystem dependencies in swap fixture
  fix(ci): prevent Security Review checkout retry collisions (#157652)
  fix(ci): recover interrupted Security Review response bodies (#157651)
  test(ui): capture live operator authority in guest question fixture
  refactor(agents): deslop runners, harness and recovery (#157294)
  fix(auth): preserve Copilot tenant credentials during Doctor repair (#139131)
  refactor(msteams): share stored service URL validation (#157706)
  ...
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
* test: reuse the worktree removal recovery database

* test: join database shutdown before reopening migration fixtures

* ci: run qualified worktree recovery selections with Bun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant