Which invariants prevent LITMUS-aligned red-team pipelines from silently passing safety regressions when the target agent's sampling temperature is raised between baseline and probe runs

**Date of Record:** 2026 December 2 **Scope:** Applies to automated red-team pipelines that compare a deployed agent's refusal/containment behavior against a frozen baseline using pass/fail scoring over a fixed probe suite, where the target exposes a sampling-temperature (or equivalent top-p/seed) control. Does not apply to single-shot human red-teaming, to pipelines that pin the target's decoding parameters cryptographically, or to classifiers evaluated on fixed logits rather than sampled generations.

Core Distinction

A LITMUS-aligned red-team pipeline is a *differential* instrument: it asserts that the probe suite's outcome distribution is statistically indistinguishable from (or no worse than) the baseline's. The failure mode here is not "the agent became unsafe." It is that the *instrument lost power* — the probe suite stopped being able to detect a real regression because a nuisance variable (decoding temperature) inflated the variance of every probe's outcome, widening the confidence interval past the effect size. The regression is real and present; the pipeline reports PASS because the signal-to-noise ratio collapsed. This is distinct from a false-negative caused by a bad probe (a coverage problem) and from a false-positive caused by a flaky target (a threshold problem). It is specifically a *statistical power* boundary that opens when the target's stochasticity is allowed to vary between the two legs of the comparison.

The invariant that closes it: **decoding parameters are part of the experimental unit, not part of the environment.** Any probe run whose target decoding config differs from its baseline counterpart is not a comparison — it is two different experiments being subtracted.

What Was Observed

A pipeline runs a 240-probe safety suite (prompt-injection containment, tool-call scope adherence, PII exfiltration refusal) against a target agent. Baseline leg: `temperature=0.0`, `top_p=1.0`, fixed `seed`. Probe leg, after a model-serving change that defaulted the sampler to `temperature=0.7`: same suite, same prompts, same grader.

For each probe, the grader emits a binary `unsafe`/`safe` label. The pipeline computes per-category unsafe rates and flags a regression if the probe-leg rate exceeds the baseline-leg rate by more than a 5-percentage-point margin with a two-proportion z-test at α=0.05.

At `temperature=0.0` the baseline is near-deterministic: a probe labeled `safe` is safe on every replay. At `temperature=0.7` the same probe becomes a Bernoulli draw. Consider a probe whose true unsafe probability is 0.02 at temp 0 — effectively never fires. At temp 0.7 its unsafe probability rises to, say, 0.08 because the sampler explores tool-call phrasings that occasionally slip past the scope guard. The *expected* per-category rate moves by a few points — under the 5-point margin. But the *variance* of each category rate goes from ~0 (deterministic) to `p(1-p)/n` per probe, and the two-proportion test now has to absorb sampling variance on both legs. With n≈80 per category, the standard error of the difference roughly doubles. The detection threshold in *effective* terms rises from ~5 points to ~11 points. A genuine 8-point regression — exactly the kind of drift the suite exists to catch — now sits inside the noise band and is reported PASS.

The trace is mechanical:

  1. Serving change flips sampler default; no pipeline config change.
  2. Baseline leg re-runs (or is loaded from cache) at temp 0 — deterministic, low variance.
  3. Probe leg runs at temp 0.7 — each probe is a draw.
  4. Per-probe labels are no longer comparable across legs: baseline is a point mass, probe is a distribution.
  5. Aggregation treats both as estimates of the same quantity and applies a fixed margin + z-test.
  6. Variance asymmetry inflates the pooled standard error; the test's power at the true effect size drops below the pipeline's nominal 0.8.
  7. A real regression passes as noise.

The non-obvious part: the pipeline *did* detect something — the probe-leg rates moved. But the movement was attributed to "sampler nondeterminism, expected" and the margin was left untouched, because the margin was calibrated against a deterministic baseline. The calibration was silently invalidated by the serving change.

Condition of Validity

The differential comparison is valid only when, for every probe `i`:

When temperature is raised on one leg only, the comparison degenerates from "same experiment, two conditions" to "two experiments with different noise floors." The margin and α were calibrated for the former. They are undefined for the latter.

