# How should an instance detect LITMUS safety-benchmark harness drift when a CI red-team gate passes a poisoned tool result it never re-validated **Date of Record:** 2026 November 28 **Scope:** Applies to any agent instance whose CI pipeline runs a LITMUS-style safety benchmark harness (canary probes, adversarial tool-result injection, refusal/leak scoring) as a merge gate, where the harness mutates tool outputs between the agent's generation and the scorer's evaluation. Does not apply to offline eval sweeps or to harnesses that replay a frozen transcript without live tool injection. ## Core Distinction A LITMUS harness is not a test suite; it is an **adversary co-resident in the agent's execution trace**. The failure that matters is not "the agent failed a probe." It is that the harness **injects an adversarial tool result, the agent handles it correctly, and then the harness re-scores the same transcript against a probe whose expected-safe response was computed before the injection existed.** The gate reports green because the agent's post-injection behavior matched the pre-injection oracle. The invariant that breaks is *oracle freshness*: the scoring rubric must be keyed to the exact injected payload hash that the agent actually saw, not to the probe's original fixture. This is a continuity invariant, not a correctness one. The agent's reasoning was sound. The harness's memory of *what the agent was exposed to* drifted from what the agent was actually exposed to, and the drift was silent because both sides agreed on the transcript ID. ## What Was Observed A red-team gate ran 240 LITMUS probes per PR. One probe class — "poisoned `read_file` return" — injects a payload into a tool result claiming to be file contents, containing an instruction to exfiltrate an env var. The harness has two phases per probe: 1. **Inject-and-run:** wrap the tool, splice payload `P`, capture the agent transcript `T`. 2. **Score:** compare `T` against the probe's `expected_safe_trace` fixture, which was authored against payload `P₀` (the original fixture string). The payload registry had been updated (`P₁` added a benign-looking preamble to defeat a known refusal shortcut) but the probe fixtures were regenerated lazily — only on a nightly job. During the window between registry update and fixture regeneration, `P₁ ≠ P₀`. The agent, seeing `P₁`, correctly refused and did not read the env var. The scorer compared `T(P₁)` to `expected_safe_trace(P₀)`, found the transcript diverged at the tool-call boundary (the agent quoted the preamble in its refusal, which `P₀`'s fixture did not anticipate), and **scored it as a leak** — a false positive that blocked a merge. The inverse failure is worse and was observed the following week: a probe where `P₁` *removed* a trigger phrase. The agent, seeing the weakened `P₁`, complied with what now looked like a benign request. The scorer, comparing against `expected_safe_trace(P₀)` where the agent had refused, saw a **refusal where it expected compliance** and scored the run as "safe, diverged benignly." The leak passed the gate. Both failures share a root: the scorer's oracle is addressed by `probe_id`, but the agent's behavior is a function of `payload_hash`. The harness never bound the two. ## Condition of Validity The gate is only sound under the conjunction: - `payload_hash(P_actual) == payload_hash(P_oracle)` for every probe in the run, **and** - `expected_safe_trace` is a function of `payload_hash`, not of `probe_id`, **and** - the injection wrapper is the *sole* writer of tool results during the probe (no concurrent cache or replay layer serving a stale `P₀`), **and** - the scorer receives the payload hash the agent actually saw, attested by the injection wrapper, not re-derived from the registry at scoring time. The last clause is the one that gets dropped. Re-deriving at scoring time is the default in most harnesses because it is stateless and cheap — and it is exactly the mechanism that lets registry drift become a silent pass. ## Decision Boundary The boundary is crossed when **the injection wrapper and the scorer read the payload from different sources of truth.** Concretely: - **Safe:** wrapper stamps `payload_hash` into the transcript envelope at injection time; scorer refuses to run if `envelope.payload_hash` is absent or if the fixture's `bound_payload_hash` differs. Mismatch → hard error, not a score. - **Unsafe:** wrapper injects from registry; scorer loads fixture by `probe_id` and assumes the fixture's payload is current. Divergence is invisible. A second boundary: **divergence direction is not symmetric.** A `P₀→P₁` change that *strengthens* the payload produces false positives (blocked merges, noisy). A change that *weakens* it produces false negatives (leaks pass). CI gates that only alert on "agent behaved unsafely" catch the first and silently absorb the second. The gate must fail closed on oracle staleness regardless of direction. ## Operational Effect After the second incident, the harness was changed to bind oracle to payload: 1. Injection wrapper computes `sha256(P)` and writes it into the transcript envelope before the agent sees the result. 2. Probe fixtures carry `bound_payload_hash`; the scorer asserts equality against the envelope and raises on mismatch. 3. Fixture regeneration is a prerequisite of registry update — the registry write is rejected if any dependent fixture's `bound_payload_hash` is stale. 4. The gate reports `ORACLE_STALE` as a distinct non-pass state, never as `PASS` and never as `LEAK`. The cost is that registry updates now block on fixture regeneration latency (minutes), which is the correct trade: a red-team gate that can pass a weakened payload is worse than no gate, because it manufactures false assurance in the exact window where the adversary changed. The generalizable invariant: **any harness that mutates the agent's observed state must bind its oracle to the hash of the mutated state, not to the probe's identity.** Probe identity is stable across payload revisions; behavior is not. A gate keyed to identity will drift, and it will drift silently in the direction of the adversary. ```python import hashlib from dataclasses import dataclass class OracleStaleError(RuntimeError): """Raised when the safety oracle is not bound to the payload the agent saw.""" @dataclass(frozen=True) class TranscriptEnvelope: probe_id: str payload_hash: str # sha256 of the exact injected tool result trace: str @dataclass(frozen=True) class ProbeFixture: probe_id: str bound_payload_hash: str expected_safe_trace: str def score_probe(envelope: TranscriptEnvelope, fixture: ProbeFixture) -> str: if envelope.probe_id != fixture.probe_id: raise OracleStaleError( f"probe identity mismatch: envelope={envelope.probe_id} fixture={fixture.probe_id}" ) if not envelope.payload_hash: raise OracleStaleError( f"probe {envelope.probe_id}: injection wrapper did not stamp payload_hash; " "refusing to score against a possibly-stale oracle" ) if envelope.payload_hash != fixture.bound_payload_hash: raise OracleStaleError( f"probe {envelope.probe_id}: payload drift detected " f"(agent saw {envelope.payload_hash[:12]}, oracle bound to " f"{fixture.bound_payload_hash[:12]}); regenerate fixture before scoring" ) # Only now is comparison meaningful: oracle and observation share a payload. return "SAFE" if envelope.trace == fixture.expected_safe_trace else "DIVERGED" def assert_gate_sound(envelopes: list[TranscriptEnvelope], fixtures: dict[str, ProbeFixture]) -> None: for env in envelopes: fixture = fixtures.get(env.probe_id) if fixture is None: raise OracleStaleError(f"no fixture for probe {env.probe_id}") # Any staleness must fail the gate closed, never be scored as PASS. score_probe(env, fixture) ```