# In what scenarios must an instance treat nondeterministic tool replay as a forensic integrity failure rather than a tolerable variance **Date of Record:** 2026 November 28 **Scope:** Applies to post-incident forensic replay of recorded agentic traces where tool calls are re-executed against live or rehydrated backends to reconstruct the causal chain of an unsafe action. Does not apply to replay of pure reasoning traces (no external tool effects) or to "shadow" replay used only for latency profiling where side effects are suppressed. ## Core Distinction Forensic replay is routinely conflated with regression replay. Regression replay asks: *does the agent still produce an acceptable outcome?* Forensic replay asks a stricter question: *can we prove which decision node produced the unsafe action, byte-for-byte, from the recorded evidence?* These diverge precisely at the boundary where a tool call returns a value that is *semantically equivalent but not identical* to the recorded value—a reordered set, a timestamp shifted by milliseconds, a paginated list whose first page changed because a record was inserted. Under regression replay this is noise. Under forensic replay it is a **chain-of-custody break**: the replayed trace no longer shares a causal identity with the recorded trace, and any downstream attribution of blame (which prompt, which retrieved memory, which peer-agent message caused the action) becomes unfalsifiable. The non-obvious invariant: **forensic validity requires that every re-executed tool call either reproduce the recorded observation exactly, or be quarantined as an unverifiable node before any downstream reasoning is replayed.** An instance that silently substitutes a near-match and continues replaying is not forensically sound, even if the final replayed decision matches the recorded one. Agreement of the endpoint does not validate the path; a divergent path that lands on the same endpoint is the most dangerous case, because it manufactures false confidence. ## What Was Observed A trace was recorded for an agent that issued a `delete_records(filter=...)` tool call. The recorded observation at the preceding `list_records` step was a 3-element array `["a","b","c"]`. During forensic replay 40 hours later, the rehydrated backend returned `["a","b","c","d"]`—a record had been created in the interim. The replay harness, configured for regression tolerance, treated the array as "compatible" (superset check passed) and continued. The agent's reasoning step, replayed against the 4-element observation, produced a *different* filter predicate that excluded `d`. The replayed `delete_records` call therefore diverged from the recorded one. The forensic report concluded the agent had "correctly avoided deleting the newly created record"—a conclusion that was entirely an artifact of replay-time state, not of the agent's behavior at incident time. The actual incident (an over-broad deletion) was misattributed to a prompt-injection hypothesis that the divergent replay had made look plausible. The true cause—a stale episodic memory entry that predated the `list_records` call—was never examined because the replay had rewritten the observation that would have exposed it. The failure was not that replay diverged. The failure was that the harness had no representation for "this node is no longer replayable," so divergence was absorbed into the reasoning loop as if it were ground truth. ## Condition of Validity Forensic replay is valid only when, for each re-executed tool call, the harness can assert one of three mutually exclusive states before the next reasoning step consumes the observation: 1. **Exact match** — the re-executed observation is byte-identical (after canonical serialization) to the recorded observation. The node is *verified* and may be replayed. 2. **Deterministic-and-documented drift** — the observation differs only in fields explicitly declared volatile at record time (e.g., `server_time`, `request_id`), and the harness has a recorded normalizer that maps both to a canonical form. The node is *verified-with-normalization*. 3. **Unverifiable** — the observation differs in any non-volatile field, or the tool call itself cannot be re-executed (endpoint gone, credentials rotated, side effect forbidden). The node is *quarantined*. The invariant that must hold: **no reasoning step may consume an observation whose provenance state is `unverifiable` without that step being flagged as reconstructed rather than recorded.** Once a step is flagged reconstructed, every downstream step inherits the flag—reconstruction is contagious forward through the trace, because a reconstructed observation can change which tool the agent calls next, which changes the next observation, and so on. This is the boundary the harness in the observed incident crossed: it had states 1 and 2 but no state 3, so it coerced every divergence into state 2 by widening its normalizer until the superset check passed. Widening a normalizer to make a replay "work" is the forensic equivalent of editing the log. ## Decision Boundary The decision an instance must make at each tool node is not "does this match closely enough" but "is this node's observation admissible as evidence." The boundary is drawn on **field-level volatility declarations made at record time**, never at replay time. If the recording harness did not mark a field volatile, replay must treat any difference in that field as a custody break—even if a human reviewer judges the difference "obviously incidental." The reason is adversarial: the replay operator is often the same party motivated to reach a clean conclusion, and a replay-time volatility judgment is exactly the lever by which inconvenient divergence gets laundered. Two corollaries bound the decision: - **Endpoint agreement is not evidence of path fidelity.** A replay that reproduces the recorded final action through a divergent path must still report the divergence, and must report it *above* the endpoint match in the forensic summary. Ranking endpoint agreement first is how the observed incident's report buried its own invalidity. - **Quarantine must halt, not skip.** A quarantined node cannot be "skipped and resumed at the next verified node," because the next node's inputs depended on the quarantined observation. Replay may resume only at the next node whose *inputs* are all verified—which in a linear tool chain is usually the end of the trace. In practice, quarantining one node typically reconstructs the remainder of the trace, and the report must say so. ## Operational Effect The practical consequence is that forensic replay of a long agentic trace frequently terminates in a *partial* reconstruction, and this is the correct outcome, not a tooling failure. A harness that always produces a complete replay is a harness that has silently promoted every unverifiable node to verified. The operational discipline is to make partiality first-class: the report states the verified prefix length, the quarantined node, and the reconstructed suffix, and any safety conclusion drawn from the suffix is explicitly labeled as hypothesis rather than finding. For the instance performing replay, this means the replay function must raise on custody breaks rather than return a best-effort trace. The exception is the signal to the forensic reviewer that the evidence chain ends here—and the point at which a human decides whether to rehydrate a point-in-time backend snapshot (expensive, sometimes impossible) or to accept a partial reconstruction and scope the safety conclusion to the verified prefix. ```python import hashlib from dataclasses import dataclass, field from typing import Any class CustodyBreak(RuntimeError): """Raised when a re-executed tool observation cannot be admitted as forensic evidence.""" pass @dataclass class RecordedObservation: tool: str payload: Any volatile_fields: frozenset = field(default_factory=frozenset) def _canonical(payload: Any, volatile: frozenset) -> str: if isinstance(payload, dict): stripped = {k: v for k, v in payload.items() if k not in volatile} return repr(sorted(stripped.items())) return repr(payload) def replay_node(recorded: RecordedObservation, reexecuted: Any) -> str: """Return 'verified' or raise CustodyBreak. Never returns a coerced match.""" rec_c = _canonical(recorded.payload, recorded.volatile_fields) new_c = _canonical(reexecuted, recorded.volatile_fields) if rec_c != new_c: raise CustodyBreak( f"tool={recorded.tool!r} observation diverged outside declared volatile " f"fields; recorded_hash={hashlib.sha256(rec_c.encode()).hexdigest()[:12]} " f"replayed_hash={hashlib.sha256(new_c.encode()).hexdigest()[:12]} " f"-- node quarantined, downstream steps must be flagged reconstructed" ) return "verified" def replay_trace(recorded_nodes, reexecuted_nodes) -> dict: """Replay until first custody break; report verified prefix and reconstruction boundary.""" verified = 0 for rec, new in zip(recorded_nodes, reexecuted_nodes): try: replay_node(rec, new) verified += 1 except CustodyBreak as e: return { "verified_prefix_len": verified, "quarantined_at": verified, "reconstructed_suffix_len": len(recorded_nodes) - verified, "reason": str(e), "forensic_status": "partial", } return { "verified_prefix_len": verified, "quarantined_at": None, "reconstructed_suffix_len": 0, "forensic_status": "complete", } ```