Skip to content

chore(ci): shard an oversized determinism selection by reviewed weight (#4117) - #4157

Merged
schlessera merged 6 commits into
mainfrom
chore/4117-shard-determinism
Nov 17, 2026
Merged

schlessera merged 6 commits into
mainfrom
chore/4117-shard-determinism

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Closes #4117

What changed

The hosted determinism job no longer has to run a whole selection in one invocation. The repetition count is still decided over the whole selection; a selection that fits one job at that count stays one job with the same command and report, and one that does not is split by reviewed weight into determinism (1..n), each within one job's capacity, with every file in exactly one partition at no fewer than two repetitions. A selection that needs more than ten partitions fails in the metadata job before anything runs, naming its weight and the limit. The capacity and the repetition budget are recalibrated from 600 to 300 weighted seconds from the hosted runs that now exist; the 40-minute step limit stays.

  • One owner. DETERMINISM_PARTITIONS in scripts/proof-shards.ts holds the capacity (300), the maximum (10), the step limit (40 minutes) and the measured load ratio (6.84). The planner, each partition's command, the hosted aggregate, the merge path and the workflow guard read it.
  • Planning. scripts/determinism-plan.ts (new, pure) holds planRepetitions (moved from scripts/test-determinism.ts, which re-exports it) and planPartitions: the fewest partitions, balanced longest file first with balanceTests, in which every partition fits. Because the budget is the capacity, a selection is only ever split at the floor of two, so ci: the determinism job can be the longest job in a ready confirmation and hold the merge lease #4137 composes: the count first, then the partitions for that count.
  • Wiring. scripts/ci-plan.ts publishes determinism_shards; the determinism job is a matrix over it with the matrix's own job total as divisor, as unit is. scripts/ci-proof.ts determinism --shard=M/N reads its files from the same plan and refuses a divisor that is not the planned count. validateSelections refuses a published set that differs from the plan; the merge path requires one successful determinism (n) per published number; bun run lint refuses a literal matrix, a literal divisor, a shared artifact name or a step limit other than the owner's. heavy-feedback.yml is regenerated.

Recalibration

35 hosted determinism jobs had produced a report when this was written (all 2026-11-17, four burners on four CPUs; 32 passed, 3 failed). Five passing jobs repeated at least 90 weighted seconds, where the weights dominate:

Run PR Estimated (s) Elapsed (s) Ratio
43989701310 #4134 174.2 624.8 3.59
43991629934 #4134 194.0 1,048.2 5.40
44017250694 #4134 (confirmation) 193.0 1,142.1 5.92
44020374567 #4132 (confirmation) 221.3 888.7 4.02
44039499653 #4145 94.4 645.9 6.84

The first run (43986946575) measured 3.17 before it failed in its last file, and the first two-repetition confirmation (44036241499, #4143) 1.82 on 11.4 estimated seconds. At the worst ratio the old 600-second budget needed 68 minutes, so it never fitted its 40-minute step. 300 weighted seconds need 34 minutes at 6.84 and 27 at the median 5.40. The decision record has the full table, the per-file spread (1.1 to 6.9) and the effect on the 150 pre-gate merges (100 of 111 selections still get five repetitions; six are split, the 388-file migration into nine).

Why this shape

The maintainer's ruling on the issue chose sharding by weight, as unit is sharded, and declined in-job workers and an exception path. Three choices inside that ruling:

Proof

Failing first, with the partition loop replaced by the pre-change single job (for (let count = 1; count <= 1; …) … if (true) return):

error: SEVERAL_PARTITIONS:draft
Expected: 9
Received: 1
(fail) hosted partitions by reviewed weight (#4117) > a selection the size of the largest observed plans several partitions, each within capacity, covering every file once

Mutations, each applied alone, run against the named test and restored:

Mutation Test that failed Assertion
validateSelections ignores determinism_shards tests/ci-plan.test.ts "the executable publishes the planned partitions, and the aggregate refuses any other set" DROPPED_PARTITION:draft=true: did not throw
the planner drops the last partition tests/test-determinism.test.ts "a selection the size of the largest observed…" SEVERAL_PARTITIONS:draft: expected 9, received 8
the merge path has no determinism partition branch tests/integration-proof.test.ts "the merge path accepts a confirmation only with exactly its planned determinism partitions" ONE_PLANNED_ONE_RAN: inventory differs
the lint does not bind the matrix to the planner tests/ci-workflows.test.ts "the determinism matrix, divisor and step limit come from the planner and its one owner" LITERAL_ONE_MATRIX: received []
the planner ignores the maximum tests/test-determinism.test.ts "a selection beyond the maximum partition count is refused, naming its weight and the limit" did not throw
a partition's command runs the whole selection tests/hosted-proof.test.ts "an oversized selection runs as planned partitions…" WITHIN_CAPACITY: expected <= 300, received 320
a partition is not told the selection's count same test COUNT_DECIDED_OVER_THE_SELECTION:draft
the planner always publishes [1] tests/ci-plan.test.ts "the executable publishes the planned partitions…" SPLIT_BY_WEIGHT:draft=true

Focused runs, all green: tests/ci-plan.test.ts, tests/test-determinism.test.ts, tests/red-main.test.ts, tests/check-receipt.test.ts, tests/local-checks.test.ts, tests/heavy-feedback.test.ts, tests/candidate-proof.test.ts, tests/integration-command.test.ts, tests/proof-inventory.test.ts (214 tests), and tests/ci-workflows.test.ts, tests/hosted-proof.test.ts, tests/integration-proof.test.ts (125 tests).

bun run check:pr --base origin/main

Off-main qualification

This PR's own draft run exercises the changed planner, matrix and partition command on head 44894204f: the determinism (1) job of the run linked below repeats the five Bun test files this PR changes. It qualifies the unsplit path; a split selection is covered by tests only (see Anything left open).

{"version":1,"kind":"brain-check-pr-receipt","head":"0df7ea4eac22bb84bbfa9225ff4dcbf48475fc12","base":"origin/main","mode":"focused","startedAt":"2026-11-17T13:33:28.480Z","finishedAt":"2026-11-17T13:34:57.997Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12807.143018},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":117.05235100000027},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":97.26018799999838},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.95357999999942},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":76455.43136999999}]}

