Skip to content

ci: test watchdogs are a worst-case catch-all: scale them under the determinism gate and stop treating them as proof #4191

Closed

Description

@schlessera

Context

Decision (maintainer, 2026-11-17): a watchdog is a catch-all for the worst case, not friction and flakiness in the average case. Two things follow:

  1. The determinism gate, which applies CPU load on purpose, scales test deadlines by a fixed factor.
  2. A deadline that only detects a hang may be raised freely. Only a deadline that asserts a product timing counts as proof.

What prompted it. tests/integration-command.test.ts has a 27-second work deadline per test: Bun's 30-second per-test cap (package.json:15, --timeout 30000) minus three seconds reserved to stop child processes and join their output (tests/integration-command.test.ts:18-27). It exists to catch a hung child. Under the determinism gate one test took 26.9 s and then 27.2 s and failed (run 44104941268). Nothing was wrong except that the watchdog sat a few seconds above the work.

Why such deadlines stay tight today:

  • One 30-second cap covers every Bun test, from a one-millisecond unit test to a test that starts twelve processes.
  • The gate runs one CPU burner per CPU. Measured hosted slowdown for Bun tests under it: 3.6 to 6.8 times (ci: a determinism selection too heavy for two repetitions can exceed the job's step limit #4117). A test that normally uses more than about a fifth of its deadline cannot pass.
  • A changed timeout is a proof-system change. The classifier flags any changed, added or removed timeout or deadline value in existing test lines (timeoutSignals, scripts/proof-system.ts:65; docs/decisions/ci-utility.md, "Proof-system lane"), which sends the change through the serialized lane with off-main qualification. Squeezing work under the existing number is cheaper than moving the number.
  • 372 test files carry an explicit timeout or deadline.

Scope

  • Scale under known load. One owner holds the gate's deadline factor, derived from the measured slowdown with margin. Under the determinism job:
    • Bun's per-test cap for the invocation is multiplied by it;
    • a small helper returns a watchdog duration multiplied by it, and in-test watchdogs that would otherwise overrun read the helper, starting with the 27-second one;
    • explicit per-test timeouts are scaled too if Bun allows it for an invocation without editing each test; if it does not, say so and name what stays unscaled.
      The job's own step limit still bounds the whole job.
  • The same for the browser repetition job (ci: repeat a PR's changed Vitest specs under load in the pinned container before merge #4163), once it is on main: Vitest's test and hook timeouts scale by that job's factor inside the repetition run.
  • Policy. Write the distinction down and make the tooling follow it:
    • A watchdog stops a hang and cleans up. It may be raised without the proof-system lane or off-main qualification. It should sit well above the test's normal duration, so that only a real hang trips it.
    • A product timing is a time the product promises (a 0.6 s hold, a one-second guard, a five-second readiness limit). It remains proof, and it is asserted on measured or controlled time, not through a test timeout.
    • The proof-system timeout check stops flagging a raised test timeout or watchdog. A lowered or removed one stays flagged.
  • Docs. AGENTS.md (testing expectations), docs/process/testing.md, docs/process/test-authoring.md (how to size a watchdog; what to do when one trips), and a decision-record section in docs/decisions/ci-utility.md that states what this supersedes: the practice of treating every deadline as proof that must not move.

Out of scope

  • Raising the 372 existing timeouts in bulk. They are raised when they trip, or when their file is next changed.
  • Product timings and the tests that assert them.
  • The number of CPU burners.

Acceptance criteria

  • A fixture test that takes about half its watchdog unloaded passes under the determinism command at the gate's load, and fails without the scaling. Both receipts are in the PR.
  • A fixture test that truly hangs still fails under the determinism command, within the scaled watchdog, with its children cleaned up.
  • bun scripts/proof-system.ts classify reports a diff that only raises a test timeout or watchdog as not a proof-system change, and one that lowers or removes one as a proof-system change. Tests for both, and a mutation that removes the distinction fails them.
  • The 27-second deadline in tests/integration-command.test.ts reads the helper, and the file passes the hosted determinism job on the PR.
  • The decision record states the factor, the hosted runs it rests on and what stays unscaled.
  • The docs say how to size a watchdog and that a tripped watchdog on a slow run is raised or scaled, not treated as a failed proof.

Verification

  • bun run check:pr --base origin/main, with failing-first and mutation receipts.
  • The PR's own hosted determinism job.

Contract impact

None. CI tooling, test helpers and process documents only.

Activity

  1. added this to the 0.45.0 milestone on Nov 17, 2026
  2. added
    type: choreTooling, CI, release plumbing, dependencies.
    area: ciCI workflows, the gates they run, release scripts, packaging.
    priority: p1Scheduled into the current or next milestone.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 17, 2026
  3. self-assigned this
    on Nov 17, 2026
  4. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-a4309e6e. Branch: chore/4191-watchdog-catch-all.

    Path overlap with open drafts #4175 (ci.yml, ci-proof.ts, determinism-plan.ts, proof-shards.ts, the CI decision record, the testing process docs, tests/integration-command.test.ts), #4173 and #4179 (the CI decision record, tests/integration-command.test.ts). The browser repetition job of #4175 is not on main, so its scaling is left to a follow-up.

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ciCI workflows, the gates they run, release scripts, packaging.priority: p1Scheduled into the current or next milestone.type: choreTooling, CI, release plumbing, dependencies.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions