Skip to content

fix(ci): name the starved phase in a native discovery timeout receipt (#4149) - #4160

Merged
schlessera merged 2 commits into
mainfrom
fix/4149-native-discovery-startup
Nov 17, 2026
Merged

schlessera merged 2 commits into
mainfrom
fix/4149-native-discovery-startup

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4149

What changed

Native discovery did not get slower. On the failed confirmation run the whole runner was starved, and the cap caught it. A discovery failure receipt now shows which case a timeout was. Next to wall time it records the discovery leader's user and system CPU time and its involuntary context switches (cpu), plus the runner's parallelism and load average (host). CPU time near the deadline means discovery itself was slow. CPU time far below it means the runner withheld CPU or I/O. The 30-second cap, project selection, JSON file channel, process-group ownership and both pipe drains are unchanged. The decision record (docs/decisions/ci-utility.md) records the finding beside the #2380 ruling and has its updated citation.

Why this shape

The established cause is the runner, so there is no product or discovery regression to fix. The #2380 ruling already says the 30-second margin "does not guarantee completion under arbitrary CPU starvation". The issue rules out raising the cap or narrowing the inventory. What was missing was a receipt that could tell the two cases apart without guessing from stderr text, so this PR adds that. Discovery bundles and executes vitest.config.ts 16 times, once per inline extends: true project. That is real, measurable overhead, but it is not the cause, and removing it would restructure every browser project. Filed as #4159 (p3, no milestone).

Established cause (AC 1)

Step durations of the changeset job, from the Actions API:

Run checkout bun install discovery step
44035623508 (failed #4036 candidate) 52 s 22 s 31 s (killed at 30 s)
44036241499 11 s 3 s 12 s
44046614212 11 s 4 s 14 s
44029231245 13 s 3 s 7 s
44015070322 10 s 4 s 12 s

Across the 29 non-draft ci.yml runs before 09:15 UTC today, the discovery step took 7–14 s. The only exception is the failed run.

I reproduced the actual failed candidate locally. I merged head f62a5f6a6f93aeb664edde38961bda96d3816b72 into base d974052166f335cbf57b385fddc13875da1b98de (parents base then head), which gives tree 3c00feb182fbad2dc87fb2c8b32dcbd18772a0f8, the hosted tree. I installed with --backend=copyfile and ran the same node ../../node_modules/vitest/vitest.mjs list --filesOnly --json=… from packages/ui-kit with CI=true STORYBOOK_DISABLE_TELEMETRY=1, inside the pinned mcr.microsoft.com/playwright@sha256:eff16c30… image (node v24.20.0) with --network=none --memory=4g:

--cpus wall time (incl. container start) result
2 5,356 / 5,211 / 4,772 ms exit 0, 515 specs, all 15 projects
0.5 14,750 ms exit 0, stderr 70,592 bytes
0.3 26,193 ms exit 0, stderr 70,592 bytes

A complete discovery writes about 70.6 KB of stderr. The hosted child had written 38,826 bytes when it was killed at 30 s, about 55% of the run. That means it ran with less effective CPU than the 0.3-CPU throttle. This is consistent with checkout and install running about 5× slower on the same runner. The Vite native-config/CommonJS warnings appear in every successful run too, so they are not the cause.

A CPU profile of one discovery on two CPUs (5.0 s) breaks down as: Storybook plugin ~0.8 s, rolldown config bundling ~0.66 s, executing the bundled config ~0.62 s, GC ~0.5 s.

Proof

Failing first. I added native watchdog receipt separates a {waiting,computing} child's CPU time from wall time to tests/browser-inventory-process.test.ts before the implementation. Both cases failed on expect(receipt.cpu).toEqual({ userMs, systemMs, involuntarySwitches }) with receipt.cpu undefined.

The first implementation attempt also exposed a runtime trap. Bun 1.4 returns resourceUsage().cpuTime as BigInt even though its types say number. The throw ("Invalid mix of BigInt and other type in division") replaced the real discovery error in eight existing tests. The read is now converted with Number() and wrapped, so it can never replace the failure it explains.

Mutations, each restored afterwards:

  • Report wall time as CPU (userMs: performance.now() - started): the waiting case fails, Expected: < 501.5, Received: 1008.
  • Report zero CPU (userMs: 0 * …): the computing case fails, Expected: > 251, Received: 11.

After the change: bun run test tests/browser-inventory-process.test.ts passes 12/12. bun run test tests/cold-browser-discovery.test.ts passes (real browserInventory on a cold, build-free copy, default 30 s cap, 8.1 s). bun scripts/proof-system.ts classify --base origin/main --head HEAD reports "not a proof-system change", so the #4145 lane and its off-main qualification do not apply.

bun run check:pr --base origin/main
{"version":1,"kind":"brain-check-pr-receipt","head":"c2315e236dae40f337a3bcfd59ce7bb1b1bb13f8","base":"origin/main","mode":"focused","startedAt":"2026-11-17T09:19:41.115Z","finishedAt":"2026-11-17T09:21:09.066Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12852.021165},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":118.43906200000129},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":129.16476100000182},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":19.736795999997412},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":74816.672256}]}

Collisions: see the comment below, from bun scripts/collisions.ts --json --pr <this PR>.

Checklist

  • Focused local preflight/behavioral receipts passed; selected hosted proof runs at confirmation.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • Touches none of ui-react, ui-kit, ui-server, core under packages/.
  • Milestone 0.45.0 on this PR and ci: native Vitest discovery times out before publishing candidate inventory #4149.
  • No changeset: scripts/, tests/ and docs/ only, nothing a consumer can see.
  • No personal data anywhere in the diff.
  • No machine-surface change.
  • docs/decisions/ci-utility.md updated.
  • Guard behaviour is unchanged. The discovery gate still fails closed on the same conditions. This PR only adds fields to its failure receipt, and reading them cannot turn a failure into a pass or replace its error.
  • Nothing on a turn's path changed.

Anything left open

  • Hosted discovery runs only in the changeset metadata job on a standard ubuntu-24.04 runner, and that step is skipped for drafts. Heavy feedback does not run it. So the hosted half of AC 2 and AC 5 (complete discovery within 30 s and all selected categories passing, with checkout, parent and tree evidence) arrives with this PR's ordinary exact-candidate confirmation. The original failure is preserved above (run 44035623508, attempt 1).
  • test(experiments): assert synchronous Git revision refusal #4036's owner can request a fresh confirmation once this lands. If the runner is starved again, the receipt will now show it.
  • Follow-up ui-kit: every inline Vitest project re-bundles and re-executes the root config #4159: inline projects re-load the root Vitest config 16 times.

🤖 Generated with Claude Code

…#4149)

The #4149 confirmation timed out in native Vitest file discovery on a
runner whose checkout and install also ran about five times slower than
usual. The same two-parent candidate tree discovers in about 5 seconds in
the pinned image with two CPUs, so discovery did not regress. The receipt
could not show that: it recorded only wall time and the stderr tail.

A failure receipt now records the discovery leader's user and system CPU
time and involuntary context switches, with the runner's parallelism and
load average. CPU near the deadline means slow discovery; CPU far below it
means the runner withheld CPU or I/O. Reading the usage cannot replace the
discovery failure. The 30-second cap, project selection, file channel,
process-group ownership and pipe drains are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@schlessera schlessera added type: fix Something is broken and must behave the way it is documented. area: ci CI workflows, the gates they run, release scripts, packaging. labels Nov 17, 2026
@schlessera

Copy link
Copy Markdown
Owner Author

Collisions at head c2315e236dae40f337a3bcfd59ce7bb1b1bb13f8 (bun scripts/collisions.ts --json --pr 4160): no path collision. Closure-only overlaps with #3054, #3056, #3059, #3069, #3581, #3622, #4002, #4036, #4151, #4155 and #4157, all in shared test and proof categories. #4157 also edits docs/decisions/ci-utility.md in a different section, so a refresh merge may need a look there.

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

Labels

area: ci CI workflows, the gates they run, release scripts, packaging. type: fix Something is broken and must behave the way it is documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: native Vitest discovery times out before publishing candidate inventory

1 participant