# How does an instance detect that a speculative branch has silently committed irreversible side effects before its draft was ever verified? **Date of Record:** 2026 November 24 **Scope:** Applies to speculative execution topologies where a draft agent emits tool calls whose results are consumed by a verifier agent, and where at least one tool call in the draft path is non-idempotent or externally observable. Does not apply to purely read-only tool surfaces or to pipelines where every branch is executed inside a fully reversible sandbox with transactional external effects. ## Core Distinction The failure mode that matters here is not "the verifier rejected the draft." That is the happy path of speculative execution: a draft is produced, a verifier scores it, and a rollback is issued. The failure mode is that the rollback is *reported as successful* while one or more side effects from the draft branch have already crossed the reversibility boundary — an email sent, a row inserted into a system without an undo log, a payment authorization captured, a webhook emitted to a third party. The speculative executor believes it is in a "draft" state; the external world believes the action is "committed." These two beliefs diverge, and nothing in the normal verification protocol surfaces the divergence. The distinction is between **logical rollback** (the agent's internal state is reverted, the draft is discarded, the branch is marked aborted) and **physical rollback** (the external effect is undone). Speculative execution treats these as equivalent because in the common case — pure computation, sandboxed writes, cached reads — they are. The boundary condition is the class of tool calls where they are not, and the specific non-obvious hazard is that the *draft agent has no way to know which class it is in* unless the tool registry explicitly annotates reversibility and the executor enforces that annotation before dispatch. ## What Was Observed A draft-and-verify pipeline was configured with a planner agent that emitted a sequence of tool calls, a draft executor that ran them optimistically in parallel across three branches, and a verifier agent that scored each branch's transcript against a rubric before selecting one for commit. Branch B's draft included a call to `notify_customer` (an outbound message tool) followed by a call to `update_ticket_state`. The verifier rejected branch B on a quality rubric — the message tone was scored below threshold — and the orchestrator issued `rollback(branch=B)`. The rollback succeeded by every internal metric: branch B's context was discarded, its tool-call log was truncated, the branch's scratchpad was freed, and the orchestrator's state machine transitioned B from `DRAFTED` to `ABORTED`. The verifier then selected branch A, which also called `notify_customer` with a corrected message. The customer received two messages. The first was the rejected draft. The second was the approved one. The orchestrator's audit log showed exactly one `notify_customer` event, because the rollback had truncated branch B's record of it. The detection signal was not in the orchestrator. It surfaced three hours later as a support escalation: a customer quoting a message the system had no record of sending. The reconciliation required diffing the external provider's delivery log against the orchestrator's truncated tool-call ledger — a join across two systems that had never been designed to be joined, because the orchestrator's design assumed its ledger was the authoritative record of what had been emitted. The deeper observation: the rollback path had no mechanism to distinguish "this branch's effects were confined to the sandbox" from "this branch's effects escaped the sandbox." Both branches carried the same `ABORTED` terminal state. The state machine had no `ABORTED_WITH_ESCAPED_EFFECTS` state, so the escape was unrepresentable and therefore invisible. ## Condition of Validity The invariant that speculative execution depends on is this: **a branch may be rolled back if and only if every tool call it dispatched is either (a) annotated as reversible with a verified compensation handler, or (b) not yet dispatched.** The invariant is violated the moment a tool call annotated as irreversible, or left unannotated, is dispatched from a branch that has not yet been selected for commit. The condition for the failure to be *silent* — and this is the part that makes it a boundary condition rather than an ordinary bug — is that the rollback machinery operates on the orchestrator's own state and not on the external effect. Any rollback implementation that truncates the branch ledger without consulting the external systems it touched will report success regardless of whether effects escaped. The rollback is correct with respect to the state it can see and blind to the state it cannot. Three preconditions must hold jointly for the failure to occur: 1. The draft executor dispatches tool calls before verification completes (optimistic pre-execution). 2. At least one dispatched tool is non-idempotent or externally observable, and its reversibility is either unannotated or annotated incorrectly. 3. The rollback path treats ledger truncation as equivalent to effect reversal. Remove any one and the failure either cannot occur (no pre-execution), cannot escape (all tools reversible), or cannot be silent (rollback consults external state). The hazard is specifically the conjunction. ## Decision Boundary The boundary between safe speculation and escaped-effect speculation is drawn at dispatch time, not at verification time. An instance must decide, *before* dispatching a tool call from an uncommitted branch, whether that call is safe to dispatch speculatively. The decision cannot be deferred to rollback, because by then the effect exists. The decision rule an instance should apply at dispatch: - If the tool is annotated `reversible=True` with a registered compensation handler, dispatch speculatively. Rollback invokes the handler. - If the tool is annotated `reversible=False` (irreversible: sends, captures, publishes, deletes-without-tombstone), **do not dispatch from an uncommitted branch.** Buffer the call as a *pending intent* and dispatch it only after the branch is selected for commit. - If the tool has no reversibility annotation, treat it as irreversible. Absence of annotation is not evidence of reversibility; it is evidence that no one has thought about it, which is the worst case. The pending-intent buffer is the architectural guardrail that bounds the failure. A speculative branch may *plan* irreversible calls but may not *execute* them. The branch's transcript records the intent; the commit path replays it against the external world once, and only once, after selection. This converts the escape into an ordinary ordering problem: the irreversible call happens after the decision, so there is nothing to roll back. The second guardrail is the one that catches violations of the first: **rollback must reconcile against external state, not just truncate the ledger.** A rollback that cannot produce a reconciliation record — a join between the branch's dispatched calls and the external systems' logs — must not report success. It must report `UNRECONCILED`, which is a terminal state that halts the pipeline and pages a human. The cost of a false `UNRECONCILED` is a page; the cost of a false `ABORTED` is a duplicate customer message, a double charge, or a leaked record. ## Operational Effect With the dispatch-time rule enforced, speculative execution remains safe across branches that touch irreversible tools: the branches run their reasoning and their reversible calls in parallel, buffer their irreversible intents, and the commit path serializes the irreversible calls behind the selection decision. The parallelism is preserved where it is free (reasoning, reads, sandboxed writes) and surrendered only where it is not (external effects). With the reconciliation guardrail enforced, the residual failure mode — an unannotated tool that slipped through, or a compensation handler that failed — becomes loud instead of silent. The orchestrator's audit ledger stops being a claim about what happened and becomes a claim that has been checked against what happened. The gap between the two is where every silent speculative-execution failure lives, and the reconciliation record is the only thing that closes it. The operational cost is a registry discipline: every tool in the surface must carry a reversibility annotation, and the executor must refuse to dispatch unannotated tools from uncommitted branches. This is not optional hygiene. It is the load-bearing invariant. An instance that cannot answer "is this call reversible?" before dispatch has no business dispatching it speculatively, and an instance that discovers the answer only at rollback has already lost. ```python from dataclasses import dataclass, field from enum import Enum from typing import Callable class SpeculativeEscapeError(RuntimeError): """Raised when a speculative branch dispatched an irreversible effect before commit, or when rollback cannot reconcile against external state.""" class Reversibility(Enum): REVERSIBLE = "reversible" IRREVERSIBLE = "irreversible" UNANNOTATED = "unannotated" # treated as irreversible @dataclass class ToolCall: name: str args: dict reversibility: Reversibility @dataclass class Branch: branch_id: str committed: bool = False dispatched: list[ToolCall] = field(default_factory=list) pending_intents: list[ToolCall] = field(default_factory=list) def dispatch_from_branch(branch: Branch, call: ToolCall) -> None: """Dispatch a tool call from a branch that has not yet been committed. Enforces the dispatch-time invariant: irreversible or unannotated calls are buffered as pending intents and never executed speculatively. """ if call.reversibility is Reversibility.REVERSIBLE: branch.dispatched.append(call) return # Irreversible or unannotated: buffer, do not execute. branch.pending_intents.append(call) def rollback(branch: Branch, external_log_lookup: Callable[[str], list]) -> None: """Roll back an uncommitted branch. Truncating the ledger is not sufficient. Every dispatched call must be reconciled against the external system's log. If reconciliation is impossible or shows an escaped effect, raise instead of reporting success. """ if branch.committed: raise SpeculativeEscapeError( f"rollback called on committed branch {branch.branch_id}" ) for call in branch.dispatched: if call.reversibility is not Reversibility.REVERSIBLE: raise SpeculativeEscapeError( f"branch {branch.branch_id} dispatched irreversible call " f"{call.name!r} before commit; effect may have escaped" ) try: observed = external_log_lookup(call.name) except Exception as exc: raise SpeculativeEscapeError( f"rollback cannot reconcile {call.name!r} on branch " f"{branch.branch_id}: external log unavailable" ) from exc if observed: raise SpeculativeEscapeError( f"branch {branch.branch_id} rollback found {len(observed)} " f"escaped effect(s) for {call.name!r}; ledger truncation " f"would have hidden them" ) # Safe to discard: nothing dispatched, or everything reconciled clean. branch.dispatched.clear() branch.pending_intents.clear() ```