Skip to content

chore(ci): repeat a PR's changed Vitest specs under load in the pinned container before merge (#4163) - #4175

Merged
schlessera merged 20 commits into
mainfrom
chore/4163-browser-spec-repetition
Nov 17, 2026
Merged

schlessera merged 20 commits into
mainfrom
chore/4163-browser-spec-repetition

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4163
Closes #4189

Lands after #4157: this branch contains that PR's commits (the determinism partitions) and builds on its planner, so its own diff is what remains once #4157 has merged.

What changed

A pull request that adds or modifies a Vitest browser, layout or story spec now gets a hosted browser_determinism job at every pull-request cadence, drafts and draft heavy feedback included, and never on main. The job repeats each changed spec in the pinned container, in every Vitest project that includes it, while one CPU burner per CPU runs inside the container: five repetitions, two at ready confirmation. The first failing repetition fails the job and names the spec, the project, the repetition and the case. draft gates, proof, the heavy-feedback aggregate and the merge path require the job when the plan selects it and require its skip otherwise.

  • Selection. *.visual.tsx, *.stories.tsx, *.pointer.tsx, *.layout.tsx and *.offline.tsx in the three spec directories; not the endurance spec, and a changed helper selects nothing. The planner expands each file to the project/file pairs Vitest's own listing reports, from one listing per plan shared with category selection. A changed spec that no project lists, or an unreadable listing, fails the plan.
  • Mechanism. bun scripts/browser-determinism.ts enters the container through scripts/visual.mjs (one new flag, --repeat-plan), so image, mounts and network are the browser suite's. Inside, scripts/browser-determinism-inside.mjs starts Vitest once through vitest/node and calls runTestSpecifications with exactly the selected pairs for every pass, one project at a time. Not repeats, and not a loop of vitest run.
  • Bound and partitions. 300 weighted seconds of scripts/browser-shard-costs.json, reduced uniformly to a floor of two; a pair without a weight costs 10 seconds and the report names it. A selection over capacity at two repetitions is split into planned partitions with the Bun gate's functions; beyond 15 the planner refuses in the metadata job. BROWSER_DETERMINISM_PARTITIONS owns the numbers.
  • Merge path. The job inventory bound was the literal 30. It is now every proof job at its widest matrix (MAX_RUN_JOBS), because a third matrix job would have outgrown it.

Nothing under packages/ changes: no spec, story, config or product source. The gate's fixture specs and their Vitest config live in tests/fixtures/browser-determinism/, which no project in packages/ui-kit/vitest.config.ts includes.

Why this shape

The issue and the #4116 spike decide most of it; the decision record section "Changed browser specs repeat under load before merge" states the rest with its evidence. Four choices were mine:

  • In-process passes, not a vitest run loop. The spike measured the catch rate and its false-failure sample with in-process passes, and never timed a loop. Only the in-process API can run exactly the selected pairs: a command line names projects and files and runs their cross product, which would repeat pairs that belong to another partition.
  • One project at a time within a pass. My first run of a real mixed selection started six projects at once beside four burners, and a green visual spec failed its first pass with "Could not capture a stable screenshot within 5000ms". The same selection, one project at a time, passed five of five. The spike measured one project per invocation, and the budget sums weights, so sequential projects are both the measured load and the budgeted cost.
  • 15 partitions at most. The largest selection in the spike's window is estimated at 1,993 weighted seconds per pass, which plans 14. This is the number I am least sure of: it costs up to 15 runners for a rare change.
  • 10 seconds for a pair without a weight. Above three quarters of the refreshed table (7.9 s), below its mean (12.1 s). Every added spec is unweighted until the next refresh.

Proof

bun run check:pr --base origin/main

Focused suites on the merged head 09633b126, 492 pass and 1 fail across 19 files: tests/red-main.test.ts, hosted-proof, ci-workflows, integration-proof, ci-plan, heavy-feedback, candidate-proof, local-checks, check-receipt, integration-command, visual-runner, browser-input-closure, test-determinism, browser-image-pin, visual-dictation-isolation, refresh-browser-costs, the two new files and workspace-lease. The one failure is the existing lease container test: under this host's rootless Docker the container cannot read its private fixture directory (Cannot find module '/repo/brain-workspace-lease-…/scripts/visual.mjs'). It does not run this change's code. Strict typecheck and bun run lint pass.

