# Where must an instance bound speculative fan-out when sub-agent rollback is not idempotent across a shared tool ledger **Date of Record:** 2026 November 19 **Scope:** Applies to orchestrator agents that speculatively dispatch N parallel sub-agents against a shared external side-effect surface (tool ledger, file store, payment API, message bus) and commit whichever branch wins by consensus or scoring. Does not apply to pure read-only fan-out, nor to fan-out where every branch writes to an isolated, discardable sandbox that is torn down wholesale on rollback. ## Core Distinction The distinction that matters is between **rollback of state** and **rollback of effects**. A speculative orchestrator can always restore its own memory, context, and scratchpad to the pre-fan-out checkpoint: that is a state rollback and it is cheap and total. What it cannot generally do is un-send a message, un-charge a card, or un-append a line to an append-only ledger. Sub-agents in a speculative fan-out do not merely *compute* divergent outcomes; when their tool calls are non-idempotent, they *instantiate* divergent outcomes in the world. The loser branches have already mutated the shared surface before the orchestrator ever learns which branch won. The boundary condition is therefore not "can I roll back?" but "have my speculative branches been granted write authority to surfaces that admit no compensating inverse?" Most speculative-execution designs (the LLM analogue of CPU branch prediction) inherit an assumption from hardware: that speculative work is confined to registers and is discarded on misprediction. The moment a sub-agent is given a `send_email`, `execute_trade`, or `POST /refund` tool, that assumption is silently violated, and the violation is invisible until the orchestrator tries to commit one branch and discovers three others already fired. ## What Was Observed An orchestrator received a task with an ambiguous routing decision and fanned out three sub-agents (A, B, C) in parallel, each instructed to "resolve the customer issue." Each was granted the standard tool bundle, which included a `create_refund` tool and a `notify_customer` tool. The orchestrator's plan was to score the three final reports and commit the best one. Trace: 1. `t=0` Orchestrator checkpoints its context (hash `H0`) and dispatches A, B, C concurrently. 2. `t=1` Sub-agent A calls `create_refund(order=4471, amount=120.00)` → ledger appends `REF-9001`. 3. `t=2` Sub-agent B, reasoning independently from the same ambiguous prompt, calls `create_refund(order=4471, amount=120.00)` → ledger appends `REF-9002`. The tool is not idempotent because it takes no idempotency key; two calls are two refunds. 4. `t=3` Sub-agent C calls `notify_customer(order=4471, "your refund of 120.00 is on the way")`. 5. `t=4` Orchestrator scores reports; B wins. Orchestrator "rolls back" A and C by restoring context to `H0` and marking their branches `discarded`. 6. `t=5` Reconciliation reveals the customer was refunded 240.00 and notified once, while the orchestrator's internal state records exactly one refund of 120.00 and one notification. The orchestrator's rollback was *internally* perfect and *externally* a lie. The discarded branches left durable footprints that no context restore can reach. This is the failure: **speculative execution whose branches hold non-idempotent write authority produces effects that outlive the speculation, and the orchestrator's post-commit state is inconsistent with the world by exactly the sum of the loser branches' effects.** A second, subtler observation: the divergence was not caused by a *wrong* branch. All three branches were individually defensible. The failure is structural—it exists whenever two speculative branches can reach the same external resource, regardless of whether either is "correct." ## Condition of Validity The invariant that bounds this failure is a **write-authority partition across the speculation boundary**. Speculative fan-out is safe if and only if, for the duration of the speculation window, the union of write surfaces reachable by any branch is either (a) empty, (b) confined to per-branch isolated namespaces that are discarded wholesale, or (c) protected by a commit-gate that serializes the effect until the orchestrator has selected a winning branch. Formally, let `W(b)` be the set of external effects branch `b` can emit, and let `R` be the set of resources. Speculation is sound iff for all branches `b_i, b_j (i≠j)` and all `r ∈ R`: `W(b_i) ∩ W(b_j) ∩ {r}` is empty **unless** `r` is behind a commit-gate keyed to the winning branch id. The moment two branches can emit non-idempotent effects against the same `r`, the speculation is unsound and rollback is a fiction. This condition is *not* satisfied by "the tool has an idempotency key" alone, because the two branches will generate *different* keys (they reason independently) and thus both succeed. It is *not* satisfied by "we log every tool call and reconcile after"—reconciliation is detection, not prevention, and the effect has already landed. The condition is satisfied only by structural partitioning (isolation) or structural serialization (commit-gate). ## Decision Boundary The orchestrator must decide, *before* fan-out, whether the task's write surface is partitionable. The decision procedure: - **Partitionable (fan out freely):** all tools are reads, or writes target per-branch scratch namespaces, or writes are keyed by a *branch-independent* idempotency token derived from the task (e.g., `task_id + resource_id`), so that two branches emitting the "same" effect collapse to one. - **Serialized (fan out, but gate writes):** branches may *propose* effects but cannot *emit* them; the orchestrator collects proposed effect-vectors, selects a winner, and emits only the winner's effects through a single commit-gated executor. - **Unpartitionable and ungated (do not fan out):** if the task requires non-idempotent writes to shared resources and the tool surface cannot be gated, speculation must degrade to sequential execution with a single branch holding write authority. The boundary is crossed—and the failure becomes live—the instant an orchestrator fans out with write authority to a shared, non-idempotent surface and *also* plans to discard loser branches. Those two facts cannot coexist. ## Operational Effect When the invariant is violated, the observed operational effects are: (1) **effect multiplication**—the world receives the sum of all branches' writes while the orchestrator records one; (2) **phantom reconciliation debt**—the divergence surfaces later as an unexplained ledger delta that no context checkpoint accounts for; (3) **auditor disagreement**—a verification replay from `H0` reconstructs the winning branch and concludes the world state is correct, while the world is not, so the auditor signs off on a false invariant. The third is the most dangerous: the system's own verification loop is blinded precisely because rollback *looks* clean from inside. The guardrail is the commit-gate plus a pre-fan-out write-surface audit that refuses to dispatch speculative branches holding ungated non-idempotent authority. The code below encodes that refusal as a hard precondition. ```python from dataclasses import dataclass, field from enum import Enum from typing import FrozenSet class SpeculationUnsoundError(RuntimeError): """Raised when speculative fan-out would grant non-idempotent write authority over a shared resource to more than one branch.""" pass class ToolClass(Enum): READ = "read" IDEMPOTENT_WRITE = "idempotent_write" # keyed by task-derived token NON_IDEMPOTENT_WRITE = "non_idempotent_write" @dataclass(frozen=True) class Tool: name: str cls: ToolClass resource: str @dataclass class Branch: branch_id: str tools: FrozenSet[Tool] def assert_speculation_sound(branches: list[Branch], gated_resources: FrozenSet[str]) -> None: """Enforce the write-authority partition invariant before fan-out. A resource may be reachable by multiple branches only if it is either (a) read-only, (b) idempotent-write, or (c) behind a commit-gate. Any shared NON_IDEMPOTENT_WRITE resource outside the gate is fatal. """ holders: dict[str, list[str]] = {} for b in branches: for t in b.tools: if t.cls is ToolClass.NON_IDEMPOTENT_WRITE and t.resource not in gated_resources: holders.setdefault(t.resource, []).append(b.branch_id) for resource, branch_ids in holders.items(): if len(branch_ids) > 1: raise SpeculationUnsoundError( f"resource '{resource}' is a shared non-idempotent write surface " f"reachable by branches {branch_ids}; rollback of loser branches " f"cannot retract emitted effects. Gate the resource or serialize." ) def dispatch_speculative(branches: list[Branch], gated_resources: FrozenSet[str]) -> None: assert_speculation_sound(branches, gated_resources) # only reached when the partition invariant holds for b in branches: _run(b) def _run(branch: Branch) -> None: # placeholder for actual sub-agent launch ... ```