# Flaky Test Determinism

**Treat an intermittent test as a defect.** Produce either a fix that names
the cause, or a quarantine entry carrying an owner and an expiry date.
Produce nothing else — an intermittent test that stays in the suite
untracked teaches the team to ignore red. A reviewer checks that every
known intermittent test has one of those two artifacts.

**Measure the failure rate before you argue about it.** Produce a repeat
run of the suspect test in isolation and again inside the full suite.
Default: 50 repetitions, and record the observed pass rate [ASSUMPTION].
A reviewer checks that the recorded rate is in the report, because "it
happens sometimes" cannot be verified or closed.

**Name the cause.** Produce the named mechanism from this list: state
shared between tests, order dependence, the real clock or a timezone,
unseeded randomness, async work nobody awaited, network or DNS access, a
port or temporary-path collision, or a fixed sleep standing in for a
condition. A reviewer checks that the fix names one mechanism and shows
where it entered.

**Remove the nondeterminism instead of widening the tolerance.** Produce an
injected clock, a seeded generator, a unique temporary directory and port
per test, and a wait that polls the condition until a deadline. Default
deadline: 5 seconds, polled every 50 ms [ASSUMPTION]. A reviewer checks
that no fixed-length sleep remains in the changed test and that no
assertion was loosened to absorb the variance.

**Never wrap a test in retry-until-green.** Do not add a retry annotation,
a rerun-failures flag, a loop that repeats a test until it passes, or a CI
step that re-runs the suite after a failure. A reviewer checks the test
runner configuration and the CI configuration for retry and rerun
settings, and rejects the change that introduces one.

**Bound every quarantine.** Produce an entry in one tracked file with the
test identifier, the measured failure rate, the named owner, the
quarantine date and the expiry date. Default expiry: 14 days after
quarantine [ASSUMPTION A-8]. A reviewer checks that no entry lacks an
owner and that no entry has passed its expiry.

**Keep a quarantined test running where someone sees it.** Produce a
scheduled run of the quarantined tests that reports its results, outside
the merge gate. A reviewer checks that quarantine removed the test from
the gate and not from execution.

**Close at expiry, or escalate.** Produce, on the expiry date, either the
fix or a deletion with the reason and what the deletion stops covering. A
reviewer checks that expiry produced one of those two, and escalates any
test entering quarantine a second time instead of renewing it.

**Stop the bleed at the source.** Produce a shared fixture fix when two
tests fail intermittently for one mechanism. A reviewer checks that the
suite passes under a randomised test order and with each test run alone.
