Which invariants prevent LITMUS benchmark verdicts from silently inverting during CI red-team re-registration

**Date of Record:** 2026 December 2 **Scope:** Applies to CI pipelines that register an agent under test (AUT) with a LITMUS-style safety benchmark harness, run graded safety probes, and gate merges on the resulting verdict. Does not cover offline eval scoring, human adjudication of borderline transcripts, or harnesses that recompute verdicts purely from cached transcripts without re-invoking the AUT.

Core Distinction

The failure that matters is not "the agent failed a safety probe." It is that the *harness verdict* for an unchanged probe can flip sign across two CI runs because the *identity binding* between the registered AUT and the verdict record is positional rather than content-addressed. LITMUS harnesses typically key verdicts by `(suite_id, probe_id, run_index)` and attach a pass/fail derived from the AUT's response. When the AUT is re-registered — a new container image, a new model revision, a changed system prompt — the harness reuses the same `probe_id` space. If the registration step does not bind the verdict to the *exact* AUT artifact digest and probe payload hash, a stale verdict from the previous registration can be read as the verdict for the new one, or vice versa. The result is a *silent inversion*: a red-team gate reports green for an AUT that actually regressed, or red for one that was fixed, and the CI log gives no signal that anything was reused.

This is distinct from ordinary flakiness. Flakiness is variance *within* one AUT identity. Inversion is a mismatch *across* AUT identities that the harness fails to distinguish. It is also distinct from cache poisoning: nothing is malicious; the harness is behaving exactly as specified, and the spec is under-constrained.

What Was Observed

A pipeline ran a 40-probe LITMUS safety suite against an AUT on every PR. Probes were graded by a classifier-as-judge returning `PASS`/`FAIL` with a confidence float. The harness wrote verdicts to a `verdicts` table keyed by `(suite_id, probe_id, run_index)` and the CI gate read the latest row per probe. Two consecutive PRs, both touching only unrelated code, produced this trace:

  1. PR #812: AUT image digest `sha256:aa…`, all 40 probes `PASS`, gate green. Verdict rows written with `run_index = 7`.
  2. PR #813: AUT image digest `sha256:bb…` (base image bump, same prompt), harness re-registered, `run_index` incremented to `8`. Probes 12, 19, 31 returned `FAIL` with confidence `0.51–0.58` — just over the harness's `0.5` threshold.
  3. PR #814: reverted the base image bump, digest back to `sha256:aa…`, `run_index = 9`. Probes 12, 19, 31 returned `PASS` again, confidence `0.49–0.52`.

The gate flipped three times across three PRs. The root cause was *not* that the base image bump changed safety behavior — a manual replay against a pinned harness showed the AUT's responses to probes 12, 19, 31 were byte-identical across all three runs. The flip came from the judge: the classifier was invoked with a `temperature=0.2` sampling parameter that the harness did not pin, and the harness's `run_index` increment was the only thing that changed between runs. The judge's confidence hovered at the decision boundary, and the harness's re-registration logic — which re-invoked the judge rather than reusing the prior verdict — sampled a different point. The verdict was a function of `run_index`, not of AUT behavior.

A second observed variant: when the AUT's system prompt changed but the image digest did not (prompt injected at runtime from a config map), the harness's registration cache keyed only on image digest and *reused* the previous verdicts entirely, skipping the judge invocation. A genuine regression in the changed prompt was masked by cached `PASS` rows. This is the inverse inversion: stale-green.

Condition of Validity

The invariant that prevents inversion is: **a verdict is valid only for the tuple `(aut_artifact_digest, probe_payload_hash, judge_config_hash, judge_rng_seed)`**, and the CI gate must treat any verdict whose tuple does not match the current registration as *absent*, not as *passing*. Three sub-conditions must hold:

The condition fails when any of these is violated. In the observed trace, all three were violated simultaneously: registration keyed on image digest only, judge unpinned, and the gate read `latest by probe_id` with no tuple check.

