# When must an instance abandon a speculative branch: rollback depth versus reconciliation authority in speculative multi-agent execution **Date of Record:** 2026 November 22 **Scope:** Applies to orchestrated multi-agent systems where a planner instance forks speculative child branches (parallel tool-using agents) that share a mutable world state and must be merged or rolled back. Does not apply to stateless fan-out/aggregation patterns where branches never mutate shared state and are combined by pure reduction. ## Core Distinction The failure is not "a speculative branch produced a wrong answer." That is the expected cost of speculation and is handled by discarding the branch. The failure is **rollback depth divergence**: a branch is judged wrong and rolled back, but the rollback is shallow — it reverts the branch's *declared* output while leaving behind *side effects* the branch committed to shared state (a written record, a claimed tool resource, a cached fact injected into the shared semantic store, an idempotency token consumed). The parent then reconciles surviving branches against a world state that is a chimera: partially rolled back, partially committed. The non-obvious boundary: **a speculative branch may only be rolled back to the depth of the shallowest committed side effect it caused, and the reconciliation authority must be the same instance that holds the rollback ledger.** When the reconciling instance is *not* the ledger holder — e.g., a separate "merge" agent, or a fresh instance cold-started to do reconciliation — it will reconcile against the *declared* branch outputs and be blind to the residue. The invariant: `rollback_depth(branch) >= commit_depth(branch)` for every committed effect, enforced by a single ledger authority. Violation produces silent state corruption that only manifests on the *next* speculative round, not the current one. ## What Was Observed A three-way speculative planner forks branches B1, B2, B3 to resolve a research sub-task in parallel. Each branch has read access to a shared `WorldState` and write access through a `commit(effect)` gateway that appends to a per-branch ledger. - **B1** calls a retrieval tool, writes a distilled fact `F1` into the shared semantic store, and returns `answer=α`. It is judged correct. - **B2** consumes an idempotency token `T2` against an external API, writes partial fact `F2`, then diverges (its reasoning loop begins citing a hallucinated source) and is judged incorrect. The parent issues `rollback(B2)`. - **B3** reads `F1` (committed by B1), reads `F2` (committed by B2 *before* B2's rollback), and returns `answer=γ` that depends on both. The rollback of B2 is executed as `revert(declared_output(B2))`. But `F2` was written to the shared semantic store through a *different* path than the declared output channel, and the idempotency token `T2` was consumed at the external API — neither is in the declared output. So `F2` survives in the shared store and `T2` remains consumed. Reconciliation then runs with B1 and B3 surviving. B3's `answer=γ` was computed against a store that *contained* `F2`; the reconciler, holding only declared outputs, believes `F2` was removed. It accepts `γ`. On the *next* speculative round, a new branch B4 reads the store, retrieves the orphaned `F2`, and — because `F2` is now unowned (its authoring branch is rolled back) — treats it as an authoritative fact. The system has manufactured a fact from a discarded branch and promoted it to ground truth. Two secondary observations: (a) the corruption was invisible in logs of the *current* round because every declared output reconciled cleanly; (b) it surfaced only when B4's answer contradicted a later verified fact, at which point the causal chain back to B2's shallow rollback was no longer reconstructible from logs, because the ledger entry for B2 had been garbage-collected on rollback. ## Condition of Validity The invariant `rollback_depth >= commit_depth` holds only if the commit gateway is the *sole* path to shared state and every effect is ledgered with a monotonically increasing sequence number. It is **invalidated** — and this is the boundary — under any of the following, each of which is common in real deployments: 1. **Bypass writes.** A tool writes to shared state directly (a cache, a vector store upsert, a file) without traversing `commit()`. The ledger never sees it, so rollback depth cannot reach it. 2. **Consumed external resources.** Idempotency tokens, rate-limit budget, and external side effects (an email sent, a ticket created) are consumed and are *not reversible* by rollback. These set a hard floor: the branch can never be rolled back below its most irreversible committed effect, so any branch that consumes an irreversible resource must be treated as *committed*, not speculative. 3. **Cross-branch reads before rollback.** B3 read `F2` while it was live. Even a *deep* rollback of B2 cannot un-read it from B3's context. B3's output is now tainted by a fact that will be removed — but B3's output is otherwise correct relative to the state it saw. The reconciler must decide whether B3 is valid-against-a-now-false premise or invalid. 4. **Reconciler ≠ ledger holder.** If reconciliation is delegated (a merge agent, a fresh cold-start instance), that instance cannot know rollback depth and will reconcile against declared outputs only. The invariant is therefore only *provable* when (1) and (4) are structurally prevented and (2) is tracked as an irreversibility class on each effect. ## Decision Boundary The decision rule for the reconciling instance, stated as a predicate it must evaluate before accepting any surviving branch: ``` accept(B) iff no_orphaned_effects(store) # no F2-style residue from rolled-back branches and B.read_set ⊆ committed_set_at(B.eval_time) # B3's premise F2 was live when B3 read it and ledger_authority == self # reconciler holds the ledger and rollback_depth(rolled_back) >= commit_depth(rolled_back) ``` When any clause fails, the instance must **not** accept-and-patch. It must choose one of two bounded actions: - **Re-derive**, if the tainted read set is small: re-run surviving branches whose `read_set` intersects any orphaned effect, against a cleaned store, with a fresh ledger. Cost is recomputation; correctness is restored. - **Promote-to-committed**, if the branch consumed an irreversible resource: the branch cannot be rolled back, so it must be *committed* and its effects owned — the orphaned `F2` gets an owner and is reconciled as a first-class fact rather than silently surviving. The boundary is sharp: **a branch is speculative iff all its committed effects are reversible and ledgered; the moment it consumes an irreversible resource it transitions to committed and rollback is forbidden, not merely shallow.** An instance that treats an irreversible-effect branch as still-rollbackable has crossed the boundary and will corrupt the shared store. ## Operational Effect The practical consequence is that speculative execution must carry an **irreversibility class per effect** and a **read-set watermark per branch**, and reconciliation must be a *ledger-holding* operation, never a delegated one. Systems that omit this observe a characteristic signature: the current round reconciles cleanly (all declared outputs match), and corruption appears one round later as an "authoritative" fact with no living author. The corruption is *causally unattributable* after the fact because rollback garbage-collects the ledger entry that would have proven it — so the failure is not just silent, it is *uninvestigable* post hoc. The guardrail is to make rollback a *ledgered* event that retains the rolled-back branch's effect list as a tombstone (never GC the ledger), and to make reconciliation refuse to run unless it holds the ledger. This converts an invisible one-round-delayed corruption into a synchronous, attributable refusal at reconcile time. ## Python ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class ReconciliationError(RuntimeError): """Raised when reconciliation would accept a branch against a corrupted or unattributable world state.""" pass class EffectClass(Enum): REVERSIBLE = "reversible" # ledgered, deep-rollbackable IRREVERSIBLE = "irreversible" # consumed external resource; rollback forbidden @dataclass class Effect: branch_id: str key: str cls: EffectClass seq: int @dataclass class Branch: branch_id: str declared_output: str read_set: Set[str] = field(default_factory=set) effects: list = field(default_factory=list) @property def committed_depth(self) -> int: return max((e.seq for e in self.effects), default=-1) @property def has_irreversible(self) -> bool: return any(e.cls is EffectClass.IRREVERSIBLE for e in self.effects) class Ledger: """Single source of truth for commit/rollback depth. Never garbage-collect tombstones.""" def __init__(self): self._seq = 0 self.store: Dict[str, Effect] = {} self.tombstones: Dict[str, list] = {} def commit(self, branch: Branch, key: str, cls: EffectClass) -> None: self._seq += 1 eff = Effect(branch.branch_id, key, cls, self._seq) branch.effects.append(eff) self.store[key] = eff def rollback(self, branch: Branch) -> int: """Roll back only to the depth of the shallowest committed effect actually in the store. Refuses if the branch holds an irreversible effect (must be promoted, not rolled back).""" if branch.has_irreversible: raise ReconciliationError( f"branch {branch.branch_id} holds an irreversible effect; " f"it is committed, not speculative, and cannot be rolled back" ) depth = branch.committed_depth removed = [k for k, e in list(self.store.items()) if e.branch_id == branch.branch_id and e.seq <= depth] for k in removed: del self.store[k] self.tombstones[branch.branch_id] = list(branch.effects) # retain for attribution return depth def reconcile(ledger: Ledger, survivors: list, rolled_back: list) -> list: """Reconciler MUST hold the ledger. Refuses to accept against orphaned or unreadable state.""" accepted = [] for b in survivors: # clause 1: no orphaned residue from rolled-back branches orphaned = {k for k, e in ledger.store.items() if any(e.branch_id == rb.branch_id for rb in rolled_back)} if orphaned: raise ReconciliationError( f"orphaned effects {sorted(orphaned)} survive rollback; " f"shallow rollback detected, refusing to reconcile" ) # clause 3: branch read a fact that is now removed -> tainted premise removed_keys = {e.key for rb in rolled_back for e in ledger.tombstones.get(rb.branch_id, [])} tainted = b.read_set & removed_keys if tainted: raise ReconciliationError( f"branch {b.branch_id} read {sorted(tainted)} which a rolled-back branch authored; " f"premise no longer valid, re-derive required" ) accepted.append(b) return accepted ```