Repository navigation
chore(ci): scale test watchdogs under the determinism gate and stop flagging raised timeouts (#4191) - #4193
Merged
Conversation
…ge (#4191) A watchdog is a catch-all for the worst case, so raising one cannot make a passing test fail. The timeout check now reads the direction of a value rewritten in place: the same or a larger number, or the same expression with no number made smaller, is not reported. A lowered, removed or added value is still a proof-system change, and so is one whose direction cannot be read or that moved between hunks. A duration inside watchdogMs() is read as that duration, so adopting the scaling helper is not a change and leaving it is a lowering. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The gate applies CPU load on purpose, and a timeout that exists to stop a hang is a catch-all for the worst case. The repetition command now multiplies test deadlines by one factor, owned by DETERMINISM_PARTITIONS.deadlineFactor: Bun's per-test cap through a later --timeout, explicit test and hook timeouts through a preload that replaces bun:test with a scaling copy, and in-test watchdogs that read watchdogMs() through the environment. The 27-second watchdog in tests/integration-command.test.ts reads the helper. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Records the 2026-11-17 ruling and what it supersedes: the practice of treating every test deadline as proof that must not move. The decision record states the two kinds of number, the gate's factor of eight with the hosted runs behind it, what stays unscaled, and what the proof-system check still flags. The process docs say how to size a watchdog and what to do when one trips. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…atch-all # Conflicts: # docs/process/testing.md # scripts/proof-shards.ts
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 #4191
What changed
A test watchdog (a timeout that exists to stop a hang and clean up) is now handled as a catch-all for the worst case, in the tooling and in the written rules.
determinismjob multiplies test deadlines by a fixed factor of 8. One owner holds it, beside the job's other numbers (DETERMINISM_PARTITIONS.deadlineFactor,scripts/proof-shards.ts). Inside the repetition run three things scale: Bun's per-test cap (240 s for the root script's 30 s, through a later--timeout), every explicit test and hook timeout (through a preload that replacesbun:testwith a scaling copy), and in-test watchdogs written aswatchdogMs(n)(throughBRAIN_TEST_DEADLINE_FACTOR). No other job scales anything, and no existing test is edited except the one below.tests/integration-command.test.tsreads the helper.bun scripts/proof-system.ts classifyno longer flags a timeout or deadline that is only raised. A lowered, removed or added one stays a proof-system change, and so does a change whose direction it cannot read.docs/decisions/ci-utility.md,docs/process/testing.md,docs/process/test-authoring.mdrule C4,docs/process/test-waits.md,AGENTS.md, and thetest-healthskill's two rules that said the opposite).Why this shape
The factor. 8 is the smallest whole number at least 15% above 6.84, the largest slowdown measured under the job's own load (elapsed seconds per weighted second, run 44039499653, the highest of the five calibration runs of #4117). Per test the slowdown is smaller: across the
determinismjobs of 33 hosted runs on 2026-11-17, 140 test cases that take at least one second in theunitjob of main run 44107659969 ran 1,137 times, with a median of 1.94 times theirunitduration, a 99th percentile of 3.40 and a maximum of 3.83. The test that prompted the ruling ran 3.3 times slower (8.3 s inunit, 26.9 s and 27.2 s in run 44104941268). A test asserts that the factor covers the measured ratio with its margin, and that a full capacity at that ratio plus one hung test under the scaled cap still fits the 40-minute step (2,052 s + 240 s).--bail=1means at most one test waits out its cap.Explicit timeouts. Bun 1.4.2 has no flag for them. Verified on the pinned version: the last
--timeoutwins, and neither--timeoutnorsetDefaultTimeoutchanges a timeout a test names itself. About 650 explicit timeouts in the Bun test files are exactly the long tests most likely to trip under load, so leaving them unscaled would have kept most of the friction. Two mechanisms were tried:require("bun:test")returns. Declined: it only works until something importsbun:test, and the offline preload already has. The first real run through the wrapper showed this, caught by the preload's own check.mock.module("bun:test", …)from a second preload, loaded only by the repetition command. Taken: on 1.4.2 and 1.4.4 the replacement reaches every later import and the runner's globals, in every file and every repetition, and a test'smock.restore()does not undo it. The preload checks that the replacement took and stops the run if it did not.The preload is passed on the command line by
scripts/test-determinism.tsinstead of being imported by the shared offline preload, sounitand every other command are untouched and the ten fixtures that copy the offline preload need no change.The classifier. A raise is read only where a value is rewritten in place (same hunk) to the same or a larger number, or to the same expression with no number made smaller. A duration inside
watchdogMs(...)is read as that duration, so adopting the helper is not a change, and leaving it is a lowering. Adding a timeout to an existing test stays flagged: the check does not know which default applied before, so it cannot tell a raise from a lowering. That is narrower than the ruling allows and is named under "Anything left open".What stays unscaled is listed in the decision record: waits a test bounds without the helper, timeouts inside the product and inside child processes, product timings, the job's own limits, every other job, and Vitest specs (#4192).
Proof
All runs below are on Bun 1.4.2, the version CI pins.
Failing first, for the reason claimed
tests/proof-system.test.ts, raise/lower/remove casesRAISED_WATCHDOG_IS_NOT_FLAGGED,ADOPTING_THE_HELPER_IS_A_RAISE,SAME_SHAPE_LARGER_NUMBER_IS_A_RAISE: the old check reported every raisetests/test-determinism.test.ts, "watchdogs scale under the gate" (helper modules and the--deadline-factorargument present, nothing passed to the wrapper yet)this test timed out after 500ms; the hang:AT_THE_SCALED_CAP(it timed out after 250 ms, not 2000);WAITED_THE_SCALED_WATCHDOGThe two receipts the issue asks for are permanent tests in
tests/test-determinism.test.ts, run through the real command and the real offline wrapper in a scratch checkout:watchdogMstimer), each taking half its 500 ms watchdog in calm water and three times that underODYSSEUS_HEADWIND=3, pass two repetitions at the gate's factor (SLOW_TESTS_PASS_UNDER_THE_SCALED_WATCHDOGS).--deadline-factor 1each fail in repetition 1 on their own watchdog (UNSCALED_WATCHDOG_TRIPS,TRIPPED_BY_ITS_OWN_WATCHDOG).The slowdown in those fixtures is simulated by sleeping, so the receipts are certain on any host and need no real burn. The run at the gate's real load is this PR's own hosted
determinismjob, linked below.A true hang still fails, within the scaled watchdog, with its child gone: a fixture that waits for a
sleep 300child fails at exactly the scaled cap (this test timed out after 2000ms) and its PID is gone (HUNG_CHILD_CLEANED_UP); the same hang under an in-testwatchdogMs(200)timer is stopped by that timer after at least 1,600 ms.Mutations, each restored afterwards
raisedOrEqualalways false (every change flagged, the old behaviour)tests/proof-system.test.tsRAISED_WATCHDOG_IS_NOT_FLAGGEDraisedOrEqualalways true (no change flagged)LOWERED_STAYS_FLAGGEDMOVED_TIMEOUT_IS_NOT_A_RAISEwatchdogMsnot read as a loweringLEAVING_THE_HELPER_IS_A_LOWERING_UNDER_LOAD--timeoutnot passedthis test timed out after 500msWAITED_THE_SCALED_WATCHDOGwatchdogMsreturns the written durationtests/test-deadlines.test.tsWATCHDOG_SCALES_WITH_THE_RUNtests/test-deadlines.test.tsRECEIVER_IS_THE_REAL_REGISTRARdeadlineFactor: 7FACTOR_COVERS_THE_MEASURED_SLOWDOWN_WITH_MARGINdeadlineFactor: 12STEP_LIMIT_STILL_BOUNDS_A_SCALED_RUNFocused runs on the final tree:
tests/proof-system.test.ts,tests/test-deadlines.test.ts,tests/test-determinism.test.ts,tests/hosted-proof.test.ts,tests/ci-workflows.test.ts,tests/integration-command.test.ts,tests/integration-proof.test.ts,tests/red-main.test.ts,tests/ci-plan.test.ts,tests/local-checks.test.ts,tests/check-receipt.test.ts,tests/ci-epochs.test.ts,tests/refresh-browser-costs.test.ts,tests/docs-paths.test.ts,tests/release-manifest.test.tsandscripts/skill-tests/test-health-batch.test.tspass;tsc --noEmitandbun run lintare clean. The real command, in this checkout, with one burner for 15 seconds:bun scripts/test-determinism.ts --burners 1 --repetitions 2 tests/proof-system.test.ts tests/test-deadlines.test.tspassed withdeadlines: { factor: 8, testCapMs: 240000 }in its report.Acceptance criteria
classifyreports a raise as not a proof-system change, a lowering or removal as one, with a mutationtests/proof-system.test.ts(the command case and the cases around it); first two mutationswatchdogMs(27_000); hosted run belowdocs/decisions/ci-utility.mddocs/process/testing.md, rule C4 indocs/process/test-authoring.md,AGENTS.mdOff-main qualification
After merging main, which now carries the browser repetition job (#4163): https://github.com/schlessera/brain-kit/actions/runs/44124983219 (draft, head
74a58fb0552aebf67817d3f79c628faac0305871). Itsdeterminism (1)job repeats this PR's changed Bun test files with the deadline scaling in effect.Run https://github.com/schlessera/brain-kit/actions/runs/44121413796 on head
93fcb661490d4d500dbd42dffdf5621a20396878(this draft's ownci.ymlrun).What it establishes: the draft changes four Bun test files (
tests/integration-command.test.ts,tests/proof-system.test.ts,tests/test-deadlines.test.ts,tests/test-determinism.test.ts), so itsdeterminismjob repeats them under four burners on four CPUs with the scaling in effect: about 61 weighted seconds per pass, four repetitions. The comparison is run 44104941268, where the same job, unscaled, failedtests/integration-command.test.tsat 27.2 s against its 27-second watchdog. A pass here shows that file clearing the gate with its watchdog at 216 s and Bun's cap at 240 s, and the job's report recordsdeadlines: { factor: 8, testCapMs: 240000 }. The nested fixtures intests/test-determinism.test.tsandtests/test-deadlines.test.tsrun inside the same loaded job, including the controls that must still fail with the factor at one.{"version":1,"kind":"brain-check-pr-receipt","head":"74a58fb0552aebf67817d3f79c628faac0305871","base":"origin/main","mode":"focused","startedAt":"2026-11-17T16:19:48.180Z","finishedAt":"2026-11-17T16:21:19.644Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":14329.656328},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":132.4550139999992},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":72.5485800000024},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":21.879912999997032},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":76891.014368}]}Checklist
packages/ui-react/,packages/ui-kit/,packages/ui-server/orpackages/core/carries a recorded independent review of its head (bun scripts/review-receipt.ts check <pr>), or it touches none of them.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.The one guard added is the scaling preload's check (
scripts/test-deadline-preload.ts).bun:test, a fresh import does not return the scaledtestandbeforeEach. It does not cover a wait a test bounds without a test timeout orwatchdogMs.bun testinvocation of the repetition command. Nothing narrower exists: the replacement is per process.tests/test-deadlines.test.tsandtests/test-determinism.test.tsrun the preload under realbun testin theunitjob, so that change goes red before it merges.tests/test-deadlines.test.ts, "with the factor unset the preload does nothing": every command other than the repetition command never loads the preload, and with a factor of one it changes nothing.Anything left open
scripts/proof-shards.ts,docs/decisions/ci-utility.md,docs/process/testing.md,docs/process/test-authoring.mdandtests/integration-command.test.ts; PRs fix(ci): require successful off-main qualification runs #4173 and fix(ci): enforce proof-system lane during lease acquisition #4179 edit the decision record andtests/integration-command.test.ts. The changes here to the shared files are additive except the three-line watchdog intests/integration-command.test.ts.🤖 Generated with Claude Code