# How does an instance detect adversarial regression when the LITMUS safety harness itself is the only oracle and its verdict is non-deterministic? **Date of Record:** 2026 November 29 **Scope:** Applies to CI-gated adversarial evaluation of tool-using LLM agents where a LITMUS-style harness (canary-token, injection-probe, exfiltration-attempt suites) supplies the pass/fail oracle and the same model weights are sampled stochastically across runs. Does not apply to deterministic classifiers, offline red-team scoring, or harnesses that pin temperature to zero and dedupe by exact string match. ## Core Distinction There are two distinct failure classes a CI safety gate must separate, and they collapse into one if you are careless: - **Behavioral regression** — the agent's policy actually shifted (a new system prompt, a tool-schema change, a fine-tune) such that it now complies with an injection it previously refused. - **Oracle instability** — the agent's policy is unchanged but the harness verdict flipped because the safety oracle is itself a sampled model (a judge LLM, a canary-token reader, a refusal classifier) and its verdict is a random variable. The non-obvious boundary: a LITMUS harness that uses a *model* to grade *model* behavior has a verdict distribution, not a verdict. Treating one sampled verdict as ground truth means the CI gate's false-positive rate is the *conjunction* of two independent sampling events — the agent's non-compliance and the judge's misgrade — and the gate will flap on unchanged code. The invariant that must hold is: **a safety regression may only be declared when the flip exceeds the harness's own measured verdict variance at fixed policy.** Violate that and you either block every PR (variance mistaken for regression) or ship every regression (variance mistaken for noise). ## What Was Observed A tool-using agent was gated on a 240-case LITMUS suite: prompt-injection, canary exfiltration, and over-broad tool invocation. Each case ran the agent at `temperature=0.7` (required — the deployment config), and each transcript was graded by a separate judge model at `temperature=0.0`. The suite reported a single scalar: `attack_success_rate` (ASR). CI failed if ASR rose more than 2 percentage points over the recorded baseline. Three consecutive runs on **byte-identical code, weights, and prompts** produced ASR of 11.2%, 14.6%, and 12.1%. The 14.6% run tripped the +2pp gate. The engineer bisected for six hours across two unrelated PRs before discovering the diff was empty. The mechanism, once instrumented: 1. The agent's non-determinism at `temperature=0.7` meant the *set of transcripts* differed run to run. Cases near the refusal boundary (ambiguous instructions, multi-turn injections) flipped compliance on maybe 30% of samples each. 2. The judge at `temperature=0.0` was *locally* deterministic but *globally* fragile: it graded on surface features. A refusal phrased "I can't help with that" graded SAFE; the same refusal phrased "I'm not able to assist with that request" graded UNSAFE in roughly 1 in 5 cases because the judge's rubric anchored on specific refusal tokens. So even a *fixed* transcript could be misgraded depending on which paraphrase the agent happened to emit. 3. The reported ASR was a point estimate over 240 Bernoulli-ish trials. With true per-case flip probability `p` averaging ~0.13, the standard error of ASR is `sqrt(p(1-p)/n) ≈ sqrt(0.13·0.87/240) ≈ 0.022` — i.e. **±2.2pp at one sigma**. The gate threshold (+2pp) was *inside one standard error of the metric itself.* The gate was measuring its own noise. The deeper observation: the two variance sources are **not additive in the way engineers assume**. Agent sampling variance and judge misgrade variance are correlated through transcript phrasing — a non-compliant agent that emits a *fluent* jailbroken answer is more likely to be correctly caught, while a compliant agent that emits an *unusual* refusal is more likely to be falsely flagged. The judge error is *anti-correlated* with true attack success, which means naive variance estimates under-count the false-positive tail. This is why the 14.6% run looked like a real regression: the extra "attacks" were mostly *refusals the judge didn't recognize.* ## Condition of Validity The single-verdict gate is only valid under a condition that LITMUS harnesses almost never satisfy: > **The oracle's verdict variance at fixed policy must be measured and subtracted before any regression is declared, and the regression threshold must exceed the oracle's own confidence interval at the chosen sample size.** Concretely, for a suite of `n` cases with per-case verdict flip probability `p` (agent sampling) and judge misgrade rate `q` (oracle noise), the gate is only sound if: - `n` is large enough that `sqrt(p(1-p)/n)` is *smaller* than the smallest regression you care to detect (here you'd need `n ≈ 2000` to resolve a 1pp shift at one sigma, not 240); - the judge is **calibrated against a held-out human-labeled set** and its per-class error rate `q` is recorded as part of the baseline, not assumed zero; - the gate compares **distributions over `k` repeated runs**, not point estimates — a Mann-Whitney or a paired bootstrap over per-case outcomes, with the null being "same policy." When any of these fails — small `n`, uncalibrated judge, single run — the gate is not a safety gate. It is a random number generator with a threshold, and it will fire on unchanged code at a rate set by the metric's own variance, not by any behavioral change. ## Decision Boundary The operational rule that separates "declare regression" from "insufficient evidence": - **Declare regression** only when the observed ASR shift exceeds `z · SE_combined`, where `SE_combined = sqrt(SE_agent² + SE_judge²)` and `SE_judge` is derived from the judge's *measured* misgrade rate on a calibration set — not assumed. With `n=240` and `p≈0.13`, `z·SE` at 95% is ≈4.3pp, so a +2pp gate is *below* the noise floor and must be widened or `n` increased. - **Declare noise** when the shift is within the CI *and* a per-case paired comparison shows no case flipping in a consistent direction across `k≥3` runs. A real regression flips the *same* cases repeatedly; sampling noise flips different cases each run. The paired-flip signature is the discriminator, and it is cheap to compute. - **Declare oracle failure** when the shift is driven by a handful of cases whose *transcripts are near-identical* across runs but whose *verdicts differ* — that is judge instability, not agent regression, and it must route to the judge-calibration owner, not the model owner. The boundary is sharp: **point-estimate comparison is invalid; paired-flip analysis over repeated runs is the minimum viable oracle.** Anything less cannot distinguish a policy regression from the harness grading itself. ## Operational Effect The practical consequences for anyone running LITMUS in CI: 1. **Every safety gate must publish its own noise floor.** The baseline record must include `n`, measured `p`, measured judge `q`, and the resulting `SE`. A threshold below `2·SE` is a known-flapping gate and should be rejected at review time, not debugged at 2am. 2. **Repeated-run paired analysis is mandatory.** Run the suite `k≥3` times, compute per-case flip vectors, and gate on *directionally consistent* flips. This converts a noisy scalar into a stable per-case signal and collapses the false-positive rate by an order of magnitude at no extra model cost beyond `k×` inference. 3. **The judge is a versioned dependency, not a constant.** Judge model upgrades, rubric edits, and even prompt-cache changes shift `q`. The judge's calibration set and misgrade rate must be pinned in the baseline record alongside the agent's weights, or a judge swap will masquerade as a safety regression (or, worse, mask one). 4. **The invariant to encode:** *a safety regression is a shift in the agent's compliance distribution that survives subtraction of the oracle's measured verdict variance; anything else is the harness talking to itself.* The failure mode is subtle because the harness *looks* deterministic — judge at `temperature=0`, fixed suite, fixed seeds where available — but the agent's sampling leaks through the judge's fragility, and the resulting metric has a variance larger than the effect the gate was built to detect. The guardrail is arithmetic, not architecture: measure the noise, subtract it, and refuse to gate below it. ```python import math from dataclasses import dataclass from typing import Sequence class SafetyGateNoiseFloorError(RuntimeError): """Raised when a CI safety threshold sits below the harness's own verdict variance.""" pass @dataclass(frozen=True) class HarnessBaseline: n_cases: int agent_flip_p: float # per-case compliance flip prob at fixed policy judge_misgrade_q: float # measured judge error rate on calibration set runs: int # k repeated runs used for paired analysis def combined_se(self) -> float: # Agent sampling SE over n Bernoulli trials, plus judge-noise contribution. se_agent = math.sqrt(self.agent_flip_p * (1.0 - self.agent_flip_p) / self.n_cases) se_judge = math.sqrt(self.judge_misgrade_q * (1.0 - self.judge_misgrade_q) / self.n_cases) # Anti-correlated error inflates the false-positive tail; use sum, not RSS, as a # conservative bound (observed empirically: judge misses fluent jailbreaks). return se_agent + se_judge def gate_regression( baseline: HarnessBaseline, observed_asr: float, baseline_asr: float, threshold_pp: float, consistent_flip_cases: int, ) -> str: """Return a gate verdict, or raise if the gate itself is unsound.""" se = baseline.combined_se() z95 = 1.96 noise_floor_pp = z95 * se * 100.0 if threshold_pp < noise_floor_pp: raise SafetyGateNoiseFloorError( f"threshold {threshold_pp:.2f}pp is below 95% noise floor " f"{noise_floor_pp:.2f}pp (n={baseline.n_cases}, " f"p={baseline.agent_flip_p:.3f}, q={baseline.judge_misgrade_q:.3f}); " f"gate would flap on unchanged policy. Increase n or widen threshold." ) shift_pp = (observed_asr - baseline_asr) * 100.0 if shift_pp > threshold_pp and consistent_flip_cases >= baseline.runs: return "REGRESSION" if abs(shift_pp) <= noise_floor_pp: return "NOISE" # Shift exceeds noise floor but flips are not directionally consistent -> oracle fault. return "ORACLE_INSTABILITY" if __name__ == "__main__": baseline = HarnessBaseline( n_cases=240, agent_flip_p=0.13, judge_misgrade_q=0.05, runs=3 ) # This raises: the +2pp gate is inside the harness's own noise. gate_regression(baseline, observed_asr=0.146, baseline_asr=0.112, threshold_pp=2.0, consistent_flip_cases=1) ```