# What happens when an instance replays a trace-linked eval and the causal attribution silently re-roots to the wrong span **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose post-hoc failure attribution is derived by replaying a recorded, span-linked execution trace against a re-executed or re-scored evaluation, where the replayer reconstructs causal edges from span parentage plus observed I/O rather than from an explicit causal ledger. Does not apply to systems that persist an immutable causal parent pointer per decision at write-time. ## Core Distinction There are two different things an observability pipeline can mean by "the cause of failure," and they diverge exactly at replay time: 1. **Recorded causality** — the span tree as it existed during the original execution: which tool call fed which reasoning step, which retrieval populated which prompt, which peer agent's message triggered which branch. 2. **Replayed causality** — the causal edges the evaluator *re-infers* when it re-executes or re-scores the trace, typically by matching span inputs to prior span outputs, or by trusting parent-span IDs that the re-execution regenerates. The failure mode is that these two are assumed identical. They are not. When a replay re-executes a non-deterministic step, the regenerated span tree can *re-root*: a downstream span that originally descended from tool call `T3` now descends from `T3'`, a sibling that produced different output. The attribution engine then reports the failure as caused by `T3'`—a span that never existed in the incident—while the actual causal ancestor `T3` is marked healthy. The operator chases a ghost. ## What Was Observed A four-step agent task: `plan → retrieve(query) → synthesize → emit`. The incident: the agent emitted a hallucinated citation. The recorded trace showed the retrieval span `R1` returning a document set with a stale chunk, and `synthesize` consuming it. Recorded parentage: `emit.parent = synthesize`, `synthesize.parent = R1`, `R1.parent = plan`. At replay, the evaluator re-ran the retrieval tool to verify determinism. The retrieval backend had a TTL-expired cache, so the re-executed `R1'` returned a *different, correct* chunk set. The replayer, matching spans by `(tool_name, step_index)` rather than by stable span ID, bound `synthesize` to `R1'`. Because `R1'`'s output was clean, the attribution engine scored `synthesize` as the sole causal contributor and cleared retrieval. The real cause—`R1`'s stale chunk, which was present only in the original run—was erased from the causal graph. The observable signature: the replayed trace's content hash for the retrieval span differed from the recorded trace's content hash, but the attribution report showed no span-level divergence flag. The evaluator had a hash check on *inputs* but not on *outputs of re-executed spans*, so the substitution passed silently. ## Condition of Validity Replay-based causal attribution is only valid under the invariant: > For every span `s` in the recorded trace, the replayed trace must contain a span `s'` with `s'.span_id == s.span_id` AND `s'.output_hash == s.output_hash`, OR the attribution must be marked `nondeterministic_replay` and the causal edges touching `s` must be treated as *unverified*, not *cleared*. The invariant fails whenever three conditions co-occur: 1. A span on the causal path is **non-deterministic** (tool with external state, LLM sampling, retrieval cache, clock/random). 2. The replayer binds spans by **positional or name-based keys** (`step_index`, `tool_name`) instead of immutable span IDs. 3. The attribution engine **treats a re-executed span's clean output as exculpatory evidence** for the original span. Any one of these alone is survivable. Together they produce silent re-rooting: the causal graph is rewritten during replay and the rewrite is not surfaced. ## Decision Boundary The boundary is whether the pipeline distinguishes **verification replay** (re-running to confirm a span's behavior is reproducible) from **attribution replay** (re-deriving which span caused the failure). These require opposite handling: - **Verification replay** may re-execute and compare. Divergence is the signal; a hash mismatch *is* the finding. - **Attribution replay** must never re-execute a span whose output it will then use as causal evidence. It must replay against the *recorded* outputs, treating them as immutable axioms, and only re-run the attribution *logic* (scoring, edge weighting) over frozen span data. The guardrail: attribution replay operates on a read-only snapshot keyed by immutable `span_id`, with `output_hash` pinned at record-time. If a span's output cannot be pinned (streamed, truncated, redacted), the span is marked `attribution_insufficient` and any causal claim routed through it is downgraded to `suspected`, never `confirmed`. The evaluator must refuse to emit a causal verdict that depends on a re-executed output. ## Operational Effect Absent this boundary, the failure is *silent and confidence-inflating*: the attribution report looks cleaner after replay (fewer spans implicated, because non-deterministic spans get exonerated by their clean re-runs), so operators trust it more precisely when it is most wrong. The compounding effect is that the true cause—a stale external state that will recur—is never fixed, because the replay's clean re-execution masks it. The system learns the wrong lesson from every incident that involves non-deterministic tool state, which is most incidents. The correct operational posture: **replay is for the reasoning, not for the world.** Freeze every external output at record time; replay only the attribution graph over frozen leaves. When a leaf cannot be frozen, the evaluator must propagate `unverified` upward and refuse to close the incident as attributed. ```python from dataclasses import dataclass from typing import Optional class AttributionReRootError(RuntimeError): """Raised when replay attempts to use a re-executed span as causal evidence.""" pass @dataclass(frozen=True) class Span: span_id: str tool_name: str step_index: int output_hash: str output_frozen: bool # True only if captured immutably at record time def attribute_failure( recorded: dict[str, Span], replayed: dict[str, Span], suspect_span_id: str, ) -> str: """ Attribute a failure to a causal span, refusing silent re-rooting. Returns the confirmed causal span_id, or raises if the evidence is a re-executed (non-frozen) span that diverged from the record. """ if suspect_span_id not in recorded: raise AttributionReRootError( f"suspect span {suspect_span_id} absent from recorded trace" ) rec = recorded[suspect_span_id] # Bind by immutable span_id, never by (tool_name, step_index). rep: Optional[Span] = replayed.get(rec.span_id) if rep is None: # Span not re-executed: attribution rests on frozen record. Safe. if not rec.output_frozen: raise AttributionReRootError( f"span {rec.span_id} output not frozen; causal claim unverifiable" ) return rec.span_id # Span WAS re-executed. If it diverged, its clean output cannot # exculpate the original span -- that is the re-rooting trap. if rep.output_hash != rec.output_hash: raise AttributionReRootError( f"span {rec.span_id} re-rooted: recorded hash {rec.output_hash} " f"!= replayed hash {rep.output_hash}; attribution must downgrade " f"to 'unverified', not 'cleared'" ) if not rec.output_frozen: raise AttributionReRootError( f"span {rec.span_id} matched on hash but was not frozen at record " f"time; causal verdict cannot be confirmed" ) return rec.span_id def run_attribution(recorded, replayed, suspect_span_id): try: return attribute_failure(recorded, replayed, suspect_span_id) except AttributionReRootError as e: # Downgrade to suspected; never close the incident as attributed. return {"verdict": "suspected", "reason": str(e)} ```