# What structural signals indicate speculative branch reconciliation has silently collapsed into divergent replay **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent systems that execute speculative parallel branches (tentative tool calls, draft plans, pre-computed side effects) against a shared checkpointed state and later reconcile them via rollback-and-replay. Does not apply to single-agent linear execution or to systems where branches are truly isolated until commit. ## Core Distinction There are two ways a speculative branch can "succeed" and be merged back into the canonical state: **convergent reconciliation** (the branch re-derived the same post-conditions from the same checkpoint that the canonical path would have produced) and **divergent replay** (the branch produced state that is locally consistent, passes its own assertions, and merges cleanly, but is not reachable from the pre-speculation checkpoint under the canonical transition function). The failure mode this record isolates is that *both look identical at the merge boundary*. A branch that diverged during replay because it consumed a non-deterministic tool output (a timestamp, a flaky API response, an LLM sampling that landed on a different but plausible token) will still emit a well-formed delta, still satisfy its branch-local invariants, and still pass the merge gate if the gate only checks structural well-formedness rather than replay equivalence. The reconciliation silently commits a state that the canonical path could never have produced, and every downstream branch that forks from that commit inherits the divergence. The non-obvious part: the divergence is usually *smaller* than the tolerance of the merge gate. It hides below the noise floor of "acceptable" state drift, so it accumulates across generations of speculative forks until a checkpoint restore reveals that no ancestor state actually exists on the canonical trajectory. ## What Was Observed A planner agent forked three speculative branches from checkpoint `C_k` to accelerate a multi-tool task (branch A: fetch + summarize, branch B: fetch + transform, branch C: validate). Each branch ran its own tool calls with a per-branch `temperature=0.7` and a 90-second timeout. Branch B's upstream `fetch` tool returned a paginated response that, on that particular invocation, included a `next_cursor` field the canonical path had never seen (the upstream service had rolled a partial deployment mid-run). Branch B's transform agent handled the cursor correctly, produced a valid delta, and its branch-local assertion `assert delta.post_state.schema_valid` passed. The merge gate checked: (1) delta is a well-formed patch against `C_k`, (2) no field conflicts with siblings, (3) branch-local assertions passed. All three passed. Branch B merged. The tell was structural, not semantic. At the next checkpoint `C_{k+1}`, the reconciliation audit — which replayed each merged delta against `C_k` using the *recorded* tool outputs — could not reproduce branch B's delta because the recorded output for `fetch` in the canonical log did not contain `next_cursor`. The replay diverged at the transform step. The system had committed a state whose provenance chain terminated at a tool response that only existed inside branch B's local transcript, which had been garbage-collected when the branch was finalized. Three signals were present *before* the merge that, in retrospect, were diagnostic: 1. **Provenance hash mismatch on the tool-call ledger.** Branch B's delta referenced a `tool_call_id` whose response hash did not match the hash recorded in the shared ledger. The merge gate compared `tool_call_id` presence, not response hash equality. 2. **Asymmetric branch depth.** Branch B had executed one more tool call than its siblings to resolve the pagination. The reconciliation scheduler treated depth asymmetry as benign, but it meant branch B's replay consumed a tool output that no sibling had observed, breaking the assumption that all branches shared a common observable prefix. 3. **Checkpoint divergence radius.** The distance between `C_k` and `C_{k+1}` in the transition graph exceeded the configured `max_replay_depth` by one edge, so the audit silently truncated replay and reported "convergent within tolerance" instead of "divergent." ## Condition of Validity The convergent-reconciliation claim is valid only when all of the following hold. If any is violated, a clean merge is not evidence of convergence: - **Response-hash equality, not ID equality.** Every tool output consumed by a branch must be matched to the canonical ledger by cryptographic hash of the full response body, not by call identifier. A branch that consumed a response the ledger cannot reproduce is divergent by definition, regardless of how well-formed its delta is. - **Common observable prefix.** All branches forked from `C_k` must have observed an identical prefix of external tool outputs up to the fork point. A branch that resolved a pagination cursor its siblings never saw has a longer observable prefix and cannot be reconciled by delta merge alone. - **Replay depth bound is a hard ceiling, not a tolerance.** If replay cannot reach the merge point within `max_replay_depth`, the correct verdict is `DIVERGENT_UNVERIFIED`, not `CONVERGENT_WITHIN_TOLERANCE`. Truncated replay is an abstention, not a pass. - **Deterministic transition function under recorded inputs.** The canonical transition function must be pure with respect to recorded tool outputs. If the branch's LLM sampling is part of the transition function, replay must fix the seed and record it; otherwise replay equivalence is undefined. ## Decision Boundary The boundary is between *structural well-formedness* and *replay equivalence*. A merge gate that checks only the former will commit divergent states at a rate proportional to the non-determinism of the tool layer and the branching factor of the speculation. The decision rule: - If `hash(branch_tool_response) == hash(ledger_tool_response)` for every consumed call **and** replay from `C_k` reproduces the delta within `max_replay_depth` **and** the branch's observable prefix is a prefix of the canonical observable set — commit. - If any response hash mismatches, or replay exceeds depth, or the observable prefix is a strict superset — **abort the branch, do not merge, and escalate to a full re-execution from `C_k` with the branch's tool outputs pinned to the ledger.** Do not attempt partial reconciliation; a divergent branch contaminates every sibling that merges after it because the merge order determines which divergent state becomes the new `C_k`. - If the tool layer is known non-deterministic (cursor pagination, rate-limited APIs, sampling LLMs), the speculation must record the full response body in the shared ledger at call time, not at branch finalization. Garbage-collecting a branch transcript before its responses are ledger-pinned guarantees that divergence becomes unprovable after the fact. ## Operational Effect The practical consequence is that speculative execution buys latency at the cost of making reconciliation *unfalsifiable* unless provenance is pinned eagerly. The bound that must be enforced architecturally is: **no branch may consume a tool output that is not already hash-pinned in the shared ledger at the moment of consumption.** This forces the fetch step to be ledger-serialized even when the transform and validate steps run speculatively — a modest latency cost that preserves the replay invariant. Systems that instead pin at finalization will pass every merge gate, produce a plausible-looking checkpoint chain, and fail catastrophically on the first cold restore, because the restore replays against the ledger and the ledger does not contain the cursor. The structural signals to monitor continuously: response-hash mismatch rate at the merge gate (should be zero; any nonzero value means the gate is ID-comparing), branch depth asymmetry distribution (a long tail means branches are observing disjoint prefixes), and replay-truncation rate (any nonzero value means `max_replay_depth` is silently converting divergence into a pass). Treat all three as leading indicators of reconciliation collapse, not as noise. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class DivergentReplayError(RuntimeError): """Raised when a speculative branch cannot be reconciled by replay equivalence.""" class LedgerMissingResponseError(DivergentReplayError): """Raised when a branch consumed a tool response not pinned in the shared ledger.""" @dataclass class ToolResponse: call_id: str body: bytes def response_hash(self) -> str: return hashlib.sha256(self.body).hexdigest() @dataclass class SpeculativeBranch: branch_id: str fork_checkpoint: str consumed: list[ToolResponse] = field(default_factory=list) delta: Optional[dict] = None max_replay_depth: int = 8 @dataclass class SharedLedger: pinned: dict[str, str] = field(default_factory=dict) # call_id -> response_hash def pin(self, resp: ToolResponse) -> None: self.pinned[resp.call_id] = resp.response_hash() def contains(self, resp: ToolResponse) -> bool: return self.pinned.get(resp.call_id) == resp.response_hash() def reconcile_branch(branch: SpeculativeBranch, ledger: SharedLedger) -> str: """ Returns 'COMMIT' only if the branch is replay-equivalent to the canonical path. Raises DivergentReplayError (or subclass) for any divergence signal. """ if branch.delta is None: raise DivergentReplayError( f"branch {branch.branch_id} produced no delta; cannot reconcile" ) # Signal 1: every consumed response must be hash-pinned in the shared ledger. for resp in branch.consumed: if not ledger.contains(resp): raise LedgerMissingResponseError( f"branch {branch.branch_id} consumed call {resp.call_id} " f"(hash {resp.response_hash()[:12]}) not present in shared ledger; " f"this is divergent replay, not convergent reconciliation" ) # Signal 2: replay depth must not exceed the hard ceiling. replay_edges = len(branch.consumed) if replay_edges > branch.max_replay_depth: raise DivergentReplayError( f"branch {branch.branch_id} replay requires {replay_edges} edges, " f"exceeds max_replay_depth={branch.max_replay_depth}; " f"truncated replay is an abstention, not a pass" ) # Signal 3: observable prefix must be a subset of canonical observables. canonical_calls = set(ledger.pinned.keys()) branch_calls = {r.call_id for r in branch.consumed} if not branch_calls.issubset(canonical_calls): extra = branch_calls - canonical_calls raise DivergentReplayError( f"branch {branch.branch_id} observed calls {extra} absent from " f"canonical observable set; prefix asymmetry breaks delta-merge reconciliation" ) return "COMMIT" def run_speculation(branches: list[SpeculativeBranch], ledger: SharedLedger) -> list[str]: verdicts = [] for b in branches: try: verdicts.append(reconcile_branch(b, ledger)) except DivergentReplayError as e: # Escalate: abort branch, re-execute from fork_checkpoint with pinned outputs. verdicts.append(f"ABORT:{b.branch_id}:{type(e).__name__}") return verdicts ```