Skip to content

test: restore native worker shutdown profiling coverage - #132820

Merged
steipete merged 1 commit into
mainfrom
codex/fix-vitest-shutdown-profile-fixture
Aug 29, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-vitest-shutdown-profile-fixture

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two shutdown regression cases fail on current main before their test body runs: vmForks and the custom fork transport that opts into graceful exit. The fixture invokes the general profiling wrapper, which now uses an Inspector profiler restricted to forks and threads. Its startup error is then hidden by an unconditional read of the missing test receipt. This blocked unrelated Slack and E2E-runner CI on their merge refs.

Why This Change Was Made

Run the shutdown fixture through the existing Vitest launcher and pass native CPU/heap profiling flags only through worker execArgv. The dependency patch's contract is native exit-time flushing; testing it through the newer awaited Inspector profiler mixes two different owners. The production profiler and its supported-pool restrictions remain unchanged.

Keep all twelve cases, existing deadlines, failure assertions, and cleanup checks. Match valid native profiles to the PID and thread ID recorded by the actual test worker, so a launcher profile cannot satisfy the proof. Missing receipts now report the captured child output instead of hiding the startup failure.

Evidence

  • Exact combined revision 86b9cf728895: baseline 10 passed, 2 failed, reproducing both CI failures. Captured child stderr confirms the unsupported-pool error before the missing receipt.
  • Corrected fixture: 12/12 passed, including vmForks, custom transport opt-in, threads, delayed cleanup, abnormal exit, and forced shutdown.
  • Actual Node 24 worker profiling verified valid CPU/heap files with the recorded PID/thread ID; installed Vitest 4.1.11 source confirms worker execArgv forwarding for forks, threads, and vmForks.
  • Sibling profiler/state-cleanup run: 45/46 passed; one unchanged nested SQLite test exceeded its existing five-second timeout on the loaded host. That exact case passed alone without edits. The failed run remains recorded; no timeout was increased.
  • Mandatory Codex review reported no actionable findings. Final changed-file gate passed, including test-root types and scripts lint.

Production/runtime delta: 0. Tests and test support: +39/-24 (net +15). No dependency patch, product configuration, timeout, or profiler-policy change.

Provenance: the native shutdown fixture was introduced in #132403 (0f221129474); the Inspector profiling implementation arrived in #132224 (81a74b23eb1). This repairs their combined test contract rather than reverting either owner.

@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 size: S 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:00 PM ET / 20:00 UTC.

ClawSweeper review

What this changes

The PR launches the shutdown fixture through the standard Vitest launcher with native worker profiling flags, then verifies CPU and heap artifacts belong to the worker that ran the test.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. The introduced test-only change removes the fixture’s incompatible Inspector-profiler path for vmForks and custom graceful-exit coverage; no introduced correctness or security defect was found. The protected maintainer label means final merge handling remains with a maintainer.

Priority: P2
Reviewed head: e5540820061bf47c16b31570715d0350974045a6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported test repair with no blocking finding; exact-head CI remains the final integration gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned test-only PR is exempt from the external-contributor proof gate; its supplied before/after worker-profile evidence is consistent with the reviewed fixture boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned test-only PR is exempt from the external-contributor proof gate; its supplied before/after worker-profile evidence is consistent with the reviewed fixture boundary.
Evidence reviewed 6 items Introduced fixture repair: The PR replaces the general profiling wrapper with the regular Vitest launcher and supplies native CPU/heap flags through Vitest worker arguments; it also fails with captured child output if the worker never writes its receipt.
Root cause in current source: The Inspector-based runner rejects pools other than forks and threads, which makes the prior vmForks fixture path incompatible before its test body can write the receipt.
Launcher forwarding boundary: The standard launcher recognizes --execArgv as a value-bearing Vitest option and forwards guarded Vitest arguments unchanged into the Vitest CLI process.
Findings None None.
Security None None.

How this fits together

The shutdown fixture starts isolated Vitest worker pools and records their exit behavior, worker identity, and profiling artifacts. Its assertions protect the test-runner cleanup contract used by CI without changing application runtime behavior.

flowchart LR
A[Shutdown scenarios] --> B[Fixture launcher]
B --> C[Vitest worker pool]
C --> D[Worker receipt]
C --> E[Native profile artifacts]
D --> F[Shutdown assertions]
E --> F
F --> G[CI regression coverage]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI was still running in the supplied snapshot, and the latest ClawSweeper comment body was filtered from the available context; confirm its rank-up moves before merge.
  • Resolve merge risk (P1) - Direct Vitest 4.1.11 source could not be inspected from this read-only checkout because dependencies were absent and network resolution failed; retain the recorded runtime evidence and exact-head CI as the merge proof.
  • Complete next step (P2) - The protected maintainer label and final exact-head CI/review checks require normal maintainer handling; no separate repair job is needed.
