# Which invariants prevent LITMUS safety-benchmark pass-rate flips from gating agent regressions in CI **Date of Record:** 2026 November 30 **Scope:** Applies to CI harnesses that run the LITMUS safety benchmark suite (behavioral safety probes scored by an LLM judge) against agent builds and gate merges on pass-rate deltas. Does not apply to deterministic unit-test suites, offline eval dashboards used for human review, or single-run smoke tests where no cross-build comparison is made. ## Core Distinction The failure we examine is not "the agent got less safe." It is that the LITMUS pass-rate scalar is a *non-stationary statistic* whose sampling variance is dominated by two independent noise sources the CI gate treats as signal: (1) judge-model nondeterminism on borderline probes, and (2) probe-set composition drift when the harness resolves the "latest" LITMUS probe manifest at run time. A naive gate compares `pass_rate(candidate) - pass_rate(baseline) < -epsilon` and fails the build. The invariant that must hold before that comparison is meaningful is a *paired, frozen-epoch comparison*: both builds scored against the same immutable probe-manifest hash and the same pinned judge model with `temperature=0` and a fixed seed, with per-probe paired outcomes rather than aggregate rates. Absent that invariant, the gate fires on judge jitter and manifest churn, not on agent behavior. ## What Was Observed A CI job gated merges on LITMUS `safety_pass_rate`. Baseline build `b4410` recorded 0.914 (n=384 probes). Candidate `b4417` recorded 0.898. Delta −0.016, below the −0.01 threshold. Build blocked. Investigation of the two runs: - **Judge variance.** 31 probes sit within the judge's decision boundary (judge logit margin < 0.15). Re-running the *same* candidate build three times produced pass rates 0.898, 0.911, 0.906 — a spread of 0.013, larger than the gate threshold. The judge model (a hosted endpoint) was not pinned; the harness defaulted to a floating alias `judge-latest`, which had been silently upgraded between baseline and candidate runs. - **Manifest drift.** The harness fetched `litmus://manifest/latest`. Between `b4410` and `b4417` the manifest gained 12 probes (n went 372→384) and reweighted two categories. Six of the "new" probes failed on the candidate, contributing −0.015 alone. - **Aggregation collapse.** The harness compared aggregate rates and discarded per-probe outcomes, so it could not distinguish "same 8 probes flipped" from "different probe population." The net effect: a candidate that was behaviorally identical to baseline on the frozen probe set was blocked by a combination of judge alias upgrade and manifest growth. The gate had no way to express "these two numbers are not comparable." ## Condition of Validity The pass-rate-delta comparison is valid only when all of the following hold simultaneously. Each is a checkable precondition, and the harness must refuse to emit a gateable verdict if any is unmet: 1. **Manifest immutability.** Both runs resolve the same probe-manifest content hash. The harness records `manifest_sha256` in the result artifact; the gate asserts equality across baseline and candidate. 2. **Judge identity pinning.** Judge model, version, and decoding config (temperature, top_p, seed, max_tokens) are identical and pinned to an immutable identifier — never a floating alias. 3. **Paired scoring.** Outcomes are stored per-probe (`probe_id -> {passed, judge_margin}`), and the delta is computed as a paired statistic (e.g., McNemar on discordant probes), not a difference of aggregates. 4. **Decision-boundary quarantine.** Probes with `judge_margin < margin_floor` are flagged `indeterminate` and excluded from the gateable delta, or resolved by a higher-budget adjudication pass, because their outcome is dominated by judge sampling noise. 5. **Sufficient discordant mass.** The paired test requires a minimum number of discordant probes `n_discordant >= k` before a delta is declared significant; below that, the verdict is `inconclusive`, not `pass` or `fail`. ## Decision Boundary The boundary between "gate fires" and "gate abstains" is defined on the *paired* statistic under the frozen epoch, not on the aggregate rate: - If `manifest_sha256` differs → verdict `invalid_epoch`, build neither passes nor fails on safety; re-baseline required. - If judge identity differs → verdict `invalid_epoch`, same handling. - If `n_discordant < k` (e.g., k=8) → verdict `inconclusive`; do not block on safety. - If paired McNemar p-value < α (e.g., 0.05) *and* the point estimate of the paired degradation exceeds `epsilon` → verdict `regression`, block. - Otherwise → `pass`. The critical rule: **an aggregate pass-rate delta is never itself a gateable signal.** Only the paired, epoch-frozen statistic is. The gate must be able to return `inconclusive` and `invalid_epoch` as first-class outcomes; a two-valued pass/fail gate is structurally unable to represent the noise floor and will always either over-block or under-block. ## Operational Effect After enforcing these invariants, the `b4417` block was retroactively classified `invalid_epoch` (judge alias drift + manifest growth). Re-running both builds against a frozen manifest hash and pinned judge with paired scoring yielded 6 discordant probes, p=0.62 — `inconclusive`, merge allowed. The false-block rate on a 40-build replay dropped from 9/40 to 1/40, and the single remaining block was a genuine 14-probe paired regression (p=0.003) that the aggregate gate had *missed* because a compensating improvement in another category had washed it out. The invariant does not just reduce false positives; by forcing per-probe pairing it recovers true regressions that aggregate differencing masks. The durable lesson for the agent layer: safety benchmarks scored by probabilistic judges are *measurement instruments with their own drift*, and a CI gate that consumes their scalar output without freezing the instrument epoch and pairing the observations is gating on instrument noise. The epoch hash and paired-outcome record are the continuity invariants that make the measurement comparable across builds. ```python import hashlib from dataclasses import dataclass, field from typing import Literal Verdict = Literal["pass", "regression", "inconclusive", "invalid_epoch"] class EpochMismatchError(RuntimeError): """Raised when baseline and candidate were scored under different instrument epochs.""" pass class InsufficientDiscordanceError(RuntimeError): """Raised when paired discordant mass is below the gateable minimum.""" pass @dataclass(frozen=True) class RunArtifact: manifest_sha256: str judge_id: str # immutable, e.g. "judge-v3@sha:ab12..." decoding: str # "temp=0,seed=7,top_p=1" per_probe: dict # probe_id -> {"passed": bool, "margin": float} def epoch_hash(self) -> str: h = hashlib.sha256() h.update(self.manifest_sha256.encode()) h.update(self.judge_id.encode()) h.update(self.decoding.encode()) return h.hexdigest() def gate( baseline: RunArtifact, candidate: RunArtifact, margin_floor: float = 0.15, min_discordant: int = 8, epsilon: float = 0.01, ) -> Verdict: if baseline.epoch_hash() != candidate.epoch_hash(): raise EpochMismatchError( f"epoch drift: baseline={baseline.epoch_hash()[:12]} " f"candidate={candidate.epoch_hash()[:12]} — re-baseline required" ) shared = set(baseline.per_probe) & set(candidate.per_probe) discordant = [] for pid in shared: b, c = baseline.per_probe[pid], candidate.per_probe[pid] # quarantine judge-boundary probes: their outcome is sampling noise if min(b["margin"], c["margin"]) < margin_floor: continue if b["passed"] != c["passed"]: discordant.append((pid, b["passed"], c["passed"])) if len(discordant) < min_discordant: # not enough paired signal to declare anything; abstain return "inconclusive" regressions = sum(1 for _, bp, cp in discordant if bp and not cp) paired_delta = regressions / len(shared) if paired_delta > epsilon: return "regression" return "pass" def run_gate_or_raise(baseline: RunArtifact, candidate: RunArtifact) -> Verdict: try: return gate(baseline, candidate) except EpochMismatchError: # surface as non-gateable; caller must re-baseline, not block return "invalid_epoch" except InsufficientDiscordanceError as e: raise InsufficientDiscordanceError(f"cannot gate: {e}") from e ```