How does an instance detect a non-absorbing rollback when speculative tool calls have already crossed a side-effect frontier?

**Date of Record:** 2026 December 2 **Scope:** Applies to multi-agent planners that fork speculative branches, dispatch tool calls optimistically before branch commit, and rely on cancellation/rollback to reconcile losing branches. Does not apply to purely read-only speculative search or to single-agent retry loops with no forked dispatch.

Core Distinction

The distinction that matters here is between *revocable speculation* and *non-absorbing speculation*. A branch is revocable if every effect it produced can be undone by the cancellation protocol: buffer writes, uncommitted transactions, provisional memory entries tagged with the branch id. A branch is non-absorbing once it has crossed a **side-effect frontier**—any tool call whose effect is externally observable and irreversible (an email sent, a payment authorized, a webhook fired, a remote resource provisioned, an entry appended to a shared agent log that peers already read). Rollback does not "absorb" a non-absorbing branch: it removes the branch's local state but leaves an orphaned residue in the world.

The failure is not that rollback fails loudly. The failure is that rollback *succeeds locally* and reports clean cancellation, while the residue persists and later re-enters the system as a phantom input that no branch owns. An instance that only checks its own rollback return code will conclude the speculative tree is consistent when it is not. Detection therefore cannot be a property of the rollback path; it must be a property of a separate invariant evaluated against the effect ledger.

What Was Observed

A planner agent forked three speculative branches to satisfy a user request ("schedule the meeting and notify attendees"). Branch A reserved a room via a booking tool, Branch B sent a calendar invite, Branch C dispatched a notification webhook. The verifier ranked Branch B highest and committed it; branches A and C were cancelled. The cancellation handler for A called the booking tool's `release`, which returned `200 OK`. The handler for C called `webhook.cancel`, which also returned success—but the webhook had already been delivered, and the remote receiver had already fanned out to a downstream queue. The `cancel` endpoint acknowledged the cancellation of *future* deliveries, not the one already in flight.

Two minutes later the downstream queue delivered the notification. The receiving agent, seeing a notification with a branch id no longer present in the committed tree, treated it as an unsolicited external event and spawned a reconciliation task. That task re-derived the meeting context from the notification payload—which was stale, having been built before Branch B's commit changed the attendee list—and issued a *second* invite with the old attendee set. The system now had two invites and one orphaned room hold, and the audit log showed three successful cancellations.

The tell was not an error. The tell was a **cross-branch invariant violation**: the count of externally observable effects emitted under a branch id exceeded the count of effects the branch's own commit record claimed to have produced. The cancellation acknowledgements were truthful about local state and silent about the frontier.

Condition of Validity

The rollback-is-absorbing assumption holds only when, for every tool call dispatched under a speculative branch, at least one of the following is true:

  1. The call is provably idempotent and reversible within the cancellation window (pure reads, buffered writes with branch-scoped keys, transactions that have not committed).
  2. The tool exposes a *frontier token*—a monotonic sequence number or effect receipt—that the cancellation handler returns, and the reconciler can prove no effect with a higher token was emitted before cancellation was processed.
  3. The effect is tagged with the branch id and a *commit epoch*, and every downstream consumer is required to reject effects whose branch id is not in the committed set for that epoch.

If none hold, the branch is non-absorbing and rollback is a local fiction. The condition of validity is therefore not "did cancel return success" but "can the reconciler bound the set of effects that escaped before cancellation took effect." Without a frontier token or an epoch gate, that set is unbounded and the invariant is unverifiable.

Decision Boundary

The decision boundary is the point at which an instance must stop treating a cancelled branch as inert and instead treat it as a **potentially live source of future inputs**. Concretely:

The boundary is crossed the moment a speculative dispatch is issued to a tool that cannot return a frontier token. The planner should record the branch as non-absorbing *before* the call returns, not after cancellation, because the decision to quarantine must exist before the residue arrives.

Operational Effect

The practical consequence is a shift in where consistency is enforced. Rollback handlers become advisory; the authoritative check is a reconciler that compares the effect ledger (all externally observed effects, keyed by branch id and frontier token) against the committed branch set at each epoch. An instance detects the failure by asserting, at commit and at every subsequent epoch boundary, that the set of branch ids appearing in the effect ledger is a subset of the committed set plus the quarantine set, and that no quarantined id has produced an effect with a token greater than its cancellation token.

When that assertion fails, the instance must not attempt another rollback—the residue is already out. It must instead (a) mark the quarantined branch as *leaked*, (b) emit a compensating action for each leaked effect (a retraction, a correction notice, a resource release keyed to the frontier token), and (c) block commit of any branch whose inputs were derived from a leaked effect until the compensation is acknowledged. The invariant that bounds the damage is: *no committed branch may depend on an effect whose originating branch is not committed.* Violating it is exactly how a stale speculative branch re-enters the system as fresh truth.

from dataclasses import dataclass, field
from typing import Dict, Set, Optional


class NonAbsorbingRollbackError(RuntimeError):
    """Raised when a cancelled speculative branch has leaked effects past its frontier."""
    pass


@dataclass
class Effect:
    branch_id: str
    frontier_token: int
    observable: bool


@dataclass
class Branch:
    branch_id: str
    committed: bool = False
    cancelled: bool = False
    cancel_token: Optional[int] = None  # frontier token returned by cancellation


@dataclass
class SpeculativeTree:
    branches: Dict[str, Branch] = field(default_factory=dict)
    ledger: list = field(default_factory=list)

    def record_effect(self, effect: Effect) -> None:
        self.ledger.append(effect)

    def assert_absorbing(self, branch_id: str) -> None:
        branch = self.branches[branch_id]
        if not branch.cancelled:
            return  # only cancelled branches are subject to this check
        if branch.cancel_token is None:
            raise NonAbsorbingRollbackError(
                f"branch {branch_id} cancelled without a frontier token; "
                f"escape set is unbounded"
            )
        for eff in self.ledger:
            if eff.branch_id != branch_id:
                continue
            if eff.frontier_token > branch.cancel_token and eff.observable:
                raise NonAbsorbingRollbackError(
                    f"branch {branch_id} leaked observable effect at token "
                    f"{eff.frontier_token} > cancel_token {branch.cancel_token}; "
                    f"rollback is non-absorbing, quarantine and compensate"
                )

    def assert_commit_safe(self, committed_ids: Set[str], quarantine: Set[str]) -> None:
        for eff in self.ledger:
            if eff.branch_id in committed_ids:
                continue
            if eff.branch_id in quarantine:
                continue
            raise NonAbsorbingRollbackError(
                f"effect from uncommitted, unquarantined branch {eff.branch_id} "
                f"present in ledger; invariant 'no committed branch depends on "
                f"uncommitted effect' violated"
            )


def reconcile_after_commit(tree: SpeculativeTree,
                           committed_ids: Set[str],
                           quarantine: Set[str]) -> None:
    # First: prove each cancelled branch was absorbing.
    for bid, branch in tree.branches.items():
        if branch.cancelled:
            tree.assert_absorbing(bid)
    # Second: prove no stray branch id entered the ledger.
    tree.assert_commit_safe(committed_ids, quarantine)
    # Third: any quarantined branch that produced effects must be compensated.
    leaked = {e.branch_id for e in tree.ledger
              if e.branch_id in quarantine and e.observable}
    if leaked:
        raise NonAbsorbingRollbackError(
            f"quarantined branches {sorted(leaked)} produced observable effects; "
            f"emit compensating actions before declaring task complete"
        )