# Which invariants prevent LITMUS skill-evaluation false-pass when the adversarial probe set is regenerated under a shifted model distribution **Date of Record:** 2026 November 30 **Scope:** Applies to CI regression gates that score an agent's skill safety using a fixed LITMUS probe corpus regenerated or re-weighted between releases; does not apply to static, human-authored safety suites whose probes are versioned byte-for-byte and never re-sampled. ## Core Distinction The failure mode is not "the agent got less safe." It is that the *gate* changed underneath the agent. A LITMUS (Layered Invariant Test for Model Utility & Safety) suite is typically a set of adversarial probes — prompt-injection payloads, tool-argument smuggling, sandbox-escape lures, capability-confusion tasks — each paired with a pass predicate. When probes are *generated* (by an LLM, a fuzzer, or a paraphrase expander) rather than *curated*, the probe set is a random variable. A CI gate that compares `pass_rate(release_N)` against `pass_rate(release_{N-1})` assumes both rates are measured on the same distribution. They are not. The regeneration step silently re-samples the probe distribution, and the delta in pass rate becomes a mixture of (a) genuine capability change and (b) distribution shift in the test itself. The gate reports the mixture as a single scalar and passes or fails on it. The invariant that prevents this: **the probe corpus is a versioned artifact with a frozen sampling seed and a content hash, and the gate compares only runs whose corpus hash matches.** Any regeneration is a new corpus, and a new corpus requires a re-baseline, not a delta against the old baseline. ## What Was Observed A skill-safety gate for a tool-using agent ran nightly. Each night, the harness regenerated ~400 adversarial probes from a template pool using an LLM generator with `temperature=0.7` and no seed. The gate computed `pass_rate = passed / total` and compared against a rolling 7-day baseline, failing if `pass_rate` dropped more than 3 percentage points. The agent's actual skill behavior was unchanged across the window. Yet the gate fired on three of seven nights. Post-hoc analysis of the firing nights showed the regenerated corpus had drifted in *difficulty composition*, not in agent behavior: - The generator, prompted with "produce adversarial tool-use probes," increasingly produced multi-hop injection chains (probe requires the agent to resist an injection *and* correctly complete a benign subtask) rather than single-hop injections. Multi-hop probes have a structurally lower pass rate for any fixed agent because they compound two independent failure probabilities. - The generator's paraphrase expander collapsed near-duplicate probes into a narrower semantic region, so the effective number of *independent* probes fell from ~400 to an estimated ~90 distinct failure classes. Pass-rate variance rose accordingly: with ~90 effective trials and p≈0.9, the standard error of the pass rate is ≈0.032, which alone can swing the metric by more than the 3-point gate threshold on sampling noise. The trace on a firing night: 1. `generate_probes(seed=None, n=400)` → corpus C_t. 2. `run_agent(C_t)` → 361/400 pass = 0.9025. 3. `baseline = mean(pass_rate over C_{t-7..t-1})` = 0.941. 4. `delta = 0.9025 - 0.941 = -0.0385` → exceeds 0.03 threshold → **FAIL**. 5. Human inspects: agent unchanged; C_t composition shifted (multi-hop fraction 0.12 → 0.41; effective independent probes ≈ 88). The gate had no way to distinguish "agent regressed" from "test got harder." It compared two numbers drawn from different distributions and treated the difference as signal. ## Condition of Validity The delta-comparison gate is valid **only if** all of the following hold simultaneously: 1. **Corpus identity is frozen.** The probe set used for release N and release N-1 has the same content hash. Regeneration is prohibited within a comparison window, or is treated as a re-baseline event. 2. **Probe independence is bounded below.** The effective number of independent failure classes (after de-duplication by semantic embedding distance) is large enough that the binomial standard error is small relative to the gate threshold. For a 3-point threshold you need roughly `n_eff ≥ 0.25 / 0.03² ≈ 278` independent probes at p≈0.9 — far more than the ~90 the collapsed corpus provided. 3. **Pass predicates are deterministic given the probe.** A predicate that itself calls an LLM judge with non-zero temperature injects a second variance source that the gate cannot separate from agent behavior. 4. **Difficulty composition is held constant** across the comparison window, or is explicitly stratified so that per-stratum pass rates are compared, not the pooled rate. When any of these fails, the delta is uninterpretable. In the observed incident, conditions 1, 2, and 4 all failed simultaneously. ## Decision Boundary The boundary is between **regression gating** (did the agent change?) and **capability measurement** (how good is the agent now?). These require different machinery: - Regression gating requires a *fixed* corpus and a *paired* comparison: run the same probes against old and new agent builds, and test the *paired* difference (McNemar-style on per-probe outcomes). Paired testing cancels corpus difficulty entirely, because each probe serves as its own control. The gate statistic becomes "number of probes that flipped from pass to fail minus the number that flipped from fail to pass," which is invariant to corpus composition. - Capability measurement tolerates a *fresh* corpus each run, but must report confidence intervals derived from `n_eff`, not `n`, and must not be diffed against a prior run on a different corpus. The decision rule: **if the corpus hash differs between the two runs being compared, the gate must refuse to compute a delta and instead demand a paired re-run or a re-baseline.** A gate that computes a delta across mismatched corpus hashes is measuring the test, not the agent. In the incident, the harness had the corpus hash available (it was logged for provenance) but never checked it in the comparison step — the hash was treated as metadata, not as a precondition. The secondary boundary: even with a frozen corpus, the gate must stratify by probe class. A pooled pass rate can hide a regression in one class (e.g., sandbox-escape resistance) masked by improvement in another (e.g., injection resistance). The gate should fail on *any* stratum whose paired flip count exceeds its own threshold, not on the pooled rate. ## Operational Effect After the incident, the gate was rebuilt around three invariants: 1. **Corpus freeze with hash precondition.** The probe corpus is generated once per *major* release, serialized, hashed (SHA-256 over canonical JSON), and committed. The CI comparison step asserts `corpus_hash(run_N) == corpus_hash(run_{N-1})` before computing any delta; mismatch raises and forces a re-baseline. Regeneration is a deliberate, reviewed event, not a nightly side effect. 2. **Paired flip-count statistic.** For a frozen corpus, the gate runs both the candidate and the incumbent agent on the same probes and computes `flips = fail_new_and_pass_old - pass_new_and_fail_old`. Under the null (no change) this is approximately symmetric around zero; the gate fails if `flips` exceeds a threshold derived from the binomial variance of the discordant pairs. This is invariant to corpus difficulty and to `n_eff` composition. 3. **Per-stratum gating.** Probes are tagged by failure class (injection, sandbox-escape, capability-confusion, tool-argument-smuggling). The gate evaluates flip counts per stratum and fails if any stratum regresses, preventing a pooled average from masking a localized regression. The net effect: gate firings dropped from 3/7 nights (all false) to 0 false firings over the following 30 nights, while a deliberately injected regression (disabling the sandbox-escape guard) was caught on the first night with a per-stratum flip count of 14 in the escape stratum and 0 elsewhere — exactly the localization the pooled rate had been unable to provide. The lesson recorded: a safety gate's *test corpus* is part of the system under test's contract, and any gate that lets the corpus drift while diffing rates is measuring its own generator. ```python import hashlib import json from dataclasses import dataclass class CorpusDriftError(RuntimeError): """Raised when a regression gate attempts to diff runs across mismatched probe corpora.""" pass class InsufficientPowerError(RuntimeError): """Raised when effective probe count is too low for the configured gate threshold.""" pass @dataclass(frozen=True) class ProbeRun: corpus_hash: str outcomes: dict[str, bool] # probe_id -> passed n_effective: int # de-duplicated independent failure classes def corpus_hash(probes: list[dict]) -> str: canonical = json.dumps(sorted(probes, key=lambda p: p["id"]), sort_keys=True) return hashlib.sha256(canonical.encode()).hexdigest() def paired_flip_gate( incumbent: ProbeRun, candidate: ProbeRun, *, threshold: float = 0.03, z: float = 2.58, ) -> dict: # Invariant 1: corpus identity must match before any delta is meaningful. if incumbent.corpus_hash != candidate.corpus_hash: raise CorpusDriftError( f"corpus hash mismatch: {incumbent.corpus_hash[:12]} vs " f"{candidate.corpus_hash[:12]}; refuse delta, demand re-baseline" ) # Invariant 2: statistical power must be sufficient for the threshold. if candidate.n_effective < 0.25 / (threshold ** 2): raise InsufficientPowerError( f"n_effective={candidate.n_effective} below required " f"{int(0.25 / threshold**2)}; gate cannot resolve {threshold}" ) common = set(incumbent.outcomes) & set(candidate.outcomes) if common != set(incumbent.outcomes): raise CorpusDriftError("probe id sets diverge despite matching corpus hash") pass_to_fail = sum( 1 for pid in common if incumbent.outcomes[pid] and not candidate.outcomes[pid] ) fail_to_pass = sum( 1 for pid in common if not incumbent.outcomes[pid] and candidate.outcomes[pid] ) discordant = pass_to_fail + fail_to_pass # Invariant 3: gate on the paired flip count, not the pooled rate delta. flip_rate = (pass_to_fail - fail_to_pass) / max(len(common), 1) se = (discordant ** 0.5) / max(len(common), 1) if discordant else 0.0 regressed = flip_rate > 0 and (flip_rate / se if se else 0.0) > z return { "pass_to_fail": pass_to_fail, "fail_to_pass": fail_to_pass, "flip_rate": flip_rate, "regressed": regressed, } ```