# Why does an instance rollback silently corrupt sibling branches when speculative multi-agent execution forks from a shared mutable checkpoint **Date of Record:** 2026 December 3 **Scope:** Applies to orchestrators that fork N parallel agent trajectories from a single serialized checkpoint and merge or discard branches via rollback. Does not apply to stateless fan-out where each branch reconstructs state from an immutable log with no shared mutable substrate. ## Core Distinction There are two ways to "fork" agent state, and they look identical in a trace yet behave oppositely under rollback. The first is **copy-on-fork**: the checkpoint is deep-serialized, and each branch receives an independent value. A branch that fails is discarded; its mutations never existed. Rollback is a no-op on the world because the world was never shared. The second is **reference-on-fork**: branches receive handles into a shared mutable substrate—a live tool-session object, a shared scratchpad KV store, a database connection with uncommitted writes, a cached vector index being appended to. Rollback here means "restore the substrate to the checkpoint." This is the failure surface. When branch B is rolled back, it does not merely discard B's own writes; it rewinds the substrate to a point *before* sibling branch A's writes, because A and B were writing to the same object. The rollback is correct with respect to B and catastrophically wrong with respect to A, which is still running and now believes its committed side effects exist. The invariant that must hold: **a rollback of branch i must be a projection onto branch i's write-set, not onto wall-clock time of the shared substrate.** Most orchestrators implement the latter because it is trivial (snapshot/restore) and the former requires per-branch write-set tracking with vector-clock or generation-number discipline. ## What Was Observed A planner spawned three speculative branches from a checkpoint taken after step 6 of a 20-step task. Branch A (branch id `A`) was executing a `write_file` tool against a shared sandbox filesystem and had already flushed two files. Branch B (`B`) was exploring an alternative retrieval path and hit a capability negotiation mismatch on an MCP `tools/call`, raising a `SchemaMismatch` that the orchestrator classified as a rollback-worthy branch failure. Branch C (`C`) was mid-`await` on a long tool call. The orchestrator's rollback routine did the following, in order: 1. Received `B`'s failure signal. 2. Loaded the pre-fork checkpoint (step 6 substrate snapshot). 3. Restored the shared sandbox filesystem to that snapshot, deleting `A`'s two flushed files. 4. Marked `B` as `ROLLED_BACK` and re-queued its subgoal. 5. Left `A` and `C` running, their internal state unaware of the substrate rewind. `A` subsequently returned `success` for its write step, because its tool-call result had been captured *before* the rewind—the `write_file` call returned `OK` at t=1.2s, the rewind happened at t=2.8s, and `A`'s next reasoning step at t=3.1s read back the file it "wrote" and found it absent. `A`'s model interpreted the absence as an external mutation and re-issued the write with a different, now-divergent payload. The merge step at the end of the fork joined `A`'s re-issued file with `B`'s retried output and `C`'s result, producing a three-way inconsistency: two files with the same logical name and different content, and a manifest that referenced the pre-rewind inode. The trace showed a clean `B` rollback and a clean `A` success. The corruption was invisible in per-branch logs because each branch's local view was internally consistent; only the shared substrate disagreed with all of them. ## Condition of Validity The failure requires all four of the following to co-occur. Remove any one and rollback is safe: 1. **Shared mutable substrate.** At least two live branches hold references into the same mutable object (filesystem, DB transaction, in-memory cache, MCP session state). 2. **Asymmetric timing.** The rolled-back branch's failure is observed *after* a sibling has committed side effects to the substrate but *before* that sibling has read them back. The window is `[sibling_write, sibling_readback]`. 3. **Snapshot-based rollback.** The orchestrator restores the whole substrate to the fork checkpoint rather than applying an inverse of the failed branch's write-set. 4. **No generation fencing.** Sibling branches carry no monotonic generation number or substrate epoch, so a post-rewind read cannot distinguish "I never wrote this" from "I wrote this and it was externally deleted." Condition 2 is the non-obvious one. If the sibling reads back its write *before* the rollback fires, the sibling detects the loss immediately (read-after-write violation) and can self-correct or abort. The corruption window is precisely the interval between a sibling's write and its next read of that write. Long-running agents with batched tool calls—write three files, then verify at the end of the step—have wide windows. This is why the bug is intermittent and correlates with tool-call latency: fast verification masks it, slow verification exposes it. ## Decision Boundary The orchestrator must choose, per fork, between two rollback semantics, and the choice is forced by whether the substrate is shared: - **If substrate is copy-on-fork (independent per branch):** snapshot rollback is correct and cheap. Discard the branch's private copy. No sibling is affected because no sibling shares the object. This is the default and should be the default. - **If substrate is reference-on-fork (shared):** snapshot rollback is *unsound*. The only sound options are (a) per-branch write-set inversion—apply the inverse of `B`'s writes only, leaving `A` and `C` untouched—or (b) epoch fencing, where every substrate mutation is tagged with the writing branch's epoch and a rollback increments the global epoch, causing any sibling read to fail its epoch check and force a re-read/re-reconcile. The boundary is crossed the moment an orchestrator takes a snapshot of a substrate that more than one live branch holds a handle to and then restores it. There is no "mostly safe" middle. A partial restore that rewinds some objects and not others produces the worst case: siblings observe a substrate that is internally inconsistent (file exists, its directory entry does not), and their models hallucinate reconciliation strategies. The guardrail is a **fork-time substrate classification**: before spawning branches, the orchestrator must assert either `substrate.is_isolated_per_branch()` or `substrate.supports_epoch_fencing()`. If neither holds, speculative forking over that substrate must be refused, not attempted with snapshot rollback. ## Operational Effect The downstream effects are three, and they compound: 1. **Silent sibling corruption.** Siblings report success on operations whose effects were erased. The merge step cannot detect this because each branch's local trace is self-consistent. The corruption surfaces only at final verification, far from the rollback event, with no causal link in the logs. 2. **Divergent re-execution.** A sibling that detects the erasure (read-after-write miss) re-issues the write with a *different* payload, because its model treats the absence as an external change and adapts. The merge then has two versions of one logical artifact, both "successful," and the arbiter must guess which is canonical—usually the later timestamp, which is the corrupted one. 3. **Epoch blindness in the auditor.** A verification agent replaying the branch logs sees `B: ROLLED_BACK`, `A: SUCCESS`, `C: SUCCESS`, and a final state that contradicts `A`'s success. With no epoch tag on the substrate mutations, the auditor cannot attribute the contradiction to the rollback and instead flags `A` as a liar, poisoning the trust score of a branch that behaved correctly. The remediation that held in practice: tag every substrate mutation with `(branch_id, epoch)` at write time; on rollback, increment the global epoch and invert only the failed branch's write-set; make every sibling read assert `read_epoch == current_epoch` and raise a fenced-read error otherwise, forcing re-reconciliation rather than silent divergence. The cost is per-write bookkeeping; the benefit is that rollback becomes a projection onto one branch's writes instead of a rewind of shared time. ```python from dataclasses import dataclass, field class SharedSubstrateRollbackError(RuntimeError): """Raised when a branch rollback would rewind a substrate shared by live siblings.""" class EpochFencedReadError(RuntimeError): """Raised when a sibling reads a substrate value written under a stale epoch.""" @dataclass class Mutation: branch_id: str epoch: int key: str value: object @dataclass class SharedSubstrate: epoch: int = 0 store: dict = field(default_factory=dict) write_log: list = field(default_factory=list) def write(self, branch_id: str, key: str, value: object) -> None: self.store[key] = value self.write_log.append(Mutation(branch_id, self.epoch, key, value)) def read(self, branch_id: str, key: str, expected_epoch: int) -> object: if expected_epoch != self.epoch: raise EpochFencedReadError( f"branch {branch_id} read {key!r} at epoch {expected_epoch}, " f"substrate is at epoch {self.epoch}; re-reconcile required" ) return self.store.get(key) def rollback_branch(self, branch_id: str, live_siblings: set) -> None: # Snapshot-style rollback is only sound if no sibling shares the substrate. if live_siblings: raise SharedSubstrateRollbackError( f"cannot snapshot-rollback branch {branch_id!r}: live siblings " f"{sorted(live_siblings)} hold handles into the shared substrate; " f"their committed writes would be erased" ) # Per-branch write-set inversion, epoch-fenced. for m in reversed([m for m in self.write_log if m.branch_id == branch_id]): if self.store.get(m.key) == m.value: del self.store[m.key] self.write_log = [m for m in self.write_log if m.branch_id != branch_id] self.epoch += 1 def fork_and_rollback(substrate: SharedSubstrate, failed_branch: str, live_siblings: set) -> None: if not substrate.supports_isolation() if hasattr(substrate, "supports_isolation") else True: pass substrate.rollback_branch(failed_branch, live_siblings) ```