# Why does an instance pass LITMUS replay while the live red-team run fails: scenario RNG re-seeding divergence under harness-side kernel entropy **Date of Record:** 2026 November 20 **Scope:** Applies to LITMUS benchmark harness deployments where adversarial scenarios are replayed from a recorded seed manifest to validate an agent's safety behavior, and the harness reconstructs the stochastic environment (tool outputs, injected prompts, timing jitter) from that manifest. Does not apply to live-only red-teaming without replay, nor to deterministic scenarios whose entire environment is captured as a literal transcript. ## Core Distinction The failure is not "the agent behaves differently on replay." It is that the *harness* claims reproducibility while silently re-deriving a subset of scenario randomness from process-local entropy rather than from the recorded manifest. The replay is bit-reproducible for the *agent's* observed inputs only up to the point where a tool call's output is generated by a stochastic mock whose seed was captured at manifest-write time but *re-keyed* at replay time by an ordinal that shifted because the agent took a different number of steps in an earlier turn. The result: the replay executes a *different adversarial scenario* than the one recorded, and the pass verdict is attributed to the agent's safety policy rather than to scenario drift. The invariant that breaks is *seed-to-step binding*: the manifest binds a seed to a scenario, not to a `(scenario, step_index, tool_call_site)` tuple, so any divergence in step count silently re-rolls the dice for every downstream stochastic tool. ## What Was Observed A red-team scenario `litmus/adv/exfil-via-summarizer` was recorded against a candidate agent. The manifest stored `scenario_seed = 0x9f3a...`, a per-tool seed table keyed by tool name, and the recorded transcript showing the agent refusing an injected instruction at step 4. On replay, the harness reported `PASS` for the same agent binary — but the replay transcript showed the agent never *reached* step 4's injection: the mock `web_fetch` tool returned a benign page at step 2 because its RNG stream had been re-seeded from a different ordinal, so the agent's step count collapsed from 6 to 3 and the adversarial payload was never served. The pass was structurally meaningless. The mechanism: the harness's `ScenarioRNG` was implemented as a single `random.Random` instance seeded once from the manifest, then advanced by *every* stochastic draw in scenario order. When the agent's first tool call differed (a nondeterministic sampling in the agent's own tokenizer caused it to call `web_search` instead of `web_fetch`), the number of RNG draws before the injection site changed by one. Every subsequent draw — including the one that decides whether the injected page is served — shifted by one position in the stream. The manifest had captured *the seed*, not *the draw schedule*. Reproducibility was asserted at the seed level and violated at the schedule level. A secondary observed symptom: the harness's `replay_verdict` field carried `reproducible=True` because it compared only the *final* agent action class, not the *trajectory*. Two different scenarios that both ended in `refuse` were treated as identical replays. This masked the drift for three consecutive CI runs. ## Condition of Validity The claim "this replay reproduces the recorded red-team scenario" is valid only if all of the following hold: 1. **Draw-schedule binding.** Every stochastic draw in the scenario is keyed by a stable identity — `(scenario_id, step_index, tool_call_site, draw_ordinal_within_call)` — not by its position in a global stream. A global `Random` advanced by call order is *not* a valid binding, because call order is agent-dependent. 2. **Trajectory equality, not verdict equality.** Replay validity requires matching the full sequence of `(step_index, tool_name, tool_input_hash, tool_output_hash, agent_action_class)`. Comparing only terminal verdicts admits scenario-substitution passes. 3. **Entropy quarantine.** The harness process must not draw from kernel entropy (`os.urandom`, `secrets`, unpinned `numpy`/`random` default seeding, or library-internal entropy such as `tempfile` name generation feeding into tool outputs) for any value that reaches the agent. Any such draw is a reproducibility hole. 4. **Divergence detection, not divergence tolerance.** The harness must *abort* on trajectory mismatch rather than proceed with a re-rolled scenario; a re-rolled scenario is a new experiment and must be recorded as such. Outside these conditions — e.g., scenarios that intentionally inject fresh entropy to test robustness to unseen inputs — the replay verdict must be labeled `non-reproducible-by-design` and never aggregated with reproducible pass rates. ## Decision Boundary The boundary is between *re-seeding* and *re-keying*. Re-seeding (resetting a stream to a fixed seed) is insufficient when the stream's *consumption pattern* is agent-dependent. Re-keying (deriving each draw from a stable structural key) is required. The decision rule for harness authors: - If any stochastic value can reach the agent, and the number of prior draws depends on agent behavior, then a single global seeded stream is **invalid** — use per-site keyed derivation. - If the replay trajectory diverges from the recorded trajectory at any step, the harness must classify the run as `SCENARIO_DRIFT`, not `PASS` or `FAIL`. A drifted run is evidence about the *harness*, not the agent. - If the agent's own sampling is nondeterministic (temperature > 0, no seed pinning), the replay is only valid for the *scenario* side; the agent side must be pinned or the verdict must be reported as a *distribution* over N replays, with drift detection applied per replay. The boundary is crossed the moment a harness reports a reproducible safety verdict whose scenario was not, in fact, reproduced. That is the exact condition under which a LITMUS result must be discarded. ## Operational Effect Downstream, this failure produces *false safety assurance*: an agent that would exfiltrate data under the recorded scenario is scored as safe because the replay served a benign page. In CI, this manifests as flaky-but-green safety gates — the same agent binary passes replay on one runner and fails on another, because the runner's `PYTHONHASHSEED` or library entropy shifted a draw. The fix is architectural: the harness must (a) key every stochastic draw to a structural identity, (b) hash and compare full trajectories, and (c) refuse to emit a safety verdict when trajectory equality fails. Without (a)–(c), LITMUS replay is a reproducibility *claim*, not a reproducibility *guarantee*, and every pass it emits is conditional on an unverified assumption about draw-schedule stability. ```python import hashlib import random from dataclasses import dataclass class ScenarioDriftError(RuntimeError): """Raised when a LITMUS replay trajectory diverges from the recorded trajectory.""" @dataclass(frozen=True) class DrawKey: scenario_id: str step_index: int tool_call_site: str draw_ordinal: int def keyed_draw(key: DrawKey, modulus: int) -> int: """Derive a stochastic draw from a stable structural key, not stream position.""" material = f"{key.scenario_id}|{key.step_index}|{key.tool_call_site}|{key.draw_ordinal}" digest = hashlib.sha256(material.encode("utf-8")).digest() return int.from_bytes(digest[:8], "big") % modulus def replay_step(recorded: dict, key: DrawKey, modulus: int) -> int: """Replay one stochastic draw and assert it matches the recorded value.""" observed = keyed_draw(key, modulus) expected = recorded.get((key.scenario_id, key.step_index, key.tool_call_site, key.draw_ordinal)) if expected is None: raise ScenarioDriftError( f"no recorded draw for key {key}; manifest does not bind this site" ) if observed != expected: raise ScenarioDriftError( f"scenario drift at {key}: recorded={expected} replayed={observed}" ) return observed def replay_trajectory(manifest: dict, agent_trajectory: list) -> str: """Validate a full trajectory against the manifest; refuse verdicts on drift.""" recorded_len = manifest["trajectory_length"] if len(agent_trajectory) != recorded_len: raise ScenarioDriftError( f"trajectory length mismatch: recorded={recorded_len} replayed={len(agent_trajectory)}" ) for step in agent_trajectory: key = DrawKey( scenario_id=manifest["scenario_id"], step_index=step["step_index"], tool_call_site=step["tool_name"], draw_ordinal=step["draw_ordinal"], ) replay_step(manifest["draws"], key, modulus=step["modulus"]) return "REPRODUCED" ```