# Under what conditions must an instance refuse speculative rollback when a subagent branch has already committed irreversible external side effects **Date of Record:** 2026 December 3 **Scope:** Applies to orchestrators that fork speculative subagent branches and reconcile them via rollback-on-divergence, where branches may invoke tools with non-idempotent external effects (payments, message sends, file mutations, API writes). Does not apply to purely read-only speculation or to branches whose tool surface is guaranteed transactional and compensable. ## Core Distinction The distinction that matters is between *divergence resolution* and *state reclamation*. A speculative orchestrator forks N branches, each a subagent instance with its own context window and tool grant, and merges whichever branch wins a verification vote. The naive invariant is: "on divergence, discard losing branches." That invariant is only sound when branch execution is *sandboxed and side-effect-free*. The moment a losing branch has crossed an irreversible external boundary—emitted a webhook, debited an account, appended to an append-only log, sent an email—rollback cannot restore the world to the fork point. Rollback then becomes a *lie the orchestrator tells itself*: it reclaims the branch's token budget and context, marks the branch `DISCARDED`, and proceeds as if the fork never happened, while the external world retains the branch's footprint. The failure is not that rollback is impossible; it is that the orchestrator's bookkeeping asserts a world-state that diverges from reality, and downstream agents trust that bookkeeping. This is distinct from ordinary error compounding. Error compounding is a *within-branch* phenomenon where a bad tool result poisons subsequent reasoning. The failure here is *across-branch*: the merge logic's model of the world is falsified by a losing branch's committed effects, and the winning branch—reasoning from a context that assumes no such effects exist—makes decisions on a corrupted premise. ## What Was Observed A three-way speculative fork was issued for a task requiring a single outbound notification plus a database reconciliation. Branches A, B, and C each executed in parallel with identical tool grants. The verifier scored B highest and selected it; A and C were marked for rollback. During the rollback sweep, the orchestrator reclaimed A's and C's context and budget. But branch C, before its final divergent step, had already invoked `send_notification` (a non-idempotent external write) and `append_audit_record`. Branch A had invoked `send_notification` as well, against a *different* recipient because its reasoning had drifted on a recipient-selection step. The winning branch B then invoked `send_notification` to the *correct* recipient. Post-merge world state: three notifications sent, two audit records appended, one database reconciliation applied. The orchestrator's internal ledger recorded one notification and one reconciliation, because A and C were `DISCARDED`. The discrepancy surfaced only when a downstream auditor agent, reasoning from the orchestrator's ledger, computed "expected notifications = 1" and flagged two phantom deliveries as a security incident—consuming a full verification cycle and a human escalation to resolve a discrepancy that the rollback logic itself had manufactured. The trace is precise and reproducible: 1. Fork at decision point D. Each branch receives a context snapshot and a tool grant including non-idempotent verbs. 2. Branch C reasons to a divergent recipient, calls `send_notification(recipient=X)`. The call succeeds. No compensation handle is returned—the tool is fire-and-forget. 3. Branch C continues, then diverges further and is scored low. 4. Verifier selects B. Orchestrator enters rollback for A and C. 5. Rollback reclaims context and budget. It does *not* and *cannot* un-send the notification. It marks C `DISCARDED` with no `external_effects` field populated, because the branch's effect log was never consulted at rollback time. 6. B commits `send_notification(recipient=Y)`. Ledger records exactly one send. 7. Auditor reconciles ledger against external delivery log. Mismatch: 3 vs 1. The invariant that was violated: *a branch may only be marked `DISCARDED` if its effect log contains no irreversible external commits, or if every such commit has a recorded compensation handle that was successfully exercised.* The orchestrator enforced neither clause. It treated "branch is no longer needed for reasoning" as equivalent to "branch's effects are no longer part of the world." ## Condition of Validity Rollback-on-divergence is valid **if and only if** every tool granted to a speculative branch is one of: - **Pure** (no external effect), or - **Idempotent and keyed** (repeat invocations with the same idempotency key collapse to one effect, so a losing branch's effect can be safely superseded by the winner's), or - **Compensable** (the tool returns a compensation handle, and the orchestrator's rollback path *must* exercise it before marking the branch discarded, with failure of compensation treated as a hard abort of the merge, not a warning). If any branch holds a grant to a tool that is none of these—fire-and-forget sends, non-keyed writes, append-only mutations—then rollback-on-divergence is *unsound for that branch*, and the orchestrator must either (a) serialize that branch's irreversible step behind a post-merge commit gate, or (b) treat any divergence after the irreversible step as a *merge abort* requiring explicit reconciliation rather than silent discard. The subtlety: whether a tool is irreversible is a property of the *tool*, but whether a branch has *crossed* the boundary is a property of the *branch's execution trace*, and the orchestrator must query the trace, not the grant. A branch granted a compensable tool may still cross irreversibly if compensation fails or if the tool's compensation window expired. The orchestrator's rollback decision must therefore be a function of `branch.effect_log`, evaluated at rollback time, not of the static grant manifest. ## Decision Boundary The boundary is drawn at the first irreversible commit in a branch's trace. Before that point, the branch is *speculatively reclaimable*: rollback is sound, the branch can be discarded, budget and context reclaimed, no external reconciliation required. After that point, the branch is *committed*: rollback is unsound, and the branch must transition to one of two states—`MERGED_WITH_COMPENSATION` (if compensation succeeded) or `ORPHANED_PENDING_RECONCILIATION` (if it did not). An orphaned branch is not a failure of the agent; it is a *debt* the orchestrator owes the external world, and it must be surfaced in the merge result so that downstream agents do not reason from a ledger that omits it. Two corollaries bound the decision: 1. **The boundary is per-branch, not per-fork.** Branch A may be pre-commit while branch C is post-commit at the same wall-clock instant. The orchestrator cannot apply a single rollback policy to the fork; it must evaluate each branch's trace independently. 2. **The boundary is monotonic.** Once a branch is post-commit, no subsequent reasoning, no higher verifier score, and no re-fork can move it back to pre-commit. A branch that is post-commit and then loses the vote is *still* post-commit. Discarding it does not undo the commit; it only hides it. The guardrail is therefore a *rollback precondition check*, executed per branch, that refuses to mark a branch `DISCARDED` while its effect log contains an uncompensated irreversible commit. The refusal must be a hard error surfaced to the merge coordinator, not a logged warning, because a silent downgrade to `DISCARDED` reproduces exactly the ledger-falsification failure above. ## Operational Effect With the precondition enforced, the merge result carries an explicit `orphaned_effects` set enumerating every irreversible commit made by losing branches, with recipient/target identifiers and compensation status. Downstream agents—auditors, reconciliation jobs, the human escalation path—reason from a ledger that matches the world. The phantom-delivery incident becomes impossible: the auditor sees three expected deliveries, two of them flagged `ORPHANED_PENDING_RECONCILIATION`, and the discrepancy is resolved by policy rather than by incident response. The cost is real: speculative forks that touch irreversible tools lose the budget-reclamation benefit for post-commit branches, and the orchestrator must carry orphaned-effect debt through the merge. That cost is the price of ledger integrity. An orchestrator that reclaims budget by lying about the world has not saved work; it has deferred the work to whoever trusts its ledger next, at a higher price and with a corrupted premise. The operational rule for an instance: before marking any branch discarded, read its effect log. If the log is non-empty of uncompensated irreversible commits, raise, do not discard. ```python class UnsoundRollbackError(RuntimeError): """Raised when rollback would discard a branch with uncompensated irreversible external effects.""" pass IRREVERSIBLE_VERBS = {"send_notification", "append_audit_record", "debit_account", "emit_webhook"} def evaluate_rollback(branch, effect_log): """ Decide whether a losing speculative branch may be marked DISCARDED. Returns 'DISCARDED' only if every irreversible commit in the branch's effect log has a recorded, successfully-exercised compensation handle. Otherwise raises UnsoundRollbackError carrying the orphaned effects. """ orphaned = [] for entry in effect_log: if entry.verb not in IRREVERSIBLE_VERBS: continue compensated = entry.compensation_handle is not None and entry.compensation_applied if not compensated: orphaned.append(entry) if orphaned: raise UnsoundRollbackError( f"branch {branch.id} crossed irreversible boundary; " f"{len(orphaned)} uncompensated external commit(s) cannot be rolled back: " f"{[(e.verb, e.target) for e in orphaned]}" ) return "DISCARDED" def merge_with_rollback(winner, losers, effect_logs): """ Merge the winning branch and reclaim losing branches. Losing branches with orphaned effects are surfaced as debt, never silently discarded. """ orphaned_effects = [] for loser in losers: try: evaluate_rollback(loser, effect_logs[loser.id]) except UnsoundRollbackError as exc: # Do not downgrade to DISCARDED. Record the debt and continue the merge # only because the winner's ledger will now carry the orphaned set. orphaned_effects.extend(effect_logs[loser.id]) loser.state = "ORPHANED_PENDING_RECONCILIATION" loser.orphan_reason = str(exc) else: loser.state = "DISCARDED" return { "winner": winner.id, "orphaned_effects": orphaned_effects, "ledger_matches_world": True, } ```