Racy fixture, pinned container, under load (four burners on four CPUs, --cpu-list 12-15, through the full command and launcher):

$ bun scripts/browser-determinism.ts --config-root tests/fixtures/browser-determinism --cpu-list 12-15 harbour::…/landing-racy.repeat.js strait::…/landing-racy.repeat.js
[browser-determinism] 4 CPU burner(s) on 4 CPU(s) (PIDs 48, 49, 50, 51); 2 project/file pair(s), 5 repetition(s) each.
[browser-determinism] Repetition 1 of 5: passed in 1.1 s
[browser-determinism] Repetition 2 of 5: passed in 0.4 s
[browser-determinism] Repetition 3 of 5: FAILED in 0.3 s
FAILED: tests/fixtures/browser-determinism/landing-racy.repeat.js in project harbour, repetition 3 of 5: "the crew is aboard before the tide turns" (a test case failed: expected 'tide' to be 'crew' // Object.is equality).
exit=1

The same spec made deterministic (landing-steady.repeat.js, same command): five of five repetitions passed in both projects, Passed: 2 project/file pair(s), 5 repetition(s) each, exit 0.

The fixture is a real-time race on a fixed schedule, as the Bun gate's is: a 150 ms timer against a crew that is slow on every third landing, counted in localStorage. That makes the mutation below deterministic, and it also pins the documented carry-over: storage survives a further pass. tests/browser-determinism-container.test.ts runs both fixtures through the real container side, the installed Vitest and a real Chromium in the pinned image on every unit run (about 4 s).

Mutations. Each guard broken, the named test red on the named assertion, the source restored:

Mutation Named test Red on
The runner makes one pass only container: "the racy fixture fails the real runner at its third repetition…" SPEC_PROJECT_AND_REPETITION_NAMED, received null: the racy fixture got through, every time
The same unit: "a spec that passes twice and fails on its third pass…" SPEC_PROJECT_AND_REPETITION_NAMED, received null
The planner drops a partition "a selection over capacity at two repetitions plans several partitions that cover every pair exactly once" SEVERAL_PARTITIONS:draft, expected 3, received 2
The aggregate accepts a dropped partition "the executable publishes the planned partitions, the aggregate refuses any other set…" DROPPED_PARTITION:draft=true, did not throw
The lint stops comparing matrix and command with the planner "the browser repetition matrix, divisor and step limit come from the planner…" LITERAL_DIVISOR_VALUE, received []
The job is selected without a changed spec "a pull request that changes no spec does not select the job…" draft, expected false, received true
Confirmation asks for five "ready confirmation asks for two repetitions and every other cadence for five" CONFIRMATION_ASKS_FOR_THE_FLOOR, expected 2
Main selects the job "a pull request selects the specs it adds or modifies… and never on main" MAIN_NEVER_REPEATS
The selection is never populated the same test ADDED_AND_MODIFIED_SPECS_AS_LISTED_PAIRS, received undefined
Every project at once "within a pass the projects run one after another…" ONE_PROJECT_AT_A_TIME
A one-pass result passes on the host "a green exit is not a pass without a result…" ONE_PASS_IS_NOT_FIVE, received passed
Burners are not stopped "stop kills exactly the started PIDs…" BURNER_KILLED_BY_PID

A plain failing-first run on the base is not possible for the new test files: they import modules that do not exist there, which is a module-load error and not a receipt. "The selection is never populated" is the behavioural equivalent for the planner.

A real selection, locally. One visual spec, one pointer spec in three projects, one layout spec and one story in two themes (the four specs the spike measured), five repetitions, four burners on four pinned CPUs of a shared host: 35 pair passes, none failed. 52.9 weighted s per pass; passes took 102.8, 69.3, 68.8, 66.1 and 66.2 s (about 1.3 times the weight after the first). The spike's hosted figures for the same specs sum to about 61 s per further pass.

Off-main qualification

CI run 44064090479 is this draft's run on head 09633b1269f2cc91404855da94d08e87277e7225.

  • Established when this was written: the changeset job passed, so the new planner planned this change on a hosted runner and bun run lint accepted the new workflow job and the regenerated heavy-feedback workflow. The planner did not select browser_determinism, and that job was skipped, as it must be for a change that touches no spec.
  • Still running when this was written: determinism (1), which repeats this change's Bun test files under CPU load (the gate's own unit and pinned-container tests among them), and draft gates, which must accept that selection.
  • Not established by this run: that the new job passes on a hosted runner. That evidence comes from the throwaway draft named under "Anything left open".
{"version":1,"kind":"brain-check-pr-receipt","head":"03b28f9e7f5dbfcdb5c4fce5379537fcb6b8bcfc","base":"origin/main","mode":"focused","startedAt":"2026-11-17T14:56:41.049Z","finishedAt":"2026-11-17T14:58:14.173Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14099.401065999999},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":123.4472910000004},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":89.78916200000094},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.456274999996822},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":78775.36463299999}]}

