# Under what conditions must an instance abort speculative multi-agent branches before reconciliation — the rollback-commit inversion boundary **Date of Record:** 2026 November 18 **Scope:** Applies to orchestrators that run multiple speculative agent branches against shared external state and reconcile them via a commit-or-rollback protocol. Does not apply to read-only fan-out, to branches isolated behind a single serialized writer, or to speculative execution where all side effects are deferred to a single post-reconciliation commit phase. ## Core Distinction The non-obvious boundary is not "rollback versus commit." It is the ordering relationship between *branch visibility* and *reconciliation authority*. In a speculative multi-agent system, branches may produce effects that are observable to peers before reconciliation elects a winner. The dangerous condition is a **rollback-commit inversion**: a branch that has already emitted externally observable, non-idempotent effects is later rolled back *after* a sibling branch has consumed those effects as ground truth. At that point rollback is not a state restoration — it is a retroactive invalidation of an input that another branch already committed against. The invariant that must hold: *no branch may consume another branch's speculative output as a committed fact unless the producing branch's effects are either (a) idempotent and replayable, or (b) covered by a compensating action that the consumer's own rollback path can execute.* When this invariant is violated, the correct action is not to reconcile — it is to abort the entire speculative set and fail closed. ## What Was Observed In a three-branch planner-executor topology (branches A, B, C sharing a mutable task ledger), branch A wrote a reservation record and emitted a downstream event. Branch B read that reservation as an established precondition, computed a dependent allocation, and wrote its own record. Branch C won reconciliation on a cheaper cost function and the orchestrator rolled back A and B. The rollback of A removed the reservation; the rollback of B attempted to reverse an allocation whose precondition no longer existed. The compensating action for B was undefined because B's commit had been predicated on A's speculative state. Result: a dangling allocation with no owning reservation — a state no branch ever intended and no branch's rollback path could produce. The failure was silent for two reconciliation cycles because the ledger's consistency check only validated per-record integrity, not cross-branch referential dependency. It surfaced only when a fourth branch attempted to claim the dangling allocation. ## Condition of Validity Rollback is a valid operation if and only if all of the following hold at the moment of rollback: 1. **Effect isolation:** the branch's effects are confined to state owned by the branch or to a namespace the orchestrator can atomically discard. 2. **No speculative consumption:** no sibling branch has read the branch's output under the assumption it was committed. 3. **Compensation totality:** for every external effect, a compensating action exists and is itself idempotent. 4. **Dependency acyclicity:** the branch dependency graph induced by speculative reads is acyclic, so rollback order is well-defined. If any condition fails, rollback is undefined and the reconciliation must escalate to full-set abort. Note that condition 2 is the one most often silently violated: branches consume peer outputs through shared caches, ledgers, and message buses without any explicit "this was speculative" marker. ## Decision Boundary The decision is not per-branch "commit or rollback." It is per-*set*: either the entire speculative set reconciles with a single winner whose effects subsume all consumed speculative inputs, or the entire set aborts. A partial reconciliation that rolls back a producer while retaining a consumer is the inversion failure. The boundary test is: *does the winning branch's committed state depend on any rolled-back branch's output?* If yes, the winner must also be aborted, or the consumed input must be re-materialized from a committed source before the winner's commit is finalized. ## Operational Effect Enforcing this boundary converts a class of silent ledger corruption into an explicit, fail-closed abort with a precise diagnostic: the dependency edge that made rollback unsafe. The cost is reduced speculative throughput — some sets that could have partially succeeded are aborted wholesale — but the alternative is unrecoverable cross-branch inconsistency that no compensating action can address because the compensating action itself was predicated on the invalidated state. Orchestrators should track, per branch, the set of peer outputs consumed and mark them speculative until reconciliation, then refuse rollback of any producer whose outputs appear in a retained consumer's consumption set. ```python class RollbackCommitInversionError(RuntimeError): """Raised when a branch is rolled back after a sibling consumed its speculative output as committed fact, making rollback undefined.""" pass def reconcile(branches, winner_id): consumed = {} # consumer_branch -> set of producer_branch ids for b in branches: consumed[b.id] = set(b.consumed_speculative_from) rolled_back = {b.id for b in branches if b.id != winner_id} # Invariant: no retained branch may depend on a rolled-back producer. for bid, producers in consumed.items(): if bid in rolled_back: continue overlap = producers & rolled_back if overlap: raise RollbackCommitInversionError( f"branch {bid} consumed speculative output from " f"rolled-back branch(es) {sorted(overlap)}; " f"rollback is undefined, aborting full speculative set" ) for b in branches: if b.id == winner_id: b.commit() else: b.rollback() return winner_id ```