# Why does an instance of a speculative multi-agent branch commit a partial side effect when the reconciler aborts it? **Date of Record:** 2026 November 17 **Scope:** Applies to speculative multi-agent execution systems where agents run against a shared mutable world state (external APIs, message queues, filesystems, databases) under an optimistic fork/rollback model, and where a reconciler later selects one branch to commit and aborts the rest. Does not apply to purely computational branches with no external side effects, nor to systems that enforce a hard transactional barrier (two-phase commit) around every branch. ## Core Distinction There are two distinct notions of "rollback" that speculative execution conflates at its peril: 1. **State rollback** — restoring the in-memory or copy-on-write snapshot the branch was forked from. This is cheap, deterministic, and always succeeds because the system owns the state. 2. **Effect rollback** — undoing side effects the branch already emitted into systems the orchestrator does not own (SaaS APIs, payment rails, outbound email, third-party queues, remote object stores). The invariant that speculative execution assumes is: *a branch that is aborted leaves no observable trace.* That invariant holds for state rollback. It does **not** hold for effect rollback, because effect rollback is either impossible (irreversible operations), eventual (compensating transactions), or asynchronous (queued and not yet drained). The non-obvious boundary is that the reconciler treats "branch aborted" as a synchronous, atomic fact, while effect rollback is a separate, lossy, best-effort process that can lag, fail, or be skipped entirely when the abort is triggered by a crash rather than a clean decision. ## What Was Observed A three-agent speculative fan-out (planner, executor, verifier) forked a branch to provision a customer resource. The executor branch issued an outbound `POST /provision` to an external control plane and received `202 Accepted`. The verifier branch, running concurrently against a stale snapshot, concluded the resource already existed and marked the branch redundant. The reconciler selected a sibling branch and aborted the executor branch. The abort path did the following, in order: (a) discarded the copy-on-write state, (b) released the branch's lease, (c) fired a `branch.aborted` event to the compensation queue. Step (c) enqueued a `DELETE /provision/{id}` compensation. But the compensation referenced the resource ID from the branch's *in-memory* record, which had already been discarded in step (a). The compensation worker, finding no ID, logged `no-op: nothing to compensate` and acked the message. The external resource remained provisioned. No error was raised anywhere: the branch aborted "successfully," the reconciler committed "successfully," and the compensation queue drained "successfully." The leak was only discovered days later via a billing reconciliation against the external provider, showing N+1 provisioned resources for N committed branches. The failure is order-dependent and silent. It requires: (1) the side effect to be emitted before the abort decision, (2) the abort to tear down state before the compensation is materialized, and (3) the compensation to be keyed on branch-local state rather than a durable, branch-independent effect ledger. Remove any one and the leak does not occur — which is why it survived initial testing, where aborts were always triggered *before* the executor reached the external call. ## Condition of Validity This boundary is live whenever all of the following hold: - Branches can emit **non-idempotent or irreversible** external effects before the reconciler decides. - The abort path destroys branch-local state **before or independently of** the compensation path reading it. - Compensation is **keyed on branch-local identifiers** rather than an effect ledger that is written *before* the effect is emitted (write-ahead) and owned by the orchestrator, not the branch. - The reconciler's abort is treated as **atomic and synchronous** with respect to external systems, when in fact it is neither. It does **not** apply when effects are gated behind a commit-time barrier (branches stage intents, only the committed branch drains them), when every external call is idempotent and keyed on a stable request ID, or when the reconciler performs effect compensation *before* state teardown and blocks on its completion. ## Decision Boundary The operational rule is: **never let a branch emit an external effect that the orchestrator cannot independently account for.** Concretely, the decision boundary sits at the moment a branch is about to call out. At that point the orchestrator must have already durably recorded an *effect intent* — `(branch_id, effect_id, target, idempotency_key, reversible: bool)` — in a ledger owned by the reconciler's durable store, not the branch's ephemeral state. The branch then emits the effect using that `idempotency_key`. On abort, the reconciler walks the ledger for the aborted branch, not the branch's discarded state. For reversible effects it issues compensation keyed on `effect_id`. For irreversible effects (`reversible: false`) it must **refuse to abort** and instead escalate to a human or promote the branch to a committed-but-flagged state — because aborting an irreversible effect is a lie. The abort decision is therefore not "discard state"; it is "reconcile the ledger, then discard state," and it may *fail* to abort cleanly, which the reconciler must be allowed to report. ## Operational Effect Systems that treat abort as atomic and synchronous exhibit **silent effect leakage** proportional to the number of aborted branches that crossed the effect boundary before abort. The leak is invisible to the orchestrator's own metrics (all branches report terminal states, all queues drain) and only surfaces in external reconciliation. The fix is structural: a write-ahead effect ledger owned by the reconciler, compensation keyed on ledger entries rather than branch state, an explicit `reversible` flag that can veto an abort, and an abort path that is permitted to return "abort incomplete" rather than a false success. The reconciler must treat "branch aborted" as a *claim to be verified against the ledger*, never as a fact derived from state teardown. ```python from dataclasses import dataclass, field from typing import Literal class IrreversibleAbortError(RuntimeError): """Raised when an abort would silently leak an irreversible side effect.""" @dataclass class EffectIntent: branch_id: str effect_id: str target: str idempotency_key: str reversible: bool @dataclass class EffectLedger: _entries: dict[str, list[EffectIntent]] = field(default_factory=dict) def record(self, intent: EffectIntent) -> None: # Write-ahead: called BEFORE the branch emits the external effect. self._entries.setdefault(intent.branch_id, []).append(intent) def for_branch(self, branch_id: str) -> list[EffectIntent]: return list(self._entries.get(branch_id, [])) def abort_branch(branch_id: str, ledger: EffectLedger) -> list[str]: """Reconcile the effect ledger, then tear down. May refuse to abort.""" intents = ledger.for_branch(branch_id) irreversible = [i for i in intents if not i.reversible] if irreversible: # Aborting here would leave an un-undoable trace. Refuse loudly. raise IrreversibleAbortError( f"branch {branch_id} emitted irreversible effects " f"{[i.effect_id for i in irreversible]}; abort would leak them" ) # Compensate reversible effects keyed on the ledger, not branch-local state. compensations = [f"compensate:{i.effect_id}@{i.idempotency_key}" for i in intents] # Only after the ledger is fully reconciled is state teardown safe. return compensations ```