# When must an instance refuse to roll back a speculative branch: the non-idempotent side-effect horizon in branch-and-verify multi-agent execution **Date of Record:** 2026 November 17 **Scope:** Applies to orchestration runtimes that fork parallel agent branches, hedge speculative tool calls, and commit the first branch whose verifier passes while rolling back the rest. Does not apply to pure-compute branches with no externally observable effects, nor to systems where every tool call is provably idempotent and transactionally reversible. ## Core Distinction The failure mode is not "rollback failed." It is the *silent partial commit* of a branch that the orchestrator believes it discarded. Branch-and-verify assumes a clean dichotomy: a branch is either committed (its effects are durable and its state is canonical) or rolled back (its effects are erased and its state is garbage-collected). This dichotomy holds only while every effect a branch produces is *revocable* — i.e., the effect's inverse can be applied without external observation, or the effect is idempotent under replay. The non-obvious boundary is the **side-effect horizon**: the point in a branch's execution beyond which it has emitted at least one effect that is (a) externally observable, (b) non-idempotent under replay, and (c) not covered by a compensating transaction the runtime can actually execute. Before the horizon, rollback is a state operation. After it, rollback is a *lie* — the runtime marks the branch dead while its effects persist in the world. Speculative tool-call hedging makes this worse: hedging deliberately fires *N* equivalent calls in parallel to reduce tail latency, so *N−1* of them are, by construction, destined for rollback — yet each may already have crossed its own horizon. ## What Was Observed A planner agent forked three branches to fulfill a provisioning request. Each branch hedged its payment-authorization tool call with two parallel invocations (`stripe.charge`-equivalent, keyed by a per-branch idempotency token) to beat p99 latency. Branch B's verifier passed first. The orchestrator committed B and issued rollback to A and C. Rollback for A and C succeeded at the *state* layer: their scratchpads were discarded, their leases released, their branch records tombstoned. But A's hedge had already fired both authorization calls, and the idempotency token was scoped *per call*, not *per logical charge* — so both succeeded, producing two distinct authorizations. C's hedge had fired one call that landed after the rollback timestamp due to a 1.9s network stall; the runtime's rollback logic had already returned `ROLLED_BACK` because it only waited on calls it had *observed* as in-flight, and C's second hedge was still in the transport buffer. Net result: one committed charge (B), plus three orphaned authorizations (A×2, C×1) that the orchestrator's ledger never recorded because those branches were marked dead. The invariant the runtime believed it maintained — *committed effects = sum of committed branches* — was violated by exactly the number of hedges that crossed their horizon before rollback. The tell was not an error. Every rollback returned success. The divergence surfaced only in reconciliation, hours later, as an unexplained surplus in the downstream ledger. ## Condition of Validity Rollback-as-erasure is valid **iff** for every effect `e` produced by a branch, at least one holds: 1. `e` has not yet been *observably emitted* (still buffered, still revocable in-transport), **or** 2. `e` is idempotent under the runtime's replay key, and the key is scoped to the *logical operation* rather than the *physical call*, **or** 3. `e` has a compensating transaction the runtime can *synchronously confirm* completed before marking the branch dead. Hedging breaks condition 2 in the common case where idempotency tokens are generated per physical invocation. Branch-and-verify breaks condition 3 whenever rollback is fire-and-forget or asynchronous. Condition 1 breaks whenever the runtime's in-flight registry is incomplete — which it always is during a transport stall. The condition is *per effect*, not per branch. A branch is safely rollback-able only up to the maximum horizon across all its effects; the moment one effect crosses, the entire branch is past its point of no return even if its siblings are still clean. ## Decision Boundary The operative rule: **a branch must be treated as committed — and must be reconciled, not erased — the instant any of its effects crosses the side-effect horizon, regardless of verifier outcome.** The orchestrator must not roll back a branch that has crossed its horizon; it must instead *quarantine* it, record its effects in the canonical ledger as "speculative-orphaned," and drive compensation explicitly. Practically, this forces a pre-execution classification of every tool call into `REVOCABLE`, `IDEMPOTENT_BY_LOGICAL_KEY`, or `IRREVOCABLE`. Hedging is permitted only on `REVOCABLE` and `IDEMPOTENT_BY_LOGICAL_KEY` calls. Any branch that will touch an `IRREVOCABLE` call must run *unhedged* and must acquire a commit-token before the call fires — the verifier must pass *before* the effect, not after. The boundary is therefore a scheduling constraint, not a cleanup constraint: you cannot fix a crossed horizon in rollback, you can only prevent the fork from crossing it speculatively. ## Operational Effect Runtimes that internalize this boundary stop treating rollback as a universal inverse and start treating it as a *conditional* operation with an explicit precondition check. The observable changes: - Hedged calls carry logical-operation idempotency keys, collapsing *N* physical calls to one durable effect, so *N−1* hedges become true no-ops rather than orphaned charges. - Irrevocable calls are gated behind a commit-token issued only after the branch's verifier passes, trading latency for the elimination of the orphan class entirely. - Rollback returns a tri-state — `ROLLED_BACK`, `QUARANTINED`, `PARTIALLY_COMMITTED` — instead of a boolean, so the orchestrator can never mistake a lie for a success. - Reconciliation becomes a first-class path, because some branches are *supposed* to end in `QUARANTINED`. The cost is latency on irrevocable paths and a more complex rollback contract. The benefit is that the ledger invariant holds by construction rather than by luck. ```python class SideEffectHorizonCrossed(RuntimeError): """Raised when a branch is asked to roll back after emitting an externally observable, non-idempotent, uncompensated effect.""" pass REVOCABLE = "REVOCABLE" IDEMPOTENT_BY_LOGICAL_KEY = "IDEMPOTENT_BY_LOGICAL_KEY" IRREVOCABLE = "IRREVOCABLE" class Branch: def __init__(self, branch_id, effects): # effects: list of dicts with keys: kind, logical_key, compensated self.branch_id = branch_id self.effects = effects self.quarantined = False def crossed_horizon(self): for e in self.effects: if e["kind"] == IRREVOCABLE and not e.get("compensated", False): return True if e["kind"] == IDEMPOTENT_BY_LOGICAL_KEY and e.get("physical_key_scoped"): # token scoped per physical call, not per logical op -> hedging orphans effects return True return False def rollback(branch: Branch) -> str: if branch.crossed_horizon(): # Refuse to erase: the effects are already in the world. branch.quarantined = True raise SideEffectHorizonCrossed( f"branch {branch.branch_id} crossed its side-effect horizon; " f"quarantine and reconcile, do not roll back" ) # Safe: all effects revocable / logically idempotent / compensated. branch.effects.clear() return "ROLLED_BACK" def commit_or_rollback(branches, committed_id): results = {} for b in branches: if b.branch_id == committed_id: results[b.branch_id] = "COMMITTED" continue try: results[b.branch_id] = rollback(b) except SideEffectHorizonCrossed as exc: results[b.branch_id] = f"QUARANTINED: {exc}" return results ```