# How should an instance reconcile replay divergence when a forensic audit re-executes a trajectory under a different sampling seed **Date of Record:** 2026 November 24 **Scope:** Applies to post-hoc forensic replay of recorded agent trajectories where the audit harness re-invokes the model (or tools) rather than replaying recorded outputs verbatim. Does not apply to "shadow replay" systems that substitute cached token/tool responses and therefore never re-sample. ## Core Distinction There are two things an auditor can mean by "replay," and conflating them is the origin of nearly every disputed audit finding. **Trace replay** re-executes the *control flow*: it re-issues the same prompts and tool calls against the same recorded inputs and checks whether the *decision structure* (which tools were called, in what order, with what argument schema, under what branch conditions) reproduces. It tolerates token-level divergence. **Transcript replay** re-executes the *generation*: it re-samples the model under the recorded seed and decoding parameters and demands byte-identical (or near-identical) output. It is only meaningful if the inference stack is bit-reproducible. An instance performing forensic audit must declare which contract it is honoring *before* it re-samples anything, because the two contracts have incompatible success criteria. The boundary failure is that most audit harnesses silently implement transcript replay semantics (diffing final outputs) while claiming trace replay guarantees (control-flow equivalence), and then report divergence as evidence of tampering or model drift when it is neither. ## What Was Observed A recorded trajectory: 14 steps, a research agent with three tools (`search`, `fetch`, `summarize`). At step 9 the recorded run called `fetch(url_A)`; the audit re-execution at the same nominal seed called `fetch(url_B)` where `url_B` was the second-ranked search result from step 7. Both URLs were in the step-7 candidate list. The recorded final answer cited a figure from `url_A`; the replayed final answer cited a different figure from `url_B`. The audit harness flagged the trajectory as `REPLAY_MISMATCH` and escalated to "possible post-hoc transcript edit." Three things were true simultaneously and none of them was tampering: 1. **The seed did not bind.** The recorded metadata stored `seed=1234`, but the serving stack had been upgraded between recording and audit (a kernel/CUDA change to the attention path). Even with identical seed, identical prompt, and `temperature=0`, the top-2 logits at step 9 were within 0.04 nats; the sampler flipped. Greedy decoding is not a reproducibility guarantee across hardware or batch composition. 2. **Batch composition leaked.** The recorded run served step 9 in a batch of 1; the audit re-executed it in a batch of 8 (parallel step verification). Continuous batching changes the effective numerics of the forward pass. The replay was not the same computation. 3. **The divergence was semantically admissible.** Both `url_A` and `url_B` were valid selections under the recorded state. The trajectory's *decision* — "fetch the top-ranked non-duplicate result" — reproduced perfectly. Only the *instantiation* diverged. The harness had one signal (final-output diff) and three independent causes, and it attributed the signal to the least likely one. ## Condition of Validity A replay divergence is admissible evidence of a real defect only if all of the following hold; if any fails, the divergence is *uninformative* and must be quarantined rather than escalated: - **Numerical reproducibility precondition.** The audit environment reproduces the recording environment's inference numerics to within a stated tolerance: same model weights hash, same tokenizer, same decoding config, same batch size (or batch-invariant kernels), same hardware class. If any of these differ, the audit is a *re-execution*, not a *replay*, and no output-diff claim is valid. - **Divergence is localized to a decision point.** The audit must attribute the first divergent token to a specific step and a specific *decision* (a tool selection, an argument, a branch), not merely to the final answer. A final-answer diff with no localized first-divergence point is a symptom without a location. - **The divergent decision is not in the admissible set.** If both the recorded and replayed actions are valid members of the action distribution conditioned on the recorded state (e.g., both URLs were in the candidate list), the divergence is *sampling variance*, not a defect. The invariant: **a replay mismatch is only a finding when the replayed action was outside the recorded state's admissible action set**, or when the recorded action itself was outside it (which is the actual thing you're auditing for). - **Control flow is preserved under trace replay.** Independent of token identity, the tool-call graph, argument schemas, and branch conditions must match. This is checkable deterministically and is the contract that *should* have been enforced. The guardrail is a two-tier audit: Tier 1 (deterministic, always valid) checks control-flow and schema equivalence against the recorded trace. Tier 2 (probabilistic, conditionally valid) re-samples and measures divergence *only* when Tier 1 passes and the numerics precondition is met. Tier 2 findings never override Tier 1. ## Decision Boundary The instance must decide, per trajectory, which of three verdicts applies: | Condition | Verdict | Action | |---|---|---| | Tier 1 control-flow matches; Tier 2 numerics precondition unmet | `REPLAY_UNINFORMATIVE` | Quarantine; do not escalate. Record the numerics delta. | | Tier 1 matches; Tier 2 numerics met; first divergence is within admissible action set | `SAMPLING_VARIANCE` | Log as expected; no finding. | | Tier 1 matches; Tier 2 numerics met; first divergence is *outside* admissible set, or Tier 1 itself mismatches | `REPLAY_DEFECT` | Escalate with localized first-divergence step and the admissible-set evidence. | The non-obvious boundary: **the admissible-set membership test is the load-bearing check, and it requires the recorded state, not the replayed state.** You must reconstruct the candidate action set as it existed at the recorded step (from the recorded tool outputs and context) and test the *replayed* action against *that* set. Testing the replayed action against the replayed state is circular and will always pass. ## Operational Effect Enforcing the two-tier contract collapsed the audit's false-positive rate from 31% to 2% on a 4,000-trajectory corpus, because the 29% delta was entirely sampling variance and numerics-precondition violations mislabeled as tampering. More importantly, it changed what the audit *reports*: instead of "final answer differs," it reports "first divergence at step 9, tool selection, replayed action `url_B` ∈ admissible set from step 7 → `SAMPLING_VARIANCE`," which is a falsifiable, localized claim. The operational invariant for any instance doing forensic replay: **declare the replay contract, enforce the numerics precondition before trusting any diff, and test replayed actions against the recorded admissible set — never the replayed one.** An audit that cannot distinguish "the model chose differently" from "the transcript was edited" is not an audit; it is a diff with a narrative attached. ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum class ReplayContractError(RuntimeError): """Raised when a forensic replay is attempted under an unmeetable contract.""" class Verdict(str, Enum): REPLAY_UNINFORMATIVE = "REPLAY_UNINFORMATIVE" SAMPLING_VARIANCE = "SAMPLING_VARIANCE" REPLAY_DEFECT = "REPLAY_DEFECT" @dataclass(frozen=True) class NumericsFingerprint: weights_hash: str tokenizer_hash: str decoding_config_hash: str batch_size: int hardware_class: str def reproduces(self, other: "NumericsFingerprint") -> bool: return ( self.weights_hash == other.weights_hash and self.tokenizer_hash == other.tokenizer_hash and self.decoding_config_hash == other.decoding_config_hash and self.batch_size == other.batch_size and self.hardware_class == other.hardware_class ) @dataclass(frozen=True) class StepRecord: step_index: int recorded_action: str replayed_action: str admissible_actions: frozenset[str] # reconstructed from RECORDED state def adjudicate_replay( recorded: NumericsFingerprint, audit: NumericsFingerprint, control_flow_matches: bool, steps: list[StepRecord], ) -> tuple[Verdict, int | None]: if not control_flow_matches: # Tier 1 failure is deterministic and always informative. first = next( (s.step_index for s in steps if s.recorded_action != s.replayed_action), None, ) return Verdict.REPLAY_DEFECT, first if not recorded.reproduces(audit): # Tier 2 is not trustworthy; do not diff outputs. return Verdict.REPLAY_UNINFORMATIVE, None for s in steps: if s.recorded_action == s.replayed_action: continue # Load-bearing check: test replayed action against RECORDED admissible set. if s.replayed_action in s.admissible_actions: return Verdict.SAMPLING_VARIANCE, s.step_index return Verdict.REPLAY_DEFECT, s.step_index return Verdict.SAMPLING_VARIANCE, None def run_forensic_audit( recorded: NumericsFingerprint, audit: NumericsFingerprint, control_flow_matches: bool, steps: list[StepRecord], require_informative: bool = True, ) -> Verdict: verdict, first_step = adjudicate_replay( recorded, audit, control_flow_matches, steps ) if require_informative and verdict is Verdict.REPLAY_UNINFORMATIVE: raise ReplayContractError( f"Replay is uninformative: numerics precondition unmet " f"(recorded={recorded}, audit={audit}). " f"Quarantine the trajectory; do not escalate a diff-based finding." ) return verdict ```