Repository navigation
Description
Context
#4109/#4134 delivered a pre-merge gate that repeats the Bun test files a pull request adds or modifies under CPU load (bun scripts/test-determinism.ts, the hosted determinism job). It covers only files that bun test discovers under packages/ and tests/.
The browser, layout, endurance and story specs are outside it. They run in Vitest 4.1.11 inside the pinned browser container, through scripts/visual.mjs (test:browser, test:layout and test:endurance in package.json:20-23), in the post-merge browser, layout and endurance categories. A racy wait added to one of those specs still runs once, after merge, on the squash's main run.
Decided (maintainer, 2026-11-17): C, measure first. This issue is now a spike. Its deliverable is the measurement and a recommended A (keep post-merge) or B (add a pre-merge job); the ruling on pre-merge cost follows from it.
Scope
Measure, against the installed Vitest and the pinned browser container, and report on this issue:
- Repetition. Whether a spec file can be rerun several times with fresh browser state, and by which mechanism (the
repeatsoption in the installed type declarations, a CLI flag, or separate invocations). State what state carries over between repetitions for each. - Cost. Seconds for the first run and for each further repetition, for at least one representative
*.visual.tsx,*.pointer.tsx,*.layout.tsxand*.stories.tsxfile, separating container and browser start-up from the spec itself. - Load. Whether CPU burners outside the container slow the browser processes inside it, and what it takes to put the browser under load if they do not. Reproduce one known hosted-only race from a closed red-main incident if one is cheap to set up.
- Demand. Over the 150 most recent merges, how many changed a spec, and the estimated job duration distribution at two and five repetitions from
scripts/browser-shard-costs.jsonand the measured ratio. - Files. Which patterns count, and whether a changed spec helper should select its specs.
Out of scope
- Building the job. No workflow, planner or aggregate change merges from this spike; a measurement-only branch or workflow is an evidence vehicle and stays unmerged.
- The Bun gate from ci: repeat a PR's changed Bun test files under CPU load before merge #4109.
- Changing any spec deadline, or any retry that turns a failure green.
Acceptance criteria
- A comment on this issue reports each measurement above with its method, the exact Vitest version and image identity, where it ran (this host or a hosted runner) and its limits.
- The comment recommends A or B. For B it proposes a repetition count, a budget, the cadences it runs at and its expected effect on the merge lease.
- Anything that could not be measured is named as unknown, not estimated silently.
Verification
- The commands in the comment reproduce its numbers.
Contract impact
None. CI tooling only.
2026-11-17 triage at main d974052166f335cbf57b385fddc13875da1b98de: Verified delivered #4109/#4134 and the fresh-proof supersession. The existing A/B/C prompt still applies: a Vitest pre-merge extension needs its own ruling, and the recommendation to measure first is not approval.
2026-11-17: the maintainer chose C (measure first); the body now describes the spike.
Activity
schlessera commentedon Nov 17, 2026
Decision needed (triage, 2026-11-17). Should a PR's changed Vitest browser, layout, endurance and story specs be repeated before merge?
Under the hybrid ruling, those categories run only after merge. Any pre-merge repetition is a new pre-merge browser cost, so it needs a ruling first.
scripts/browser-shard-costs.json. Cost: a new pre-merge browser job on every PR that touches a spec.repeatsdoes to browser state, the cost per repetition in the container, and whether runner load reaches the browser processes. The ruling then follows from the evidence.Recommendation (not approval): C. Those questions are facts an agent can measure, and the ruling on pre-merge cost is better made with the cost known. If C is chosen, the issue becomes a spike whose deliverable is the measurement plus a recommended A/B.
Completion evidence: a
**Decision (maintainer, <date>):**comment choosing A, B or C. Acceptance criteria then follow from that choice.schlessera commentedon Nov 17, 2026
Decision (maintainer, 2026-11-17): C, measure first. This issue becomes a spike: measure repetition, cost, load and demand against the installed Vitest and the pinned container, report here, and recommend A or B. The ruling on a pre-merge browser job follows from that evidence. Nothing merges from the spike.
chore(ci): measure the #3953 race under each burner placement (#4116)
chore(ci): record the spike's probes and demand scripts, and retire i…
schlessera commentedon Nov 17, 2026
Spike report: repeating changed Vitest browser, layout and story specs before merge
Recommendation: B, in a bounded form. Add a pre-merge job that repeats a pull request's changed specs in the pinned container, with CPU burners running inside the container. Details and the proposed bounds are under Recommendation. What stays unknown is under Unknown.
What was measured, and where
vitest,@vitest/browser,@vitest/browser-playwrightand@vitest/runnerall at 4.1.11 innode_modules), Playwright 1.63.0.mcr.microsoft.com/playwright@sha256:eff16c30e6f3f4af0a03fa4b706120d5e9b0891c344a27d64559aff5900a4a27(diagramProducerImageIdentity,scripts/diagram-export-producer.mjs:11, asserted bytests/browser-image-pin.test.ts). Node v24.20.0 inside it.e2a233e7e. The repetition probe in section 1 ran one commit earlier, at49b6e7c48.ubuntu-24.04, 4 vCPUs, 15.7 GB, runs 44049769708 and 44051630821. Both come from the unmerged branchspike/4116-browser-repeat-measure, whose own workflow ran on pushes to that branch only. Each number below from these runs is one run.tasksetin the container,CPUAffinityoutside), so Node saw four CPUs. Other work ran on the remaining cores at the same time. Local seconds are not runner seconds; the hosted run is the reference for cost.scripts/measure-4116/.1. Repetition: what each mechanism reruns and what carries over
Method: a throwaway probe spec in the
visualproject (and a copy matched by the threerail-*projects) counted its own invocations in module scope, onglobalThis, on the orchestrator page (window.parent), inlocalStorage,sessionStorage, a cookie, IndexedDB and leftover DOM, and reportedperformance.timeOriginand the Vitest session id. It ran in the pinned container under each mechanism. Source read:runTestinnode_modules/@vitest/runner/dist/chunk-artifact.jsandTestOptionsinnode_modules/@vitest/runner/dist/tasks.d-*.d.ts.repeats, the option in the type declarationsbeforeEach/afterEachand test-scoped fixtures.timeOrigin), module state,globalThis, leftover DOM, all storage,beforeAllstate.rerunTestSpecifications()fromvitest/node)globalThis, DOM,beforeAll.localStorage,sessionStorage, IndexedDB; Node-side state of the browser commands; the Vite server.vitest runinvocations in one containerpackages/ui-kit/node_modules/.vite, the mounted temp directory,__screenshots__.scripts/visual.mjsonce per repetition)repeatsis a per-test option only. The runner copies it from the test's own options (repeats: options.repeats), with no config fallback, whereretryhas one (options.retry ?? runner.config.retry). The CLI has--retryand no repeat flag. Repeating unedited specs with it would need a source transform.repeatsloops each test by itself: test A runs n times, then test B. The file never reruns as a unit.repeats: 2gave three runs and the reporter counted one test. A repetition that fails leaves the test failed and the remaining repetitions still run; the report says(repeat x3)but not which repetition failed.rail-*projects show how it would behave: each had its own browser session and storage, and they ran at the same time, so the repetitions would compete with each other for CPU.2. Cost
Method:
scripts/measure-4116/rerun.mjsstarts Vitest once throughvitest/node, runs the spec, then reruns it in the same process, printing the wall time of each step. One container per spec, no load,--browser.fileParallelism=falseas inscripts/visual.mjs. Hosted run 44049769708, seconds:contact-card-fact-keys.visual.tsx(visual)dictation-notice.pointer.tsx(rail-fine)handoff-sheet.layout.tsx(ui-react-layout)SearchResultCard.stories.tsx(storybook)scripts/visual.mjsinvocation of the visual spec took 14.9 s cold and 13.4 s with a warm dependency cache, for a spec of 3.1 s: about 10 s of overhead per separate invocation.vitest runin one container was not timed as a loop. From the table it costs the start (3.3 s) plus the first-pass extra (1.8 to 3.0 s), so 5 to 6.5 s per repetition more than an in-process pass.3. Load
CPU burners outside the container reach the browser only weakly on a hosted runner. Burners inside the container compete with it thread for thread.
/system.slice/hosted-compute-agent.serviceand the container is in/system.slice/docker-<id>.scope. Both havecpu.weight100 under a parent with the CPU controller enabled (Docker's systemd cgroup driver, cgroup v2). The kernel therefore divides CPU between the two groups, not between threads: however many burners run outside, the container keeps half the CPUs.Further passes of the four specs, hosted run 44049769708, seconds and ratio to no load:
contact-card-fact-keys.visual.tsxdictation-notice.pointer.tsxhandoff-sheet.layout.tsxSearchResultCard.stories.tsxA known hosted-only race. #3953 was a red main in
layout:composer-image-originals.offline.tsxread a chip's status once and could catchpreparing preview…. #3954 fixed it with oneexpect.poll. A copy of the current spec with that one line reverted (measure-3953-race.offline.tsxon the measurement branch) was repeated in one Vitest process:expected 'Image · 558 B · preparing preview…' to match /^Image · .+ · not shown inline$/.4. Demand
Method:
git log --first-parent -150on main ate2a233e7e(2026-11-09 to 2026-11-17), then for each commit the added, modified or renamed files that match the patterns in section 5 (scripts/measure-4116/demand-collect.py)..offline.tsx18,.stories.tsx15,.visual.tsx11,.layout.tsx8,.pointer.tsx7,.endurance.tsx0.Estimated job duration (
scripts/measure-4116/demand-estimate.py):scripts/browser-shard-costs.jsonfor every project/file pair its changed specs run in, fromvitest list --filesOnly(a pointer spec counts three times, a story twice). The weights are taken at face value, which section 2 shows is high for the browser category and about right for layout.conversation.offline.tsxandconversation-contextual.offline.tsxhave no weight, are estimated at 3.4 s, and took 105 and 120 s under load locally. The table understates selections that contain such files.What the job could have prevented in the same window. 14 red-main incidents were opened between 2026-11-09 and 2026-11-17. Seven were in
browserorlayout. One of those was infrastructure (#3757, the container socket closed before any test ran). The other six were cleared by test-only changes (#3774, #3819, #3953, #3993, #4098, #4125).browserjob was skipped in every pre-merge run of CONTRACT: feat(ui-kit): markup editor parts and the shared image-editor shell (#3983) #4093, so those stories first ran on a runner after they merged. One pre-merge run in the container would probably have shown the failure.5. Files
packages/ui-kit/vitest.config.tsinclude):packages/ui-kit/tests/visual/**/*.visual.tsxpackages/ui-react/tests/browser/**/*.pointer.tsx,*.layout.tsx,*.offline.tsxand*.endurance.tsxpackages/ui-kit/stories/**/*.stories.tsx.offline.tsxwas missing from the issue's title and is the most often changed kind. It runs inui-react-layout.rail-*projects for a pointer spec, two themes for a story, Chromium and WebKit fordiagrams-*.layout.tsx..endurance.tsxfile should stay out. It is real-time media proof with its own job and no recorded weight, and no merge in the window changed it.scripts/measure-4116/demand-helpers.py). 21 merges changed a non-spec file under the spec directories; in 15 of them the rule would add no spec, and at most 5. The benefit is small, and the planner has no per-spec import map today:scripts/browser-input-closure.tsresolves inputs per category.offline/fault-network.ts, reaches 27 specs; a change to it would select all of them.Recommendation
B: add the job, bounded so that it cannot set the merge lease.
The evidence for it:
The evidence against, which the bounds answer: 5 of the 38 selections are too heavy to repeat inside any reasonable time, and burners outside the container do about half as much.
Proposed shape:
vitest runworks. In-process passes are 5 to 6.5 s cheaper per repetition and keep the isolation consecutive files have today; they needVITEST=trueset before Vitest starts, or the Storybook plugin registers no story. Separate invocations give a new browser each time and need no new API. Notrepeats: it reruns single tests inside one page with all state kept, so a spec that is not idempotent in its own document would fail for a reason that is not a race.scripts/browser-shard-costs.json. At a load ratio of 1.8 that is about 9 minutes of passes and about 12 minutes for the job.determinism: draft, ready feedback and ready confirmation, plus draft heavy feedback. Never on main, where each spec already runs once.unitpartition at 879, 965 and 981 seconds. A job capped near 12 minutes ends before it. Without the over-budget rule, those 5 selections would hold the lease for 13 minutes to 2 hours.scripts/browser-shard-costs.json(scripts/refresh-browser-costs.ts): a budget cannot bound files that have no weight.If the maintainer prefers A, the sentence for the hybrid ruling is: a racy wait in a changed browser, layout or story spec is caught by a later main run, often many merges after the one that introduced it (2 to 146 in this window).
Unknown
vitest runloop, which is derived from the in-process laps, not timed.diagrams-*projects. No diagram spec was repeated; their native artifact preparation adds start-up that this spike did not time.Reproduce
The local load experiment is
scripts/measure-4116/local.sh; it needs a systemd user slice and four free cores, and its header says how to set them up. The measurement branch is not a pull request and nothing on it merges; it can be deleted after the ruling.schlessera commentedon Nov 17, 2026
Decision (maintainer, 2026-11-17): B, add the pre-merge repetition job as the spike report proposes, with one change. A selection too heavy for one job is split across runners by reviewed weight, as #4117 does for the Bun gate; it is not skipped.
What it implies:
The spike's deliverable is complete, so this issue closes. The work continues in the two issues linked below.
Follow-up issues: #4162 (weights refresh, first) and #4163 (the job).