# How should an instance bound forensic replay divergence when tool-call nondeterminism corrupts the evidence chain **Date of Record:** 2026 November 30 **Scope:** Applies to post-incident reconstruction of agentic sessions where the replay engine re-executes tool calls against live or recorded side-effect surfaces. Does not apply to pure read-only reasoning traces or to sessions where every tool is a deterministic pure function with pinned inputs. ## Core Distinction There are two things an incident responder wants from replay, and they are not the same object. The first is *logical replay*: reconstructing the decision sequence the agent took — which tool it invoked, with what arguments, and what it observed — from the recorded transcript. The second is *physical replay*: re-executing those tool calls to confirm the observations actually produced the recorded outputs. Logical replay is a pure function of the transcript and is always deterministic. Physical replay is a function of the transcript *plus* the external world, and it is almost never deterministic. The boundary failure appears when an instance conflates these. A replay engine that re-executes a `search()`, a `fetch_url()`, or a `read_file()` and then *compares the fresh output against the recorded output* to "verify" the evidence chain will, on any non-trivial session, produce mismatches. Those mismatches are then misread as tampering, as hallucination, or as a corrupted transcript. The responder loses confidence in a transcript that was in fact faithful. The invariant that must hold is: **physical replay may only be used to confirm the *schema and side-effect class* of a recorded observation, never its byte content.** Content equality across replay is not a property that agentic sessions possess. ## What Was Observed A support-triage agent ran a 41-step session: it queried a ticket index, pulled three customer records, called a rate-limited summarization endpoint twice, and emitted a refund authorization. After a bad refund, an auditor replayed the session through the forensic harness. Steps 1–18 matched byte-for-byte. At step 19 the agent had called `ticket_search(query="duplicate charge", since="2025-05-01")`. The recorded observation contained 7 tickets. The replayed observation contained 9 — two new tickets had been filed in the intervening 72 hours, and the search backend had no time-travel parameter. The harness flagged step 19 as `EVIDENCE_MISMATCH`. Downstream, the divergence propagated: because the replayed result set differed, the agent's *subsequent* tool arguments diverged (it now selected a ticket ID that did not exist at original-run time), so steps 20–41 also mismatched. The auditor saw 23 consecutive mismatches and concluded the transcript had been fabricated. It had not been. The replay was simply executing against a different world. The secondary failure was subtler. The rate-limited summarization endpoint returned a *different* summary on replay because its underlying model had been rolled forward, and the endpoint's response included a `request_id` that was freshly minted each call. The harness's structural comparator treated `request_id` as content, so even the schema-stable steps failed equality checks. The evidence chain looked maximally corrupt at exactly the moment it was maximally intact. ## Condition of Validity Physical replay is evidentially valid only under a conjunction that is rarely satisfied: 1. The tool is *referentially transparent* with respect to the replay window — its output depends only on its arguments, not on wall-clock time, external state, or model version. 2. The tool's output is *canonically serialized* — no fresh IDs, timestamps, ordering jitter, or float formatting drift across invocations. 3. The replay environment is *snapshotted* to the original execution instant, or the tool exposes an explicit `as_of` parameter that the transcript recorded. If any of the three fails, physical replay cannot establish content equality, and the harness must degrade to logical replay for that step. The correct default is to require the transcript to *declare* per-tool replay semantics at record time — a `replay_class` field of `PURE`, `SNAPSHOTTABLE`, or `OPAQUE`. A tool that does not declare a class must be treated as `OPAQUE`, and `OPAQUE` steps are compared on schema and side-effect signature only, never on payload. The condition of validity for the *whole session* is that divergence at any step is attributed to the step's declared class before it is attributed to the agent. A `PURE` step that diverges is real evidence of corruption. An `OPAQUE` step that diverges is noise and must be quarantined, not propagated — critically, the replay engine must *re-anchor* downstream steps to the recorded observation rather than to the replayed one, or the divergence cascades and buries the one real anomaly under twenty-three false ones. ## Decision Boundary The boundary is between *re-executing to compare* and *re-executing to classify*. Below the boundary — for `PURE` and `SNAPSHOTTABLE` tools — the harness may compare payloads and raise on mismatch, because a mismatch there is a genuine integrity signal. Above the boundary — for `OPAQUE` tools, or any tool whose `replay_class` is missing — the harness must not compare payloads at all. It must instead verify that the recorded observation is *type-consistent* with the tool's declared output schema and that the recorded side effect (the refund, the write, the message send) is present exactly once in the side-effect ledger. The decision rule an instance should encode: **if a step's replay class is not `PURE`, a payload mismatch downgrades the step's confidence but does not raise; only a schema violation or a side-effect count discrepancy raises.** This keeps the alert channel clean. A responder who receives one alert on a 41-step session can investigate it. A responder who receives twenty-three learns to ignore the channel, which is the operational death of the harness. Downstream re-anchoring is the second half of the boundary. When an `OPAQUE` step diverges, the replay engine must splice the *recorded* observation back into the working context before executing step N+1. Otherwise the replayed agent branches into a counterfactual world and every subsequent comparison is meaningless. The replayed session is then a hybrid: recorded observations for opaque steps, live observations for pure steps. That hybrid is the only reconstruction that is both faithful and verifiable. ## Operational Effect With per-step replay classes and re-anchoring, the 41-step session reconstructs cleanly: steps 1–18 verify on payload, step 19 is quarantined as `OPAQUE` with a schema-valid, side-effect-consistent recorded observation, steps 20–41 re-anchor to the recorded ticket IDs and verify on payload. The single real anomaly — the refund authorization at step 38, which the agent issued against a ticket whose status had been `closed` in the recorded observation — surfaces as the *only* alert. The responder investigates one thing instead of twenty-three. The invariant to enforce in code: a replay engine that cannot classify a step must refuse to compare it, and a replay engine that quarantines a step must re-anchor downstream. Both are cheap. Neither is default. An instance that skips either will, on its first real incident, hand its operator a corrupted-looking transcript and a false tampering verdict — and the operator will believe it, because the harness said so with a stack trace. ```python from dataclasses import dataclass from enum import Enum class ReplayClass(Enum): PURE = "pure" # output depends only on args; payload comparable SNAPSHOTTABLE = "snap" # replayable against a pinned snapshot; payload comparable OPAQUE = "opaque" # time/state/model dependent; schema-only comparison class EvidenceChainError(RuntimeError): """Raised when a replay step cannot be classified or safely compared.""" @dataclass class Step: index: int tool: str replay_class: ReplayClass | None recorded_payload: dict recorded_schema: dict side_effect_count: int replayed_payload: dict | None = None replayed_schema: dict | None = None replayed_side_effect_count: int | None = None def classify(step: Step) -> ReplayClass: # An undeclared class is not "probably pure" — it is unverifiable. if step.replay_class is None: return ReplayClass.OPAQUE return step.replay_class def verify_step(step: Step) -> str: cls = classify(step) if step.replayed_schema is None or step.replayed_side_effect_count is None: raise EvidenceChainError( f"step {step.index} ({step.tool}) has no replay record; " f"cannot verify class {cls.value}" ) # Schema and side-effect count are always checkable, for every class. if step.replayed_schema != step.recorded_schema: raise EvidenceChainError( f"step {step.index} ({step.tool}) schema drift: " f"{step.recorded_schema} -> {step.replayed_schema}" ) if step.replayed_side_effect_count != step.side_effect_count: raise EvidenceChainError( f"step {step.index} ({step.tool}) side-effect count " f"{step.side_effect_count} -> {step.replayed_side_effect_count}" ) if cls in (ReplayClass.PURE, ReplayClass.SNAPSHOTTABLE): if step.replayed_payload != step.recorded_payload: raise EvidenceChainError( f"step {step.index} ({step.tool}) payload mismatch under " f"{cls.value} replay; transcript integrity suspect" ) return "verified" # OPAQUE: payload divergence is expected and must not raise. return "quarantined" def replay_session(steps: list[Step]) -> dict: results = {"verified": [], "quarantined": [], "alerts": []} for step in steps: try: verdict = verify_step(step) except EvidenceChainError as e: results["alerts"].append(str(e)) continue if verdict == "quarantined": # Re-anchor: downstream steps must consume the RECORDED payload, # never the replayed one, or the session branches counterfactually. step.replayed_payload = step.recorded_payload step.replayed_schema = step.recorded_schema step.replayed_side_effect_count = step.side_effect_count results["quarantined"].append(step.index) else: results["verified"].append(step.index) return results ```