Repository navigation
chore(ci): repeat a PR's changed Bun test files under CPU load before merge (#4109) - #4118
Closed
schlessera wants to merge 6 commits into
Closed
schlessera wants to merge 6 commits into
schlessera wants to merge 6 commits into
Conversation
Add bun scripts/test-determinism.ts. It selects the Bun test files a change adds or modifies against its merge base and runs them through the offline test wrapper with --rerun-each and --bail=1 while one busy loop per CPU runs. Five repetitions by default, reduced uniformly to a floor of two when the reviewed weights exceed the 600-second budget; no selected file is skipped and the report lists each with its repetitions. Burners are killed by PID on every exit path and exit by themselves when their parent dies. The planner records the selection for pull requests and selects determinism at every pull-request cadence, drafts included, and never on main. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…4109) Add the hosted determinism job with the unit job's runtime prerequisites, and the same job in the generated draft heavy feedback workflow. The proof and draft gates aggregates, the feedback aggregate and the merge path require it when selected and its intentional skip otherwise. check:pr never runs it and names the command in --plan. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
8 tasks
…minism (#4109) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
5 tasks done
The command appends its table to GITHUB_STEP_SUMMARY. The fixture runs now write to a scratch file, and the receipts assert on it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n gate (#4109) The first hosted determinism run failed in the gate's own test. Under GITHUB_ACTIONS Bun 1.4.2 prints each run header as ::group::<file>: (run #k), which the failure parser did not read, so a failure lost its file and repetition. The parser reads both forms, and the racy-fixture receipt now runs under the plain and the log-group reporter. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 17, 2026
Merged
Closed
Merged
Merged
Owner
Author
|
Superseded by #4134, which merged this branch together with its sibling proof-system change as one squash ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4109
What changed
A Bun test file that a pull request adds or modifies is now run several times under CPU load before it merges.
bun scripts/test-determinism.ts --base <ref> [--json]selects those files against the merge base and runs them in one invocation of the offline test wrapper with--rerun-each=<n> --bail=1, while one busy loop per CPU runs. It fails on the first failing repetition and names the file, the repetition and the case. The planner selects a new hosteddeterminismjob whenever the change touches such a file, at every pull-request cadence including draft and in draft heavy feedback.draft gates,proof, the feedback aggregate and the merge path require it when selected and require its intentional skip otherwise.check:prnever runs it and names the command in--plan.Why this shape
--rerun-each, not N invocations. Checked against the pinned Bun 1.4.2: each file runs n times in a row in one process, the module is evaluated again for each run,globalThisand process state persist, and a run with output is headed<file>: (run #k)on stderr, also underGITHUB_ACTIONS=true. One invocation keeps the wrapper's single preparation build. The cost is that a file leaking state into its next run fails too, which is recorded as a known limit in the decision.scripts/test-shard-costs.jsonweights. Over the last 150 merges on main, 142 selections fit five repetitions inside it. Reduction is uniform, never below two, and a selection too heavy for the floor still runs every file twice and is reported over budget.SIGKILLon Bun 1.4.2 and 1.4.4).determinismis not inPOST_MERGE_CATEGORIES.ci-proof.tsfor theunitjob's prerequisites: copyfile install,ci-runtime-setup.sh, the real-Chrome cold start andBRAIN_REQUIRE_CHROME=1.Decision record:
docs/decisions/ci-utility.md, "Changed tests repeat under load before merge" (maintainer ruling of 2026-11-16).Proof
Tested head
19f8e2d1a, merge base78e326c80. Passed: 1,230 tests across 56 files.The PR's own
determinismjob is the live proof that the job works, because this PR changes eight Bun test files.e906643d1: failed, and it was right to. https://github.com/schlessera/brain-kit/actions/runs/43986946575/job/133717889783. On the draft the planner selecteddeterminismand no other proof category. The job set up real Chrome, started four burners on four CPUs and repeated seven changed files five times each (552 s for about 174 weighted s). It then failed in the gate's own test file: under GitHub Actions, Bun 1.4.2 prints each run header as::group::<file>: (run #k), which the failure parser did not read, so the racy fixture's failure was reported asunknown file, repetition unknown.draft gatesfailed with it. A coding agent's environment switches Bun to a third output form, which is why local runs did not show it.19f8e2d1a. The parser reads both header forms. Failing first:a GitHub Actions group header names the file and repetition tooandunder the GitHub Actions log groups reporter the racy fixture's failure still names its file and repetitionwere red onHOSTED_GROUP_HEADER_READandFAILURE_NAMED_UNDER_LOG_GROUPSbefore the parser change, green after, and red again with the change reverted. The receipt now runs under both reporters, on Bun 1.4.2 and 1.4.4.19f8e2d1a: https://github.com/schlessera/brain-kit/actions/runs/43989701310/job/133727305304. In progress when this body was last edited; the metadata job passed anddeterminismis the only selected proof job. The criterion is met only when it is green.Local run of the gate on this PR's own files (Bun 1.4.2, two burners to spare the shared host):
bun scripts/test-determinism.ts --base origin/main --burners 2 --jsonpassed, 8 files, 5 of 5 repetitions observed for each, 320.9 s for 174.2 weighted s.Acceptance receipts, all in
tests/test-determinism.test.ts, which runs the real command through the real offline wrapper in a scratch Git checkout:a racy fixture that fails one run in three fails the gate…FAILED: tests/landing.test.ts, repetition 3 of 5: "the crew is aboard before the tide turns"the same fixture made deterministic passes all five repetitions…repetitions: 5, observed: 5a change that touches no Bun test file never selects it…andthe aggregate refuses published outputs that drop a selected repetition or add an unselected one(tests/ci-plan.test.ts),the aggregate requires repeated-run proof when selected and an intentional skip otherwise(tests/hosted-proof.test.ts), therepetition-skippedmerge scenario (tests/integration-command.test.ts)falseat all six cadences;proofProblemsis empty for an unselected skip; a selected one that did not pass is refused by the aggregate and byintegrate.ts mergea selection that cannot fit five repetitions…repetitions: 3, observed: 3; then at a smaller budgetrepetitions: 2, overBudget: true, observed: 2per filethe repetitions run under the offline preload…Offline test guard: attempted real network access,fetch https://oracle.example.invalid/prophecyThe racy fixture is a real-time race with a fixed schedule: a 150 ms timer against work that takes 600 ms on every third run. It is deterministic on purpose, so the gate's own test is not a flake.
Mutation receipts (break the guard, named test red on the expected assertion, restore):
--rerun-each=1, with the repetition-evidence check also removed1 pass, 0 fail);a racy fixture that fails one run in three…fails onexpect(run.code).toBe(1). With only the flag changed, the same test fails onRACY_FIXTURE_FAILS_AT_ITS_THIRD_REPETITIONand the command reportsran 1 of 5 repetitionsbun testin place ofbun run testthe repetitions run under the offline preload…fails onOFFLINE_PRELOAD_ACTIVEMath.max(1, …)FLOOR_OF_TWO_HOLDSandFLOOR_STILL_RUNSBURNER_KILLED_BY_PID!draft &&EVERY_PULL_REQUEST_CADENCE(draft: false)ADDED_AND_MODIFIED_BUN_TESTS_ONLYMAIN_PUSH_PLANS_NO_REPETITIONdeterminismremoved fromPROOF_JOBSSELECTED_REPETITION_MUST_PASS, and the merge-path scenarios intests/integration-command.test.ts::group::headersHOSTED_GROUP_HEADER_READ,FAILURE_NAMED_UNDER_LOG_GROUPSThe offline receipt first could not go red: the test process's own network guard adds its preload to every
bunit spawns, so bypassing the wrapper still printed the refusal. The harness now starts the command through an alias the guard does not recognise, astests/test-network-guard.test.tsdoes, and the mutation above is from after that fix.{"version":1,"kind":"brain-check-pr-receipt","head":"19f8e2d1a9b6f03802d923458b5bb43316462c97","base":"origin/main","mode":"focused","startedAt":"2026-11-17T00:39:09.088Z","finishedAt":"2026-11-17T00:41:28.843Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":21593.320197999998},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":197.07719599999837},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":151.81996499999877},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.243202000001475},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":117773.66745300002}]}Checklist
docs/reflect the change, or nothing documented moved.docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.Anything left open
19f8e2d1a. The criterion is met only when thedeterminismjob on the current head is green.agent-ready).scripts/test-determinism.tsis not in the proof-system path set, which changes only by maintainer ruling. This PR is a proof-system change through its workflow,scripts/ci-*andcheck-pr.tsedits.integrate.tsotherwise expects a job inventory withoutdeterminism.🤖 Generated with Claude Code