From 0a9e44258b00d4e7c22658d9f662b9501b868678 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 17 Nov 2026 20:13:18 +0000 Subject: [PATCH] fix(ci): qualify oversized determinism files and warn before running --- docs/decisions/ci-utility.md | 70 ++++++++++++++++--- scripts/test-determinism.ts | 9 +++ .../determinism-single-file-runs.json | 54 ++++++++++++++ tests/test-determinism.test.ts | 52 ++++++++++++++ 4 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 tests/fixtures/determinism-single-file-runs.json diff --git a/docs/decisions/ci-utility.md b/docs/decisions/ci-utility.md index 41124f4a7a..acb8c9d78d 100644 --- a/docs/decisions/ci-utility.md +++ b/docs/decisions/ci-utility.md @@ -2123,14 +2123,14 @@ two. Of those eight, six are split (five into two or three partitions, the migration into nine) and two are a single file. An oversized selection costs up to ten runners for its two repetitions. -**Known limit.** All eight contain a real-browser runtime test whose two -repetitions alone exceed the capacity; the heaviest weighs 349.7 seconds per -pass. Sharding cannot help a single file. It runs alone, at the floor, and no -hosted run has yet measured whether it finishes inside the step limit -([#4156](https://github.com/schlessera/brain-kit/issues/4156)). The five -calibration runs are all tooling and backend tests; a refreshed weight table -or a different mix of tests changes the ratio, and the capacity is to be -recalibrated from the reports then. +**Single-file capacity.** In that historical replay, all eight contain a +real-browser runtime test whose two repetitions alone exceed the capacity; +the heaviest then weighed 349.7 seconds per pass. Sharding cannot help a +single file: it runs alone, at the floor. The later +[single-file measurements](#single-files-above-capacity-are-measured-under-load) +cover the four files identified by #4156, using refreshed weights and the +scaled watchdogs. A refreshed weight table or a different mix of tests changes +the ratio, and the capacity is to be recalibrated from the reports then. **Known limits.** Repetitions of one file share a process. Bun 1.4.2 evaluates the module again for each run, but `globalThis` and process state persist, so a @@ -2139,6 +2139,60 @@ story specs run in the pinned container and have [their own gate](#changed-browser-specs-repeat-under-load-before-merge); the one endurance spec is not repeated. +### Single files above capacity are measured under load + +Measured on 2026-11-17 for [#4156](https://github.com/schlessera/brain-kit/issues/4156), +in [run 44161515414, attempt 1](https://github.com/schlessera/brain-kit/actions/runs/44161515414) +on the throwaway draft [#4232](https://github.com/schlessera/brain-kit/pull/4232). +Comment-only edits selected all four originally identified files. The planner +split them into four jobs, one file per job, each repeated **twice** under +four CPU burners on four CPUs. The existing [#4191 watchdog policy](#test-watchdogs-are-a-worst-case-catch-all) +was active: factor **8**, with a 240-second default per-test cap. No test, +deadline or repetition count was changed for the measurement, and no job was +retried. + +The #4155 weight refresh had already changed the two-pass estimates: only +parallel-sessions and association-signout still exceeded the 300-second +capacity. Connection-continuity and hygiene-review were measured as well, +as required by the original issue. Each `determinism-proof-` artifact +contains `determinism-report.json` and `determinism-junit.xml`; both show +exactly two repetitions and no failures or skips. Report elapsed time includes +the offline wrapper and the setup/builds inside repetition; the full proof +step also includes the job command's preparation. + +| File | Two-pass estimate (s) | Report elapsed (s) | Proof step (s) | Hosted job | +| --- | --- | --- | --- | --- | +| `packages/ui-react/tests/parallel-sessions-runtime.test.ts` | 874.690 | 1429.3 | 1433 | [job 134317060865](https://github.com/schlessera/brain-kit/actions/runs/44161515414/job/134317060865) | +| `packages/ui-react/tests/association-signout-runtime.test.ts` | 388.612 | 722.4 | 729 | [job 134317060918](https://github.com/schlessera/brain-kit/actions/runs/44161515414/job/134317060918) | +| `packages/ui-react/tests/connection-continuity-runtime.test.ts` | 290.866 | 511.7 | 525 | [job 134317060892](https://github.com/schlessera/brain-kit/actions/runs/44161515414/job/134317060892) | +| `packages/ui-server/tests/hygiene-review.test.ts` | 276.280 | 473.0 | 482 | [job 134317060923](https://github.com/schlessera/brain-kit/actions/runs/44161515414/job/134317060923) | + +Every job's checkout log and `proof-checkout.json` names synthetic merge +`7e4008a99199f708b0f71ae01f4d19b615248312`, tree +`6eafef9615efcf86ef47ff7172d9105b0057cd58`, with parents main +`0aeb62a7acaef51deabe6a6bc84d3b7b1b72e286` and measurement head +`33485434a248168db55d423199f3ff06cbe9fe89`. The immutable commit API and local +Git object agree. These are sizing observations of that tree, not proof for a +later candidate. The draft was closed without merging and its branch deleted +after collecting the artifacts. + +**Decision: retain the 40-minute step.** The heaviest single file completed +in 1,429.3 seconds; its full step took 1,433 seconds, leaving 967 seconds of +headroom. A larger step or a file split is unnecessary on this evidence. +The capacity, partition maximum, floor of two and factor of eight stay as +ruled. One hosted observation per file does not guarantee every future run +fits, and the tooling/backend calibration ratio is not a per-file bound. + +The checked-in measurement inventory in +[`tests/fixtures/determinism-single-file-runs.json`](../../tests/fixtures/determinism-single-file-runs.json) +is checked against the reviewed weights: a newly oversized file needs hosted +evidence or an explicit recorded remedy before its coverage test can pass. +The job writes its oversized-file warning **before** starting the wrapper +(`const oversized`, `scripts/test-determinism.ts:197-205`), naming the file, +repetition estimate, capacity and step limit. A step timeout therefore leaves +the known unsplittable case in the summary even when no completion report can +be written. + ## Changed browser specs repeat under load before merge The maintainer ruled on 2026-11-17 diff --git a/scripts/test-determinism.ts b/scripts/test-determinism.ts index 17e236142a..cec2bab29c 100644 --- a/scripts/test-determinism.ts +++ b/scripts/test-determinism.ts @@ -193,6 +193,15 @@ export async function runDeterminism(options: RunOptions): Promise { } for (const line of describePlan(plan, burnerCount)) log(line); if (factor > 1) log(`Test deadlines scaled by ${factor} under load: Bun's per-test cap is ${deadlines.testCapMs} ms, and explicit test and hook timeouts and watchdogMs() watchdogs are multiplied the same way.`); + // Write before starting the wrapper: a step timeout cannot reach the completion summary. + const oversized = plan.files.filter(entry => entry.weightSeconds * entry.repetitions > plan.budgetSeconds); + if (oversized.length) { + const warning = ["### Single file exceeds partition capacity", "", + ...oversized.map(entry => `- \`${entry.file}\`: ${entry.repetitions} repetitions cost ${(entry.weightSeconds * entry.repetitions).toFixed(1)} weighted s against ` + + `${plan.budgetSeconds} s capacity. This file cannot be split across partitions; hosted planning runs it alone within the ${DETERMINISM_PARTITIONS.stepMinutes}-minute proof step.`), "", ""].join("\n"); + log(warning.trim()); + if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, warning); + } const files = plan.files.map(entry => entry.file), started = performance.now(); mkdirSync(dirname(join(root, JUNIT_PATH)), { recursive: true }); rmSync(join(root, JUNIT_PATH), { force: true }); diff --git a/tests/fixtures/determinism-single-file-runs.json b/tests/fixtures/determinism-single-file-runs.json new file mode 100644 index 0000000000..c266425719 --- /dev/null +++ b/tests/fixtures/determinism-single-file-runs.json @@ -0,0 +1,54 @@ +{ + "packages/ui-react/tests/association-signout-runtime.test.ts": { + "run": 44161515414, + "job": 134317060918, + "outcome": "passed", + "repetitions": 2, + "observed": 2, + "estimatedSeconds": 388.612, + "elapsedSeconds": 722.37, + "proofStepSeconds": 729.0, + "deadlineFactor": 8, + "burners": 4, + "cpus": 4 + }, + "packages/ui-react/tests/connection-continuity-runtime.test.ts": { + "run": 44161515414, + "job": 134317060892, + "outcome": "passed", + "repetitions": 2, + "observed": 2, + "estimatedSeconds": 290.866, + "elapsedSeconds": 511.711, + "proofStepSeconds": 525.0, + "deadlineFactor": 8, + "burners": 4, + "cpus": 4 + }, + "packages/ui-react/tests/parallel-sessions-runtime.test.ts": { + "run": 44161515414, + "job": 134317060865, + "outcome": "passed", + "repetitions": 2, + "observed": 2, + "estimatedSeconds": 874.69, + "elapsedSeconds": 1429.306, + "proofStepSeconds": 1433.0, + "deadlineFactor": 8, + "burners": 4, + "cpus": 4 + }, + "packages/ui-server/tests/hygiene-review.test.ts": { + "run": 44161515414, + "job": 134317060923, + "outcome": "passed", + "repetitions": 2, + "observed": 2, + "estimatedSeconds": 276.28, + "elapsedSeconds": 472.992, + "proofStepSeconds": 482.0, + "deadlineFactor": 8, + "burners": 4, + "cpus": 4 + } +} diff --git a/tests/test-determinism.test.ts b/tests/test-determinism.test.ts index 0dc01b9d0b..44605cac53 100644 --- a/tests/test-determinism.test.ts +++ b/tests/test-determinism.test.ts @@ -11,6 +11,8 @@ import { } from "../scripts/test-determinism"; import { planPartitions, selectPartition } from "../scripts/determinism-plan"; import { DETERMINISM_PARTITIONS } from "../scripts/proof-shards"; +import { FILE_COST_SECONDS } from "../scripts/test-shards"; +import singleFileRuns from "./fixtures/determinism-single-file-runs.json"; const ROOT = join(import.meta.dir, ".."); // The wrapper, its preload and what they import, as tests/experiment-tier.test.ts copies them. @@ -27,6 +29,31 @@ async function gone(pid: number, withinMs: number): Promise { return !alive(pid); } +describe("oversized single-file hosted coverage (#4156)", () => { + test("every reviewed file above the two-pass capacity has a hosted measurement inside the step limit", () => { + const oversized = Object.entries(FILE_COST_SECONDS) + .filter(([, weight]) => weight * FLOOR_REPETITIONS > DETERMINISM_PARTITIONS.capacitySeconds) + .map(([file]) => file).sort(); + expect(oversized.filter(file => !Object.hasOwn(singleFileRuns, file)), "NEW_OVERSIZED_FILES_NEED_HOSTED_MEASUREMENT_OR_A_RECORDED_REMEDY") + .toEqual([]); + const records = singleFileRuns as Record; + for (const [file, measured] of Object.entries(records)) { + expect(measured.run, file).toBeGreaterThan(0); + expect(measured.job, file).toBeGreaterThan(0); + expect(measured.outcome, file).toBe("passed"); + expect([measured.repetitions, measured.observed], file).toEqual([FLOOR_REPETITIONS, FLOOR_REPETITIONS]); + expect(measured.deadlineFactor, file).toBe(DETERMINISM_PARTITIONS.deadlineFactor); + expect([measured.burners, measured.cpus], file).toEqual([4, 4]); + expect(measured.estimatedSeconds, file).toBeGreaterThan(0); + expect(measured.elapsedSeconds, file).toBeGreaterThan(0); + expect(measured.elapsedSeconds, file).toBeLessThan(DETERMINISM_PARTITIONS.stepMinutes * 60); + expect(measured.proofStepSeconds, file).toBeGreaterThanOrEqual(measured.elapsedSeconds); + expect(measured.proofStepSeconds, file).toBeLessThan(DETERMINISM_PARTITIONS.stepMinutes * 60); + } + }); +}); + describe("repetition budget", () => { const costs = { "tests/argo.test.ts": 20, "tests/ithaca.test.ts": 30 }; @@ -383,6 +410,31 @@ async function determinismUnder(env: Record, dir: st } describe("the command, through the real offline wrapper", () => { + test("an oversized file is named in the job summary before its first repetition starts", async () => { + const f = checkout({ "tests/cyclops.test.ts": 160 }); + f.write("tests/cyclops.test.ts", `import { expect, test } from "bun:test"; +import { existsSync, readFileSync } from "node:fs"; +test("the crew sees the oversized passage before setting sail", () => { + const path = process.env.GITHUB_STEP_SUMMARY!; + const summary = existsSync(path) ? readFileSync(path, "utf8") : ""; + expect(summary).toContain("Single file exceeds partition capacity"); + expect(summary).toContain("tests/cyclops.test.ts"); + expect(summary).toContain("320.0 weighted s"); + expect(summary).toContain("300 s capacity"); + expect(summary).toContain("${DETERMINISM_PARTITIONS.stepMinutes}-minute proof step"); +}); +`); + f.commit("an oversized passage"); + const run = await determinism(f.dir, "--base", f.base); + expect(run.code, run.output).toBe(0); + expect(run.report.files).toEqual([{ file: "tests/cyclops.test.ts", weightSeconds: 160, weighted: true, repetitions: 2, observed: 2 }]); + expect(run.summary).toContain("cannot be split across partitions"); + // A normal file produces only the ordinary completion summary. + const normal = await determinism(f.dir, "tests/harbour.test.ts"); + expect(normal.code, normal.output).toBe(0); + expect(normal.summary).not.toContain("Single file exceeds partition capacity"); + }); + test.each(Object.keys(REPORTERS) as (keyof typeof REPORTERS)[])("under the %s reporter the racy fixture's failure still names its file and repetition", async reporter => { const f = checkout(); f.write("tests/landing.test.ts", RACY); f.commit("a race against the tide"); const run = await determinismUnder(reporterEnv(f.dir, reporter), f.dir, "--base", f.base);