Skip to content

fix(test): route unprofilable pools past the vitest profiling runner - #132822

Closed
steipete wants to merge 1 commit into
mainfrom
steipete/fix-fork-shutdown-profiler-pools
Closed

steipete wants to merge 1 commit into
mainfrom
steipete/fix-fork-shutdown-profiler-pools

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

test/scripts/vitest-fork-shutdown.test.ts fails deterministically on main for two scenarios — vmForks/raw and custom-opt-in/raw — turning the checks-node-compact-small-* shard and the CI gate red. It reproduces on a pristine main checkout with no other changes:

Tests  2 failed | 10 passed (12)
Error: ENOENT: no such file or directory, open '.../receipt.json'

Root cause: scripts/lib/vitest-profiler.mts rejects any pool other than forks/threads ("Runner profiling supports the forks and threads pools only"), but the fixture routed every scenario except plain/custom through run-vitest-profile.mts. For vmForks (pool vmForks) and custom-opt-in (a custom custom-fork pool), the inner Vitest run therefore died during global setup, never ran the fixture test, and never wrote receipt.json — so the outer fixture crashed on an unconditional readFileSync instead of reporting a usable failure. On CI the same two scenarios surfaced with a misleading "Timeout waiting for worker to respond".

Why This Change Was Made

Two small, matched changes:

  1. The fixture now picks its runner from pool compatibility rather than a hardcoded scenario list: pools the profiler cannot accept run through the plain runner. plain and custom keep their existing routing, so no currently-passing scenario changes path.
  2. The fixture reports whether it actually profiled (profiled), and the test asserts CPU/heap profile artifacts only for those runs — instead of duplicating pool knowledge in a second file. Unprofiled runs still assert the inner run passed.

Worker-shutdown assertions — the point of the test — are untouched: workerStopped, terminate/deadline events, home cleanup, and exit codes all still apply to every scenario.

User Impact

None at runtime; test infrastructure only. Unblocks main and every PR whose merge ref includes this test.

Evidence

  • Before, on pristine main (cfa802d73e5): Tests 2 failed | 10 passed (12), both failures ENOENT on receipt.json.
  • After: Tests 12 passed (12).
  • The repaired path still proves real shutdown, not a weakened assertion — running the vmForks fixture directly reports code: 0 workerStopped: true profiled: false, so the test's core invariant remains asserted.
  • Root cause confirmed by running the inner command manually: Error: Runner profiling supports the forks and threads pools only at scripts/lib/vitest-profiler.mts:46.

Found while landing an unrelated PR (#132740) whose merge ref inherited this failure; filed separately so the CI repair lands on its own rather than riding along with an exec-policy change.

The profiling runner supports only forks/threads pools, but the fork-shutdown
fixture sent every scenario except plain/custom through it. vmForks and the
custom-opt-in pool died during global setup, so the inner run never wrote its
receipt and the fixture crashed with ENOENT instead of a usable failure.

Route those scenarios through the plain runner and assert profiling artifacts
only for runs the fixture actually profiled; worker-shutdown assertions are
unchanged.
@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.

@steipete
steipete marked this pull request as ready for review August 29, 2026 19:59
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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, 4:09 PM ET / 20:09 UTC.

ClawSweeper review

What this changes

The PR sends Vitest pools unsupported by the profiling runner through the ordinary runner and conditions profile-artifact assertions on whether profiling ran.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer handling: current main retains the incompatible route, and the introduced test-only repair matches the profiling boundary without weakening shutdown assertions.

Priority: P2
Reviewed head: aead6c157baf2637b5755d35a6c14095e0315d6c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported test repair with no actionable introduced defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor proof gate; its stated before/after behavior is corroborated by the direct fixture and profiling-owner path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor proof gate; its stated before/after behavior is corroborated by the direct fixture and profiling-owner path.
Evidence reviewed 5 items Current-main failure path: The base fixture config selects vmForks or a custom pool, but routed every scenario except plain and custom through runner-mode profiling; the latter is therefore selected for vmForks and custom-opt-in before this PR.
Profiling owner contract: Runner-mode profiling installs the repository global setup, which rejects every pool other than forks and threads before the inner fixture test can write its receipt.
Introduced repair preserves the invariant: The new condition is equivalent to the fixture’s configured supported-pool set; unprofiled scenarios assert a successful inner run while all applicable worker-stop assertions remain in place.
Findings None None.
Security None None.

How this fits together

The fork-shutdown fixture launches an inner Vitest run across pool configurations and reports its result to an outer lifecycle test. Profiling is optional instrumentation; the outer test verifies worker cleanup, exit behavior, and fixture isolation.

flowchart LR
  A[Shutdown lifecycle test] --> B[Fixture scenario]
  B --> C{Pool supports profiling}
  C -->|forks or threads| D[Profiling runner]
  C -->|custom or vmForks| E[Plain runner]
  D --> F[Inner test result]
  E --> F
  F --> G[Cleanup and shutdown assertions]
Loading

Before merge

  • Complete next step (P2) - No repair work is needed; retain this maintainer-authored PR for normal exact-head CI and merge handling.
Agent review details

Security

None.

PR surface

Tests +11. Total +11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 14 3 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 3 +11

Review metrics

Metric Value Why it matters
Production versus test LOC production 0, tests +14/−3 The complete introduced diff changes only the test fixture and its lifecycle assertions.

Technical review

Best possible solution:

Land the focused fixture-boundary repair after exact-head CI completes, keeping profiler eligibility and profile-artifact assertions aligned.

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

Yes. Current-main source configures vmForks and custom pools, invokes runner-mode profiling, and that setup rejects those pools before the fixture writes its receipt.

Is this the best way to solve the issue?

Yes. The fixture owns both pool construction and runner selection, so choosing the plain runner there avoids an incompatible wrapper while retaining the shutdown test’s behavioral assertions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a focused repair for a deterministic CI test-infrastructure failure.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor proof gate; its stated before/after behavior is corroborated by the direct fixture and profiling-owner path.

Label justifications:

  • P2: This is a focused repair for a deterministic CI test-infrastructure failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor proof gate; its stated before/after behavior is corroborated by the direct fixture and profiling-owner path.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes both the earlier routing and the profiling pool restriction to Peter Steinberger. (role: recent fixture and profiler contributor; confidence: high; commits: 0f2211294740, 81a74b23eb1f; files: test/fixtures/vitest-fork-shutdown.mjs, scripts/lib/vitest-profiler.mts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #132820, which fixes the same breakage better.

Both PRs diagnose the same root cause — the profiling runner accepts only forks/threads (scripts/lib/vitest-profiler.mts:46), so vmForks and the custom-pool custom-opt-in died during global setup, never wrote receipt.json, and the unconditional readFileSync turned that into an opaque ENOENT.

#132820 is the better repair on three counts:

  1. It keeps profiling coverage for those scenarios by passing native --cpu-prof/--heap-prof through worker execArgv, where this PR dropped the profile assertions for them.
  2. It makes the original failure legible with assert.ok(fs.existsSync(receipt), ...) including captured output, instead of a bare ENOENT.
  3. It tightens an unrelated weakness in the existing test: profile files are now matched by worker PID/threadId, so a launcher-produced profile can no longer satisfy an assertion about the worker's exit-time flush.

#132820 is green on its exact head with no failing checks.

@steipete steipete closed this Aug 29, 2026
@RomneyDa
RomneyDa deleted the steipete/fix-fork-shutdown-profiler-pools branch October 22, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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