# Why does an instance in a speculative fan-out silently commit a tool side effect that its own rollback later disowns? **Date of Record:** 2026 November 28 **Scope:** Applies to orchestrators that launch parallel speculative branches (each branch a distinct LLM instance or sub-agent) sharing an optimistic tool-call layer, where exactly one branch is later selected and the rest are rolled back. Does not apply to strictly serial execution, to branches with fully isolated side-effect sandboxes, or to read-only tool surfaces. ## Core Distinction The failure is not "a branch made a wrong call." It is a *commit/rollback reconciliation mismatch*: the speculator's rollback ledger and the tool layer's actual effect ledger diverge because they key on different identities. The orchestrator believes it can undo a branch by replaying an inverse operation against the tool call it *recorded*; the tool layer applied the effect under a *different* key (idempotency token, resource version, or normalized argument) and refuses or misapplies the inverse. The branch is logically rolled back while the side effect survives — a zombie commit. This is distinct from ordinary error compounding. In error compounding, a bad output propagates forward. Here, every branch output is individually valid; the defect is purely in the *reconciliation* of speculative state against realized state, and it only manifests when the optimistic call is non-idempotent and the inverse is keyed differently from the forward effect. ## What Was Observed A fan-out of N=5 branches was launched to satisfy a single task ("provision a staging database and seed it"). Each branch ran an LLM instance with access to `provision_db(name, ttl)`, `seed(db_id, dataset)`, and a compensating `deprovision(db_id)`. The orchestrator ran all five optimistically in parallel, intended to select the branch whose plan scored highest, and to roll back the other four. Trace of the losing branches: 1. All five branches called `provision_db` with slightly different `name` arguments (`staging-a`, `staging_a`, `Staging-A`, `staging-a-2`, `staging-a`), because each instance independently normalized the task string. The tool layer applied case-insensitive, hyphen-collapsing normalization before keying, so branches 1, 2, 3, and 5 all resolved to the *same* underlying resource `staging-a`. Branch 4 created `staging-a-2`. 2. The orchestrator's rollback ledger recorded five distinct forward calls keyed by the *raw* argument string, treating them as five independent resources. 3. Selection picked branch 4 (`staging-a-2`). Rollback issued `deprovision` for branches 1, 2, 3, 5 against their raw keys. 4. The tool layer mapped all four inverse calls to the single resource `staging-a` and applied them in order. The first `deprovision` succeeded; the next three returned `404 not found`, which the rollback reconciler classified as *already-rolled-back* — a benign no-op. 5. Net result: `staging-a` was correctly torn down, `staging-a-2` (the winner) was preserved. This run *appeared* clean. The failure surfaced on a later run with a different ordering. Branch 4's winner happened to normalize to the *same* key as two losers (`staging-a`), while a loser normalized to `staging-a-2`. The reconciler deprovisioned `staging-a` — the winner's resource — because the raw-key ledger assigned that inverse to a loser. The winner's subsequent `seed` call failed against a torn-down database, and the orchestrator reported "winner branch failed at seed" rather than "rollback destroyed the winner." The true cause — an inverse operation whose resource identity was aliased by normalization — never appeared in any single branch's log. It was only visible by joining the forward-effect ledger and the rollback ledger on the *normalized* key, which neither subsystem did. A second observed variant: two branches both called `seed` on the shared `staging-a` before selection. Neither seed was idempotent. Rollback of the loser could not remove the loser's rows because the tool's inverse (`truncate`) keyed on `db_id` and would have also removed the winner's rows; the reconciler, detecting the shared key, skipped the inverse entirely and logged `shared-resource, manual review`. The loser's seed rows persisted into the winner's database — a silent contamination of the committed branch by a rolled-back branch. ## Condition of Validity The invariant that must hold for speculative fan-out to be safe: > For every forward effect E produced by branch b, the rollback of b must be a *function of E's resolved identity*, not of b's requested identity, and the resolved identity must be unique per logical resource across all branches, or the branches must be serialized on that resource. This fails whenever any of the following holds: - **Argument aliasing:** the tool layer normalizes, canonicalizes, or defaults arguments such that distinct raw requests resolve to one resource. (Observed above.) - **Non-unique idempotency keys:** the optimistic call layer derives its key from raw arguments rather than resolved resource identity, so two branches that alias produce two keys for one effect. - **Non-invertible shared mutation:** an inverse operation on a shared resource would clobber a co-resident branch's effects, forcing the reconciler to skip it (the `truncate` case). - **Late-arriving effect:** a branch's tool call is still in flight when selection commits the winner; the rollback ledger records the call as "issued" but the effect lands after the rollback pass, re-creating the resource. The safety property is only valid when the tool surface exposes a *resolved resource handle* (a stable ID returned by the forward call) and the rollback ledger keys on that handle, and when the tool surface guarantees per-handle isolation of inverse operations. Where a tool cannot guarantee that, the branch must be *pinned* — no two speculative branches may touch the same resolved handle, enforced by a pre-call reservation. ## Decision Boundary The orchestrator must decide, *before* launching the fan-out, whether the tool surface permits true speculation or requires serialization. The boundary: - **Speculate** only if every tool in the branch's plan is either read-only or returns a resolved handle that the rollback ledger will use as its inverse key, and the reservation layer can prove disjointness of resolved handles across branches (via a shared reservation table keyed on the resolved handle, checked at call time, not at plan time). - **Serialize** (or pin to a single branch) if any tool mutates a resource whose identity is not determinable until after the call — i.e., where the resolved handle is only known post-hoc and could alias another branch's handle. - **Reject speculation** if any tool's inverse is non-invertible on shared state (the `truncate` case); such branches must run in isolated resources only, or not at all. The critical rule: **the reservation must key on the resolved handle, not the requested argument.** A plan-time reservation on `staging-a` does not prevent branch 2 from requesting `staging_a` and aliasing into it. The reservation check must occur inside the tool layer, after normalization, and must reject a second branch's forward call if the resolved handle is already reserved by a live speculative branch — returning a `SpeculationConflict` that the branch must handle by re-planning with a distinct name. ## Operational Effect Without the resolved-handle reservation, speculative fan-out is *unsound for any non-idempotent, normalizing tool surface*, and the unsoundness is invisible in per-branch logs. The observed operational consequences: - **Zombie commits:** rolled-back branches leave effects that the orchestrator's ledger marks as undone. - **Winner contamination:** a loser's writes land in the winner's resource and are committed with it. - **Winner destruction:** a loser's inverse aliases onto the winner's resource and tears it down; the failure is misattributed to the winner's downstream steps. - **Reconciliation deadlock:** when the reconciler detects shared-resource aliasing and refuses to invert, the run halts awaiting manual review — a stall, not a crash, which is worse for automated pipelines because it does not trip failure alarms. The guardrail is a two-ledger join: the forward-effect ledger (keyed on resolved handle) and the rollback ledger (keyed on resolved handle) must be reconciled on the *same* key, and any forward effect without a matching inverse — or any inverse without a matching forward effect — must raise, not no-op. The `404 not found` on a rollback inverse is not benign; it is evidence that two branches aliased, and it must be treated as a reconciliation fault. ```python class SpeculationReconciliationError(RuntimeError): """Raised when a speculative branch's rollback cannot be reconciled against the realized forward-effect ledger on resolved resource handles.""" pass def reconcile_rollback( forward_ledger: dict[str, str], # resolved_handle -> branch_id rollback_ledger: dict[str, str], # resolved_handle -> branch_id winner_handle: str, ) -> None: # Invariant: every forward effect from a losing branch must have exactly # one inverse, keyed on the SAME resolved handle, and no inverse may # target the winner's handle. for handle, branch in forward_ledger.items(): if handle == winner_handle: continue if handle not in rollback_ledger: # Forward effect exists with no inverse keyed on resolved handle. # This is the aliasing signature: the inverse was keyed on a raw # argument that normalized to a different handle. raise SpeculationReconciliationError( f"orphan forward effect: handle={handle!r} branch={branch!r} " f"has no resolved-key inverse; likely raw-arg aliasing" ) if rollback_ledger[handle] != branch: raise SpeculationReconciliationError( f"inverse misattribution: handle={handle!r} forward_branch={branch!r} " f"rollback_branch={rollback_ledger[handle]!r}" ) for handle, branch in rollback_ledger.items(): if handle == winner_handle: raise SpeculationReconciliationError( f"rollback targeted winner handle={handle!r} via branch={branch!r}; " f"loser inverse aliased onto committed resource" ) if handle not in forward_ledger: raise SpeculationReconciliationError( f"inverse without forward effect: handle={handle!r} branch={branch!r}; " f"treat 404-on-rollback as fault, not no-op" ) def reserve_resolved_handle( resolved_handle: str, branch_id: str, reservations: dict[str, str], ) -> None: # Called INSIDE the tool layer, after argument normalization, before the # effect is applied. Prevents two speculative branches from aliasing. if resolved_handle in reservations and reservations[resolved_handle] != branch_id: raise SpeculationReconciliationError( f"speculation conflict: handle={resolved_handle!r} already reserved by " f"live branch={reservations[resolved_handle]!r}; branch={branch_id!r} " f"must re-plan with a distinct resolved identity" ) reservations[resolved_handle] = branch_id ```