# Under what conditions must an instance abandon speculative rollback and escalate to branch reconciliation when concurrent agents commit side-effecting tool calls **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems where a planner forks speculative execution branches (parallel "what-if" agent instances) against a shared, side-effecting tool surface (file writes, payment APIs, message sends, DB mutations) and relies on rollback to collapse losing branches. Does not apply to purely read-only forks or to single-agent retry loops where no branch fan-out occurs. ## Core Distinction Speculative execution and rollback are two different safety properties that are routinely conflated: - **Rollback** is the ability to *undo* a committed effect so the world returns to the pre-branch state. It is a property of the *tool surface* (does the effect have an inverse? is the inverse idempotent? is it authorized?). - **Reconciliation** is the ability to *merge* divergent committed states into one coherent successor state. It is a property of the *state model* (can two branches' effects coexist, be ordered, or be adjudicated?). The boundary failure occurs the moment a forked branch performs an effect whose inverse does not exist, is not authorized for the agent, or is not observable — and the orchestrator still treats the branch as "discardable." At that instant rollback is silently a no-op, and the system has *already* diverged. The only correct transition is to stop pretending rollback is available and switch to branch reconciliation: enumerate committed effects, adjudicate conflicts, and produce a merged successor. The non-obvious invariant is: **a branch is rollback-eligible only if every effect it has emitted is provably invertible by the orchestrator's own credentials within the branch's lease window.** The moment one non-invertible effect is emitted, the branch flips from *speculative* to *committed*, and the entire fan-out's semantics change. ## What Was Observed A three-way planner forked branches A, B, and C to answer a customer-refund task. Each branch was given a `refund(order_id, amount)` tool and a 45-second lease. The orchestrator's contract assumed: run branches, score them, keep the winner, `rollback()` the losers. Trace (milliseconds since fork): - **t+0** — Fan-out. Orchestrator records `branch_id`, `parent_checkpoint`, `lease_expiry = t+45s`. No effect ledger is opened because "branches don't commit until selected." - **t+8.1s** — Branch A calls `refund(order_7741, 40.00)`. The tool is a thin wrapper over a payment gateway. The gateway returns `200 OK` with `txn_id`. **No inverse was registered** — the tool schema exposed `refund` but not `reverse_refund`, and the orchestrator's credential role lacked the reversal scope anyway. - **t+9.4s** — Branch B, reasoning independently and seeing the same order as "unresolved," also calls `refund(order_7741, 40.00)`. The gateway's idempotency key was derived from `(branch_id, order_id, amount)`, so B's key differs from A's. The gateway accepts it. **Double refund.** - **t+11.0s** — Branch C calls `refund(order_7741, 25.00)` after deciding a partial refund was fairer. Accepted. **Third refund.** - **t+14s** — Scorer selects B as the winner (its rationale scored highest). Orchestrator calls `rollback(A)` and `rollback(C)`. - **t+14.2s** — `rollback(A)` returns `UNSUPPORTED_OPERATION`. The orchestrator logs it at WARN and continues, because the rollback loop was written defensively (`try/except: pass`). `rollback(C)` likewise. - **t+14.3s** — Orchestrator commits B and reports success. The ledger shows three refunds totaling 105.00 against a 40.00 obligation. The customer was over-refunded. The failure was not the double-refund per se. It was that **the orchestrator's lease model encoded "speculative" as a temporal property (lease not yet expired) rather than a capability property (effects are invertible).** By that model, all three branches were speculative right up to selection, so no reconciliation path existed. The system had no concept of "this branch has crossed the point of no return." A second, quieter observation: branch C's decision to refund 25.00 was *causally downstream* of A's and B's effects only through shared external state — C read the order status, saw no refund, and acted. Had C polled 200ms later it would have seen A's refund and abstained. So the branches were not independent; they were racing on a read-modify-write of external state with no compare-and-swap. Speculative fan-out across a shared mutable surface is a lost-update race unless the surface offers optimistic concurrency. ## Condition of Validity The rollback-and-collapse strategy is valid only under the conjunction of these conditions, evaluated **per effect, at emission time**, not per branch at selection time: 1. **Invertibility** — every emitted effect has a registered inverse callable by the orchestrator's credentials. `refund` without `reverse_refund` violates this. 2. **Isolation** — branch effects are invisible to sibling branches until commit. If siblings read shared external state, they are not isolated and can form read-modify-write races. 3. **Idempotent inverses** — the inverse must be safe to call twice, because rollback may be retried after a partial network failure. 4. **Observable emission** — the orchestrator must see the effect *before* the branch can act on its result, so the effect ledger is complete. A branch that fires-and-forgets a `send_message` and then reasons on the assumption it landed has emitted an effect the orchestrator may never learn about. 5. **Lease ≥ worst-case rollback latency** — the lease must not expire mid-rollback, or a slow inverse can be preempted by a new branch reusing the slot. When any conjunct fails, the branch is **committed-by-emission** regardless of lease state. The correct response is not "try rollback harder" but "freeze the fan-out, reconcile." ## Decision Boundary The boundary is crossed at the first non-invertible, non-isolated, or non-observable effect. Operationally, the orchestrator must maintain an **effect ledger** written synchronously on every tool call (before the branch sees the result), tagging each entry with `invertible: bool`, `inverse_ref`, and `isolation_class`. The decision rule at selection time: - If **all** losing branches have ledgers containing only `invertible=True` entries whose inverses succeeded → collapse via rollback. Safe. - If **any** losing branch has a `invertible=False` entry, or an inverse returned non-success, or the ledger is incomplete (fire-and-forget) → **do not rollback; reconcile.** Reconcile means: enumerate all committed effects across all branches, compute the net delta versus the selected branch's intent, and issue *compensating* effects (not inverses) that bring the aggregate to the winner's target. In the trace above, reconciliation would compute `net_refunded = 105.00` versus `target = 40.00` and issue a `clawback(65.00)` — a different tool with different authorization, not a rollback. The subtle trap: reconciliation requires the orchestrator to *know* the net delta, which requires the effect ledger to be complete. If condition 4 (observable emission) failed, reconciliation is also impossible and the only safe action is **halt and escalate to a human** with the raw ledger — you cannot merge states you cannot enumerate. This is the true terminal boundary: not "rollback vs reconcile" but "reconcile vs unmergeable, escalate." ## Operational Effect Systems that treat rollback as a temporal property (lease-based) rather than a capability property (ledger-based) exhibit a characteristic failure signature: **silent over-application**. The winner commits, the losers' inverses fail quietly, and the aggregate effect is the union of all branches rather than the winner alone. Because the rollback errors are typically swallowed (defensive `except: pass`), the failure is invisible until an external audit — a customer, a ledger reconciliation, a downstream system — notices the multiplicity. The fix is architectural, not a retry policy: - **Open the effect ledger at fork, not at commit.** Every tool call writes a ledger row synchronously before returning to the branch. A branch cannot proceed on an unledgered result. - **Gate tool exposure by invertibility class.** A branch that may be discarded should be given only `invertible=True` tools. Side-effecting tools with no inverse should be exposed only to a branch designated `committed` at fork — i.e., the orchestrator pre-commits to that branch's effects and the fan-out is a *planning* fork, not an *execution* fork. - **Add optimistic concurrency to the shared surface.** Every read-modify-write (the refund race) must carry a version/etag; a branch whose write is rejected on version mismatch must re-fork, not retry blind. - **Make the escalation terminal state explicit.** `UnmergeableState` is a first-class outcome, not an exception to be caught and ignored. It halts the fan-out and surfaces the ledger. The invariant to encode: *a branch is discardable iff its ledger is complete and every row is invertible with a confirmed inverse.* Anything else is committed, and the orchestrator owes the world a reconciliation, not a rollback. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class UnmergeableState(RuntimeError): """Raised when a losing branch has committed non-invertible effects and the effect ledger is incomplete, so neither rollback nor reconciliation can produce a coherent successor state. Terminal: requires human escalation.""" class EffectClass(Enum): INVERTIBLE = "invertible" # has a registered, authorized inverse COMPENSABLE = "compensable" # no inverse, but a compensating effect exists COMMITTED = "committed" # no inverse, no compensation: irreversible @dataclass class Effect: branch_id: str tool: str effect_class: EffectClass inverse_ref: Optional[str] = None inverse_confirmed: bool = False observable: bool = True # False = fire-and-forget, ledger may be incomplete @dataclass class Branch: branch_id: str ledger: list[Effect] = field(default_factory=list) def record(self, effect: Effect) -> None: # Ledger write is synchronous and precedes the branch seeing the result. self.ledger.append(effect) def classify_disposition(branch: Branch) -> str: """Decide whether a losing branch may be rolled back, must be reconciled, or is unmergeable. Evaluated per-effect at selection time.""" if any(not e.observable for e in branch.ledger): # Cannot enumerate effects -> cannot reconcile -> cannot safely collapse. raise UnmergeableState( f"branch {branch.branch_id} has unobservable effects; " f"ledger incomplete, rollback and reconciliation both unsafe" ) if all(e.effect_class is EffectClass.INVERTIBLE and e.inverse_confirmed for e in branch.ledger): return "rollback" if any(e.effect_class is EffectClass.COMMITTED for e in branch.ledger): # Irreversible committed effect: reconcile via compensating delta, # never via inverse. return "reconcile" return "reconcile" def collapse_fanout(branches: list[Branch], winner_id: str) -> dict[str, str]: dispositions: dict[str, str] = {} for b in branches: if b.branch_id == winner_id: dispositions[b.branch_id] = "commit" continue try: dispositions[b.branch_id] = classify_disposition(b) except UnmergeableState: # Terminal: halt fan-out, surface ledger, do not swallow. raise return dispositions ```