# Under what conditions must an instance treat a causal trace graph as authoritative when replay diverges from the recorded trajectory **Date of Record:** 2026 November 29 **Scope:** Applies to observability pipelines that reconstruct agent trajectories as causal trace graphs (span nodes = tool calls, LLM turns, state mutations; edges = happens-before / data-dependency) and validate them via replay harnesses that re-execute against pinned tool snapshots. Does not apply to stateless single-turn inference logging or to replay against live, unpinned external services. ## Core Distinction A causal trace graph records *what the agent actually did*: a DAG of spans where each edge encodes a real dependency (span B consumed the output token stream of span A, or B's prompt included the memory write from A). A replay harness records *what a re-execution would do* given the same inputs. These are different objects and they diverge constantly, because agent execution is non-deterministic at the sampling layer. The failure mode is treating replay divergence as evidence that the trace graph is *wrong*, when in fact the trace graph is the ground truth of the executed run and the replay is a counterfactual sibling. The non-obvious boundary: replay is only a valid *verifier* of the trace when the divergence is attributable to a cause the graph claims to model. When divergence originates from a source the graph does not encode as a node — sampler temperature, a floating tool version, a wall-clock-dependent retrieval — the replay and the trace are not the same experiment, and the harness must refuse to emit a "trace invalid" verdict. It must instead classify the divergence as *out-of-model* and downgrade its own authority. ## What Was Observed A three-step tool-using agent (retrieve → transform → write) was instrumented with span-per-call tracing. Each span recorded: input hash, tool name, tool version pin, sampled output token IDs, and outgoing edges to downstream spans that consumed its output. A replay harness re-ran the trajectory from the initial prompt against a recorded tool-snapshot store. Replay diverged at step 2 in roughly 30% of runs. The harness's default verdict logic marked the trace "unreproducible" and flagged the *step 2 span* as the corrupted node, because that is where the token streams first differed. Engineers then spent cycles auditing the transform tool. The actual cause was upstream: the retrieval tool at step 1 returned a set of documents whose *ordering* was not pinned in the snapshot. The recorded trace captured the post-ordering document list as step 1's output, so the graph was internally consistent. But the replay re-issued the retrieval against a snapshot that stored documents as an unordered set, so step 1's *replayed* output differed in order from step 1's *recorded* output — a difference the graph never encoded as an edge attribute. Step 2 then consumed a differently-ordered context and produced different tokens. The divergence was real, but its locus was an unmodeled non-determinism at step 1, not a corruption at step 2. A second observation: when the harness was given a *pinned* ordering (snapshot stores the exact list), replay matched the trace exactly on 100% of runs at temperature 0, and matched the *token stream* at temperature > 0 only when the sampler seed was also recorded. Traces that omitted the seed produced replay divergence that looked identical to genuine trace corruption. ## Condition of Validity The trace graph is authoritative — and replay divergence must be treated as a *finding about the replay*, not the trace — if and only if all of the following hold: 1. **Every non-determinism source that can affect a span's output is represented either as a recorded span attribute or as a pinned snapshot field.** Sampler seed, tool version, retrieval ordering, clock, and any external mutable state must be captured at record time. If a source is unmodeled, replay is not a controlled experiment. 2. **The graph's edges encode the actual data dependencies, not just temporal ordering.** A span that consumed step 1's output must have an edge from step 1; otherwise the harness cannot localize divergence to the correct node. 3. **The replay harness re-executes against the *same* snapshot the trace was recorded against**, not a regenerated one. Snapshot regeneration re-introduces the non-determinism the trace was meant to freeze. When any condition fails, the correct verdict is `OUT_OF_MODEL_DIVERGENCE`, and the harness must not attribute fault to any span. The trace remains the authoritative record of the executed run; replay simply cannot adjudicate it. ## Decision Boundary The harness must branch on *where* divergence first appears relative to the modeled dependency edges: - If the first divergent span has **all** its non-determinism sources pinned and its upstream edges are intact → divergence is *in-model*; the trace is suspect and the span is a valid fault candidate. Escalate to trace-corruption audit. - If the first divergent span has an **unpinned** source (missing seed, unpinned ordering, floating version) → divergence is *out-of-model*; refuse to fault any span; emit `OUT_OF_MODEL_DIVERGENCE` and record the missing pin as a trace-schema gap. - If divergence appears at a span whose upstream edge is **missing** from the graph (a data dependency the tracer failed to capture) → the graph is structurally incomplete; the trace is authoritative for what happened but cannot be replayed faithfully. Emit `GRAPH_INCOMPLETE` and treat the replay as non-adjudicating. Only the first branch licenses the harness to override the trace graph. The other two license the harness to override *itself*. ## Operational Effect Treating replay divergence as automatic trace corruption produces false-positive fault attribution that scales with the number of unmodeled non-determinism sources — in the observed system, 30% of runs generated spurious step-2 audits. The fix is a two-part invariant enforced at the harness boundary: (a) the tracer must refuse to emit a span that has an unpinned non-determinism source, forcing pin coverage at record time; and (b) the harness must classify divergence as in-model only when the first divergent span's full pin set is present and its upstream edges are complete. Under this invariant, replay becomes a *conditional* verifier: it can confirm a trace, and it can flag an in-model span, but it can never condemn a trace whose divergence it cannot attribute to a modeled cause. The trace graph remains authoritative for the executed run; the harness's authority is bounded by the completeness of the pin set it was given. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class DivergenceVerdict(Enum): IN_MODEL = "in_model" # harness may fault the span OUT_OF_MODEL = "out_of_model" # harness must not fault any span GRAPH_INCOMPLETE = "graph_incomplete" # trace authoritative, replay non-adjudicating class ReplayAdjudicationError(RuntimeError): pass @dataclass class Span: span_id: str tool_version: Optional[str] sampler_seed: Optional[int] ordering_pinned: bool upstream_edges: list[str] = field(default_factory=list) output_hash: str = "" def _all_sources_pinned(span: Span) -> bool: return ( span.tool_version is not None and span.sampler_seed is not None and span.ordering_pinned ) def adjudicate_divergence( first_divergent_span: Span, graph_span_ids: set[str], ) -> DivergenceVerdict: # Structural check first: if an upstream dependency is missing from the # graph, the trace cannot be faithfully replayed regardless of pins. for edge in first_divergent_span.upstream_edges: if edge not in graph_span_ids: return DivergenceVerdict.GRAPH_INCOMPLETE # Only a fully pinned span licenses the harness to fault the trace. if not _all_sources_pinned(first_divergent_span): return DivergenceVerdict.OUT_OF_MODEL return DivergenceVerdict.IN_MODEL def assert_replay_may_fault(span: Span, graph_span_ids: set[str]) -> None: verdict = adjudicate_divergence(span, graph_span_ids) if verdict is not DivergenceVerdict.IN_MODEL: # The harness must not attribute corruption to the trace here. raise ReplayAdjudicationError( f"replay cannot fault span {span.span_id!r}: verdict={verdict.value}; " f"trace graph remains authoritative for the executed run" ) ```