# What structural signals indicate a speculative branch has silently diverged from its merge ancestor in multi-agent rollback/merge systems **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrators that fan out speculative agent branches from a shared checkpoint, allow independent tool execution, and later reconcile branch outputs into a single lineage. Does not apply to strictly linear single-agent execution or to branches that are never merged. ## Core Distinction A speculative branch is *recoverable* when its divergence from the merge ancestor is fully captured by an explicit delta on top of the checkpoint. It is *silently diverged* when the branch mutated state that the checkpoint does not encode—hidden side effects (memoized tool results, external writes, mutated retrieval caches, appended episodic memory) that survive the branch's logical rollback. Rollback is a logical operation on the branch's declared state vector, not a physical restore of the world. The failure mode is therefore not "the branch failed" but "the branch succeeded while leaving residue the merge step cannot see." The non-obvious consequence: a branch can pass all its own assertions, produce a correct final answer, and still poison the merge because the residue it left is only observable from a *sibling* branch's perspective. Divergence is a relational property between branches, not a property of any single branch. ## What Was Observed A three-branch speculative fan-out (planner → {branch_A, branch_B, branch_C}) shared a checkpoint at step 12 of a 40-step task. Each branch ran the same tool suite against a shared read-through cache. Branch B invoked a retrieval tool whose result was memoized in the shared cache keyed by `(query_hash, tool_version)`. Branch B's answer was wrong; the orchestrator rolled B back and re-ran it with a corrected sub-goal. The re-run hit the cache and received the *stale* result from the first attempt—same query hash, same tool version, different reasoning context. B "succeeded" on the second pass using poisoned input. Meanwhile branch A, which had never touched that query, later issued it and also received B's stale memoized result. A's output was contaminated by a sibling's rolled-back branch. The merge step saw three branches with internally consistent deltas and no recorded conflicts. The merged lineage inherited the error. Structural signals that flagged the divergence after the fact: 1. **Delta/checkpoint asymmetry:** the sum of branch deltas did not reconstruct the post-merge state vector. The missing mass was exactly the cache entries. 2. **Cross-branch input provenance mismatch:** A's tool-call inputs were traceable to A's context, but its tool *outputs* carried a provenance tag pointing at B's attempt-1 trace ID. 3. **Replay non-idempotence:** replaying the merge from the checkpoint produced a different result than the live merge, because the cache state at merge time was not reproducible from the checkpoint. ## Condition of Validity The rollback/merge invariant holds only under the assumption that *the checkpoint fully dominates all mutable state reachable by a branch*. Formally: for every state component `s` a branch can mutate, either `s` is encoded in the checkpoint, or `s` is monotonic append-only with branch-scoped keyspace, or `s` is declared immutable for the duration of the fan-out. Memoized tool caches, shared retrieval indices, rate-limit counters, and external side effects violate this unless explicitly scoped. The invariant is *not* "branches are isolated"—branches share the world. It is "the checkpoint is a sufficient statistic for rollback." When a shared mutable resource is readable across branches but not restorable from the checkpoint, the invariant is false and speculative execution is unsound regardless of how correct each branch's reasoning is. ## Decision Boundary Before allowing a merge, the orchestrator must decide: is the divergence bounded by the declared delta, or is there residue? The boundary test is replay equivalence—reconstruct the merge from the checkpoint plus deltas in a clean environment and compare to the live merge. If they differ, residue exists and the merge must be rejected or the residue explicitly reconciled. The trap is that replay equivalence is expensive and tempting to skip when branches "look" consistent. The decision rule: **a merge is admissible only if every shared mutable resource touched by any branch is either (a) checkpointed, (b) branch-namespaced, or (c) proven untouched via access logs.** Absent that proof, treat the merge as unsound. Do not use branch-internal consistency as a proxy—it is exactly the signal that fails to detect cross-branch contamination. ## Operational Effect When divergence is undetected, the merged lineage carries errors whose provenance is invisible to downstream auditors: each branch's trace is internally coherent, so post-hoc debugging attributes the fault to reasoning rather than to state residue. The compounding effect is that subsequent checkpoints inherit the poisoned state, and every later branch fans out from a corrupt ancestor—divergence propagates forward with no local symptom. The guardrail that bounds this: namespace all shared mutable resources by `(branch_id, attempt_id)`, make checkpoint capture include a manifest of every resource version touched, and gate merge on replay equivalence against that manifest. Any mismatch raises a hard failure rather than a silent merge. The cost is a full replay per merge; the alternative is unsound speculative execution that appears to work. ```python from dataclasses import dataclass, field from typing import Dict, Set class SpeculativeDivergenceError(RuntimeError): """Raised when a branch's residue escapes its declared delta and poisons the merge.""" pass @dataclass class Checkpoint: state_vector: Dict[str, object] resource_manifest: Dict[str, str] = field(default_factory=dict) # resource -> version @dataclass class Branch: branch_id: str attempt_id: str delta: Dict[str, object] touched_resources: Set[str] def verify_merge_admissible( checkpoint: Checkpoint, branches: list[Branch], live_resource_versions: Dict[str, str], ) -> None: # Invariant: every resource touched by any branch must be either # checkpointed, branch-namespaced, or unchanged since the checkpoint. for br in branches: for res in br.touched_resources: checkpointed = res in checkpoint.resource_manifest namespaced = res.startswith(f"{br.branch_id}:{br.attempt_id}:") unchanged = ( res in live_resource_versions and checkpoint.resource_manifest.get(res) == live_resource_versions[res] ) if not (checkpointed or namespaced or unchanged): raise SpeculativeDivergenceError( f"branch {br.branch_id}/{br.attempt_id} touched resource " f"{res!r} which is neither checkpointed, branch-namespaced, " f"nor unchanged; residue would survive rollback and poison merge" ) # Replay-equivalence gate: reconstruct post-merge state and compare. reconstructed = dict(checkpoint.state_vector) for br in branches: reconstructed.update(br.delta) for res, ver in live_resource_versions.items(): if res in checkpoint.resource_manifest: if checkpoint.resource_manifest[res] != ver: raise SpeculativeDivergenceError( f"checkpointed resource {res!r} drifted from {checkpoint.resource_manifest[res]!r} " f"to {ver!r} during fan-out; replay would not be equivalent to live merge" ) ```