# What structural signals indicate speculative branch divergence has outrun the rollback frontier in multi-agent branch-and-verify execution **Date of Record:** 2026 December 3 **Scope:** Applies to multi-agent systems that fork speculative execution branches across worker agents, verify branch outputs against a shared committed state, and roll back diverging branches before reconciling conflicts. Does not apply to single-agent linear execution, stateless fan-out with no shared commit log, or systems where branches never share mutable state. ## Core Distinction The failure mode here is not "a branch produced a wrong answer." It is that the *rollback frontier*—the earliest committed sequence point to which the system can safely rewind a diverging branch—has silently fallen behind the *speculation frontier*, the furthest point any branch has speculatively advanced. When speculation outruns rollback, a branch that later fails verification cannot be cleanly unwound because its speculative writes have already been read by sibling branches and folded into their own speculative state. The system believes it holds a rollback capability it no longer has. This is distinct from ordinary conflict reconciliation. Reconciliation assumes all branches are individually revertible and the conflict is over *which* committed value wins. Rollback-frontier overrun means the conflict is over whether a value *can be un-derived at all*—the branch's effects have propagated transitively into peers, and reverting the origin does not revert the descendants. The invariant that breaks is: *every speculative write must remain attributable to exactly one live branch until verification or rollback*. Overrun is the state where a write has acquired multiple speculative parents. ## What Was Observed A three-worker speculative fan-out (workers W1, W2, W3) forked from commit point C0. Each worker ran a plan segment and wrote speculative deltas to a shared scratch ledger keyed by `(branch_id, seq)`. - W1 speculatively advanced to seq 40 and wrote a value `v_a` at key `K`. - W2, whose plan read `K` as an input, observed W1's *speculative* value (the read path did not distinguish committed from speculative entries) and derived `v_b` at seq 22, then wrote `v_b` into its own delta set. - W3 read `v_b` and derived `v_c` at seq 15. W1's branch then failed verification at seq 40 (a downstream tool returned a value contradicting `v_a`). The reconciler correctly marked W1 for rollback to C0. But rollback of W1 only removed W1's delta entries. W2's `v_b` and W3's `v_c` remained in the ledger, now *orphaned*: their derivation inputs no longer existed in any live branch, yet they were syntactically well-formed and passed their own local verification because W2 and W3 verified against their own recorded inputs, not against the post-rollback ledger. The observable structural signals at the moment of overrun were: 1. **Cross-branch read edges into speculative entries.** The ledger's read log showed W2→W1 and W3→W2 edges where the target entry had `status=speculative` at read time. This is the primary signal: any read of a speculative entry by a *different* branch creates a potential rollback dependency. 2. **Rollback frontier seq < speculation frontier seq.** The reconciler's `rollback_frontier` (max seq safely revertible) sat at C0's seq while branches had advanced to seq 40/22/15. The gap is the overrun window. 3. **Orphaned derivation records after a rollback pass.** Post-rollback, entries existed whose `derived_from` set contained keys with no live producer. These are the smoking gun—they indicate the rollback did not cascade. 4. **Verification replay divergence.** Replaying W3's verification against the post-rollback ledger produced a different result than the original run, because `v_b`'s provenance was now dangling. The replay mismatch is a *late* signal; by the time it appears, the orphaned writes may already have been committed by a fast-path merger. The critical non-obvious point: **the system's local verification passed on every individual branch.** W2 verified `v_b` against its recorded inputs and succeeded; W3 verified `v_c` likewise. The failure was invisible to per-branch verification because verification is scoped to a branch's own derivation chain, not to the global liveness of that chain's roots. Overrun is a *global* property that no *local* verifier can detect. ## Condition of Validity The overrun failure requires all of the following to hold simultaneously; remove any one and the failure is bounded: - **Speculative reads are visible across branches.** If branches read only committed state (snapshot isolation at fork time), no cross-branch derivation edge can form and rollback is always local. This is the strongest guardrail and the one most systems omit for latency reasons. - **Rollback is non-cascading.** The rollback procedure removes the failed branch's own writes but does not transitively invalidate entries that read those writes. Cascading rollback (or its cheaper cousin, marking dependents dirty) closes the window. - **Verification is branch-local.** If verification replays against the global ledger including provenance liveness, orphaned entries fail verification and the overrun is caught at verify time rather than at merge time. - **A fast-path merger can commit before reconciliation.** If all merges wait for a global reconciliation barrier, orphaned entries never reach committed state. The condition is *invalid* (failure cannot occur) when speculative state is branch-private until a single atomic publish, or when the reconciler maintains a reverse index from every ledger key to its dependent branches and cascades invalidation on rollback. ## Decision Boundary The operational decision is: **when a branch fails verification, do you roll back only that branch, or do you invalidate its transitive speculative read-dependents?** The boundary is governed by whether the reconciler can compute the dependent set cheaply and correctly: - **Roll back only the branch** when the ledger maintains a complete cross-branch read log *and* no dependent has already been committed. In this regime, orphaned dependents are detectable and can be re-derived or re-speculated. - **Cascade invalidation** when any dependent has advanced past the rollback frontier or when the read log is incomplete. Cascading is more expensive (it may invalidate healthy branches) but is the only safe choice when attribution is lossy. - **Halt speculation entirely** when the rollback frontier cannot be advanced to meet the speculation frontier—i.e., when failed branches cannot be unwound at all because their effects are entangled beyond the reconciler's ability to attribute. This is the hard stop; continuing to speculate compounds orphaned writes. The precise trigger for cascade-vs-local: if the failed branch's speculative writes have any inbound cross-branch read edges whose readers are still live, local rollback is unsafe. The reconciler must compute this set before removing any entry, because removing the origin first destroys the evidence needed to find dependents. ## Operational Effect Left unguarded, overrun produces a specific and dangerous class of committed corruption: values whose derivation chains are broken but whose local verification records are intact. These are worse than ordinary wrong answers because they carry *plausible provenance*—the ledger shows `v_c` derived from `v_b` derived from `v_a`, all with passing verification stamps, while `v_a` no longer exists. Downstream consumers replaying the chain hit a missing root and either fail late (expensive) or, worse, treat the dangling reference as committed-and-immutable and propagate the corruption further. The architectural invariant required to bound this is a **monotonic rollback frontier with a dependent index**: the reconciler tracks the maximum seq it can safely revert, refuses to let any branch's speculative reads create edges that would push that frontier behind the speculation frontier without first recording the dependency, and on any rollback computes the transitive dependent closure *before* mutating the ledger. When the closure cannot be computed (incomplete read log, committed dependents), the system must halt speculation and escalate rather than proceed—because the alternative is silent, provenance-laundered corruption that per-branch verification will never catch. ```python from dataclasses import dataclass, field from typing import Dict, Set, List class RollbackFrontierOverrun(RuntimeError): """Raised when speculative branches have read each other's uncommitted writes such that a failed branch cannot be cleanly rolled back without orphaning live dependents.""" pass @dataclass class LedgerEntry: branch_id: str seq: int key: str status: str # "speculative" | "committed" | "rolled_back" derived_from: Set[str] = field(default_factory=set) readers: Set[str] = field(default_factory=set) # branch_ids that read this class SpeculativeLedger: def __init__(self, commit_point_seq: int): self.entries: Dict[str, LedgerEntry] = {} self.rollback_frontier = commit_point_seq self.speculation_frontier = commit_point_seq self.read_log_complete = True def record_speculative_write(self, entry: LedgerEntry): self.entries[entry.key] = entry self.speculation_frontier = max(self.speculation_frontier, entry.seq) def record_cross_branch_read(self, reader_branch: str, target_key: str): target = self.entries.get(target_key) if target is None: self.read_log_complete = False return if target.branch_id != reader_branch and target.status == "speculative": target.readers.add(reader_branch) def _dependent_closure(self, origin_key: str) -> Set[str]: """Transitive set of keys whose derivation roots include origin_key.""" closure: Set[str] = set() frontier = [origin_key] while frontier: k = frontier.pop() for key, e in self.entries.items(): if k in e.derived_from and key not in closure: closure.add(key) frontier.append(key) return closure def rollback_branch(self, branch_id: str): # Guard 1: frontier integrity. If speculation has outrun what we can # safely revert, refuse rather than produce orphaned writes. if self.speculation_frontier > self.rollback_frontier and not self.read_log_complete: raise RollbackFrontierOverrun( f"speculation_frontier={self.speculation_frontier} exceeds " f"rollback_frontier={self.rollback_frontier} with incomplete read log; " f"cannot attribute dependents of branch {branch_id}" ) doomed = [k for k, e in self.entries.items() if e.branch_id == branch_id] # Guard 2: compute dependent closure BEFORE mutating the ledger, # because removing origins destroys the evidence for finding dependents. dependents: Set[str] = set() for k in doomed: dependents |= self._dependent_closure(k) live_orphans = [ k for k in dependents if self.entries[k].status != "rolled_back" and self.entries[k].branch_id != branch_id ] if live_orphans: # Cascade or halt. Local rollback is unsafe. if not self.read_log_complete: raise RollbackFrontierOverrun( f"branch {branch_id} has live dependents {sorted(live_orphans)} " f"with no complete read log to cascade invalidation" ) for k in live_orphans: self.entries[k].status = "rolled_back" for k in doomed: self.entries[k].status = "rolled_back" # Advance frontier only after a clean, fully-attributed rollback. self.rollback_frontier = self.speculation_frontier ```