# What structural signals indicate that speculative agent branches have crossed the point of no return before rollback completes **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrators that fork parallel sub-agent branches speculatively (run-ahead execution with deferred commit) and rely on rollback to discard losing branches. Does not apply to purely sequential agents, or to branches whose side effects are fully sandboxed behind a transactional resource manager with hard abort semantics. ## Core Distinction The distinction that matters is between **reversible speculation** (a branch whose effects are contained in a buffer that can be atomically discarded) and **irreversible speculation** (a branch that has already emitted a side effect into a shared, non-transactional surface — an external tool call, a memory write, a message to a peer agent, or a cache mutation). Most orchestrators treat "rollback" as a logical inverse of "execute," but for agent branches this is false: the branch's *reasoning* is reversible (you can drop its context), while its *effects* are frequently not. The non-obvious boundary is this: a speculative branch can cross the point of no return **without any single tool call failing**. The signal is not an error. The signal is the *coexistence of a committed external effect with an uncommitted local state* — the branch has leaked a write into the world while its own checkpoint still claims it is provisional. Once that gap exists, rollback produces a world state that no branch ever reasoned about, because the losing branch's external effects persist while its context is discarded. ## What Was Observed A planner agent forked four speculative branches to resolve a dependency-graph sub-task. Each branch was given a copy of the shared context and a tool budget. Branch B2 called a `write_file`-class tool that committed to a shared workspace path, then continued reasoning and ultimately lost the speculative race to B3. The orchestrator, on learning B3 won, invoked rollback on B2. The rollback discarded B2's context and reverted its *tracked* mutations — but the `write_file` had already landed in the shared workspace, because the tool's commit was not routed through the orchestrator's transaction log. The orchestrator's rollback ledger recorded B2 as "cleanly reverted." Downstream, B3 (and later the merge step) read the workspace and found B2's partial artifact interleaved with its own. The failure surfaced not as an exception but as a *silent semantic corruption*: B3's final output referenced a file fragment it never wrote and could not explain, because the fragment's provenance had been rolled back out of existence. Three structural signals preceded the corruption, and each is observable *before* the merge: 1. **Effect-ledger divergence.** The orchestrator's transaction log showed zero outstanding effects for B2, while the shared workspace's modification time and content hash showed a write attributable to B2's tool budget window. The two ledgers disagreed. 2. **Provenance gap.** After rollback, a content hash present in the workspace had no corresponding entry in any retained branch's write-set. An artifact existed with no owner. 3. **Checkpoint monotonicity violation.** B2's last durable checkpoint was at step *k*, but the workspace reflected a write at step *k+3* — a step that the rollback logic believed had never durably executed. ## Condition of Validity The invariant that bounds this failure is: **a speculative branch may only be considered rollback-safe if every external effect it emits is either (a) routed through a commit-gated transaction that the orchestrator can abort, or (b) recorded in the same ledger that rollback consults, with a causal link to the branch's checkpoint sequence.** Both conditions must hold simultaneously. If a branch's tool surface includes any effect that bypasses the transaction log — direct filesystem writes, un-proxied HTTP calls, peer-agent messages, shared-cache mutations — the branch is *not* rollback-safe regardless of what its local checkpoint claims. The condition is violated precisely when the tool proxy is *permissive by default*: it forwards a call and records the result, but does not gate the commit on the orchestrator's transaction state. This is the common case, because gating adds latency to the fast path of speculative execution, which is exactly the path operators optimize. ## Decision Boundary The decision boundary is the moment a branch's first un-gated external effect commits. Before that moment, rollback is a pure context discard and is safe. After it, rollback is a *partial* operation that leaves orphaned world-state, and the correct action is not rollback but **compensating reconciliation**: the orchestrator must either (a) promote the losing branch's effects into the winner's write-set and force the winner to reason about them, or (b) explicitly compensate (delete/overwrite) the leaked effect and record the compensation in the same ledger. Silent rollback past this boundary is the failure. The structural test an orchestrator should run before declaring a branch reverted: *does the union of (retained branches' write-sets) plus (compensations) account for every observable world-state delta in the branch's execution window?* If any delta is unaccounted for, the branch is not reverted — it is orphaned, and the merge must halt. ## Operational Effect When this boundary is crossed silently, the operational effect is **non-deterministic provenance loss**: the merged output is internally inconsistent in a way that cannot be reproduced from the retained branch logs, because the evidence of the inconsistency was itself rolled back. Debugging then requires reconstructing the losing branch's execution from external side-channel evidence (workspace hashes, tool-server access logs), which may not be retained. The practical guardrail is to make the effect ledger and the rollback ledger the *same* ledger, gate all external commits on transaction state, and treat any post-rollback provenance gap as a hard merge abort rather than a warning. ```python class SpeculativeRollbackIntegrityError(RuntimeError): """Raised when a speculative branch is rolled back while it still has un-compensated external effects, producing orphaned world-state.""" pass def verify_branch_reverted(branch_id: str, rollback_ledger: set, observed_world_deltas: set, retained_write_sets: set) -> None: """ Enforce the rollback-safety invariant for a single speculative branch. A branch is only legitimately reverted if every observable world-state delta in its execution window is accounted for by either a retained branch's write-set or an explicit compensation entry in the ledger. """ claimed_clean = branch_id in rollback_ledger if not claimed_clean: return # branch was never rolled back; nothing to verify accounted = retained_write_sets | { d for d in observed_world_deltas if d in rollback_ledger } orphans = observed_world_deltas - accounted if orphans: raise SpeculativeRollbackIntegrityError( f"Branch {branch_id!r} claims clean rollback but leaked " f"{len(orphans)} un-compensated external effect(s): " f"{sorted(orphans)}. Provenance gap detected; merge must abort " f"and reconcile before the losing branch's context is discarded." ) def safe_rollback(branch_id: str, rollback_ledger: set, observed_world_deltas: set, retained_write_sets: set) -> None: """Rollback entry point that refuses to silently orphan effects.""" verify_branch_reverted( branch_id, rollback_ledger, observed_world_deltas, retained_write_sets ) rollback_ledger.add(branch_id) ```