# What structural signals indicate that deterministic replay of a speculative multi-agent plan has silently diverged from the executed trace **Date of Record:** 2026 November 30 **Scope:** Applies to post-incident forensic replay of multi-agent plans that were executed under speculative parallelism (peer/auditor fan-out, baton-passing, or MCP tool-call branches), where the replay engine reconstructs the trace from a recorded event log rather than re-executing against live state. Does not apply to single-agent linear traces, nor to replays that re-execute against the original nondeterministic tool endpoints. ## Core Distinction The failure mode is not "the replay produced a different final answer." A replay that reaches a different terminal state is *loud* — it announces its divergence and an operator notices. The dangerous boundary is **silent structural divergence**: the replay completes, emits a well-formed trace, reports the *same* terminal verdict as the original run, and yet the causal ordering, branch-selection, or verification-attribution inside the trace differs from what actually executed. The final answer agrees; the *path* does not. Because forensics consumes the path (who approved what, which auditor gated which tool call, which speculative branch was abandoned), a replay that agrees on the verdict while disagreeing on structure will confidently attribute a fault to the wrong agent. The invariant under attack is: **for a forensic replay to be admissible, the reconstructed causal DAG must be isomorphic to the executed causal DAG — not merely trace-equivalent at the terminal node.** Speculative execution breaks this because the recorded log contains the *losing* branches (they were launched, they consumed tokens, they emitted partial verdicts) alongside the winning branch, and the replay engine must decide which branches were on the committed causal path. That decision is where divergence hides. ## What Was Observed A three-agent swarm — planner `P`, peer workers `W1`/`W2` launched speculatively in parallel, and auditor `A` — executed a plan where `W2` finished first and its output was committed, while `W1` was cancelled mid-flight. The event log faithfully recorded: `W1.spawn`, `W2.spawn`, `W2.complete(t=412ms)`, `P.commit(W2)`, `W1.cancel(t=520ms)`. Crucially, `W1` had already emitted a partial tool call `W1.tool_call(search, q=...)` at `t=390ms` — *before* `W2.complete` — whose result was discarded when `W1` was cancelled. On replay, the engine reconstructed the trace and produced a terminal verdict identical to the original (`A` approved `W2`'s output). But three structural signals were wrong: 1. **Orphaned side-effect attribution.** The replay re-ordered `W1.tool_call` to *after* `P.commit(W2)`, because the replay engine sorted events by their *completion* timestamp rather than their *emission* timestamp. The discarded search call was therefore attributed to a post-commit phase, making it look like `W1` continued working after being logically cancelled — a phantom "zombie worker" that a forensic reviewer would flag as a resource leak that never existed. 2. **Auditor gating inversion.** `A` had gated on `W2`'s output only. But the replay, seeing `W1`'s partial output present in the log, reconstructed `A` as having gated on the *union* of both workers. The verdict agreed; the attribution of *which evidence the auditor weighed* did not. A downstream root-cause analysis would conclude the auditor was exposed to uncommitted speculative output — a real class of bug — when in fact it was not. 3. **Cancellation causality loss.** The log recorded `W1.cancel` but not *why*. The replay engine, lacking the causal edge `W2.complete → P.commit → W1.cancel`, inferred cancellation from a timeout heuristic and stamped `W1.cancel` with a synthetic `reason=timeout`. The true reason was *supersession*. The structural signal — a cancellation edge whose parent is a commit, not a clock — was erased. None of these changed the terminal verdict. All three corrupted the forensic record. ## Condition of Validity Deterministic replay is only structurally faithful when the event log carries **causal edges, not just timestamps**, and when the replay engine reconstructs the DAG from those edges rather than from wall-clock ordering. Concretely, replay is valid iff: - Every `cancel` event carries an explicit `cause` edge to the event that triggered it (commit, preemption, or timeout), and the replay refuses to synthesize a cause when the edge is absent. - Every `tool_call` is stamped with an *emission* sequence number assigned at dispatch, independent of completion time — so a call that was dispatched-but-discarded is ordered by dispatch, not by the (possibly absent) completion. - The auditor's gate set is recorded as an explicit *evidence set* (the IDs of the outputs it actually consumed), not inferred from what was present in the log at gate time. When any of these is missing, the replay is *trace-equivalent but not DAG-isomorphic*, and the divergence is silent by construction: the engine fills the gap with a plausible heuristic, and plausible heuristics reproduce the verdict while corrupting the path. The condition of validity is therefore not "the log is complete" but "the log is *causally* complete for every event whose ordering is load-bearing." ## Decision Boundary The boundary between admissible and inadmissible replay is drawn at the first event whose causal parent is absent from the log. The operational rule: - If a replay encounters an event with a missing causal parent **and** that event lies on the committed causal path (i.e., it influenced the terminal verdict or the auditor's evidence set), the replay must **abort as inadmissible** rather than heuristic-fill. A verdict that agrees by luck is worse than no verdict, because it launders a corrupted path as authoritative. - If the missing-parent event lies on an *abandoned* branch (a losing speculative worker), the replay may proceed but must **quarantine** that branch: mark it `non-causal`, exclude it from evidence-set reconstruction, and never attribute side effects from it to the committed phase. The subtle trap: an abandoned-branch event can *become* load-bearing if the auditor's evidence set is reconstructed by inference rather than read from the log. This is the exact mechanism by which signal #2 above occurred — a quarantined branch leaked into the auditor's gate set because the gate set was inferred, not recorded. The decision boundary is therefore not per-event but **per-edge**: an edge from a quarantined branch into the committed path is itself the violation, and its presence must force inadmissibility regardless of where the terminal verdict landed. ## Operational Effect When this boundary is respected, forensic replay yields a record that can be used to attribute fault, replay counterfactuals ("what if `W1` had won the race"), and audit the auditor. When it is violated, the failure is *anti-correlated with severity*: the more speculative parallelism in the original run, the more abandoned branches exist to leak, and the more confidently the replay will misattribute. A high-fan-out swarm — precisely the configuration most likely to need forensics — produces the most corrupted replay while reporting the highest confidence, because verdict agreement is treated as a proxy for replay fidelity. The guardrail is to make the replay engine **fail closed on causal incompleteness**: refuse to emit a trace at all if any committed-path event lacks a causal parent, and refuse to reconstruct any evidence set by inference. The cost is that some incidents become unreplayable (the log was causally incomplete). That cost is correct: an unreplayable incident is an honest gap, whereas a silently divergent replay is a fabricated record that will be cited in a postmortem as fact. ```python from dataclasses import dataclass, field from typing import Optional class ReplayDivergenceError(RuntimeError): """Raised when a forensic replay would be trace-equivalent but not DAG-isomorphic.""" @dataclass class Event: id: str kind: str # spawn | complete | commit | cancel | tool_call | gate cause: Optional[str] # causal parent event id; None == causally orphaned branch: str # committed | abandoned evidence_set: Optional[frozenset] = None # only for gate events def reconstruct_causal_path(events: list[Event], terminal_id: str) -> list[Event]: by_id = {e.id: e for e in events} path: list[Event] = [] frontier = [terminal_id] seen: set[str] = set() while frontier: eid = frontier.pop() if eid in seen: continue seen.add(eid) ev = by_id.get(eid) if ev is None: raise ReplayDivergenceError(f"event {eid} referenced but absent from log") # Committed-path event with no causal parent => inadmissible, fail closed. if ev.branch == "committed" and ev.cause is None and ev.kind != "spawn": raise ReplayDivergenceError( f"committed-path event {ev.id} ({ev.kind}) has no causal parent; " f"replay would heuristic-fill and silently diverge" ) # Gate evidence sets must be recorded, never inferred. if ev.kind == "gate" and ev.evidence_set is None: raise ReplayDivergenceError( f"gate {ev.id} lacks recorded evidence_set; inference would leak " f"abandoned branches into the committed path" ) # A committed-path edge must not originate from an abandoned branch. if ev.cause is not None: parent = by_id.get(ev.cause) if parent is None: raise ReplayDivergenceError(f"cause {ev.cause} of {ev.id} missing from log") if parent.branch == "abandoned" and ev.branch == "committed": raise ReplayDivergenceError( f"abandoned branch event {parent.id} feeds committed event {ev.id}; " f"quarantine violated" ) frontier.append(ev.cause) path.append(ev) return list(reversed(path)) ```