Skip to content

Commit 3e6ac46

Browse files
Sravan1011claude
andcommitted
fix: explicit unarmed marker for the placeholder latency baseline
The previous fail-on-zero behavior made every trusted run red until a CI-captured baseline was committed — and this PR cannot ship one, since it runs from a fork without secrets. Per review, the comparison is now gated on the baseline file itself: - baseline.json declares latency_guard: unarmed — the latency test skips with a loud arming message while the recall guard stays active (dropping --baseline-file entirely would have disabled recall too) - committing a CI-captured benchmark-results-<sha> artifact as baseline.json arms the guard automatically: artifacts carry no latency_guard flag - a zero p95 WITHOUT the unarmed marker still fails as a misconfigured baseline, and a non-zero p95 WITH the marker fails as inconsistent, so the guard can never be silently inactive by accident Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 85618ba commit 3e6ac46

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

benchmarks/ci/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,16 @@ The harness compares the current run's metrics against `baseline.json`:
6969
- **Latency**: Fails if P95 increases by more than the threshold (default 20%)
7070
- **Recall**: Fails if Recall@5 drops by more than the threshold (default 5pp)
7171

72-
A zero latency baseline **fails** comparison runs rather than skipping — the
73-
guard cannot stay silently inactive. To arm it, commit a CI-captured
74-
baseline (see "Updating the baseline" below).
72+
The latency guard arms itself from the baseline file:
73+
74+
- The checked-in placeholder declares `"latency_guard": "unarmed"` — the
75+
latency test skips with a loud message while recall remains guarded, so
76+
trusted runs are not red before the first baseline exists.
77+
- To arm the guard, download the `benchmark-results-<sha>` artifact from a
78+
trusted CI run and commit it as `baseline.json`. Artifacts carry no
79+
`latency_guard` flag, so committing one arms the guard automatically.
80+
- A zero p95 **without** the unarmed flag fails the run as a misconfigured
81+
baseline — the guard can never be silently inactive by accident.
7582

7683
Thresholds are configurable via CLI flags:
7784

benchmarks/ci/baseline.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"commit": "f4732a1",
33
"timestamp": "2026-07-20T05:35:00+00:00",
4-
"_note": "Recall values are measured (hardware-independent) so the recall guard is active. Latency values are intentionally zero and the latency guard FAILS on zero baselines in comparison runs \u2014 the first trusted CI run will be red until a CI-captured baseline is committed: run the Benchmark workflow (update_baseline=true also works), download the benchmark-results-<sha> artifact, and commit it here. Latency baselines must come from CI runners; numbers from other hardware are not comparable.",
4+
"latency_guard": "unarmed",
5+
"_note": "Recall values are measured (hardware-independent) so the recall guard is active. Latency values are zero and 'latency_guard: unarmed' marks this file as the explicit placeholder: the latency regression test skips (loudly) instead of failing every trusted run. To arm the latency guard, run the Benchmark workflow on a trusted ref, download the benchmark-results-<sha> artifact, and commit it as this file \u2014 artifacts carry no latency_guard flag, so committing one arms the guard automatically. A zero p95 WITHOUT the unarmed flag fails the run as a misconfigured baseline. Latency baselines must come from CI runners; numbers from other hardware are not comparable.",
56
"latency_ms": {
67
"p50": 0,
78
"p95": 0,

benchmarks/ci/test_bench_ci_moss.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,32 @@ def test_no_latency_regression(self, request, benchmark_results):
420420

421421
_assert_baseline_compatible(baseline, benchmark_results)
422422

423+
if baseline.get("latency_guard") == "unarmed":
424+
# The checked-in placeholder declares itself unarmed: latency
425+
# baselines must come from CI runners, and none has been captured
426+
# yet. Skip loudly (recall is still guarded) instead of failing
427+
# every trusted run until the first artifact lands.
428+
if baseline_p95 != 0:
429+
pytest.fail(
430+
"baseline.json marks latency_guard as 'unarmed' but contains "
431+
"a non-zero p95 — remove the latency_guard flag to arm the "
432+
"guard."
433+
)
434+
pytest.skip(
435+
"LATENCY GUARD NOT ARMED — baseline.json is the explicit "
436+
"placeholder (latency_guard: unarmed). To arm it: download the "
437+
"benchmark-results-<sha> artifact from a trusted CI run and "
438+
"commit it as benchmarks/ci/baseline.json (the artifact carries "
439+
"no latency_guard flag, so committing it arms the guard)."
440+
)
441+
423442
if baseline_p95 == 0:
424-
# A zero baseline means the latency guard has never been armed.
425-
# Skipping here would let every run pass with the guard silently
426-
# inactive — fail instead, with the arming procedure.
443+
# Zero without the explicit unarmed marker is a misconfigured
444+
# baseline, not a placeholder — never a silent pass.
427445
pytest.fail(
428-
"Baseline p95 is zero — the latency guard is not armed. Run the "
429-
"Benchmark workflow with update_baseline=true, download the "
430-
"benchmark-results-<sha> artifact, and commit it as "
431-
"benchmarks/ci/baseline.json (values must come from CI runners; "
432-
"this run's artifact works too)."
446+
"Baseline p95 is zero but baseline.json does not declare "
447+
"latency_guard: unarmed — the baseline is misconfigured. Commit "
448+
"a CI-captured baseline or restore the explicit placeholder."
433449
)
434450

435451
regression = (current_p95 - baseline_p95) / baseline_p95

0 commit comments

Comments
 (0)