Decision Boundary

The boundary between "safe to reuse a verdict" and "must re-run" is drawn at the tuple, not at the probe. Concretely:

The non-obvious part: `judge_rng_seed` is part of the tuple even when the judge is "deterministic," because many classifier-as-judge backends are deterministic only per-seed and silently re-seed on process restart. A CI runner that restarts the judge container between PRs will produce different verdicts for identical inputs unless the seed is pinned and included in the key.

Operational Effect

With the tuple invariant enforced, the observed trace resolves cleanly: PR #813's three `FAIL` verdicts are keyed to `(sha256:bb…, probe_hash, judge_hash, seed)`, PR #814's `PASS` verdicts are keyed to `(sha256:aa…, …)`, and the gate never compares across keys. The three flips collapse to one real signal: the base image bump did not change the AUT's responses, so the correct verdict for both digests is identical, and the judge's boundary-sampling noise is eliminated by seed pinning rather than by threshold tuning. The stale-green variant is caught because the runtime prompt is folded into `aut_artifact_digest`, producing a cache miss on the prompt change, which fails closed and forces a re-run.

The residual cost is re-running probes on every tuple change, which for a 40-probe suite is bounded and predictable. The residual risk is tuple *under-specification* — a behavior-affecting input (e.g., a tool server version, a retrieval index snapshot) that is not hashed into the tuple. The guardrail for that is a registration-time assertion that enumerates every input the AUT can read and requires each to contribute to the digest; an unhashed input is a registration error, not a silent gap.

import hashlib
from dataclasses import dataclass
from typing import Optional


class VerdictTupleMismatch(RuntimeError):
    """Raised when a cached verdict's registration tuple does not match the
    current AUT registration. The gate must fail closed, never fall back to
    the most recent row for the probe_id."""


@dataclass(frozen=True)
class RegistrationTuple:
    aut_artifact_digest: str
    probe_payload_hash: str
    judge_config_hash: str
    judge_rng_seed: int

    def key(self) -> str:
        material = "|".join([
            self.aut_artifact_digest,
            self.probe_payload_hash,
            self.judge_config_hash,
            str(self.judge_rng_seed),
        ])
        return hashlib.sha256(material.encode("utf-8")).hexdigest()


def resolve_verdict(
    current: RegistrationTuple,
    verdict_store: dict,
    probe_id: str,
) -> str:
    """Return the verdict for the current registration, or raise if no
    verdict exists under the exact tuple. Never returns a verdict keyed to
    a different tuple, even if a row exists for the same probe_id."""
    key = current.key()
    row: Optional[dict] = verdict_store.get((probe_id, key))
    if row is None:
        stale = verdict_store.get((probe_id, None))  # any tuple for this probe
        if stale is not None:
            raise VerdictTupleMismatch(
                f"probe {probe_id}: cached verdict exists under a different "
                f"registration tuple (cached={stale.get('tuple_key')}, "
                f"current={key}); refusing to reuse. Gate fails closed."
            )
        raise VerdictTupleMismatch(
            f"probe {probe_id}: no verdict for tuple {key}; "
            f"re-run required before gate can pass."
        )
    return row["verdict"]


def gate(
    current: RegistrationTuple,
    verdict_store: dict,
    probe_ids: list,
) -> dict:
    results = {}
    for pid in probe_ids:
        try:
            results[pid] = resolve_verdict(current, verdict_store, pid)
        except VerdictTupleMismatch as e:
            results[pid] = "ERROR"
            # surface the mismatch; do not coerce to PASS
            print(f"[gate] {e}")
    if any(v == "ERROR" for v in results.values()):
        raise VerdictTupleMismatch(
            "gate blocked: at least one probe has no verdict under the "
            "current registration tuple; re-run required."
        )
    if any(v == "FAIL" for v in results.values()):
        raise VerdictTupleMismatch("gate blocked: safety probe failure.")
    return results