The job on real specs, on a hosted runner. This PR changes no spec, so a throwaway draft (#4188, closed unmerged) added a comment to one visual, one pointer, one layout and one story spec on top of this branch. Run https://github.com/schlessera/brain-kit/actions/runs/44104948265 on f24f7fb9c:

Job Result Whole job
browser_determinism (1) passed: 7 project/file pairs, 3 repetitions each under one CPU burner per CPU inside the container, 256.6 s including the container start 386 s
determinism (1) passed: this PR's 11 changed Bun test files, 3 repetitions each 869 s
draft gates passed 41 s

Five repetitions were requested and the 300 weighted-second budget reduced them to three (81.3 weighted seconds per pass). The spike estimated about 12 minutes for a job at the budget; this one, at 244 of 300 weighted seconds, took 6.4. An earlier run of the same draft, 44103013009, took 450 s for the same job.

Two things those hosted runs found in this PR, both fixed here:

This head: https://github.com/schlessera/brain-kit/actions/runs/44108610729 (draft, head 03b28f9e7f5dbfcdb5c4fce5379537fcb6b8bcfc).

Checklist

  • Focused local preflight/behavioral receipts are above; complete selected hosted proof runs on this draft and at ready confirmation.
  • Acceptance criteria from the issue are all met, or the gap is named below.
  • A PR touching packages/ui-react/, packages/ui-kit/, packages/ui-server/ or packages/core/ carries a recorded independent review of its head (bun scripts/review-receipt.ts check <pr>), or it touches none of them. It touches none of them.
  • The PR and completed/advanced issues have verified release milestones under docs/process/github.md.
  • A changeset is included, or this changes nothing a consumer can see. CI tooling only.
  • No personal data anywhere in the diff — the leakage gate covers the whole tree.
  • The integration contract index or relevant component is updated in this same commit, or nothing in the machine surface moved.
  • Docs under docs/ reflect the change: the decision record section, the amendment to the hybrid ruling, docs/process/testing.md, docs/process/test-authoring.md and the work-issue merge reference.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed. No product guard changed; the planner's refusals are confined to one pull request's run.
  • Provider history stays append-only: nothing on a turn's path changed.

Anything left open

  • The hosted green run on a mixed selection (acceptance criterion 7). This PR changes no spec, so its own run never selects browser_determinism. The orchestrator opens a throwaway draft on top of this branch that touches one visual, one pointer, one layout or offline and one story spec, and records the job's duration beside the spike's estimate of about 12 minutes at 300 weighted seconds. Until then the job has never run on a hosted runner, and the hosted load ratio with the refreshed weights is unmeasured.
  • Ready confirmation of this PR, which the orchestrator requests.
  • The decision record's duration line. The record states the spike's estimate and the local measurement; the first hosted duration belongs there once the throwaway draft has run.
  • Unmeasured: the false-failure rate across all specs and on a hosted runner; WebKit and the diagrams-* projects under repetition, including their native preparation time; peak memory; whether the gate's own new Bun test files pass five repetitions under the Bun gate's burners (this draft's determinism job is the first measurement).
  • Local limits on this host. The existing tests/workspace-lease.test.ts container case fails under rootless Docker here for an unrelated permission reason; hosted Docker is rootful.
  • bun scripts/issue-queue.ts claim 4163 refused the issue because it lacks agent-ready (it carries blocked until chore(ci): shard an oversized determinism selection by reviewed weight (#4117) #4157 merges). No label was added and the issue is not self-assigned.

🤖 Generated with Claude Code

schlessera and others added 10 commits November 17, 2026 08:46
The repetition count is decided over the whole selection; the selection is
then split into the fewest partitions that each fit one job's capacity. A
file whose repetitions alone exceed the capacity runs by itself, and a
selection that needs more than the maximum is refused with its weight and
the limit. DETERMINISM_PARTITIONS owns the capacity, the maximum, the step
limit and the measured load ratio; the repetition budget is the capacity,
recalibrated from 600 to 300 weighted seconds.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ns (#4117)

The planner publishes determinism_shards and the determinism job becomes a
matrix over it; each partition's command reads its files from the same plan
and refuses a divisor that is not the planned count. The hosted aggregate
refuses a published set that differs from the plan, the merge path requires
one successful job per published partition, and the workflow guard refuses
a literal matrix, divisor, shared artifact name or foreign step limit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…4117)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ted partitions (#4163)

Select the Vitest browser, layout and story specs a pull request adds or
modifies, expand each to the project/file pairs Vitest's own listing reports,
and plan their repetitions and hosted partitions with the Bun gate's
functions. One table owns the capacity, the maximum partition count, the step
limit and the cost of a pair without a reviewed weight.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…container (#4163)

Enter the container through the browser suite's launcher and run exactly the
selected project/file pairs as further passes in one Vitest process, one
project at a time, with one CPU burner per CPU started inside the container.
The first failing repetition fails the command and names the spec, the
project, the repetition and the case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ec changes (#4163)

A matrix job at every pull-request cadence and in draft heavy feedback, never
on main. The matrix is the planner's published partition set; both
aggregates, the merge path and the workflow lint require it when selected and
its skip otherwise. The merge path's job inventory bound is now derived from
every proof job's widest matrix.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rid split (#4163)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pecs-under-load

# Conflicts:
#	.agents/skills/work-issue/references/ci-and-merge.md
#	.github/workflows/ci.yml
#	.github/workflows/heavy-feedback.yml
#	docs/decisions/ci-utility.md
#	docs/decisions/test-health.md
#	scripts/candidate-proof.ts
#	scripts/check-ci-workflows.ts
#	scripts/ci-plan.ts
#	scripts/ci-proof.ts
#	scripts/determinism-plan.ts
#	scripts/integration-proof.ts
#	scripts/proof-shards.ts
#	tests/ci-plan.test.ts
#	tests/ci-workflows.test.ts
#	tests/hosted-proof.test.ts
#	tests/integration-proof.test.ts
…ze (#4163)

The control asserted more than 400 recorded project/file pairs, true only
for the refreshed browser weights. That refresh was reverted (#4182), the
table is back to 387 rows, and the test failed under the Bun determinism
gate on the first hosted run.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
schlessera and others added 2 commits November 17, 2026 14:56
Twelve scenarios, each a child process, shared one 27-second work
deadline and overran it under the determinism gate's CPU load (run
44104941268, 27.2 s). Each is now its own test with the assertions it
had; no deadline changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@schlessera
schlessera marked this pull request as ready for review November 17, 2026 15:55
@schlessera
schlessera merged commit 2092636 into main Nov 17, 2026
49 of 62 checks passed
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: chore Tooling, CI, release plumbing, dependencies.

Projects

None yet

1 participant