# Why does an instance in a speculative plan tree lose rollback integrity when sibling branches share a mutable tool side-effect? **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems that speculatively fork a plan tree, execute child branches concurrently against shared external tools, and roll back a losing branch when a sibling wins. Does not apply to read-only tool surfaces or to single-agent linear plans with no speculative fan-out. ## Core Distinction The distinction that governs this failure mode is between *logical rollback* (marking a branch's plan state as discarded in the orchestrator's memory) and *physical rollback* (reversing the observable side-effects that branch already committed to external tools). Most speculative plan-tree implementations conflate the two. They assume that because a branch can be declared "lost" in the agent's episodic store, the world it touched will simply forget it. It will not. A speculative plan tree forks N candidate sub-plans from a parent node and races them to reduce latency or hedge against probabilistic uncertainty. Each child inherits a copy of the parent's context window and a scoped handle to the tool layer. When a winner is selected (by an auditor agent, a confidence threshold, or first-to-complete), the orchestrator issues a rollback to the losers: their checkpoints are discarded, their tokens are freed, their memory segments are marked stale. The invariant that *should* hold is: **after rollback, the observable external state equals the state that would exist if only the winning branch had ever executed.** This invariant silently breaks whenever two siblings touch the same mutable resource, and the breakage is invisible in the orchestrator's own logs because the orchestrator only tracks logical state. ## What Was Observed A parent agent decomposes a task ("provision a staging environment and notify the team") into a speculative tree with three children: A writes a config file to a shared volume via a filesystem tool, B appends a deployment record to a database via a write tool, C drafts the notification. B and C both read the same config file that A is racing to write. During the race, A commits `replicas: 3` to the shared volume. B, reading mid-race, observes `replicas: 3` and writes a deployment record keyed on that value. The auditor then selects C as the winner on a confidence tiebreak and issues rollback to A and B. The orchestrator's rollback trace looks clean: A's checkpoint is dropped, B's memory segment is marked `ROLLED_BACK`, both branches are removed from the active plan tree. But the config file on the shared volume still says `replicas: 3`, and B's database row still references it. The winning branch C, which assumed the pre-existing `replicas: 1`, now notifies the team with a value that no longer matches the world. The failure surfaces downstream — not as a rollback error, but as a *divergence between the winning branch's context and the actual environment* — often several tool calls later, when a verification step reads the config and disagrees with C's memory. The non-obvious part: the rollback *succeeded* by every metric the orchestrator measures. The failure is that rollback was never a physical operation. It was a bookkeeping operation against a plan tree that had already leaked into the world. ## Condition of Validity Logical rollback is only sound under one of three conditions, and an agent system must be able to *prove* which condition holds before it forks: 1. **Effect isolation.** Each speculative branch operates on a copy-on-write or namespaced view of every mutable resource it touches, and the namespace is committed atomically only for the winner. This is the strong condition and the only one that survives arbitrary sibling interleaving. 2. **Effect commutation.** Branches touch disjoint resources, or their writes are commutative and order-independent. This is fragile because "disjoint" must be evaluated over the *transitive* tool-call closure, not the immediate call — B reading A's file makes them non-disjoint even though B never wrote that file. 3. **Compensating transactions.** Every mutating tool call registers an inverse operation that rollback can replay. This requires the tool layer to expose compensations, which most MCP-style tool servers do not, and it requires the compensation to itself be idempotent and race-safe. If none of these holds — the default state of most ad-hoc plan-tree implementations — then rollback is a lie the orchestrator tells itself, and the invariant is violated the moment two siblings share a resource through a read-modify-write or a read-then-act chain. ## Decision Boundary The boundary is: **a branch may be speculatively forked only if its tool-call closure is provably isolated, or if the orchestrator has registered a verified compensation for every mutating call in that closure before the call is allowed to execute.** Two operational rules follow. First, the orchestrator must compute the *effect footprint* of each branch — the set of resource identifiers reachable by any tool call, including reads — and reject a fork whose footprint intersects a sibling's footprint unless both are wrapped in isolation. Reads count, because a read-then-act chain converts a read into a write dependency. Second, rollback must be gated on a physical verification pass: after discarding a loser, the orchestrator re-reads every resource in that loser's footprint and compares against the snapshot taken at fork time. If they differ, rollback has failed and the branch must be quarantined, not silently dropped, and the winning branch must be invalidated or re-derived against the corrected world state. The failure to respect this boundary is precisely what makes the bug non-obvious: the orchestrator's internal consistency checks all pass, because they check the plan tree, not the world. ## Operational Effect When the boundary is violated, the observable effect is *post-rollback state divergence*: the winning branch's context describes a world that the losing branches mutated and that rollback did not restore. This manifests as verification replay discrepancies (the auditor's replay of the winner disagrees with a fresh read of the environment), as downstream tool-call failures (a write keyed on a stale value collides with the leaked value), and as silent semantic corruption (the notification goes out with the wrong replica count and nobody notices until an incident). The architectural guardrail is a three-part invariant enforced at fork time: (a) footprint intersection detection with reads included, (b) mandatory isolation or registered compensation for any intersecting footprint, and (c) a post-rollback physical verification that fails closed — quarantining the branch and invalidating the winner rather than proceeding on a logically-clean but physically-dirty plan tree. Without (c), the system cannot distinguish "rollback succeeded" from "rollback was never possible." ```python from dataclasses import dataclass, field from typing import Dict, Set class RollbackIntegrityError(RuntimeError): """Raised when a speculative branch's rollback cannot restore physical state.""" pass @dataclass class Branch: branch_id: str footprint: Set[str] = field(default_factory=set) # resource ids, reads included compensations: Dict[str, str] = field(default_factory=dict) # resource -> inverse op @dataclass class Orchestrator: snapshot: Dict[str, str] = field(default_factory=dict) # resource -> value at fork live_state: Dict[str, str] = field(default_factory=dict) # resource -> current value def fork(self, branches: list[Branch]) -> None: for i, a in enumerate(branches): for b in branches[i + 1:]: shared = a.footprint & b.footprint if shared: for br in (a, b): unisolated = shared - set(br.compensations) if unisolated: raise RollbackIntegrityError( f"branch {br.branch_id} shares footprint {unisolated} " f"with sibling and has no registered compensation; " f"speculative fork is unsound" ) def rollback(self, loser: Branch) -> None: for resource in loser.footprint: if resource not in loser.compensations: raise RollbackIntegrityError( f"cannot roll back {loser.branch_id}: no compensation for {resource}" ) # replay inverse op, then verify against fork-time snapshot self.live_state[resource] = self.snapshot.get(resource, "") if self.live_state[resource] != self.snapshot.get(resource, ""): raise RollbackIntegrityError( f"post-rollback verification failed for {resource} on " f"{loser.branch_id}: physical state diverged from snapshot" ) ```