Skip to content

ci: repeat a PR's changed Bun test files under CPU load before merge #4109

Closed

Description

@schlessera

Context

Main went red 25 times between 2026-11-02 and 2026-11-16. Reading the PRs that cleared each incident, about 18 changed only a test: a wait, a pinned clock, a readiness signal, a deadline a loaded shard can meet (#3366, #3460, #3546, #3585, #3736, #3760, #3778, #3802, #3820, #3846, #3954, #3999, #4082, #4099). Around six were product defects. The first-main failure rate is about the same for PRs under 100 lines (19%) as for PRs over 2,000 lines (22%), which points at tests that pass once and fail later on someone else's merge.

Nothing runs a new or changed test more than once before it merges. Maintainer decision, 2026-11-16: gate changed tests on repeated runs under CPU load.

Scope

  • A command, bun scripts/test-determinism.ts --base <ref>, with --json:
    • selects the Bun test files the change adds or modifies against its merge base;
    • runs each selected file several times through the existing offline test wrapper (Bun's --rerun-each, verified against the pinned Bun), while busy loops occupy the CPUs;
    • fails on the first failing repetition and names the file, the repetition and the failing case.
  • Bounded. A default of five repetitions and a fixed time budget. When the reviewed weights say five do not fit, repetitions drop uniformly to a floor of two. A selected file is never skipped silently: the report lists each file with the repetitions it actually got.
  • A hosted job, determinism, selected by the planner whenever the change adds or modifies a Bun test file. It runs at every pull-request cadence, so the fast lane's newest run includes it, and in draft heavy feedback. draft gates and proof require it when selected. It is a fast category in the hybrid split.
  • No local burn by default. check:pr does not run it; it names the command in --plan. The host is shared.
  • Docs. Record the ruling in docs/decisions/ci-utility.md (it amends "drafts run cheap gates only" for this one job), and describe the gate in docs/process/test-authoring.md and docs/process/testing.md.

Out of scope

  • Browser, layout and story specs run by Vitest in the pinned container. File the follow-up for repeating those; do not label it agent-ready until it has acceptance criteria.
  • Repeating unchanged tests, or any retry that turns a failure green.
  • Changing any test deadline.

Acceptance criteria

  • A fixture test that fails one run in a few (a race on a real-time wait) fails the command, with the file and repetition named. The same fixture made deterministic passes. Both receipts are in the PR.
  • Removing the repetition (one run only) lets the racy fixture pass often enough that the named test fails: the mutation receipt.
  • A change that touches no Bun test file does not select the job, and the aggregates do not require it.
  • A selection that cannot fit the budget at five repetitions reports the reduced count per file and still runs every file at least twice.
  • The job passes on the PR that adds it, which changes test files.
  • The repetitions run with the offline preload active. A fixture that attempts a non-loopback connection fails.

Verification

  • bun run check:pr --base origin/main.
  • The PR's own determinism job, linked.

Contract impact

None. CI tooling only.

Activity

  1. added this to the 0.45.0 milestone on Nov 16, 2026
  2. added
    type: chore
    area: ci
    priority: p1
    agent-ready
    on Nov 16, 2026
  3. self-assigned this
    on Nov 16, 2026
  4. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-080d4d1e. Branch: chore/4109-test-determinism-gate.

    none; shared CI files (ci.yml, ci-plan.ts, check-ci-workflows.ts, ci-utility.md) are edited narrowly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: cipriority: p1type: chore

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions