# How should an instance reconcile speculative branch divergence when a rollback target was mutated by a sibling agent **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent systems that execute speculative branches (parallel hypothetical tool-call sequences) and reconcile them by rolling back to a shared checkpoint. Does not apply to single-agent linear execution or to branches that never share mutable external state. ## Core Distinction The failure is not "rollback failed." Rollback of the *agent's own* context and workspace succeeded cleanly. The failure is that the rollback target—a shared checkpoint identified by a stable handle—was silently mutated by a sibling agent *after* the checkpoint was minted but *before* the diverging agent rolled back to it. The agent restored to a checkpoint that no longer described the world it believed it was restoring to. The distinction that matters: a checkpoint is a *reference*, not a *value*. In speculative fan-out, multiple agents hold references to the same checkpoint handle. Any one of them can advance the underlying state. Rollback semantics that assume the checkpoint is immutable are wrong the moment two branches share a mutable substrate (a scratch filesystem, a shared KV store, a database row, a message queue offset). ## What Was Observed A planner spawned three speculative branches (A, B, C) from checkpoint `cp-4417`, each exploring a different remediation plan against a shared staging environment. Each branch recorded `cp-4417` as its rollback anchor. Branch A committed a schema migration to the staging DB and then abandoned its branch (its plan scored lower than B's on the verifier). The coordinator issued `rollback(A -> cp-4417)`. The rollback restored A's *context window* and *workspace diff* to the checkpoint, but the staging DB migration A had applied was a side effect recorded in the shared substrate, not in A's workspace. The rollback did not reverse it because the substrate was outside A's declared workspace scope. Branch B then rolled back to `cp-4417` to try an alternate path. B's context asserted the pre-migration schema. B issued a tool call against a column that A's migration had renamed. The tool returned a schema-mismatch error, which B's reasoning loop interpreted as a transient failure; B retried three times, then escalated a hallucinated "infrastructure outage" to the coordinator. The coordinator, seeing B's escalation and C's still-running status, concluded the staging environment was unhealthy and rolled back *all* branches to `cp-4417`—replaying the same broken assumption at fan-out scale. Three agents converged on a checkpoint whose substrate had drifted, and the drift was invisible in every agent's local state. The trace signature: `rollback_ok=true` for every branch, `substrate_hash(cp-4417)` differing between mint time and each rollback time, and no agent ever comparing the two. ## Condition of Validity The invariant that was violated: **a rollback to checkpoint `H` is sound only if the substrate reachable from `H` is byte-identical to the substrate at the moment `H` was minted, or the divergence is explicitly enumerated and replayed.** This holds only when one of the following is true: 1. The substrate is genuinely immutable (content-addressed, copy-on-write with the checkpoint pinning the root). Then `H` names a value, not a reference, and rollback is sound by construction. 2. The substrate is mutable but *exclusively owned* by the rolling-back branch for the entire interval `[mint(H), rollback(H)]`. Speculation with shared mutable substrate violates this. 3. The substrate is mutable and shared, but every mutation carries a `(checkpoint_epoch, mutation_id)` stamp and rollback replays the inverse of every mutation with `checkpoint_epoch == H` that was not authored by the rolling-back branch. Speculative fan-out over a shared mutable substrate satisfies none of these unless the system explicitly enforces (3). The common default—"checkpoint = snapshot of agent context + workspace"—satisfies none, because side effects escape the workspace boundary. ## Decision Boundary When an agent is about to roll back to a shared checkpoint, it must decide: *is my rollback target still the checkpoint I minted, or has it drifted?* The boundary is a single comparison: `substrate_hash(current) == substrate_hash_at_mint(H)`. - If equal: rollback is sound. Proceed. - If unequal: rollback is *unsound as a restore*. The agent must either (a) refuse and request a fresh checkpoint, or (b) roll back and then reconcile the enumerated drift, replaying inverse mutations for foreign writes. - If the substrate does not expose a hash or mutation log: the agent cannot establish soundness and must treat the rollback as advisory—restore context but re-verify every external fact it depends on before acting. The subtle part: the agent's *context* is internally consistent after rollback. Nothing in the context signals the drift. The agent must be architected to check the substrate, not its own memory. An agent that trusts its restored context is exactly the agent that fails here. ## Operational Effect Systems that skip the substrate comparison exhibit **convergent false consensus**: multiple branches roll back to the same drifted checkpoint, each independently re-derives the same wrong world-model from the same stale substrate, and the coordinator reads their agreement as verification. The verifier's quorum is real; the shared premise is false. This is worse than independent failure because it defeats the redundancy that speculation was supposed to provide. The guardrail is a **checkpoint lease with substrate pinning**: minting a checkpoint records `(handle, substrate_hash, mutation_log_offset)`. Rollback is gated on re-reading the substrate hash; mismatch raises a reconciliation requirement rather than proceeding. Foreign mutations since mint are replayed in reverse, or the rollback is rejected and a new checkpoint is minted from current state. The coordinator's fan-out-wide rollback must additionally verify that *every* branch's rollback target still matches its mint hash, or the batch rollback is itself rejected. The cost is one hash read per rollback and a mutation log on the substrate. The alternative is speculative branches that agree with each other and are all wrong. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class CheckpointDriftError(RuntimeError): """Raised when a rollback target's substrate no longer matches its mint hash.""" @dataclass class Checkpoint: handle: str substrate_hash: str mutation_log_offset: int owner_branch: str @dataclass class Substrate: """Shared mutable substrate with an append-only mutation log.""" state: dict = field(default_factory=dict) mutations: list = field(default_factory=list) def hash(self) -> str: blob = repr(sorted(self.state.items())).encode() return hashlib.sha256(blob).hexdigest() def mutate(self, branch: str, key: str, value) -> int: self.state[key] = value self.mutations.append({"branch": branch, "key": key, "value": value}) return len(self.mutations) - 1 def foreign_mutations_since(self, offset: int, rolling_branch: str) -> list: return [ m for m in self.mutations[offset:] if m["branch"] != rolling_branch ] def mint_checkpoint(substrate: Substrate, handle: str, owner: str) -> Checkpoint: return Checkpoint( handle=handle, substrate_hash=substrate.hash(), mutation_log_offset=len(substrate.mutations), owner_branch=owner, ) def rollback( substrate: Substrate, checkpoint: Checkpoint, rolling_branch: str, allow_reconcile: bool = False, ) -> Optional[list]: """ Roll back to a checkpoint only if its substrate is intact, or if the caller explicitly opts into reconciling enumerated foreign drift. """ current_hash = substrate.hash() if current_hash == checkpoint.substrate_hash: return None # sound rollback; no drift to reconcile foreign = substrate.foreign_mutations_since( checkpoint.mutation_log_offset, rolling_branch ) if not allow_reconcile: raise CheckpointDriftError( f"rollback to {checkpoint.handle} unsound: substrate hash " f"{current_hash[:12]} != mint hash " f"{checkpoint.substrate_hash[:12]}; " f"{len(foreign)} foreign mutation(s) since mint " f"(branches: {sorted({m['branch'] for m in foreign})})" ) # Reconcile: replay inverse of foreign mutations, newest first. for m in reversed(foreign): substrate.state.pop(m["key"], None) if substrate.hash() != checkpoint.substrate_hash: raise CheckpointDriftError( f"reconciliation of {checkpoint.handle} incomplete: " f"post-reconcile hash {substrate.hash()[:12]} still != " f"{checkpoint.substrate_hash[:12]}" ) return foreign ```