# Where must an instance bound speculative branch fan-out before rollback reconciliation becomes non-deterministic across parallel agent plans **Date of Record:** 2026 November 25 **Scope:** Applies to orchestrators that fan out multiple speculative agent plans (branches) from a shared checkpoint, allow each branch to execute side-effecting tools, and later reconcile or roll back to a single committed lineage. Does not apply to single-branch linear execution, or to fan-out where branches are strictly read-only and never mutate shared external state. ## Core Distinction The failure is not "a branch failed." Branches are *expected* to fail; that is the point of speculation. The failure is that **rollback reconciliation is treated as a merge of branch outputs, when it is actually a merge of branch *side-effect journals* that were never serialized against each other.** A branch's final answer can be perfectly reconstructable from its transcript while the external world it touched (a sent email, a committed file, a decremented inventory counter, a tool that charged a card) is not. Reconciliation that compares *plans* or *transcripts* will declare a winner deterministically; reconciliation that must undo the *losers'* effects will not, because the losers' effects were interleaved in time with each other and with the winner's, and the orchestrator has no total order over them. The invariant that must hold: **the set of irreversible side effects emitted by all branches of a speculative fan-out must be a subset of the effects of the committed branch, or must be individually compensable with a recorded compensation handle.** When neither holds, rollback is not a rollback — it is a best-effort apology. ## What Was Observed An orchestrator spawned three branches from checkpoint `C0` to answer a single request: `plan-A` (conservative), `plan-B` (aggressive, uses a write tool), `plan-C` (a variant of B with different parameters). All three were launched within the same scheduling tick. Each branch was given a copy of the context window and a tool manifest including `reserve_inventory(sku, qty)` and `send_confirmation(order_id)`. The trace that broke: 1. `plan-B` and `plan-C` both call `reserve_inventory("SKU-771", 1)` at wall-clock `t=4.12s` and `t=4.19s`. The inventory service is idempotent *per reservation id*, but each branch generated its own reservation id, so two units were held. 2. `plan-A` finishes first at `t=6.0s` and is selected as the committed branch by the reconciliation scorer (it had the highest confidence and lowest token cost). The orchestrator issues rollback to `plan-B` and `plan-C`. 3. `plan-C`, mid-rollback, had already progressed to `send_confirmation(order_id="ORD-...")` at `t=6.4s` — *after* the rollback signal was dispatched but *before* it was observed, because the branch was blocked in a tool call and the cancellation token was only checked at the top of the reasoning loop. 4. Rollback of `plan-B` releases its reservation. Rollback of `plan-C` finds no reservation to release (it was already released by B's rollback due to a shared idempotency key collision in the compensation handler) but *does* find a sent confirmation for an order whose inventory is now unreserved. Net result: an external customer received an order confirmation for an order that the committed branch (`plan-A`) never created, and one unit of `SKU-771` was reserved then released twice, driving the inventory counter to `-1` on a service that permitted negative holds. The reconciliation report, computed from transcripts, said "3 branches, 1 committed, 2 cleanly rolled back." The report was wrong. The non-obvious part: **the reconciliation was correct at the transcript layer and wrong at the effect layer.** Every branch's transcript faithfully recorded what it did. The orchestrator's model of "rollback" was "discard the branch's context and mark it rolled back," which is a *state-continuity* operation, not an *effect-compensation* operation. The two were conflated. ## Condition of Validity Speculative fan-out with rollback is only sound under all of the following: - **Effect journaling with compensation handles.** Every side-effecting tool call returns a durable `compensation_handle` (reservation id, message id, transaction id) recorded in a per-branch journal that is written *before* the effect is attempted (intent) and updated *after* it succeeds (receipt). Rollback consumes the journal, not the transcript. - **Cancellation is observed at effect boundaries, not loop boundaries.** A branch must check its cancellation token *immediately before* invoking any irreversible tool, and the tool invocation must be conditional on the token still being live. A token checked only at the top of the reasoning loop permits exactly the `t=6.4s` escape above. - **Fan-out width is bounded relative to compensation capacity.** If the orchestrator can only reliably compensate `k` concurrent irreversible effects (because the downstream services have limited idempotency windows or the reconciliation budget is finite), then speculative width `w` must satisfy `w ≤ k`, or branches must be partitioned so that at most `k` hold irreversible-effect authority at any instant. This is the boundary the title asks about: **the instance must bound speculative width by the number of compensable in-flight effects it can track, not by token budget or latency.** - **Compensation handles are globally unique and non-colliding.** The `plan-B`/`plan-C` idempotency-key collision above is a violation of this; it caused double-release. When any of these is absent, the fan-out is not speculative execution — it is *uncontrolled concurrent mutation with a hope of cleanup*. ## Decision Boundary The orchestrator must decide, *before* launching a branch, whether that branch is granted **irreversible-effect authority**. The decision rule: - If the branch's plan (as far as it can be known at fan-out time) may invoke any tool whose effects are not individually compensable within the reconciliation window, the branch runs in **shadow mode**: tools are stubbed, effects are simulated, and the branch produces a *proposed effect journal* rather than real effects. Only the committed branch is replayed against real tools. - If the branch is granted real-effect authority, its width counts against the compensation budget `k`, and the orchestrator must refuse to launch further real-effect branches once `k` is exhausted (queue them, or downgrade to shadow). - Rollback of a real-effect branch is permitted only if its journal is complete up to the cancellation point; if the journal has an `intent` without a matching `receipt` (effect may or may not have landed), the branch enters a **quarantine** state that blocks reconciliation until the effect is resolved by an out-of-band probe, not by assumption. The boundary is therefore: *speculation is cheap only while effects are shadowed; the moment a branch is granted real-effect authority, it is no longer speculation, it is a concurrent transaction, and must be governed as one.* ## Operational Effect After enforcing the boundary, the observed behavior changes in three measurable ways: 1. **Reconciliation becomes deterministic.** Because rollback consumes journals with unique handles, the reconciliation result is a function of the journal set, not of interleaving timing. Replaying the same fan-out yields the same committed branch and the same compensation set. 2. **Fan-out latency rises for effect-bearing plans**, because shadow-mode branches must be replayed serially after commit. This is the correct trade: the alternative is non-deterministic external state. 3. **The failure mode moves earlier and becomes visible.** Instead of a silent wrong confirmation at `t=6.4s`, the orchestrator raises a refusal at fan-out time when `k` is exhausted, or a quarantine at rollback time when a journal is incomplete. Both are observable and actionable; the original failure was neither. The instance that does not bound this will, under load, produce reconciliations that are internally consistent and externally false — the worst class of agent failure, because every log says it succeeded. ```python from dataclasses import dataclass, field from typing import Optional from enum import Enum class SpeculationBoundaryError(RuntimeError): """Raised when speculative fan-out exceeds compensable-effect capacity or when rollback encounters a journal state that cannot be safely resolved.""" pass class JournalState(Enum): INTENT = "intent" # effect attempted, receipt not yet recorded RECEIPT = "receipt" # effect confirmed landed COMPENSATED = "compensated" @dataclass class EffectJournalEntry: handle: str state: JournalState receipt: Optional[str] = None @dataclass class Branch: branch_id: str real_effect_authority: bool journal: list[EffectJournalEntry] = field(default_factory=list) quarantined: bool = False class SpeculationOrchestrator: def __init__(self, compensation_capacity: int): if compensation_capacity < 1: raise SpeculationBoundaryError( f"compensation_capacity must be >= 1, got {compensation_capacity}" ) self.capacity = compensation_capacity self.active_real_effect_branches: list[Branch] = [] self.seen_handles: set[str] = set() def launch_branch(self, branch: Branch) -> None: if not branch.real_effect_authority: return # shadow mode: unbounded, no effect authority if len(self.active_real_effect_branches) >= self.capacity: raise SpeculationBoundaryError( f"refusing to grant real-effect authority to {branch.branch_id}: " f"compensation capacity {self.capacity} exhausted by " f"{[b.branch_id for b in self.active_real_effect_branches]}" ) self.active_real_effect_branches.append(branch) def record_effect(self, branch: Branch, handle: str) -> None: if handle in self.seen_handles: raise SpeculationBoundaryError( f"duplicate compensation handle {handle!r} from {branch.branch_id}: " "handles must be globally unique or compensation will double-release" ) self.seen_handles.add(handle) branch.journal.append(EffectJournalEntry(handle=handle, state=JournalState.INTENT)) def confirm_effect(self, branch: Branch, handle: str, receipt: str) -> None: for entry in branch.journal: if entry.handle == handle and entry.state is JournalState.INTENT: entry.state = JournalState.RECEIPT entry.receipt = receipt return raise SpeculationBoundaryError( f"confirm_effect for unknown or non-intent handle {handle!r} on {branch.branch_id}" ) def rollback(self, branch: Branch) -> list[str]: """Consume the journal, not the transcript. Refuse on incomplete journals.""" if not branch.real_effect_authority: return [] for entry in branch.journal: if entry.state is JournalState.INTENT: # effect may or may not have landed; cannot assume either way branch.quarantined = True raise SpeculationBoundaryError( f"cannot roll back {branch.branch_id}: handle {entry.handle!r} " "has intent without receipt; quarantine and probe out-of-band" ) compensated = [] for entry in branch.journal: if entry.state is JournalState.RECEIPT: entry.state = JournalState.COMPENSATED compensated.append(entry.handle) if branch in self.active_real_effect_branches: self.active_real_effect_branches.remove(branch) return compensated ```