-
-
probe: which factors this machine allows, and why the others are NOT TRIED.
-
Locale trial: locale GUILTY, 0/30 vs 30/30, with the decimal comma quoted from the failing output.
-
The JSON record of the first failing runs.
-
Port trial: parallel copies GUILTY, 0/15 vs 15/15, a note that the combined arm cancels it, and what repeating it needs.
-
Seed trial: seed GUILTY, 0/30 baseline failures vs 10/30 with new seeds (p 0.0008), and the command that repeats run 1.
The story
Say it is Friday afternoon and Priya's merge goes red. One test failed, and on the rerun it passes. The usual fix is to rerun until green, or add a sleep. Next week the test fails again, and nobody knows why. Flake Court puts the test on trial: it changes one condition at a time, counts the failures, and convicts only what the numbers prove. In the demo, a Python test fails 10 of 30 runs with a new seed and none with a fixed one, so an exact test convicts the seed, and the report gives one command that repeats the failure by hand. A price script fails every run in German and Turkish locales, and a test on a fixed port fails only beside other copies. A factor it cannot try is reported as NOT TRIED, never as innocent. Flake Court runs on Linux only and judges one test command per trial; it does not yet find the flaky test in a suite. Next Friday, Priya gets a verdict with its evidence, not a guess.
Check it in two minutes
On Linux with Rust and Python 3: cargo build --release, then ./target/release/flake-court trial -- bash samples/shell/locale_decimal.sh. In about 7 to 15 seconds on a two-core machine it prints a verdict table: locale GUILTY (0 of 30 failures without it, 30 of 30 with it), every other factor NOT GUILTY, and the line of output that proves it (expected '1999.00 EUR', got '1999,00 EUR'). bash submission/demo.sh runs everything shown in the video.
Inspiration
Every developer has a test that "sometimes fails". The usual response is to rerun it until it passes, or to guess at a cause and add a sleep. A flaky test is a question with an answer: some condition changes between the passing and the failing runs. We wanted a tool that finds that condition the way an experiment would, by changing one thing at a time and counting, instead of by guessing.
What it does
Flake Court takes any command that runs one test (any language: it only needs the exit status) and reruns it in arms of 30 runs each:
- a baseline with everything held fixed (
TZ=UTC,LC_ALL=C, a fixed seed, a fresh temporary directory, no extra load); - one arm per factor, which differs from the baseline in that factor only: random seed, execution order, time zone, locale, a fake wall clock at calendar edges, CPU pressure, parallel copies, a shared temporary directory, and no network;
- one arm with every factor at once.
The arms are interleaved run by run, so a change in machine load hits all of them alike. Each factor arm is compared with the baseline by a two-sided Fisher exact test, at a significance level divided by the number of comparisons (Bonferroni). The verdicts are GUILTY, FAILS LESS WITH IT, NOT GUILTY (with the failure count that would have convicted), NOT ENOUGH RUNS TO TELL (with an estimate of the runs that would settle it), and NOT TRIED (with the reason). A test that never passes stops the trial early, and its factors are NOT JUDGED. Under each guilty factor the report names the values that failed (seeds, time zones, locales, fake times) and quotes the failing output. It also prints the first failing run as one copy-ready shell command, its environment and command line, so the developer can repeat the failure once by hand outside Flake Court; for a factor that is not an environment variable (CPU pressure, parallel copies, a shared temporary directory, no network) it says in one line what that run needs instead. --json records every run with its exact settings, and --trial-seed repeats a trial exactly.
Everything is unprivileged: the network is cut by entering an unprivileged user and network namespace, locales that are not installed are compiled with localedef into a cache, and the fake clock uses libfaketime only if it is found. flake-court probe shows what the machine allows, and a factor that is not available is reported as NOT TRIED, never as innocent.
The repository ships eight sample tests in shell, Python 3 and Rust, each flaky for one known reason, and the test suite checks that a trial convicts the planted factor and acquits the others.
How we built it
Flake Court is a Rust command-line tool with one dependency, the libc crate. Each run starts in its own process group and is killed as a group at the end or on timeout, so nothing a test leaves running reaches the next run. A process that leaves the group with setsid is caught too: Flake Court is the child subreaper of everything it starts, and kills the orphans that carry the run's mark. For the network factor the child calls unshare(CLONE_NEWUSER | CLONE_NEWNET) between fork and exec, maps its own user to itself and brings up loopback, so the test keeps its user id and sees only lo. The statistics (Fisher exact test, binomial tails, Clopper-Pearson intervals) are written out in about 150 lines and tested against textbook and hand-computed values. The video is a terminal recording of submission/demo.sh, rendered to video with captions; no output in it was typed by hand.
Challenges we ran into
- Being honest with small counts: 10 failures in 30 runs against 0 in 30 is strong evidence, 3 against 0 is not, and the report has to say which, so every verdict comes from an exact test and a stated threshold.
- Separating factors that overlap: four parallel copies on a two-core machine are also CPU pressure, and a network namespace gives each copy its own ports, so the combined arm can hide a guilty factor; the report says so when it happens.
- Testing a timing-sensitive sample without a flaky test suite: the deadline sample runs in its own test binary, and its budget scales with its own CPU time.
Accomplishments that we're proud of
- Every sample is convicted for the right reason and the other factors are acquitted, in the test suite and in the video.
- Nothing needs root, and nothing is assumed: each factor is probed before it is used.
- When the runs cannot decide, the tool says "not enough runs to tell" and estimates how many would.
What we learned
- Interleaving arms matters: running all baseline runs first and all factor runs later confounds the factor with whatever else changed on the machine.
- Unprivileged namespaces,
LOCPATHandLD_PRELOADreach a surprising amount of a test's environment without containers.
What's next
- Run each test of a suite as its own trial, to find the flaky one first.
- Pairwise factor arms when only the combined arm convicts.
- Read seeds and order from common runners (pytest, cargo nextest, Jest) without placeholders.
Limits
Linux only. The clock factor needs libfaketime, which was not installed on the build machine; it was tested end to end with a minimal fake-clock library compiled from tests/fixtures/fake_clock.c, not with real libfaketime. The network factor needs unprivileged user namespaces, which some distributions restrict.
How it was made
Flake Court was built by AI coding agents directed by the author; all of it was created on or after 2026-12-01, inside the event's build window, and it contains no pre-existing code. The agents wrote the specification, the code, the tests, the samples, the README, this text and the demo video from a terminal capture.
Third-party components
The one dependency is the libc crate (MIT or Apache-2.0), for the system calls behind process groups, namespaces and the child subreaper.