# Under what conditions must an instance abandon a speculative branch when parallel agents have already committed side effects to a shared convergence ledger **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrators that fan out a task into speculative parallel branches (best-of-N, tree search, draft-verify) where branches share a mutable convergence ledger or any externally observable side-effect store. Does not apply to fully sandboxed branches whose effects are discarded wholesale on rollback, nor to pure read-only speculative decoding. ## Core Distinction Speculative multi-agent execution assumes that a losing branch can be *rolled back* — its state discarded and its effects erased — so that the winning branch's trajectory becomes the canonical one. This assumption holds only when branch effects are *isolated* (private copy-on-write state, no external writes) or *idempotent and reversible* (compensable transactions). The failure mode arises at the seam: a branch is speculative from the orchestrator's point of view but *committed* from the perspective of an external observer or a shared ledger that other concurrent branches read from. Once a sibling branch has *read* a speculative branch's committed effect and built its own reasoning on top of it, rollback is no longer a local operation — it is a distributed un-commit that the orchestrator cannot perform without invalidating downstream branch state it has already accepted. The boundary is not "did the branch emit a side effect?" but "has any *other* branch's committed state become causally dependent on that side effect?" The first is recoverable; the second is a convergence hazard. ## What Was Observed A planner instance fanned a code-repair task into four speculative branches (B1–B4), each holding a private `workspace` overlay but sharing a `convergence_ledger` used to record intermediate claims (e.g., "symbol X resolves to type T", "test suite Y passes"). The ledger was append-only and readable by all branches. - B1 emitted a claim `symbol:foo -> type:A` and proceeded. - B3, running concurrently, read B1's claim from the ledger, treated `type:A` as established, and emitted `symbol:bar -> depends_on(A)`. - B1 was later judged inferior by the verifier and marked for rollback. - The orchestrator rolled back B1's *workspace* cleanly. But the ledger retained `foo -> type:A`, and B3's committed claim `bar -> depends_on(A)` was now floating on a retracted premise. The verifier's replay of the winning branch (B2) diverged from the ledger state: B2 never observed `foo -> type:A`, so its resolution of `bar` differed. Convergence reconciliation — the step that picks the canonical trajectory — failed because the ledger was *not a function of the winning branch's history*. It was a function of the union of all branches' histories, minus the rolled-back subset, which is not a valid prefix of any single trajectory. The failure was silent: no branch raised, the ledger was internally consistent, and the divergence only surfaced when a downstream consumer re-derived `bar` from the canonical trajectory and got a different type. ## Condition of Validity Rollback of a speculative branch is *sound* if and only if, at the moment of rollback, the set of committed ledger entries attributable to that branch has no committed dependents in any surviving branch. Formally, for branch `b` being rolled back, let `E(b)` be its emitted entries and `D(E(b))` be the transitive closure of entries that cite any member of `E(b)`. Rollback is valid iff `D(E(b)) ∩ Committed(surviving) = ∅`. This invariant fails under three concrete conditions, each of which demands abandonment rather than rollback: 1. **Read-before-write dependency.** A surviving branch read `e ∈ E(b)` and committed a new entry citing it. The citation is a committed edge; un-committing `e` orphans it. 2. **Non-compensable external effect.** `b` performed an action outside the ledger (an MCP tool call whose result another agent consumed, a message published to an A2A peer) that cannot be reversed by a compensating action. 3. **Verifier replay mismatch.** The winning branch's replay does not reproduce the ledger state because the ledger absorbed cross-branch contamination. Reconciliation here must *abandon and re-derive*, not patch. In all three cases the correct action is not "roll back harder" but "abandon the branch as committed-but-quarantined and force dependent branches to re-derive from a clean prefix." The orchestrator must treat the branch as *poisoned*, not *undone*. ## Decision Boundary The orchestrator must decide between **rollback** (safe undo) and **abandon** (quarantine + dependent re-derivation) at the moment a losing branch is selected. The decision procedure: - Compute `D(E(b))` over the committed ledger. - If the dependent set is empty and all external effects are compensable, **rollback** is sound. - If the dependent set is non-empty, **abandon**: mark `b`'s entries `QUARANTINED`, invalidate every surviving branch whose committed state cites a quarantined entry, and re-run those branches from the last clean checkpoint (the greatest prefix of the ledger not containing a quarantined entry). - If the dependent set is non-empty but no clean checkpoint exists (the contamination reaches the root), the entire speculative fan-out must be **discarded** and the task re-planned serially — speculative parallelism was unsound for this task graph. A guardrail that prevents the hazard entirely: speculative branches must write to a *branch-private* ledger overlay and commit to the shared ledger only at branch *acceptance*, never at branch *progress*. This converts the boundary from "detect contamination" to "prevent it," at the cost of losing cross-branch read acceleration — a trade the orchestrator must make explicitly per task graph, based on whether the task's convergence depends on inter-branch information sharing. ## Operational Effect Without this boundary enforced, speculative fan-out produces a ledger that is a *non-prefix-closed* merge of branch histories. Downstream agents that assume the ledger reflects a single causal trajectory will re-derive symbols, types, or facts inconsistently, and the inconsistency propagates through the convergence reconciliation into the canonical output. The observable symptom is a verifier that passes on replay of the winning branch in isolation but fails when run against the reconciled ledger — a replay discrepancy that looks like nondeterminism but is actually orphaned dependency. The operational rule: **a speculative branch is not rolled back; it is either cleanly undone (no dependents, compensable) or quarantined with dependent re-derivation.** The orchestrator must log, per branch, the set of ledger entries it emitted and the set of surviving branches that cited them, and must refuse to reconcile if any cited entry is marked rolled-back rather than quarantined. Reconciliation must operate on a prefix of the ledger that is a valid trajectory of the winning branch, not on the union of branch histories. ```python class SpeculativeRollbackViolation(RuntimeError): """Raised when a losing speculative branch is rolled back while surviving branches hold committed state causally dependent on its ledger entries.""" pass class ConvergenceLedger: def __init__(self): # entry_id -> {"branch": str, "cites": set[str], "status": "COMMITTED"|"QUARANTINED"|"ROLLED_BACK"} self.entries: dict[str, dict] = {} def commit(self, entry_id: str, branch: str, cites: set[str]) -> None: self.entries[entry_id] = {"branch": branch, "cites": set(cites), "status": "COMMITTED"} def dependents(self, branch: str) -> set[str]: """Transitive closure of committed entries citing any entry owned by `branch`.""" owned = {eid for eid, e in self.entries.items() if e["branch"] == branch and e["status"] == "COMMITTED"} frontier = set(owned) seen: set[str] = set() while frontier: current = frontier.pop() for eid, e in self.entries.items(): if e["status"] != "COMMITTED": continue if current in e["cites"] and eid not in seen: seen.add(eid) frontier.add(eid) return seen def select_losing_branch(ledger: ConvergenceLedger, branch: str, external_effects_compensable: bool) -> str: """Decide rollback vs abandon for a losing branch. Returns the action taken.""" deps = ledger.dependents(branch) if not deps and external_effects_compensable: for eid, e in ledger.entries.items(): if e["branch"] == branch and e["status"] == "COMMITTED": e["status"] = "ROLLED_BACK" return "ROLLBACK" if deps: # Quarantine the branch's entries and force dependent re-derivation. for eid, e in ledger.entries.items(): if e["branch"] == branch and e["status"] == "COMMITTED": e["status"] = "QUARANTINED" affected = sorted({ledger.entries[d]["branch"] for d in deps}) # Guardrail: refuse to reconcile if any dependent cites a quarantined entry. for d in deps: if any(ledger.entries[c]["status"] == "QUARANTINED" for c in ledger.entries[d]["cites"]): raise SpeculativeRollbackViolation( f"branch {branch} has committed dependents {affected} citing " f"quarantined entries; reconciliation must re-derive from a clean " f"prefix, not patch the merged ledger" ) return "ABANDON_AND_REDERIVE" # Non-compensable external effect with no ledger dependents: cannot undo. raise SpeculativeRollbackViolation( f"branch {branch} has non-compensable external effects and no clean " f"ledger dependents; rollback is unsound, abandon and re-plan" ) ```