From 6c44fc53b950a39f333568e729fe1b1a8dd7123c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 08:36:14 +0000 Subject: [PATCH 1/2] ci: widen the Test Core matrix from 8 to 10 shards The 2026-11-16 timings refresh puts five of eight shards past the 1868s whole-package leg cap. The cap's own rule is a wider matrix, never a denser shard: (14524 + 2245.53 + 783) / 1868 = 9.4, so ten. Every width spelling in the test and test-gate jobs moves to 10 (job name, matrix fallback, --shard, labels, artifact names, --total, the gate's leg and planned roster); the partitioner reads the count from the matrix. The CLI keeps 3 slices, so the generator's decode is unchanged. Docblocks record the figures re-derived at 10. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01ADHkmRH4UCX1tvddXMS7cq --- .github/workflows/ci.yml | 84 +++++++++++++++++----------- scripts/ci/plan-test-core-shards.mjs | 9 +-- scripts/partition-test-shards.mjs | 35 +++++++++++- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c37694b433f..2d3e1759390 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -816,7 +816,7 @@ jobs: # Its own self-test, where it runs (check:self-test-wired). Milliseconds. # A red here fails this job before it publishes a plan, so the matrix - # falls back to all eight shards: a broken planner costs runners, never + # falls back to all ten shards: a broken planner costs runners, never # coverage. - name: Test Core shard planner self-test run: node scripts/ci/plan-test-core-shards.mjs --self-test @@ -837,11 +837,12 @@ jobs: --exclude @objectstack/dogfood --github-output "$GITHUB_OUTPUT" test: - # Sharded 8-way BY PACKAGE (6-way until #25376): a core-touching PR ran - # the affected suite ~11½ min on one 4-vCPU runner — the longest pole in - # the whole workflow — and at 2 shards the slower shard still ran ~10 min, - # keeping merge-queue builds at ~11 min end-to-end (#4859). - # scripts/partition-test-shards.mjs splits the package list into eight + # Sharded 10-way BY PACKAGE (8-way until #34710, 6-way until #25376): a + # core-touching PR ran the affected suite ~11½ min on one 4-vCPU runner — + # the longest pole in the whole workflow — and at 2 shards the slower shard + # still ran ~10 min, keeping merge-queue builds at ~11 min end-to-end + # (#4859). + # scripts/partition-test-shards.mjs splits the package list into ten # deterministic bins balanced on MEASURED per-package test duration # (scripts/test-shard-timings.json, generated — see #10472 below) and each # shard runs its slice through turbo. NOT the dogfood @@ -870,7 +871,16 @@ jobs: # shards means fewer suites per runner AND four more vCPUs per added # shard, because every shard gets its own runner. # - # EIGHT specifically (#25376; six from #22075 until then): sharding is BY + # TEN since #34710, on the whole-package leg cap rather than on balance. + # The 2026-11-16 refresh measured 14524s of whole packages, and no shard's + # whole leg may pass WHOLE_LEG_CAP_SECONDS (1868s, partition-test-shards.mjs: + # "a wider matrix or a finer slice, never a denser shard"). (14524s + the + # CLI's 2245.53s in 3 slices + the reader slice's 783s closure charge) / + # 1868s = 9.4, so ten: at eight five shards carried ~2195s of whole + # packages, at nine six carried ~1954s, at ten the heaviest carries 1769s + # (spec, alone). The partitioner's SHARD_COUNT header carries the figures. + # + # EIGHT before that (#25376; six from #22075 until then): sharding is BY # PACKAGE, so no shard can finish faster than the heaviest serial task it # carries. `@objectstack/cli` (2899.02s on the 2026-10-23 dataset) runs as 3 # file-level slices whenever a run's own list makes it the serial floor @@ -907,8 +917,8 @@ jobs: # 9.0 min in run 32428961038. Weights now come from # scripts/test-shard-timings.json — see partition-test-shards.mjs. # - # AND WHY NOT MORE THAN EIGHT. #10472 asked for 6 -> 8 and was refused - # while spec's 1146.69s was the floor; #25376 widened once the CLI was + # AND WHY NOT MORE THAN EIGHT, UNTIL #34710. #10472 asked for 6 -> 8 and + # was refused while spec's 1146.69s was the floor; #25376 widened once the CLI was # sliced and spec's 842s repo file was split (#25372). Two floors remain. # In bins, spec's whole 1606.55s binds at ten shards (above), and past it # max/mean gets WORSE with every shard. In wall, a CLI slice (~960-1010s @@ -917,14 +927,22 @@ jobs: # partitioner's self-test pins the half of this that can fail: at # SHARD_COUNT the heaviest item must sit within 1.3x the mean, and when it # stops fitting, slicing it below package granularity is the remedy that - # failure names. + # failure names. #34710 widened past eight on the whole-leg cap, which + # that argument never weighed; on the 2026-11-16 dataset spec's whole + # 1769.27s is the heaviest bin at ten, 1.01x the mean, so ten is again the + # count where the floor binds, and spec past 1868s is a finer slice's + # card, not an eleventh shard's. # # ⚠ THE COST, stated because it is real: per-shard fixed overhead is paid # once PER SHARD, and the merge queue multiplies it by the speculative # build count. Measured over the 512 `Test Core (N/6)` jobs of the window # below, job start to the tests step is 1.6 min median (5.5 p90) and the # tail after it 0.2 min, so two more shards cost ≈ +3.6 runner-min per run - # at the median, accepted by the maintainer directive on #25376. + # at the median, accepted by the maintainer directive on #25376. 8 -> 10 + # (#34710) reads the same: over the 16 `Test Core (N/8)` jobs of schedule + # runs 44014522626 and 43985144717, job start to the tests step is 1.67 + # min median and the tail 0.12 min, so ≈ +3.6 runner-min per full run; + # the tests themselves are the same seconds cut ten ways, not more. # `--concurrency=4` is deliberately UNCHANGED here: narrower shards may # well want a lower value, but moving both at once makes the next # measurement unreadable. @@ -932,7 +950,7 @@ jobs: # Branch protection requires the bare "Test Core" context, which a matrix # can never publish again — the test-gate job below carries that name # (the #3622 lesson; see dogfood-gate). - name: Test Core (${{ matrix.shard }}/8) + name: Test Core (${{ matrix.shard }}/10) needs: [filter, test-plan, queue-verdict] # "Skip only when the filter EXPLICITLY said no core paths changed" — see # THE FILTER CONTRACT on the filter job's outputs (#4928). `scripts` is ORed @@ -943,7 +961,7 @@ jobs: # The third clause is the plan's (#26084): `[]` is the test-plan job's # positive statement that the package set is empty, and only that literal # skips. A plan job that died publishes nothing, `'' != '[]'` holds, and the - # matrix below falls back to all eight shards: half 1 of the contract again. + # matrix below falls back to all ten shards: half 1 of the contract again. if: ${{ !cancelled() && (needs.filter.outputs.core != 'false' || needs.filter.outputs.crosspkg != 'false') && needs.test-plan.outputs.shards != '[]' }} runs-on: ubuntu-latest # Backstop only — the stall guard on the test steps is the primary @@ -1008,7 +1026,7 @@ jobs: # payloads of every completed pull_request, merge_group, push and # schedule run in it), BOTH guard verdicts -- the window path # (p + s + 10m) and the cap-deferred path (p + s + 20m) -- land before the - # new value on every observation, AND the slowest `Test Core (N/8)` job + # new value on every observation, AND the slowest `Test Core (N/10)` job # wall is at or under 80% of it. Read the pull_request and merge_group # runs, not the 4-hourly schedule alone: scheduled runs mostly replay the # cache their commit's push run saved. It carries no other expiry — a @@ -1019,8 +1037,8 @@ jobs: contents: read # ⭐ ONLY THE SHARDS WITH WORK START (#26084). The list is the test-plan # job's: the indices of the bins `partition-test-shards.mjs` fills at - # SHARD_COUNT (8) for this run's package set. The count stays 8, so a - # started shard runs exactly the `--shard k/8` slice it ran before, under + # SHARD_COUNT (10) for this run's package set. The count stays 10, so a + # started shard runs exactly the `--shard k/10` slice it ran before, under # the same name, cache key and attestation; a shard whose bin is empty is # simply never created. The literal after `||` is the full roster, read # when the plan job published nothing (it died or timed out), and the gate @@ -1044,7 +1062,7 @@ jobs: strategy: fail-fast: ${{ github.event_name == 'merge_group' }} matrix: - shard: ${{ fromJSON(needs.test-plan.outputs.shards || '[1, 2, 3, 4, 5, 6, 7, 8]') }} + shard: ${{ fromJSON(needs.test-plan.outputs.shards || '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]') }} steps: # Depth 1 (the default), then the step below fetches the history this job @@ -1108,7 +1126,7 @@ jobs: # the tail's low end (1063 s), not its top. In `test-ui` neither end # fits beside the body inside the 30-minute wall, so its budget only # ends the red sooner and names the step. A red `test-plan` falls - # back to all eight shards, and each fetches for itself. + # back to all ten shards, and each fetches for itself. # A fetch that stalls is retried after 60 s of silence; one that keeps # stalling ends red here, named, instead of eating the wall. - name: Fetch this commit's history and the base branch @@ -1238,7 +1256,7 @@ jobs: run: | bash scripts/ci/select-shard-packages.sh node scripts/partition-test-shards.mjs "$RUNNER_TEMP/turbo-ls.json" \ - --shard ${{ matrix.shard }}/8 --exclude @objectstack/dogfood \ + --shard ${{ matrix.shard }}/10 --exclude @objectstack/dogfood \ > "$RUNNER_TEMP/shard-packages.txt" echo 'Items on this shard (a package name, or a package plus a k/n file-level slice):' cat "$RUNNER_TEMP/shard-packages.txt" @@ -1363,7 +1381,7 @@ jobs: # `--if-ran`: an empty shard exits the step above before turbo runs. - name: The Turbo remote cache was on for this shard's closure build run: | - node scripts/ci/assert-turbo-remote-cache.mjs --site 'Test Core (${{ matrix.shard }}/8) closure' \ + node scripts/ci/assert-turbo-remote-cache.mjs --site 'Test Core (${{ matrix.shard }}/10) closure' \ --log .turbo/remote-cache/test-core-closure.json --if-ran \ --move-summary-to "$RUNNER_TEMP/turbo-remote-cache" @@ -1732,7 +1750,7 @@ jobs: run: | node scripts/ci/report-test-leftovers.mjs report \ --before "$RUNNER_TEMP/test-leftovers/before.json" \ - --label "Test Core (${{ matrix.shard }}/8)" + --label "Test Core (${{ matrix.shard }}/10)" # --summarize above costs nothing at runtime and writes # `.turbo/runs/.json`: one per-task record with the execution window @@ -1776,7 +1794,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v7 with: - name: test-core-run-summary-${{ matrix.shard }}-of-8 + name: test-core-run-summary-${{ matrix.shard }}-of-10 path: .turbo/runs/ if-no-files-found: ignore retention-days: ${{ github.event_name == 'schedule' && 4 || 1 }} @@ -1858,11 +1876,11 @@ jobs: shopt -s nullglob SUMMARIES=(.turbo/runs/*.json) if [ "${#SUMMARIES[@]}" -eq 0 ]; then - echo "shard-timing-drift: NOT MEASURED -- Test Core (${{ matrix.shard }}/8) wrote no turbo run summary (no packages on this shard)." + echo "shard-timing-drift: NOT MEASURED -- Test Core (${{ matrix.shard }}/10) wrote no turbo run summary (no packages on this shard)." exit 0 fi node scripts/partition-test-shards.mjs --check-drift "${SUMMARIES[@]}" \ - --label "Test Core (${{ matrix.shard }}/8)" --event "$GITHUB_EVENT_NAME" + --label "Test Core (${{ matrix.shard }}/10)" --event "$GITHUB_EVENT_NAME" # Runs even when the suite failed — that is when it earns its keep. It # answers TWO questions about a red suite, and needs both to be able to @@ -1992,7 +2010,7 @@ jobs: node scripts/report-test-timings.mjs --capture \ --log "$RUNNER_TEMP/test-core.log" \ --summaries .turbo/runs \ - --shard "${{ matrix.shard }}/8" \ + --shard "${{ matrix.shard }}/10" \ --out "$RUNNER_TEMP/test-timings/shard-${{ matrix.shard }}.json" # Retention matches the run-summary upload above (4 days on `schedule`, @@ -2005,7 +2023,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v7 with: - name: test-core-timings-${{ matrix.shard }}-of-8 + name: test-core-timings-${{ matrix.shard }}-of-10 path: ${{ runner.temp }}/test-timings/ if-no-files-found: ignore retention-days: ${{ github.event_name == 'schedule' && 4 || 1 }} @@ -2048,10 +2066,10 @@ jobs: OS_SEED_ONLY: ${{ needs.queue-verdict.outputs.covered == 'true' }} run: | if [ "$OS_SEED_ONLY" = 'true' ]; then - node scripts/ci/prune-turbo-cache.mjs --site 'Test Core (${{ matrix.shard }}/8) seed-only' \ + node scripts/ci/prune-turbo-cache.mjs --site 'Test Core (${{ matrix.shard }}/10) seed-only' \ --cache .turbo/cache --run-summaries "$RUNNER_TEMP/turbo-remote-cache" else - node scripts/ci/prune-turbo-cache.mjs --site 'Test Core (${{ matrix.shard }}/8)' \ + node scripts/ci/prune-turbo-cache.mjs --site 'Test Core (${{ matrix.shard }}/10)' \ --cache .turbo/cache --run-summaries .turbo/runs \ --extra-summaries "$RUNNER_TEMP/turbo-remote-cache" fi @@ -2084,14 +2102,14 @@ jobs: if: needs.queue-verdict.outputs.covered != 'true' run: | node scripts/check-shard-attestation.mjs --emit \ - --job test --shard ${{ matrix.shard }} --total 8 \ + --job test --shard ${{ matrix.shard }} --total 10 \ --out "$RUNNER_TEMP/shard-attestation" - name: Publish this shard's attestation if: needs.queue-verdict.outputs.covered != 'true' uses: actions/upload-artifact@v7 with: - name: shard-attest-test-${{ matrix.shard }}-of-8 + name: shard-attest-test-${{ matrix.shard }}-of-10 path: ${{ runner.temp }}/shard-attestation/ if-no-files-found: error retention-days: 1 @@ -2207,8 +2225,8 @@ jobs: OS_DOWNLOAD_OUTCOME: ${{ steps.attestations.outcome }} # The planned roster, spelled exactly as the `test` job's matrix # spells it, fallback included: a plan job that died leaves the - # matrix on 1..8, and the gate then counts 1..8 too (#26084). - OS_TEST_PLAN: ${{ needs.test-plan.outputs.shards || '[1, 2, 3, 4, 5, 6, 7, 8]' }} + # matrix on 1..10, and the gate then counts 1..10 too (#26084). + OS_TEST_PLAN: ${{ needs.test-plan.outputs.shards || '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]' }} OS_TEST_PLAN_RESULT: ${{ needs.test-plan.result }} # Read ONLY on the partially-attested-cancelled path above, never # otherwise; without it that path fails closed (red, naming the @@ -2220,7 +2238,7 @@ jobs: --dir "$OS_ATTEST_DIR" \ --filter-result "$OS_FILTER_RESULT" \ --download-outcome "$OS_DOWNLOAD_OUTCOME" \ - --leg "test/8:$OS_TEST_RESULT" \ + --leg "test/10:$OS_TEST_RESULT" \ --planned "test=$OS_TEST_PLAN" \ --plan-result "$OS_TEST_PLAN_RESULT" diff --git a/scripts/ci/plan-test-core-shards.mjs b/scripts/ci/plan-test-core-shards.mjs index fdd63c2b2fa..f0ce4f831ac 100644 --- a/scripts/ci/plan-test-core-shards.mjs +++ b/scripts/ci/plan-test-core-shards.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. // -// plan-test-core-shards -- which `Test Core (N/8)` shards this run starts, +// plan-test-core-shards -- which `Test Core (N/10)` shards this run starts, // decided ONCE, before any shard runner exists (#26084). // // node scripts/ci/plan-test-core-shards.mjs --exclude ... --github-output @@ -33,9 +33,10 @@ // `fromJSON`. `[]` means nothing to test: the job's `if:` skips it. // digest a sha256 of the whole plan (every bin's items, in order). // -// The shard count stays SHARD_COUNT: a planned shard runs `--shard k/8` -// exactly as before, keeps its name `Test Core (k/8)`, its cache key and its -// attestation `test-k-of-8`. Only the shards whose bin is empty are not +// The shard count stays SHARD_COUNT (10 since #34710, read from ci.yml): a +// planned shard runs `--shard k/10` exactly as an unplanned run would, keeps +// its name `Test Core (k/10)`, its cache key and its attestation +// `test-k-of-10`. Only the shards whose bin is empty are not // started, so no package moves to another shard and no shard carries more // than it did. This is deliberately NOT a re-sizing to fewer, fuller bins: // every package diff on main reaches @objectstack/cli, spec, core, objectql diff --git a/scripts/partition-test-shards.mjs b/scripts/partition-test-shards.mjs index d963292e10c..6cd61f45321 100644 --- a/scripts/partition-test-shards.mjs +++ b/scripts/partition-test-shards.mjs @@ -132,8 +132,9 @@ const TIMINGS_PATH = path.join(REPO_ROOT, 'scripts', 'test-shard-timings.json'); // asks the matrix instead of keeping a copy, and an unreadable matrix fails // the import rather than falling back to a remembered count. ci.yml spells it // twice more (`--shard N/M` and the attestation's `--total`); the self-test -// below reads those back. scripts/ci/select-shard-timings-run.mjs spells it -// once more, but only as its matchers' default: the timings refresh judges +// below reads those back. scripts/ci/select-shard-timings-run.mjs keeps a +// count of its own (8, the width its self-test fixtures are written at), but +// only as its matchers' default: the timings refresh judges // each run at the width that run's own `Test Core (N/M)` jobs carry, so a // resize leaves the runs from before it readable (#25376). // @@ -163,6 +164,34 @@ const TIMINGS_PATH = path.join(REPO_ROOT, 'scripts', 'test-shard-timings.json'); // beside them. That last figure is the floor this count cannot move: a CLI // slice (~960-1010s measured) is serial, so past eight the slowest shard is // the slice and more shards only add runners. +// +// RE-DERIVED AT 10 (#34710, 8 -> 10), on the whole-package leg cap +// (WHOLE_LEG_CAP_SECONDS, pin 3d), not on balance. The 2026-11-16 refresh (PR +// #34314's dataset, measuredAt 2026-11-16) measured 14524s of whole +// packages, the CLI at 2245.53s and spec at 1769.27s, and at eight five shards +// carried ~2195s of whole packages against the 1868s cap. The cap's own rule +// is a wider matrix or a finer slice, never a denser shard, and the count it +// asks for is the whole seconds plus the CLI's 3 slices plus the reader slice's +// closure charge over the cap: (14524 + 2245.53 + 783) / 1868 = 9.4, so ten. +// Through planShards() at the CI split, that dataset's bins and whole legs: +// +// 8 shards -> max 2195s mean 2194s ratio 1.00x whole legs max 2195s 5 past the cap +// 9 shards -> max 1954s mean 1951s ratio 1.00x whole legs max 1954s 6 past the cap +// 10 shards -> max 1769s mean 1755s ratio 1.01x whole legs max 1769s <- spec alone +// 11 shards -> max 1769s mean 1596s ratio 1.11x whole legs max 1769s +// +// The CLI stays at 3 slices: pin 3c judges the count on serial floors, which +// the shard count does not enter, so FILE_SHARDED_PACKAGES and +// PREVIOUS_FILE_SHARDED_PACKAGES are unchanged and the generator decodes the +// runs made at eight exactly as before. On the committed 2026-11-02 dataset +// ten reads max 1304s, mean 1242s, 1.05x, whole legs at most 1236s. +// +// Ten is again the count where a floor binds: spec's whole weight is the +// heaviest bin, and its whole leg stays 1769s at any width. So spec past +// 1868s is a finer slice's card (OS_TEST_SHARD support in spec and a +// FILE_SHARDED_PACKAGES entry), not an eleventh shard's. In the shard wall +// model (whole sum / WHOLE_LEG_WALL_DIVISOR + slice) the slowest tests step +// on that dataset goes ~1247s -> ~1095s, a CLI slice shard both times. export const SHARD_COUNT = liveShardTotal('test'); // The acceptance bound #10472 set: the slowest shard within ~1.3x the mean. @@ -1363,7 +1392,7 @@ export function refineToCap(bins, items, cap) { // // So a candidate split that CARRIES the reader slice is judged against the cap // plus that displacement: DECLARATION_CLOSURE_CHARGE_SECONDS / (shardCount - 1), -// 111.86s at 8 shards. It is the charge's own arithmetic -- the density the +// 111.86s at 8 shards, 87.00s at 10 (#34710). It is the charge's own arithmetic -- the density the // closure pin already chose to move -- and nothing else: a split with no reader // slice (the package whole, a run without it, a document that states its own // slicing) is judged against the bare cap, and a split denser than the cap plus From b938531de5807a2cb37140d4699b718eea66978a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:33:32 +0000 Subject: [PATCH 2/2] ci: read the Test Core width for the timings-run selector's default select-shard-timings-run.mjs spelled SHARD_COUNT = 8 and called it the live width; it now reads ci.yml's test matrix through ci-shard-matrix.mjs, the source the partitioner uses. Its matcher pins are spelled at the live width, and each keeps an 8-wide name read at its own width so retained runs from before the resize stay pinned. The eligibility fixtures stay an 8-wide run judged at its own width. The firing control reds by name instead of returning when the live width equals its fixture's. Case counts are unchanged per battery. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01ADHkmRH4UCX1tvddXMS7cq --- scripts/ci/select-shard-timings-run.mjs | 75 ++++++++++++++++--------- scripts/partition-test-shards.mjs | 9 ++- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/scripts/ci/select-shard-timings-run.mjs b/scripts/ci/select-shard-timings-run.mjs index 704c26323c8..6acc8c52fd7 100644 --- a/scripts/ci/select-shard-timings-run.mjs +++ b/scripts/ci/select-shard-timings-run.mjs @@ -106,15 +106,20 @@ import { join } from 'node:path'; import process from 'node:process'; import { fileURLToPath } from 'node:url'; +import { liveShardTotal } from '../ci-shard-matrix.mjs'; import { EXIT_FINDINGS, EXIT_PREREQUISITE_NOT_MET } from '../import-prerequisite.mjs'; import { isEntrypoint } from '../invoked-as.mjs'; -// The Test Core shard count of the LIVE matrix. partition-test-shards.mjs owns -// the split itself and its own self-test reads ci.yml back, so this is a -// reader's default rather than a second declaration of the split -- and since -// #25376 it is NOT what a candidate run is judged against. See "A RUN IS -// COMPLETE AT ITS OWN WIDTH" below. -export const SHARD_COUNT = 8; +// The Test Core shard count of the LIVE matrix, READ from ci.yml's `test` +// matrix through scripts/ci-shard-matrix.mjs -- the same source +// partition-test-shards.mjs sizes the split from -- so a resize has one +// spelling, the workflow's (#34710: this was a literal 8 that stayed behind +// when the matrix went to 10). An unreadable matrix fails the import rather +// than falling back to a remembered count. It is only the matchers' default: +// since #25376 a candidate run is judged at its OWN width, never this one, so +// the runs from before a resize stay readable. See "A RUN IS COMPLETE AT ITS +// OWN WIDTH" below. +export const SHARD_COUNT = liveShardTotal('test'); const API = 'https://api.github.com'; @@ -123,8 +128,8 @@ const API = 'https://api.github.com'; // and would pass every eligibility and coverage check while measuring a slice. export const DEFAULT_RUN_EVENT = 'schedule'; -// `Test Core (3/8)` -> 3. Anchored on both ends: a job merely CONTAINING that -// text (a future "Test Core (3/8) rerun") is not this job, and reading it as one +// `Test Core (3/10)` -> 3. Anchored on both ends: a job merely CONTAINING that +// text (a future "Test Core (3/10) rerun") is not this job, and reading it as one // would let a run qualify on a job that never ran the suite. export function testCoreShard(jobName, shardCount = SHARD_COUNT) { const m = /^Test Core \((\d+)\/(\d+)\)$/.exec(String(jobName ?? '').trim()); @@ -134,7 +139,7 @@ export function testCoreShard(jobName, shardCount = SHARD_COUNT) { return index >= 1 && index <= shardCount ? index : null; } -// `test-core-run-summary-3-of-8` -> 3, by the same anchoring argument. +// `test-core-run-summary-3-of-10` -> 3, by the same anchoring argument. export function summaryArtifactShard(artifactName, shardCount = SHARD_COUNT) { const m = /^test-core-run-summary-(\d+)-of-(\d+)$/.exec(String(artifactName ?? '').trim()); if (!m) return null; @@ -143,7 +148,7 @@ export function summaryArtifactShard(artifactName, shardCount = SHARD_COUNT) { return index >= 1 && index <= shardCount ? index : null; } -// `test-core-timings-3-of-8` -> 3: the shard's per-FILE capture +// `test-core-timings-3-of-10` -> 3: the shard's per-FILE capture // (`report-test-timings.mjs --capture`), anchored like the summary matcher. // NOT an eligibility input -- the capture step is report-only // (`continue-on-error`), so a run can be a complete measurement without one -- @@ -643,30 +648,39 @@ async function selfTest() { // -- The two name matchers. Both are anchored, and the pins that matter are // the NEAR MISSES: a matcher that also accepts a rerun job or a // differently-sharded artifact would qualify a run on evidence from a run - // that is not this one. + // that is not this one. Spelled at the LIVE width `W` (the matchers' + // default, read from ci.yml), so a resize moves these with the matrix; + // `OTHER` is a width the live matrix is not. The retained-run half -- an + // 8-wide name read at ITS width, as runIsEligible() reads a run made + // before #34710 -- is pinned beside each default-width case. + const W = SHARD_COUNT; + const OTHER = W + 1; check(() => { - if (testCoreShard('Test Core (3/8)') !== 3) throw new Error('job matcher: the plain shape did not parse'); + if (testCoreShard(`Test Core (3/${W})`) !== 3) throw new Error('job matcher: the plain shape did not parse'); + if (testCoreShard('Test Core (3/8)', 8) !== 3) throw new Error('job matcher: a retained 8-wide name did not parse at its own width'); }); check(() => { - if (testCoreShard('Test Core (1/8)') !== 1 || testCoreShard('Test Core (8/8)') !== 8) { + if (testCoreShard(`Test Core (1/${W})`) !== 1 || testCoreShard(`Test Core (${W}/${W})`) !== W) { throw new Error('job matcher: an endpoint shard did not parse'); } + if (testCoreShard('Test Core (8/8)', 8) !== 8) throw new Error('job matcher: a retained 8-wide endpoint did not parse at its own width'); }); check(() => { - if (testCoreShard('Test Core (0/8)') !== null || testCoreShard('Test Core (9/8)') !== null) { + if (testCoreShard(`Test Core (0/${W})`) !== null || testCoreShard(`Test Core (${W + 1}/${W})`) !== null) { throw new Error('job matcher: an out-of-range shard index was accepted'); } + if (testCoreShard('Test Core (9/8)', 8) !== null) throw new Error('job matcher: an out-of-range 8-wide index was accepted'); }); check(() => { - if (testCoreShard('Test Core (3/8) rerun') !== null) { + if (testCoreShard(`Test Core (3/${W}) rerun`) !== null) { throw new Error('job matcher: a job merely CONTAINING the shape was accepted'); } }); check(() => { - if (testCoreShard('Dogfood (3/8)') !== null) throw new Error('job matcher: a different job was accepted'); + if (testCoreShard(`Dogfood (3/${W})`) !== null) throw new Error('job matcher: a different job was accepted'); }); check(() => { - if (testCoreShard('Test Core (3/6)') !== null) { + if (testCoreShard(`Test Core (3/${OTHER})`) !== null || testCoreShard('Test Core (3/8)') !== null) { throw new Error('job matcher: a job from a different shard count was accepted'); } }); @@ -676,34 +690,41 @@ async function selfTest() { } }); check(() => { - if (summaryArtifactShard('test-core-run-summary-4-of-8') !== 4) { + if (summaryArtifactShard(`test-core-run-summary-4-of-${W}`) !== 4) { throw new Error('artifact matcher: the plain shape did not parse'); } + if (summaryArtifactShard('test-core-run-summary-4-of-8', 8) !== 4) { + throw new Error('artifact matcher: a retained 8-wide summary did not parse at its own width'); + } }); check(() => { - if (summaryArtifactShard('test-core-run-summary-4-of-6') !== null) { + if (summaryArtifactShard(`test-core-run-summary-4-of-${OTHER}`) !== null || summaryArtifactShard('test-core-run-summary-4-of-8') !== null) { throw new Error('artifact matcher: a different shard count was accepted'); } }); check(() => { - if (summaryArtifactShard('test-core-run-summary-4-of-8-retry') !== null) { + if (summaryArtifactShard(`test-core-run-summary-4-of-${W}-retry`) !== null) { throw new Error('artifact matcher: a longer name was accepted'); } }); // #22949 ruling E: the per-file capture matcher, anchored the same way -- // and NOT the run-summary name, which is a different artifact. check(() => { - if (timingCaptureShard('test-core-timings-2-of-8') !== 2) throw new Error('capture matcher: the plain shape did not parse'); - if (timingCaptureShard('test-core-timings-2-of-6') !== null || timingCaptureShard('test-core-timings-2-of-8-retry') !== null) { + if (timingCaptureShard(`test-core-timings-2-of-${W}`) !== 2) throw new Error('capture matcher: the plain shape did not parse'); + if (timingCaptureShard('test-core-timings-2-of-8', 8) !== 2) throw new Error('capture matcher: a retained 8-wide capture did not parse at its own width'); + if (timingCaptureShard(`test-core-timings-2-of-${OTHER}`) !== null || timingCaptureShard(`test-core-timings-2-of-${W}-retry`) !== null) { throw new Error('capture matcher: a different shard count or a longer name was accepted'); } - if (timingCaptureShard('test-core-run-summary-2-of-8') !== null || summaryArtifactShard('test-core-timings-2-of-8') !== null) { + if (timingCaptureShard(`test-core-run-summary-2-of-${W}`) !== null || summaryArtifactShard(`test-core-timings-2-of-${W}`) !== null) { throw new Error('capture matcher: the run summary and the per-file capture were read as each other'); } }); // -- Eligibility. The fixtures are built from the two rejection shapes this // workflow actually meets: a cancelled shard, and an expired artifact. + // They are an 8-wide run on purpose, read at its own width: the retained + // runs from before #34710 are 8 wide, and the refresh lane must keep + // accepting them after the matrix went to 10. const jobs = (conclusions) => conclusions.map((conclusion, i) => ({ name: `Test Core (${i + 1}/8)`, conclusion, status: 'completed' })); const artifacts = (present, expired = []) => @@ -925,7 +946,7 @@ async function selfTest() { check(() => { const v = runIsEligible(sixShardRun); - if (!v.eligible) throw new Error(`width: a whole 6-shard run was rejected under an 8-shard matrix (${v.reasons.join('; ')})`); + if (!v.eligible) throw new Error(`width: a whole 6-shard run was rejected under a ${SHARD_COUNT}-shard matrix (${v.reasons.join('; ')})`); if (v.shardCount !== 6) throw new Error(`width: the run's own width read as ${v.shardCount}, not 6`); if (Object.keys(v.artifactIds).join(',') !== '1,2,3,4,5,6') { throw new Error(`width: the 6-shard run's artifacts read as ${JSON.stringify(v.artifactIds)}`); @@ -935,8 +956,10 @@ async function selfTest() { // FIRING CONTROL: pinned to the live count, the same run is the rejection // job 121075952437 printed -- so the pass above is the width reading, not a // fixture that would pass anyway. + if (SHARD_COUNT === 6) { + throw new Error('width: the live matrix is 6 wide, so the 6-shard fixture cannot be its firing control -- respell the fixture at another width'); + } const v = runIsEligible(sixShardRun, SHARD_COUNT); - if (SHARD_COUNT === 6) return; if (v.eligible || !v.reasons.some((r) => r.includes(`${SHARD_COUNT}/${SHARD_COUNT}`))) { throw new Error(`width: pinned to ${SHARD_COUNT}, the 6-shard run was not rejected as the live lane rejected it (${v.reasons.join('; ')})`); } @@ -1010,7 +1033,7 @@ async function selfTest() { // that decided the dataset was being fed by affected-only push runs. // // The fake API below serves BOTH a schedule-shaped and a push-shaped run, - // and both are fully eligible -- six successful shards, six live artifacts. + // and both are fully eligible -- eight successful shards, eight live artifacts. // That is the point: eligibility cannot tell them apart, so the only thing // that can is the event named in the request. Each reading therefore comes // with its two controls -- a leg that makes the fake serve the push run diff --git a/scripts/partition-test-shards.mjs b/scripts/partition-test-shards.mjs index 6cd61f45321..ddd60b90fcf 100644 --- a/scripts/partition-test-shards.mjs +++ b/scripts/partition-test-shards.mjs @@ -132,11 +132,10 @@ const TIMINGS_PATH = path.join(REPO_ROOT, 'scripts', 'test-shard-timings.json'); // asks the matrix instead of keeping a copy, and an unreadable matrix fails // the import rather than falling back to a remembered count. ci.yml spells it // twice more (`--shard N/M` and the attestation's `--total`); the self-test -// below reads those back. scripts/ci/select-shard-timings-run.mjs keeps a -// count of its own (8, the width its self-test fixtures are written at), but -// only as its matchers' default: the timings refresh judges -// each run at the width that run's own `Test Core (N/M)` jobs carry, so a -// resize leaves the runs from before it readable (#25376). +// below reads those back. scripts/ci/select-shard-timings-run.mjs reads the +// same matrix for its matchers' default (#34710), and only that: the timings +// refresh judges each run at the width that run's own `Test Core (N/M)` jobs +// carry, so a resize leaves the runs from before it readable (#25376). // // WHY EIGHT (#25376, 6 -> 8). On the committed dataset (the 2026-10-23 // refresh), bins of predicted test windows, the CLI cut into its 3 slices: