Skip to content

Commit 87af852

Browse files
test(spec): split build-schemas-check-mode.test.ts into six files so the repo project runs them in parallel (#25428)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoPahKKD78gi4RU2syTTB675)_ Fixes #25372 Clause-②: no Metadata-protocol: none The card's re-scope (option A, triage comment `6358468116`): split `packages/spec/scripts/build-schemas-check-mode.test.ts` into several files so the `repo` vitest project runs them in parallel. Test-only; no `turbo.json`, partition, `ci.yml` or shard-count change. ## What changes - **One 5135-line file becomes six test files and one shared module.** vitest runs a file's tests one at a time, so this file (841.97 s, 92 tests, the slowest file of PR run 39893808670) was spec's `test:repo` floor on its own. The `repo` project's pool is vitest's default (`cores - 1`, so 3 workers on a 4-vCPU runner; `VITEST_MAX_WORKERS` from `scripts/vitest-worker-cap.mjs` only ever lowers it), so separate files run on separate workers. - **`build-schemas-check-mode.fixture.ts`** (not a `.test.ts`, so neither project collects it) carries the family header, the sandbox builders, the #9068 git discipline, `run()`, and every constant more than one block reads. The old root `beforeAll`/`afterAll` become `useSharedSandbox(rootScriptsDir)`, which each test file calls once, so every file builds its own shared sandbox (an `fs.mkdtemp`, so two files never share one). Module state stays per file because vitest isolates each test file's module graph. - **The 15 `describe` blocks move verbatim**, grouped by subject and balanced on a measured local run of the original file (seconds are that run's per-block sums): | File | Blocks | Tests | Local share (s) | |---|---|---|---| | `.manifest.test.ts` | #4711, #16431, #5371, #12588 | 18 | 149.2 | | `.deleted-baseline.test.ts` | #4650 | 15 | 137.5 | | `.anchor.test.ts` | #5235, #5358 | 15 | 125.6 | | `.git-topology.test.ts` | #5370, #5847, #6452 (the three own-sandbox blocks) | 17 | 157.9 | | `.retired-keys.test.ts` | #4659, #17969 | 13 | 130.9 | | `.deletion-proofs.test.ts` | #4725, #5898, #18865 | 14 | 127.1 | Block-local constants travel with their block; constants two files read live in the fixture. - **Each test file names its out-of-package input.** `check:cross-package-test-inputs` reads a test file's own source, not the modules it imports, so five of the six files at first stopped showing that they run against the repo-root `scripts/` and the gate asked to move them to `local`. Each file now resolves `../../../scripts` itself and hands it to `useSharedSandbox()`, which is the path the fixture symlinks into every sandbox. They stay in the `repo` project. - **`vitest.repo-tests.json`** lists the six files in place of the one. - **Budget lines.** Each file carries its own `// test-budget:` line. No CI reading of a split file exists yet, so each figure is apportioned: the pre-split file's slowest CI reading (983.3 s, run 38798542648, the reading the old 1230 line rested on) times the file's share of the local run, times 1.25, rounded up to 10 s (190 to 240 s). Each line says so and asks to be re-measured once CI has read the file on its own. - **Prose references** to the old file name in `packages/spec/scripts/**` (`build-schemas.ts` and eight sibling tests) point at the split file or the fixture they mean. - No changeset: `scripts/` ships in no package's `files[]` (spec's `files` is `dist`, `json-schema`, `liveness`, `prompts`, `llms.txt`, `README.md`, `src/**/*.zod.ts`, `CHANGELOG.md`). ## Verification (head `78a4221bd`) - **No case lost.** `vitest list --project repo` on the old file and on the six new files, file prefix stripped, sorted: 92 and 92 names, `diff` empty. `vitest list --project local` matches none of the files. - **Timing, before and after (local, same 4-core box, same lock, labelled local):** the original file alone took 839.06 s (92/92 passed). The six split files run together as the `repo` project: 370.44 s wall, 92/92 passed, slowest file `git-topology` 205.4 s. The before figure from CI is on the card: 841.97 s for the file, spec two-task total 1212.41 s (PR run 39893808670) and 1494.69 s in merge-group run 39894014103. The after figure from CI is this PR's own `Test Core` timing table, read by the seat at review. - `pnpm --filter @objectstack/spec build`, `typecheck` (includes `check:scripts-typecheck`): exit 0. `pnpm --filter @objectstack/spec test`: 711/711 files, 21634 passed, 1 todo. - `node scripts/pm/dispatch-gates.mjs --commands` derived 66 families on the final head `78a4221bd`; all 66 ran and exit 0. `--ran` reconciliation: 66 run, 0 NOT-MEASURED, 0 UNRUN. On the first sweep (head `9f2ed009f`, 63 families) `check:cross-package-test-inputs` answered 1 (fixed above), `check-plugin-teardown-shape --self-test` answered 3 (its pinned control commit was missing from the shallow clone; fetched), and `check:dual-build-cjs-loads` / `check:lean-entry-closure` answered 3 (no built dist); all exit 0 on the final sweep. ## Acceptance notes - The card's done-when number ("spec's two-task total in a merge-group `Test Core` timing table drops") can only be read after this lands in a merge group; the before figure above is the one to compare against. - `scripts/git-env.d.mts:9` (repo root, outside this card's file surface) still names the old file in prose, and `scripts/report-test-timings.mjs:935/943` uses the old name as a fixture log line (correct as data). Noted, not changed. - The cross-package scan does not follow a test file's imports into same-package helper modules. Here each file now names its input itself; other tests whose out-of-package reads live only in an imported helper would be unseen by the same scan. Noted, not filed. ## CI after-numbers (run 39963105499, head `dce4c6406`, `pull_request`, Test Core aggregate job 120460015448) - **Slowest file in spec:** 841.97 s before (the one file, PR run 39893808670). After, the six files read 457.69 s (`git-topology`), 420.84 s (`deleted-baseline`), 386.75 s (`deletion-proofs`), 147.50 s (`retired-keys`), 140.73 s (`manifest`) and 104.13 s (`anchor`). The slowest is now 457.69 s. - **Spec's two-task total** (the card's done-when quantity): 1113.11 s in this PR run, against 1212.41 s in PR run 39893808670 and 1494.69 s in merge-group run 39894014103. The merge-group comparison can be read only after this lands. - **Load cost:** on a shared runner, the files run side by side and each takes longer than its serial share. The six together are 1657.6 s of file time, against 842 s for the one file. The wall drops because they overlap. - **Shard tests steps in this run:** 10.6 to 20.4 min (slowest shard 4/6). That is a reading of this run, not a comparison of like with like. - **Budget lines** were re-set from this reading in `ab63b4e7e`: each is the CI reading × 1.25, rounded up (580, 530, 490, 190, 180 and 140 s). They replace the first apportioned estimates (190 to 240 s), which assumed each file keeps its serial share and came in under the three heaviest readings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01P8iUGfP2wffkVBD5uSfDgq --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent dc3e5b9 commit 87af852

18 files changed

Lines changed: 5542 additions & 5150 deletions

‎packages/spec/scripts/build-schemas-check-mode.anchor.test.ts‎

Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.deleted-baseline.test.ts‎

Lines changed: 981 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.deletion-proofs.test.ts‎

Lines changed: 926 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.fixture.ts‎

Lines changed: 693 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.git-topology.test.ts‎

Lines changed: 979 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.manifest.test.ts‎

Lines changed: 681 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.retired-keys.test.ts‎

Lines changed: 789 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/spec/scripts/build-schemas-check-mode.test.ts‎

Lines changed: 0 additions & 5135 deletions
This file was deleted.

‎packages/spec/scripts/build-schemas.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,9 +1822,9 @@ function computeGuidanceRoutes(): GuidanceRoutes {
18221822
* so a diff that rewrites this constant AND `authorable-surface.base.json`'s
18231823
* `description` to the same bytes leaves `baseRev` and `keys` untouched and
18241824
* `check:authorable-surface` green. Both halves in one reviewed diff, or neither —
1825-
* a one-sided edit is the fatal case above, and `build-schemas-check-mode.test.ts`
1826-
* is what says so, because it seeds its fixtures with the description read off the
1827-
* committed file and runs THIS generator against them.
1825+
* a one-sided edit is the fatal case above, and `build-schemas-check-mode.*.test.ts`
1826+
* are what say so, because they seed their fixtures with the description read off the
1827+
* committed file and run THIS generator against them.
18281828
*
18291829
* "Written only by `gen:schema`" still UNDER-states the rule rather than
18301830
* contradicting it: the writer is still this generator (`scripts/build-schemas.ts`),
@@ -2022,7 +2022,7 @@ function verifyCommittedSurfaceBase(
20222022
// coincidence, and would therefore be exactly where a file-validating-file
20232023
// comparison could hide. Keeping the keys git-sourced is what stops it; the pin
20242024
// is behavioural (a key shed from this file is still caught under `.git/shallow`
2025-
// — see build-schemas-check-mode.test.ts) rather than a comment asserting it.
2025+
// — see build-schemas-check-mode.git-topology.test.ts) rather than a comment asserting it.
20262026
//
20272027
// The ancestry half is NOT established by that caller, and cannot be: a
20282028
// truncated history cannot show the rev is upstream. It is the rev the tree

‎packages/spec/scripts/def-key-collisions.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ describe('formatDefKeyCollisions', () => {
241241
// ─────────────────────────────────────────────────────────────────────────
242242
//
243243
// The green side of this guard has plenty of witnesses: every `gen:schema`,
244-
// every `check:authorable-surface`, and `build-schemas-check-mode.test.ts`'s
245-
// whole suite run the unmutated script. The RED side has none — and a gate
244+
// every `check:authorable-surface`, and the `build-schemas-check-mode.*.test.ts`
245+
// files' whole suite run the unmutated script. The RED side has none — and a gate
246246
// that has never been observed failing is not known to be a gate (#5168's
247247
// finding, applied here). So this one case puts the deleted limb back: it
248248
// re-declares `HttpMethodSchema` alongside the renamed `HttpMethodSubsetSchema`
@@ -257,7 +257,7 @@ describe('formatDefKeyCollisions', () => {
257257
// guard. The assertions below therefore also check the run reached the
258258
// generation summary first.
259259
//
260-
// Sandbox discipline copied from `build-schemas-check-mode.test.ts` and
260+
// Sandbox discipline copied from `build-schemas-check-mode.fixture.ts` and
261261
// `openapi-self-consistency.test.ts`: the script resolves `OUT_DIR` and every
262262
// artifact path from its own `__dirname`, so running a mutated copy in place
263263
// would rewrite the package's real (gitignored) `json-schema/` while a

0 commit comments

Comments
 (0)