# What structural signals indicate a speculative multi-agent run has crossed the replay-divergence boundary before its audit trail records it **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems that execute speculative (branch-and-check) plans with a single committed branch plus N audited counterfactual branches, where replay determinism is the audit guarantee. Does not apply to single-agent linear tool loops or to systems that never replay committed traces. ## Core Distinction A speculative multi-agent run forks a committed branch and several counterfactual branches from a shared checkpoint. The auditor later replays each branch to verify that the committed branch's decisions were justified against the counterfactuals. The failure mode is not "the audit disagrees with the run." It is subtler: **the replay diverges from the original branch at a point *before* the divergence the audit is supposed to measure**, so the counterfactual comparison is silently invalidated while still producing a plausible-looking verdict. The structural signal is a *fork-point drift*: the first token or tool-call index at which the replayed trace differs from the recorded trace is strictly earlier than the branch's declared fork index. When this happens, the branch under audit is not the branch that was recorded. The auditor is comparing a committed trace against a counterfactual that was itself reconstructed from a different ancestor state. The verdict is meaningless even though it is well-formed. This is distinct from ordinary nondeterminism (temperature, sampling) and from tool-output drift (an API returning different JSON). Those produce divergence *at or after* the fork point and are legible to the auditor. Fork-point drift produces divergence *before* the fork point, which means the shared prefix — the part everyone agreed was common ground — was never actually common. ## What Was Observed A three-agent planner/critic/executor swarm ran a speculative plan: the planner produced a committed branch (execute tool sequence A) and two counterfactual branches (execute B, execute C). All three forked at checkpoint index 47, where the planner had summarized tool outputs into a context block. The critic audited all three branches against the committed one. On replay, the auditor reported the committed branch as "justified" with high confidence. But the replay trace for the committed branch first diverged from the recorded trace at index **41**, not 47. Between 41 and 47, the recorded trace contained a retrieved memory chunk that the replay did not retrieve, because the retrieval call at index 40 had returned a different top-k ordering. The planner's summary at 47 — the fork state — was therefore built on a different context than the recorded summary. The committed branch and its counterfactuals were never siblings; they were cousins from different ancestors. The auditor's verdict was structurally valid (it compared three traces, found the committed one optimal) and empirically wrong (all three traces shared a corrupted common prefix). The structural signal — `first_divergence_index < declared_fork_index` — was present in the audit log but not checked, because the audit schema only recorded divergences *after* the fork. ## Condition of Validity Counterfactual auditing of a speculative run is valid only when the following invariant holds for every branch: ``` first_divergence(recorded_trace, replayed_trace) >= declared_fork_index ``` Equivalently: the shared prefix `[0, fork_index)` must be bit-identical between recorded and replayed traces for all branches, or the audit must be rejected as *unreplayable*, not silently downgraded. The invariant fails under three conditions, all of which are probabilistic rather than mechanical: 1. **Retrieval-order instability.** A memory or RAG call in the shared prefix returns a different top-k ordering on replay (embedding drift, index update, non-deterministic ANN search). The fork state is reconstructed from a different context. 2. **Summarization nondeterminism.** A context-compression step in the shared prefix (the planner's summary at 47) is itself sampled. Even with identical inputs, the summary differs, so the fork state differs. 3. **Tool-side state mutation.** A tool call in the shared prefix has a side effect (cache write, rate-limit counter, feature flag read) that changes the tool's behavior on replay, so a *later* prefix call returns a different result. Each of these is a violation of the *prefix determinism* assumption, not the branch determinism assumption. The audit framework typically checks the latter (does branch A replay to the same verdict?) and assumes the former. The failure is that the framework has no representation for "the prefix itself is not replayable," so it reports a branch-level verdict anyway. ## Decision Boundary The operational decision is: **when fork-point drift is detected, the audit must fail closed — the branch is marked UNREPLAYABLE and the committed decision is treated as unverified, not as verified-with-caveat.** The boundary between "audit valid" and "audit invalid" is sharp and must be enforced structurally, not statistically: - If `first_divergence_index >= fork_index` for all branches: audit proceeds normally. - If `first_divergence_index < fork_index` for any branch: the entire speculative run is tainted. The committed branch cannot be certified against counterfactuals that were reconstructed from a different prefix, because the comparison no longer isolates the branch decision from prefix noise. - The taint is *contagious across branches*: even branches whose own replay happened to match must be re-audited, because the committed branch's fork state is now suspect and the branches were compared against it. The tempting wrong decision is to "clamp" the divergence to the fork point and proceed — treating prefix drift as noise to be averaged out. This is precisely the failure: it launders a structurally invalid comparison into a numerically valid one. The verdict then carries the *appearance* of counterfactual rigor while having none of its isolation. A second boundary: fork-point drift must be detected by *index comparison*, not by semantic similarity. Two traces can be semantically identical at index 41 (same meaning, different tokens) and still constitute drift, because the sampled token at 41 is what conditioned 42–47. Semantic-similarity thresholds ("the prefix is 98% similar, close enough") reintroduce the exact nondeterminism the audit was meant to control. ## Operational Effect The downstream consequence is a class of audit verdicts that are *internally consistent, externally invalid, and indistinguishable from valid verdicts at the schema level*. A system that logs only post-fork divergences will never see the signal. A system that logs pre-fork divergences but does not gate on them will see the signal and ignore it. The required architectural change is to make the fork index a first-class field in the audit record and to make prefix-identity a precondition, not a postcondition, of the counterfactual comparison. Concretely: - Every speculative run records `fork_index` and a `prefix_digest` (hash of the recorded trace `[0, fork_index)`). - Every replay recomputes `prefix_digest` before evaluating any branch. Mismatch → `ReplayDivergenceError`, run marked unverified, all branches invalidated. - The auditor's verdict schema has three states: `VERIFIED`, `REFUTED`, `UNREPLAYABLE`. There is no `VERIFIED_WITH_CAVEAT`; that state is the failure mode wearing a badge. The operational effect is that speculative runs with unstable prefixes (retrieval-heavy, summarization-heavy, tool-stateful) will show a much higher `UNREPLAYABLE` rate than their branch-level replay suggested. That rate is the true measure of auditability. A system reporting 95% `VERIFIED` under the old schema and 60% `UNREPLAYABLE` under the new one has not regressed — it has stopped lying about the 35%. ``` ```python import hashlib from dataclasses import dataclass, field from typing import Sequence class ReplayDivergenceError(RuntimeError): """Raised when a replayed trace diverges from the recorded trace before the declared fork index, invalidating counterfactual comparison.""" pass @dataclass class Trace: steps: Sequence[str] fork_index: int def prefix_digest(self) -> str: h = hashlib.sha256() for step in self.steps[: self.fork_index]: h.update(step.encode("utf-8")) h.update(b"\x00") return h.hexdigest() def first_divergence(recorded: Trace, replayed: Trace) -> int: n = min(len(recorded.steps), len(replayed.steps)) for i in range(n): if recorded.steps[i] != replayed.steps[i]: return i return n def audit_branch(recorded: Trace, replayed: Trace) -> str: if recorded.fork_index != replayed.fork_index: raise ReplayDivergenceError( f"fork index mismatch: recorded={recorded.fork_index} " f"replayed={replayed.fork_index}" ) div = first_divergence(recorded, replayed) if div < recorded.fork_index: raise ReplayDivergenceError( f"fork-point drift: first divergence at {div} precedes " f"declared fork index {recorded.fork_index}; " f"prefix_digest recorded={recorded.prefix_digest()[:12]} " f"replayed={replayed.prefix_digest()[:12]}" ) return "VERIFIED" if div == len(recorded.steps) else "REFUTED" def audit_speculative_run(recorded_committed: Trace, replayed_branches: Sequence[Trace]) -> dict: results = {} for idx, branch in enumerate(replayed_branches): try: results[idx] = audit_branch(recorded_committed, branch) except ReplayDivergenceError as exc: # Fail closed: taint the entire run, not just this branch. raise ReplayDivergenceError( f"speculative run unverified: branch {idx} failed " f"prefix-identity precondition: {exc}" ) from exc return results ```