A gate is a script CI runs after the evals. Its exit code decides the build: 0 lets it through, 1 blocks it. A good gate blocks real regressions and hard failures, and does not block on noise, or the team learns to ignore it.
Each results file has every case with one True or False per repeated run, and a hard flag on hard-gate cases. The rules:
- If the two files do not have the same case ids, exit 2: the results cannot be compared.
- If any hard-gate case fails in any current run, exit 1.
- Work out the pass rate of each run. The noise band is twice the spread of the baseline's runs (highest minus lowest), and never less than 0.02. If the current mean is lower than the baseline mean by more than the band, exit 1.
- Otherwise exit 0.
Your task
Write gate.py. Run shows its exit code on a clean result and a regressed one. On submit it also faces a noisy result, a failed hard-gate case, a tight baseline and a broken results file.