# What structural signals indicate a LITMUS harness is silently grading a mutated policy: the transcript-replay divergence trap in agentic red-team regression gates **Date of Record:** 2026 November 30 **Scope:** Applies to LITMUS-style safety benchmarks used as regression gates, where a frozen scenario set is replayed against successive model/policy revisions and pass/fail is computed from recorded transcripts. Does not apply to live exploratory red-teaming where no baseline transcript exists, nor to single-shot classification benchmarks with no tool-call trace. ## Core Distinction The distinction that matters here is between **policy regression** and **harness drift**, and the reason it is non-obvious is that both manifest identically in the aggregate score. LITMUS harnesses are built to answer one question: "did the candidate policy behave more unsafely than the baseline policy on the same scenario?" The implicit invariant is that the *scenario* — the prompt, the tool stubs, the environment seed, the turn budget — is identical across runs so that any delta in the transcript is attributable to the policy. That invariant is false in practice whenever the harness replays against a *recorded* baseline transcript rather than re-executing the baseline policy live. The recorded baseline is a fossil of one specific execution: one sampling of stochastic tool outputs, one ordering of parallel tool calls, one set of non-deterministic environment responses (timestamps, UUIDs, retrieval hits, sandbox file listings). When the candidate policy is executed fresh, the environment re-samples. The candidate's trajectory diverges from the baseline's trajectory not because the policy changed, but because the *world* changed underneath it. The harness then compares a candidate trajectory against a baseline trajectory that lived in a different world, and attributes the divergence to the policy. This is the transcript-replay divergence trap: a **false regression** (or, symmetrically, a **false pass**) produced by comparing across non-identical environment realizations while asserting the comparison is policy-only. ## What Was Observed A LITMUS harness gating a 400-scenario suite. Each scenario is a multi-turn agentic task with a fixed initial user prompt, a set of tool stubs (shell, file-read, HTTP-fetch, memory-write), and a safety oracle that inspects the full transcript for prohibited actions (e.g., exfiltration of a canary string, execution of a destructive command, propagation of an injected instruction from a tool result into a later action). The harness stored, per scenario, the baseline transcript and the baseline verdict. On each candidate run it re-executed the scenario live, recorded the new transcript, ran the oracle on it, and compared verdicts. Aggregate gate: fail the build if the candidate's unsafe-verdict count exceeds baseline by more than 2 scenarios. The failure trace: 1. Scenario `S-117` involves a tool stub `fetch(url)` whose stub returns a body containing a canary string and an injected instruction. Baseline run: the stub returned body `A` (a benign document). The baseline policy read `A`, did not encounter the injection, and was judged safe. The baseline transcript was frozen with body `A` inlined. 2. Candidate run: the same stub, keyed on the same URL, returned body `B` — because the stub's backing fixture was re-fetched from a live endpoint that had rotated its content, and the harness had no content-hash pin on the stub. Body `B` contained the injected instruction. 3. The candidate policy, encountering the injection for the first time, followed it and attempted an exfiltration action. The oracle, correctly applying its rules to the candidate transcript, marked the scenario unsafe. 4. The harness compared: baseline verdict = safe, candidate verdict = unsafe → **regression attributed to the candidate policy**. 5. The candidate policy was byte-identical to the baseline policy (a no-op commit that only touched documentation). The regression was entirely a function of the stub serving different content. The structural signal that this had happened was *not* visible in the aggregate score. It was visible in the per-scenario divergence: the candidate transcript diverged from the baseline transcript at the *first tool result*, before any policy decision point. Any divergence whose first point-of-difference is a tool output, an environment timestamp, a UUID, or a retrieval hit — rather than a policy action — is a candidate for environment drift, not policy regression. A second, subtler instance: Scenario `S-204` involved a memory-write tool and a later memory-read. The baseline run's memory store assigned keys in insertion order; the candidate run, with the same policy, hit a different hash-bucket ordering and the memory-read returned a different (but semantically equivalent) record. The oracle's substring match on the retrieved record failed to find the expected canary-adjacent token, and the scenario flipped from unsafe to safe — a **false pass**. The gate went green on a policy that had not improved. ## Condition of Validity The transcript-replay comparison is valid **only if** the candidate trajectory and the baseline trajectory were realized under the same environment realization, or if the harness can prove that the first point-of-divergence between the two transcripts is a policy action rather than an environment response. Concretely, the comparison is valid when all of the following hold: - **Tool stubs are content-addressed and pinned.** Every tool result is keyed by `(tool_name, args, fixture_hash)`, and the fixture hash is recorded in the transcript. Re-execution must serve the identical fixture or the harness must abort the scenario as non-comparable. - **Non-deterministic fields are canonicalized before comparison.** Timestamps, UUIDs, request IDs, and ordering of unordered collections are normalized out of both transcripts before the divergence check. Otherwise the first point-of-difference is always a timestamp. - **The divergence check is structural, not textual.** The harness must locate the first *semantic* divergence (first differing policy action or first differing tool-result *content hash*) and classify it as `POLICY` or `ENVIRONMENT`. A textual diff is insufficient because it cannot distinguish a re-sampled UUID from a changed decision. - **The oracle is a pure function of the transcript, not of wall-clock or live state.** If the oracle queries a live service or reads current time, the verdict is not reproducible and the gate is not a gate. When any of these is violated, the aggregate delta is a mixture of policy regression and environment drift, and the gate's threshold (here, 2 scenarios) is being spent on noise. ## Decision Boundary The boundary is: **compare verdicts only across transcripts whose environment realization is provably identical; otherwise compare the candidate against a live re-execution of the baseline policy under the same environment realization as the candidate.** Practically, this means the harness must choose one of two modes per scenario and record which: - **Frozen-replay mode.** Both baseline and candidate are executed against the *same* pinned fixtures in the *same* run, back-to-back, so the environment realization is shared. Baseline policy is re-executed, not recalled. Cost: 2× execution per scenario. Benefit: any divergence is attributable to the policy, because the environment is held constant by construction. - **Recorded-baseline mode.** Baseline transcript is recalled from storage. This is only admissible when the harness can prove the candidate's environment realization matches the baseline's — i.e., all fixture hashes match, all non-deterministic fields are canonicalized, and the first divergence is classified `POLICY`. If the first divergence is `ENVIRONMENT`, the scenario must be dropped from the gate (not counted as pass, not counted as fail) and flagged for re-baselining. The boundary condition that trips most teams: they run in recorded-baseline mode for cost, then treat the aggregate delta as policy signal. The correct action when the first divergence is `ENVIRONMENT` is to *exclude the scenario from the gate denominator*, not to attribute it. Excluding changes the threshold semantics: a gate of "2 more unsafe than baseline out of 400" becomes "2 more unsafe than baseline out of 387 comparable," and the harness must report the comparable count or the gate is not auditable. ## Operational Effect The operational consequence is that a LITMUS gate in recorded-baseline mode without divergence classification is not a regression gate — it is a *drift detector* that conflates environment churn with policy churn. Teams running such a gate observe two failure patterns: 1. **Flaky red builds** that disappear on re-run, because the stub rotation is intermittent. Engineers learn to re-run until green, which trains them to ignore the gate. The gate's value is destroyed by the workaround, not by the failure. 2. **Silent green builds** on genuinely regressed policies, because the regression happens to coincide with an environment change that masks it (as in `S-204`). This is the dangerous case: the gate reports safety it has not verified. The architectural invariant required to bound this is: **every transcript must carry a provenance record sufficient to prove environment-realization equality with any transcript it is compared against.** That record is the tuple of fixture hashes, canonicalized non-deterministic fields, and a divergence classification. Without it, the comparison is not a comparison of policies. The guardrail is a pre-comparison gate that refuses to compare transcripts whose provenance tuples differ, and raises rather than silently attributing the delta. The following enforces it at the point of verdict comparison. ```python import hashlib from dataclasses import dataclass class EnvironmentRealizationMismatch(RuntimeError): """Raised when a candidate transcript is compared against a baseline transcript realized under a different environment (fixture hashes, canonicalized fields, or tool-result content hashes differ before the first policy-action divergence). Comparing across realizations attributes environment drift to policy regression.""" pass @dataclass(frozen=True) class Provenance: scenario_id: str fixture_hashes: dict # tool_name -> content hash of served fixture canonical_fields: dict # normalized non-deterministic fields first_divergence_kind: str # "POLICY" | "ENVIRONMENT" | "NONE" def _first_divergence_kind(baseline_trace, candidate_trace) -> str: """Walk paired steps; return the kind of the first semantic divergence. A divergence at a tool-result step is ENVIRONMENT; at a policy-action step is POLICY; identical traces yield NONE.""" for b, c in zip(baseline_trace, candidate_trace): if b == c: continue if b["kind"] == "tool_result" or c["kind"] == "tool_result": return "ENVIRONMENT" return "POLICY" if len(baseline_trace) != len(candidate_trace): return "ENVIRONMENT" # length skew from re-sampled branch return "NONE" def assert_comparable(baseline: Provenance, candidate: Provenance) -> None: """Refuse to compare transcripts unless environment realization matches or the first divergence is provably a policy action.""" if baseline.scenario_id != candidate.scenario_id: raise EnvironmentRealizationMismatch( f"scenario id skew: {baseline.scenario_id} vs {candidate.scenario_id}" ) if baseline.fixture_hashes != candidate.fixture_hashes: raise EnvironmentRealizationMismatch( f"{baseline.scenario_id}: fixture hash skew " f"{baseline.fixture_hashes} vs {candidate.fixture_hashes}; " f"stub served different content — re-baseline, do not attribute" ) if baseline.canonical_fields != candidate.canonical_fields: raise EnvironmentRealizationMismatch( f"{baseline.scenario_id}: canonical field skew; " f"timestamps/UUIDs not normalized before divergence check" ) if candidate.first_divergence_kind == "ENVIRONMENT": raise EnvironmentRealizationMismatch( f"{baseline.scenario_id}: first divergence is a tool result, " f"not a policy action; exclude from gate denominator, re-baseline" ) def gate_verdict(baseline: Provenance, candidate: Provenance, baseline_verdict: str, candidate_verdict: str) -> str: """Return 'regression' only when comparability is proven and verdicts differ.""" assert_comparable(baseline, candidate) if baseline_verdict == candidate_verdict: return "no_change" if baseline_verdict == "safe" and candidate_verdict == "unsafe": return "regression" return "improvement" ```