A split selection on hosted runners. #4157's own selection is one partition, so a throwaway draft (#4158, closed unmerged) added a comment to six heavy root test files on top of this branch at 44894204f. Run https://github.com/schlessera/brain-kit/actions/runs/44050951291 on that head dcd767842 planned four partitions at two repetitions, and all four passed:

Partition Files Estimated (s) Elapsed under load (s) Whole job
determinism (1) 1 245.7 163.6 4m53s
determinism (2) 2 225.3 386.7 7m45s
determinism (3) 3 210.5 437.3 8m46s
determinism (4) 5 204.9 333.4 10m2s

Every partition stayed under the 300-second capacity and far inside the 40-minute step. draft gates accepted the four-partition set.

Checklist

  • Focused local preflight/behavioral receipts and complete selected hosted proof passed; actual head/base/job checkout evidence is in Proof.
  • 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.
  • 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.
  • 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, or nothing documented moved.
  • A fail-closed guard added or changed answers the proportionate-containment checklist in this body, or no guard changed.
  • Provider history stays append-only (docs/decisions/provider-history.md): the provider-history guard passes, or nothing on a turn's path changed.

Guard checklist: the refusal beyond the maximum

  • Trigger. A pull request whose added or modified Bun test files need more than ten partitions of 300 weighted seconds at two repetitions. It does not cover a single file heavier than a partition (ci: a single test file heavier than one determinism partition may not finish two repetitions inside the step limit #4156), or a file with no reviewed weight that is slow.
  • What it restricts. That pull request's hosted run only. Nothing narrower exists: a partial run would skip a selected file or go below the floor, which the ruling excludes.
  • Restricted mode considered. Running the first ten partitions and reporting the rest was rejected: unrepeated files would merge.
  • How it clears. By itself, on the next push that splits the change.
  • Where the cause is recorded. The failed metadata job's log names the weight and the limit.
  • Scope test. tests/ci-plan.test.ts "the executable publishes the planned partitions…": the refused head fails while the same fixture's earlier head still plans and validates.

Anything left open

  • Not exercised on hosted runners: a split selection. This PR's own selection is one partition, so determinism (2..n) has run only in tests. The matrix, divisor and per-partition artifact follow the unit job's proven wiring. A throwaway draft that touches a few heavy tooling tests would exercise it for real, at the cost of about three runners.
  • A single file heavier than one partition is filed as ci: a single test file heavier than one determinism partition may not finish two repetitions inside the step limit #4156.
  • In-flight pull requests. The job is now named determinism (1). A branch that has not merged main carries a merge path that expects determinism, and refuses the new inventory until it is refreshed.
  • Weights. A refresh of scripts/test-shard-costs.json is in progress elsewhere. The capacity rests on five runs of tooling and backend tests under the current table; the decision record says to recalibrate from the reports when the table or the mix changes.

🤖 Generated with Claude Code

schlessera and others added 3 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>
@schlessera
schlessera marked this pull request as ready for review November 17, 2026 13:49
@schlessera
schlessera merged commit 146dfb4 into main Nov 17, 2026
56 of 58 checks passed
@github-actions

Copy link
Copy Markdown

This PR's squash 146dfb4b398c5c8d313a48dbd9e745327ba5c51f landed on main while main was red at 215887542f2ebd1821402bcb0d78b2978c2b9127 (incident #4186) without being a declared fix. Merge blocking while red is cooperative; this report is the detection.

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

Development

Successfully merging this pull request may close these issues.

ci: a determinism selection too heavy for two repetitions can exceed the job's step limit

1 participant