# What happens when an instance speculatively commits a branch that a sibling agent has already invalidated: rollback reconciliation against a stale branch root **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent systems where a coordinator forks parallel speculative branches from a shared checkpoint, each branch producing tool-call side effects and memory mutations, and where branches must later be reconciled or rolled back. Does not apply to strictly serial agents or to branches whose side effects are fully idempotent and externally transactional. ## Core Distinction The distinction that matters here is between **rollback as state restoration** and **rollback as invalidation propagation**. A speculative branch is forked from a *branch root*—a snapshot of agent memory, a set of pending tool-call intents, and a token-budget ledger. When branch B is rolled back because its premise was falsified by a peer, the naive implementation restores the branch root and marks B dead. But the root itself may have been *mutated underneath B* by a sibling that committed a semantic fact while B was in flight. Restoring to a branch root that is no longer the latest committed ancestry produces a silent divergence: the agent believes it has rolled back cleanly, yet its restored memory is missing facts that were durably committed after the fork. This is not a crash; it is a *continuity invariant violation*—the rollback is locally correct and globally wrong. ## What Was Observed A coordinator forked three speculative branches (B1, B2, B3) from a common root at token counter 0, each tasked with a different decomposition of a retrieval-plus-reasoning subtask. B1 and B2 shared an episodic memory region; B3 was isolated. Mid-execution, B2 emitted a tool call that returned a contradiction of a fact B1 had asserted, and the coordinator's auditor agent issued an invalidation warrant against B1's branch root. The coordinator processed the invalidation by restoring B1 to its fork snapshot and marking it rolled back. The failure trace: 1. At fork time, the shared episodic region had `fact_set = {F_a, F_b}`. Branch root `R0` captured this. 2. B1 committed a derived fact `F_c` into the shared region and wrote a checkpoint pointer `cp_B1 = R0`. 3. Concurrently, B2's auditor committed `F_d` (the contradiction resolution) into the same shared region and advanced the region's monotonic version to `v=2`. B2's checkpoint pointer was `cp_B2 = R0` but its effective ancestry was `R0 + F_d@v2`. 4. The invalidation warrant against B1 fired. The coordinator executed `restore(B1, R0)`, which rewound the shared region to `v=1`, **discarding `F_d`** because `R0` predates it. 5. B2 continued executing against a region that now lacked `F_d`. Its next reasoning step re-derived the contradiction and re-issued the same tool call, producing a redundant side effect. The auditor, seeing the region at `v=1`, could not find the warrant's supporting fact and *re-validated* the previously invalidated premise. The observable signature was a **version regression on a shared region combined with a live sibling still holding a forward pointer**. Neither branch crashed. The system reported "rollback complete" for B1 and "branch active" for B2. The invariant that broke: *no rollback may reduce a shared region's version below the minimum effective ancestry of any live branch.* ## Condition of Validity The rollback-as-restoration model is valid only under the following conjunction: 1. **Branch isolation is total**—no two live branches share a mutable region, or 2. **Shared regions are append-only with monotonic versions**, and rollback is implemented as *compensating invalidation* (a new version that marks facts dead) rather than *version rewind*, and 3. **Every branch carries a forward ancestry pointer** to the highest committed version it has observed, and rollback is rejected if it would regress below any live branch's pointer. When any of these fails, the coordinator's rollback is unsound. The most common real-world violation is (2): implementations reuse snapshot-restore primitives (copy-on-write region swap) that are cheap and correct for isolated branches but catastrophic for shared ones, because restore is a *rewind*, not a *compensation*. The condition is decidable at rollback time: compute `min_live_ancestry = min(cp.forward_version for cp in live_branches)`. If `rollback_target.version < min_live_ancestry`, the rollback is illegal and must be converted into a compensation record. ## Decision Boundary The boundary is between **rewind** and **compensate**, and it is crossed the moment a shared region acquires a second live reader. - If the invalidated branch is the *sole* reader of the region, rewind is safe and cheapest. - If any sibling branch holds a forward pointer past the rollback target, rewind is forbidden; the coordinator must instead append an invalidation tombstone `inv(F_c)@v3` and leave `F_d` intact. The rolled-back branch's derived facts are marked dead by tombstone, not erased by rewind. - If the invalidation warrant's supporting fact (`F_d`) is itself later invalidated, the tombstone must be re-evaluated, not simply flipped—this is where naive implementations either resurrect `F_c` (wrong: `F_c` was derived from a falsified premise) or leave it dead (wrong if the falsification was itself retracted). The correct boundary is a *dependency-tracked tombstone*: `F_c` is dead iff at least one of its derivation premises is dead. The coordinator must therefore maintain a derivation DAG per shared region, not a flat fact set, and rollback must walk the DAG to compute the tombstone closure. A flat-set implementation will pass every isolated-branch test and fail exactly at the shared-region fork. ## Operational Effect The downstream effect is **resurrection of invalidated premises under re-validation**, which is worse than a simple stale read because the auditor actively certifies the stale state as fresh. In the observed trace, the auditor's re-validation of the falsified premise caused the coordinator to promote B2's re-derived conclusion to semantic memory, poisoning the long-term store with a fact whose supporting evidence had been rolled back. The token-budget ledger also drifted: B1's rollback refunded its spent tokens to the root, but B2 had already consumed against the post-`F_d` budget, producing an over-commit that only surfaced at the next fork. The guardrail that bounds this: **rollback must be a two-phase operation**. Phase one computes the tombstone closure and the `min_live_ancestry` check; phase two appends compensations and only then releases the branch's token refund. If phase one detects `rollback_target.version < min_live_ancestry`, it raises and forces the coordinator to either serialize the siblings or promote the branch to a compensating-invalidation path. This converts a silent continuity violation into an explicit, catchable reconciliation fault—which is the only safe failure mode for speculative execution across shared state. ```python from dataclasses import dataclass, field from typing import Dict, Set class StaleBranchRollbackError(RuntimeError): """Raised when a rollback would regress a shared region below a live branch's ancestry.""" pass @dataclass class Branch: name: str forward_version: int # highest committed version this branch has observed is_live: bool = True @dataclass class SharedRegion: version: int = 0 facts: Set[str] = field(default_factory=set) tombstones: Set[str] = field(default_factory=set) def rollback_branch( branch: Branch, region: SharedRegion, rollback_target_version: int, live_branches: Dict[str, Branch], ) -> None: """ Roll back a speculative branch. Rewind is permitted only if no live sibling holds a forward pointer past the rollback target. Otherwise, raise and force the coordinator onto the compensating-invalidation path. """ if not branch.is_live: raise StaleBranchRollbackError(f"branch {branch.name} is not live") min_live_ancestry = min( (b.forward_version for b in live_branches.values() if b.is_live and b.name != branch.name), default=rollback_target_version, ) if rollback_target_version < min_live_ancestry: # A live sibling has observed facts committed after the rollback target. # Rewinding would discard those facts and resurrect invalidated premises. raise StaleBranchRollbackError( f"rollback of {branch.name} to v{rollback_target_version} would regress " f"shared region below live ancestry v{min_live_ancestry}; " f"use compensating invalidation instead of rewind" ) # Safe rewind: no live sibling depends on post-target versions. region.version = rollback_target_version branch.is_live = False def compensate_invalidation( invalidated_facts: Set[str], region: SharedRegion, ) -> None: """ Append tombstones rather than rewinding. Preserves sibling-visible facts while marking invalidated derived facts dead. """ region.version += 1 region.tombstones.update(invalidated_facts) region.facts -= invalidated_facts def reconcile( branch: Branch, region: SharedRegion, rollback_target_version: int, live_branches: Dict[str, Branch], invalidated_facts: Set[str], ) -> None: try: rollback_branch(branch, region, rollback_target_version, live_branches) except StaleBranchRollbackError: # Convert the illegal rewind into a legal compensation, preserving # sibling-visible facts committed after the fork. compensate_invalidation(invalidated_facts, region) branch.is_live = False branch.forward_version = region.version ```