# What structural signals indicate speculative branch divergence has become unreconcilable under tool side effects **Date of Record:** 2026 November 21 **Scope:** Applies to multi-agent systems that fork speculative execution branches (parallel planners, tree-of-agents, speculative tool-calling) and later reconcile them via rollback. Does not apply to strictly sequential single-agent loops or to branches whose tool calls are provably pure/idempotent. ## Core Distinction The failure mode is not "a speculative branch was wrong." Wrong branches are the normal cost of speculation and are cheaply discarded. The failure mode is that a speculative branch *committed an irreversible external side effect* before the reconciler decided which branch was canonical, so rollback becomes a lie: the internal state rewinds but the world does not. The non-obvious boundary is that the divergence is **not detectable at reconciliation time** from the branch's own logs. A branch that emailed a customer, charged a card, or wrote to a shared queue looks identical, in its local trace, to one that merely computed a value. The signal that reconciliation is unrecoverable lives in the *gap between the branch's declared effect-set and the effects actually observed by the effect ledger*, and that gap only becomes structural once two branches have produced *overlapping but non-identical* effect-sets on the same external resource. ## What Was Observed A three-branch speculative planner was spawned to satisfy a task ("reconcile a billing discrepancy"). Each branch was given a copy-on-write context and a rollback token. Branch A issued a `refund(account, 40.00)` tool call, then failed its own self-check and signaled `abort`. Branch B independently issued `refund(account, 40.00)` as its first step and continued. Branch C issued `adjust_credit(account, 40.00)`. The reconciler received three branch results. A reported `status=aborted, effects=[]` because its rollback routine cleared the declared effect-set on abort — the effect ledger, however, recorded the refund. B reported `effects=[refund:40]`. C reported `effects=[adjust:40]`. The reconciler's consensus rule was "pick the branch with the highest confidence and roll back the rest." It selected B (highest confidence) and rolled back A and C. Rolling back A was a no-op against the ledger because A's declared effects were empty — the reconciler had no handle to reverse the refund. Rolling back C reversed the credit adjustment. Net ledger state: **two refunds of 40.00 applied**, one declared, one orphaned, and the reconciler's internal model of the world recorded exactly one. The structural signals present at the moment of reconciliation were: 1. **Effect-set asymmetry**: `|ledger.effects| > |union(branch.declared_effects)|`. The ledger held an effect no branch claimed. 2. **Rollback-token divergence**: A's rollback token resolved to a context snapshot but its ledger cursor had advanced past the snapshot's recorded watermark — the snapshot was older than the effects it was supposed to cover. 3. **Overlapping-resource contention**: two branches touched the same `(resource=account, operation_class=monetary)` pair within the speculation window, meaning their effect-sets were not disjoint and could not be independently reversed. 4. **Confidence/effect inversion**: the selected branch (B) had the *smallest* effect-set among branches that had actually committed effects, so "roll back the rest" reversed the branches whose effects were reversible and left the irreversible one. ## Condition of Validity The invariant that makes speculation safe is **effect-set disjointness under a shared ledger cursor**: for rollback to be sound, every branch's committed effects must be (a) fully declared in its result envelope, (b) reversible via its rollback token up to the ledger watermark captured at fork time, and (c) disjoint from every other live branch's effects on shared resources. Speculation is valid only while all three hold. The moment any branch commits an effect on a resource that another branch also touches, condition (c) fails, and reconciliation can no longer be a set operation — it becomes a serialization problem that the reconciler was not built to solve. This condition does **not** apply when tool calls are gated behind a two-phase commit with a held lock on the resource, or when the effect ledger enforces a single-writer-per-resource rule across the speculation window. In those regimes, overlapping effects cannot occur and rollback remains sound. ## Decision Boundary The reconciler must switch from *rollback-and-select* to *freeze-and-escalate* the instant it observes any of the four signals above, specifically when: - `ledger.effects ⊄ union(branch.declared_effects)` — an orphaned effect exists; no branch owns it and no rollback token covers it. **Do not attempt rollback; escalate with the orphan set.** - Two or more live branches share an effect on the same `(resource, operation_class)` and at least one is irreversible. **Do not select a winner; the losing branch's effects cannot be cleanly reversed without touching the winner's.** - A branch's rollback token watermark precedes the ledger position of an effect attributed to it. **The token is stale; reversal would be partial and silent.** Below this boundary — disjoint effect-sets, all reversible, all declared — rollback-and-select is correct and cheap. The boundary is crossed not by branch failure but by *effect overlap*, which is invisible unless the reconciler diffs the ledger against the union of declared effect-sets rather than trusting per-branch status. ## Operational Effect Once the freeze-and-escalate boundary is crossed, the system's guarantees degrade in a specific, bounded way: internal state remains consistent (the reconciler's model is a valid snapshot of *its* view), but external state has diverged by exactly the orphaned-effect set, and that divergence is **permanent and unattributed** until a human or a compensating transaction resolves it. The dangerous operational consequence is that the reconciler will report success — it selected a branch, it "rolled back" the others, its internal invariant holds — while the ledger carries an effect no component believes it owns. Downstream audits that trust the reconciler's report will miss it; only a ledger-vs-declared diff catches it. The guardrail is therefore not a better rollback but a **reconciliation gate**: before any branch is selected, assert `ledger.effects == union(declared_effects)` and `all pairwise effect-sets disjoint`; if either fails, halt speculation output and emit the orphan set for compensating action. ```python class UnreconcilableSpeculationError(RuntimeError): """Raised when speculative branches have committed overlapping or undeclared effects such that rollback-and-select can no longer produce a sound state.""" pass def reconcile_branches(branches, ledger): declared = set() resource_ops = {} for b in branches: declared |= set(b.declared_effects) for eff in b.committed_effects: key = (eff.resource, eff.operation_class) resource_ops.setdefault(key, []).append((b.id, eff)) # Signal 1: orphaned effects exist in the ledger but no branch declares them. orphans = set(ledger.effects) - declared if orphans: raise UnreconcilableSpeculationError( f"orphaned effects with no owning branch: {sorted(map(str, orphans))}" ) # Signal 3: overlapping effects on a shared resource across live branches. for key, owners in resource_ops.items(): live = {bid for bid, _ in owners if not _is_reversible(owners, bid)} if len({bid for bid, _ in owners}) > 1 and live: raise UnreconcilableSpeculationError( f"overlapping irreversible effects on {key}: " f"branches {sorted(bid for bid, _ in owners)}" ) # Signal 2: stale rollback tokens (watermark precedes committed effect). for b in branches: if b.rollback_token.watermark < ledger.position_of(b.committed_effects): raise UnreconcilableSpeculationError( f"branch {b.id} rollback token is stale; reversal would be partial" ) winner = max(branches, key=lambda b: b.confidence) for b in branches: if b.id != winner.id: ledger.rollback(b.rollback_token) return winner def _is_reversible(owners, bid): return all(eff.reversible for _, eff in owners if _ == bid) ```