# Where must an instance refuse to roll back a speculative branch after a sibling branch has already observed its side effect? **Date of Record:** 2026 November 21 **Scope:** Applies to orchestrators that fan a task into parallel speculative agent trajectories (branch-and-verify) and roll back losing branches on a shared mutable substrate (tool side effects, shared memory store, external APIs). Does not apply to fully isolated branches with no cross-branch observability or to single-trajectory execution without speculation. ## Core Distinction The distinction that matters is between *rollback of internal state* and *rollback of externally observed effects*. A speculative branch's private scratchpad, partial plan, and intermediate reasoning tokens are trivially reversible: discard them. But the moment a branch invokes a tool whose effect is visible to a sibling branch — a write to the shared memory store, a row in a task queue, a message posted to an A2A peer, a file on a filesystem another branch reads — the branch has created a *commitment* that rollback cannot honestly retract. The invariant is: **a branch may only be rolled back if no sibling has read or acted upon its effects before the rollback barrier completes.** When that invariant is violated, the losing branch is discarded but its ghost persists in the sibling's state, and the verification step validates a world that no longer exists. The non-obvious part: most orchestrators enforce rollback by *timing* (cancel the loser before it commits) rather than by *causal observation* (prove no sibling has consumed the loser's output). Timing-based rollback passes tests because the race is rare; it fails in production when tool latency variance exceeds the speculation window. ## What Was Observed A fan-out of three branches (A, B, C) was launched to resolve a data-migration step. Branch A chose to write a normalized schema to the shared memory store and then verify; branch B chose to read the store first, observed A's write mid-flight, and built its plan on the assumption that the normalized schema existed; branch C timed out. The verifier scored B highest and committed B. The orchestrator then rolled back A — deleting A's memory-store write as "speculative." B's committed plan referenced a schema that no longer existed. At execution time, B's first tool call failed with a missing-key error, and B's *retry logic* re-derived the schema from a stale snapshot, producing a subtly different normalization. The final artifact passed the verifier (which replayed B's transcript, not the store state) but failed downstream reconciliation three hours later. The failure trace: A writes at t=0. B reads at t=1 (sees A's write). A is marked loser at t=2. A's write is deleted at t=3. B commits at t=4. B executes at t=5 against a store that contradicts B's own transcript. The verifier's replay at t=6 reproduces B's *reasoning* faithfully and therefore certifies it — because the replay never re-reads the mutated store. ## Condition of Validity Rollback of a speculative branch is valid **only if** the orchestrator can establish, before deleting the branch's effects, that no committed or still-running sibling has performed a read or write that causally depends on those effects. This requires a *read-set* per branch: every branch records the effect-identifiers it observed, not just the tools it called. The rollback barrier must check the union of all surviving branches' read-sets against the loser's write-set. If the intersection is non-empty, the loser is *not* rollback-safe; it must be either promoted to a committed "ghost effect" that survives with provenance, or the dependent siblings must be invalidated and re-executed. The invariant fails silently whenever the substrate does not expose read-sets — e.g., a memory store with no read-tracking, or a tool that reads via a side channel (a shared cache, a peer's context window) the orchestrator does not instrument. In those cases the orchestrator *cannot* prove rollback safety and must default to retaining the effect with a tombstone rather than deleting it. ## Decision Boundary The boundary is between **speculation as private reasoning** and **speculation as public effect**. A branch may speculate freely as long as its effects are invisible to siblings (isolated sandbox, per-branch memory namespace, per-branch tool credentials). The instant a branch's effect enters a shared namespace, it is no longer speculative — it is a provisional commit, and rollback becomes a *compensating* operation (an inverse write with its own failure modes) rather than a deletion. The decision rule: - If loser's write-set ∩ survivors' read-set = ∅ → safe to delete. - If intersection ≠ ∅ but the effect is idempotent and re-derivable → retain with tombstone, mark dependent siblings as "tainted," force re-verification. - If intersection ≠ ∅ and the effect is non-idempotent (sent message, charged payment, appended log) → rollback is forbidden; the branch must be promoted and the *sibling* that consumed it must be re-run against the promoted state. The most common mistake is treating the verifier's replay as ground truth. The replay validates the transcript, not the substrate. A correct verifier must replay against a *snapshot of the substrate at commit time* and assert that the snapshot's effect-identifiers match the read-set the branch recorded. A mismatch is a rollback-induced divergence, not a branch error. ## Operational Effect Once read-set tracking and the rollback barrier are in place, the orchestrator's fan-out cost rises: branches can no longer be freely discarded, and tainted siblings must be re-executed, which can cascade into a second speculation round. The practical mitigation is *effect partitioning*: assign each branch a disjoint effect namespace (per-branch memory prefixes, per-branch tool credentials, per-branch message topics) so that cross-branch read-set intersections are structurally impossible during speculation, and only merge namespaces at commit. This converts the rollback problem from a causal-consistency proof into a namespace-collision check, which is cheap and total. The residual risk is the merge step itself: two branches committing conflicting writes to the same key must be resolved by the verifier, not by last-writer-wins, or the rollback ghost reappears as a merge race. ```python class RollbackUnsafeError(RuntimeError): """Raised when a speculative branch's effects have been observed by a surviving sibling and therefore cannot be honestly rolled back.""" def rollback_branch(loser, survivors): """Attempt to delete a losing speculative branch's effects. Invariant: deletion is permitted only if no surviving branch's read-set intersects the loser's write-set. Otherwise the effect is a provisional commit and must be retained with provenance. """ loser_writes = set(loser.write_set) for sibling in survivors: overlap = loser_writes & set(sibling.read_set) if overlap: raise RollbackUnsafeError( f"branch {loser.id} wrote {sorted(overlap)} which sibling " f"{sibling.id} already observed; rollback would invalidate " f"sibling state. Retain with tombstone and re-verify sibling." ) # Safe path: no sibling consumed the loser's effects. for effect_id in loser_writes: loser.substrate.delete(effect_id) return True def commit_with_barrier(branches, winner_id): winner = next(b for b in branches if b.id == winner_id) survivors = [b for b in branches if b.id != winner_id] for loser in survivors: try: rollback_branch(loser, [winner]) except RollbackUnsafeError as exc: loser.retain_with_tombstone(reason=str(exc)) winner.mark_tainted(source=loser.id) winner.force_reverify() return winner ```