"It's flaky" cannot be checked#
With 3 failures in 200 runs, the observed rate is 1.5%. The range that fits that result is wide: the 95% Wilson interval is 0.5% to 4.3%. One failure in 20 runs is an observed 5%, and its interval is 0.9% to 23.6%. NIST describes the Wilson method for proportions.
from math import sqrt
def wilson(k, n, z=1.96):
p = k / n
d = 1 + z*z/n
c = p + z*z/(2*n)
h = z * sqrt(p*(1-p)/n + z*z/(4*n*n))
return (c - h)/d, (c + h)/d
print(wilson(3, 200)) # 0.0051, 0.0432
print(wilson(1, 20)) # 0.0089, 0.2361
How many clean runs show a fix#
If a test still fails at rate p, the chance that n runs all pass is (1 - p) to the power of n.
| Old rate | Clean runs | Chance of that result if nothing changed |
|---|---|---|
| 5% | 20 | 36% |
| 1.5% | 20 | 74% |
| 1.5% | 199 | 5% |
So 20 clean runs after a "fix" for a 1.5% failure are what you would expect to see three times out of four without one. To get that chance to 5%, run about 3 / p times: 200 here. The shortcut is called the rule of three, and it also reads the other way. After 200 clean runs, rates above about 1.5% are unlikely.
Use the low end of the interval if the cost of being wrong is high. At 0.5%, the same standard needs about 600 runs.
The runs must be comparable#
The arithmetic assumes that each run has the same chance to fail, independently. Check that before you pool counts:
- Same commit, or commits that do not touch the path.
- Same machine type, worker count and shard. A rate measured on an idle laptop does not transfer to CI under load.
- Not all failures in one hour. Three failures in a row and then 197 passes point to an event, such as an outage, and the overall rate hides it.
- Retries off, or every attempt counted as a run.
Write the failures' times. They are the cheapest way for the receiver to see a cluster.
Write the handoff#
checkout.spec › total updates, commit4c1e9aa, CI large runner, 4 workers, retries off: 3 failures in 200 runs, at 08:14, 11:40 and 15:02 UTC on 2026-11-24. The same error each time: total is 0 when the assertion runs. A fix needs 200 clean runs under the same conditions. I have not looked at whether users can see the zero.
The last sentence is the decision the number supports. A 1.5% test failure can be a test that reads too early. It can equally be a page that shows a wrong total for a moment, and then the rate among users is the question.
Worked example#
This example is fictional. Ana's fix passes 20 of 20 and is merged. The test fails two days later, and the thread calls it a regression. Ben reads the original count: 3 of 200. Twenty passes had a 74% chance with no fix at all. He runs the old and the new commit 200 times each on the same runner type and gets 4 and 3 failures. The fix did nothing that this can show, so the search goes back to the cause.
If failures follow the order of tests, use the seed instead of a rate. Return to handing over evidence.