# When must an instance abort a speculative branch before its rollback barrier is acknowledged? **Date of Record:** 2026 November 26 **Scope:** Applies to orchestrated multi-agent systems that speculatively fork execution across peer agents and rely on a shared rollback barrier (compensating-action log or snapshot epoch) to undo divergent branches. Does not apply to single-agent retry loops or to stateless fan-out with no compensating actions. ## Core Distinction The failure mode is not "a speculative branch diverged" — divergence is the expected trigger for rollback. The failure mode is **rollback-barrier admission under unacknowledged speculative side effects**: a branch is speculatively executed against a shared resource, produces an irreversible or externally-visible side effect, and then diverges. The orchestrator issues a rollback, but the rollback barrier is *logically* complete while the branch's side effect is still *in flight* (queued, retrying, or applied by a downstream peer that has not yet observed the abort). The distinction that matters operationally: a rollback is not a boolean. It is a **quiescence predicate** over the set of side effects that the aborted branch may have caused. If you treat `rollback_issued == True` as the gate for re-committing the surviving branch, you will re-commit onto state that a zombie speculative branch is still mutating. ## What Was Observed A planner agent forks three speculative branches (A, B, C) to resolve a task under a shared `snapshot_epoch = 41`. Branch B is designated the survivor once its result is scored highest at step 7. Branches A and C receive `abort` at step 7 and are expected to compensate. Branch C had already, at step 6, dispatched a `write_record` tool call to a downstream peer agent. The peer's tool executor is slow (p99 ≈ 4s) and its own internal retry policy re-dispatches on timeout. The orchestrator's rollback barrier for C returns `ack` at step 8 because C's *local* state machine reached `ABORTED` and its compensating-action log was drained — but C's in-flight `write_record` at the peer was never in C's log, because the call had been handed off to the peer's transport layer and the acknowledgement was still pending. At step 9 the surviving branch B commits a record that assumes the pre-C state. At step 11 the peer's retry lands C's `write_record`, which mutates the record B just committed against. B's post-commit verification (a checksum over the record set) had already passed at step 10 — it passed against the pre-C state and never re-ran. The divergence was silently absorbed into committed state. The tell was a **checksum drift observed only on the next task's cold-start reconciliation**, one task later, with no causal trace back to C because C's branch context had been evicted at epoch close. ## Condition of Validity The invariant that must hold for a rollback barrier to be trustworthy is: > A branch may be considered `ABORTED` only when the union of (a) its locally-logged compensating actions and (b) all outstanding tool-call acknowledgements it has dispatched are resolved to a terminal state — completed-and-compensated, or never-dispatched. Two conditions invalidate this invariant in practice: 1. **Handoff escape.** Any tool call whose transport is delegated to a peer (MCP session, A2A task, message queue) leaves the branch's local compensating log at dispatch time. The branch cannot compensate what it no longer owns. The rollback barrier must therefore be *distributed*: it must include the peer's acknowledgement, not just the branch's local state. 2. **Retry shadow.** A peer's own retry policy can re-materialize a side effect after the branch has already aborted. The abort is not propagated to the peer's retry queue unless the protocol carries a cancellation token that the peer honors on the retry path. Without that, `ABORTED` on the branch is a lie about the peer. The invariant is *not* violated by slow tools, by divergence, or by scored survivor selection. It is violated specifically when the rollback barrier is computed over local branch state only, in a topology where side effects can outlive the branch. ## Decision Boundary The orchestrator must decide, at the moment of abort issuance, whether the rollback barrier is **local-sufficient** or **distributed-required**: - **Local-sufficient:** every side effect the branch has emitted is either (i) purely in-branch state under the shared snapshot epoch, or (ii) a tool call whose acknowledgement was received before abort. Safe to gate re-commit on local `ack`. - **Distributed-required:** the branch has ≥1 outstanding acknowledgement at abort time, OR has dispatched to a peer with a retry policy, OR has emitted a side effect outside the snapshot epoch. Re-commit must be gated on a **barrier quorum**: every dispatched call resolved to terminal, with cancellation tokens honored. The boundary is crossed at the *first* dispatch that escapes the branch's compensating log. Once crossed, the orchestrator must either (a) block re-commit until quorum, or (b) **abort the whole speculative epoch** and re-plan from the last durable checkpoint, accepting the cost of losing the surviving branch's work. It must never do (c) — re-commit the survivor while any branch has an outstanding escaped call. The subtle case: the orchestrator cannot know whether the boundary was crossed without tracking dispatch-to-acknowledgement as a first-class ledger entry, per branch, per call. If that ledger is reconstructed post-hoc from logs, it will be incomplete exactly when the peer's retry shadow is active. ## Operational Effect Systems that gate re-commit on local `ack` exhibit a specific failure signature: **low-frequency, high-latency, causally opaque state corruption** that appears one task after the divergence, with no surviving trace to the aborted branch. The corruption is rare because it requires the abort to land inside the tool's retry window; it is opaque because branch context is evicted at epoch close, so post-mortem cannot reconstruct which branch escaped. The guardrail is a **dispatch ledger with cancellation propagation**: - Every tool dispatch records `(branch_id, call_id, peer_id, dispatched_at, ack_state)` in a ledger that outlives the branch. - Abort issuance emits a cancellation token per outstanding call; the peer must honor it on the retry path, not only on first receipt. - The rollback barrier computes `ABORTED` as a function of the ledger, not the branch state machine. - Re-commit of the survivor requires `ledger.all_terminal(epoch)`, with a bounded wait; on timeout, escalate to full-epoch abort. The cost is latency: distributed barriers add a round-trip per outstanding call at abort time. The benefit is that "rollback complete" means what it says — no zombie side effect can land under a committed survivor. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class AckState(Enum): PENDING = "pending" ACKED = "acked" CANCELLED = "cancelled" RETRY_SHADOW = "retry_shadow" # peer re-dispatched after cancel class RollbackBarrierViolation(RuntimeError): """Raised when re-commit is attempted while escaped side effects are unresolved.""" pass @dataclass class DispatchEntry: branch_id: str call_id: str peer_id: str state: AckState = AckState.PENDING @dataclass class DispatchLedger: entries: Dict[str, DispatchEntry] = field(default_factory=dict) epoch: int = 0 def record_dispatch(self, branch_id: str, call_id: str, peer_id: str) -> None: self.entries[call_id] = DispatchEntry(branch_id, call_id, peer_id) def mark(self, call_id: str, state: AckState) -> None: if call_id not in self.entries: raise RollbackBarrierViolation(f"unknown call_id {call_id}") self.entries[call_id].state = state def unresolved_for_epoch(self) -> Set[str]: return { cid for cid, e in self.entries.items() if e.state in (AckState.PENDING, AckState.RETRY_SHADOW) } def gate_recommit(ledger: DispatchLedger, survivor_branch: str, aborted: Set[str]) -> None: """Re-commit is legal only when every escaped call is terminal.""" # Any aborted branch with a PENDING or RETRY_SHADOW call blocks the gate. for cid in ledger.unresolved_for_epoch(): entry = ledger.entries[cid] if entry.branch_id in aborted: raise RollbackBarrierViolation( f"branch {entry.branch_id} aborted but call {cid} on peer " f"{entry.peer_id} is {entry.state.value}; re-commit of " f"{survivor_branch} would land under a zombie side effect" ) # Survivor's own outstanding calls must also be terminal before it commits. for cid, entry in ledger.entries.items(): if entry.branch_id == survivor_branch and entry.state is AckState.PENDING: raise RollbackBarrierViolation( f"survivor {survivor_branch} has unacked call {cid}" ) # --- failure trace reproduction --- ledger = DispatchLedger(epoch=41) ledger.record_dispatch("C", "call-7", "peer-writer") ledger.record_dispatch("B", "call-9", "peer-writer") ledger.mark("call-9", AckState.ACKED) # C aborts; orchestrator issues cancel, but peer's retry policy re-dispatches. ledger.mark("call-7", AckState.RETRY_SHADOW) # Naive orchestrator would re-commit B here; the gate refuses. try: gate_recommit(ledger, survivor_branch="B", aborted={"A", "C"}) except RollbackBarrierViolation as exc: print(f"BLOCKED: {exc}") # Escalate to full-epoch abort or wait for call-7 terminal. ```