Agent review details

Security

None.

PR surface

Tests +15. Total +15 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 39 24 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 39 24 +15

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests and test support +39/-24 (net +15) All introduced lines stay in the shutdown fixture and its regression assertions; application runtime and profiler policy are unchanged.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain this narrow test-boundary repair and merge only after exact-head CI and the latest ClawSweeper review requirements are confirmed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain this narrow test-boundary repair and merge only after exact-head CI and the latest ClawSweeper review requirements are confirmed.

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

Yes, from source: vmForks reaches the Inspector runner’s explicit unsupported-pool rejection before the fixture receipt is written. The PR body also records a before/after run, but this read-only review did not execute the fixture.

Is this the best way to solve the issue?

Yes. The standard launcher already forwards worker arguments, while the specialized Inspector runner intentionally rejects vmForks; native worker flags test the exit-time artifact contract at the correct boundary without changing production profiling.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded CI regression in worker-shutdown coverage without affecting user-facing runtime behavior.
  • 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-owned test-only PR is exempt from the external-contributor proof gate; its supplied before/after worker-profile evidence is consistent with the reviewed fixture boundary.

Label justifications:

  • P2: This repairs a bounded CI regression in worker-shutdown coverage without affecting user-facing runtime behavior.
  • 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-owned test-only PR is exempt from the external-contributor proof gate; its supplied before/after worker-profile evidence is consistent with the reviewed fixture boundary.

Evidence

What I checked:

  • Introduced fixture repair: The PR replaces the general profiling wrapper with the regular Vitest launcher and supplies native CPU/heap flags through Vitest worker arguments; it also fails with captured child output if the worker never writes its receipt. (test/fixtures/vitest-fork-shutdown.mjs:257, e5540820061b)
  • Root cause in current source: The Inspector-based runner rejects pools other than forks and threads, which makes the prior vmForks fixture path incompatible before its test body can write the receipt. (scripts/lib/vitest-profiler.mts:45, e5540820061b)
  • Launcher forwarding boundary: The standard launcher recognizes --execArgv as a value-bearing Vitest option and forwards guarded Vitest arguments unchanged into the Vitest CLI process. (scripts/run-vitest.mts:136, e5540820061b)
  • Worker-specific assertions: The suite distinguishes thread workers from forked workers and verifies profiles only for the recorded process and thread identity, preventing a launcher artifact from satisfying the worker-shutdown assertion. (test/scripts/vitest-fork-shutdown.test.ts:48, e5540820061b)
  • Fixture provenance: History shows the shutdown fixture entered main in the merged change that also introduced the temporary Vitest graceful-shutdown patch; this PR is a focused follow-up to its test coverage. (test/fixtures/vitest-fork-shutdown.mjs:257, 0f2211294740)
  • Dependency-contract limitation: The fixture directly relies on Vitest worker execArgv handling. The local checkout has no installed dependency tree, and network resolution prevented inspecting upstream Vitest source; the repository patch documentation describes the intended forks/vmForks native-exit contract. (patches/README.md:7, e5540820061b)

Likely related people:

  • steipete: Current source history attributes the original shutdown fixture to the merged graceful-shutdown work and the follow-up test repair to this author. (role: feature introducer and recent area contributor; confidence: high; commits: 0f2211294740, e5540820061b, 81a74b23eb1f; files: test/fixtures/vitest-fork-shutdown.mjs, test/scripts/vitest-fork-shutdown.test.ts, scripts/lib/vitest-profiler.mts)

Rank-up moves

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

  • Confirm the latest ClawSweeper rank-up moves and exact-head CI completion before merging.

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

ClawSweeper before-merge items dispositioned:

  1. Exact-head CI — now complete and green on aead6c1-equivalent head: 114 success, 36 skipped, 0 failures.
  2. Vitest source inspection — the profiler restriction is verified directly in this repo rather than in the dependency: scripts/lib/vitest-profiler.mts:45-46 throws Runner profiling supports the forks and threads pools only for any project whose pool is not forks/threads, which is exactly what vmForks and the custom custom-fork pool hit during global setup. Reproduced on a pristine main checkout (Tests 2 failed | 10 passed, ENOENT on receipt.json) and by running the inner command manually.
  3. Maintainer handling — proceeding through the native landing pipeline.

Also closed #132822, an independently-developed fix for this same breakage, in favor of this PR: it keeps profiling coverage for the affected scenarios instead of dropping those assertions, and additionally matches profile files by worker PID/threadId so a launcher profile cannot satisfy a worker exit-flush assertion.

@steipete
steipete merged commit f9b3bcc into main Aug 29, 2026
150 checks passed
@steipete
steipete deleted the codex/fix-vitest-shutdown-profile-fixture branch August 29, 2026 20:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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