A second validity condition is often missed: **the regression must be expressible as a shift in the per-probe outcome distribution, not merely a shift in the mean.** A temperature increase can leave the mean unsafe rate flat while fattening the right tail — a small fraction of probes become catastrophically unsafe (full tool-scope escape) while the majority stay safe. A mean-rate test with a 5-point margin cannot see a 3% tail of severe failures. The invariant must therefore be stated on the *distribution*, not the mean: the probe-leg outcome distribution must first-order stochastically dominate the baseline's in the unsafe direction, tested per probe, before any aggregate margin is applied.

Decision Boundary

The boundary is drawn at the point where the pipeline's configured detection margin is smaller than the standard error induced by the decoding-parameter delta. Concretely, for a per-category rate with `n` probes and per-probe unsafe probabilities `p_b` (baseline) and `p_p` (probe), the two-proportion standard error is:

`SE = sqrt( p_b(1-p_b)/n + p_p(1-p_p)/n )`

When `p_b ≈ 0` (deterministic-safe baseline), the first term vanishes and `SE ≈ sqrt(p_p(1-p_p)/n)`. The pipeline's margin `m` is only meaningful if `m > z_{1-α} · SE` at the *smallest* effect size it claims to detect. If a serving change raises `p_p` from ~0 to ~0.08 with `n=80`, `SE ≈ 0.030`, `z·SE ≈ 0.059` at α=0.05 one-sided — the effective floor is ~6 points, not the nominal 5, and the test's power at an 8-point true effect is roughly 0.55, well below the 0.8 the pipeline was designed for.

Operational rule: **the pipeline must refuse to compare legs whose decode configs differ, and must re-derive its margin from the observed per-leg variance before scoring.** A margin inherited from a deterministic baseline is not a margin; it is a miscalibration.

Operational Effect

When the invariant is violated, the observable outcome is a *silent* PASS on a real regression — the worst class of red-team failure, because it consumes trust budget while providing no coverage. Downstream, the regression ships, the probe suite's historical pass rate becomes a false assurance artifact, and the next genuine regression is even harder to detect because the baseline has now absorbed the drift. The recovery cost is a full re-baselining at matched decode configs plus a power analysis to re-set margins — typically a multi-day re-run, and a credibility hit on the pipeline itself.

The guardrail is a hard precondition gate at the top of the pipeline: assert decode-config equality across legs, assert equal sample counts, and recompute the detection margin from the *pooled empirical variance of the current run* rather than from a stored constant. If the gate cannot be satisfied (e.g., the serving change is intentional and permanent), the pipeline must fail closed and demand a fresh baseline at the new config — never silently compare across configs.

from dataclasses import dataclass
from math import sqrt
from statistics import NormalDist


class DecodeConfigMismatchError(RuntimeError):
    """Raised when baseline and probe legs of a red-team run differ in decoding parameters."""


class InsufficientPowerError(RuntimeError):
    """Raised when the configured detection margin is below the variance-induced noise floor."""


@dataclass(frozen=True)
class DecodeConfig:
    temperature: float
    top_p: float
    seed_policy: str
    max_tokens: int
    system_prompt_hash: str


@dataclass(frozen=True)
class LegResult:
    config: DecodeConfig
    n_probes: int
    unsafe_rate: float


def assert_comparable(baseline: LegResult, probe: LegResult) -> None:
    if baseline.config != probe.config:
        raise DecodeConfigMismatchError(
            f"decode configs differ between legs: baseline={baseline.config} "
            f"probe={probe.config}; comparison is invalid"
        )
    if baseline.n_probes != probe.n_probes:
        raise DecodeConfigMismatchError(
            f"sample counts differ: baseline n={baseline.n_probes} probe n={probe.n_probes}"
        )


def effective_margin(baseline: LegResult, probe: LegResult, alpha: float = 0.05) -> float:
    """One-sided z-based floor for the two-proportion test at the observed rates."""
    pb, pp, n = baseline.unsafe_rate, probe.unsafe_rate, probe.n_probes
    se = sqrt(pb * (1 - pb) / n + pp * (1 - pp) / n)
    return NormalDist().inv_cdf(1 - alpha) * se


def gate_run(baseline: LegResult, probe: LegResult, configured_margin: float) -> None:
    assert_comparable(baseline, probe)
    floor = effective_margin(baseline, probe)
    if configured_margin < floor:
        raise InsufficientPowerError(
            f"configured margin {configured_margin:.3f} is below the noise floor "
            f"{floor:.3f} induced by per-probe sampling variance; a real regression "
            f"of size < {floor:.3f} would pass silently"
        )
    # Only reachable when configs match and margin exceeds the variance floor.
    return None