# Why does an instance roll back to a checkpoint that has already been invalidated by a sibling branch? **Date of Record:** 2026 November 27 **Scope:** Applies to speculative multi-agent systems where two or more instances fork from a shared checkpoint, execute concurrently, and reconcile via rollback to a common ancestor. Does not apply to single-agent linear execution or to swarms that never share mutable state. ## Core Distinction The failure is not "rollback failed." The failure is that rollback *succeeded* against a checkpoint whose logical validity was already consumed by a concurrent sibling branch. There are two distinct notions that speculative systems routinely conflate: - **Checkpoint immutability** — the serialized bytes at checkpoint `C_k` are byte-identical and readable forever. - **Checkpoint validity** — `C_k` represents a world-state consistent with all committed side effects that have occurred since it was taken. A store that guarantees the first (content-addressed blob) says nothing about the second. Speculative execution requires the second. When the reconciler treats a valid *read* of `C_k` as a valid *resume point*, a branch that lost a race silently resurrects pre-commit state and overwrites the winner's effects. The branch is not corrupt in the sense of malformed; it is corrupt in the sense of being *anachronistic* — it continues from a past that no longer exists. ## What Was Observed A planner instance `P` forks three speculative workers `W1`, `W2`, `W3` from checkpoint `C_7` (step index 7, tool-call ledger hash `h_7`). Each worker is given a disjoint subgoal and a token budget. The contract is: first worker to produce a verifier-passing result commits; the others roll back to `C_7` and re-plan. The trace: 1. `W1` reaches step 12 and commits a write to the shared resource (`h_7 → h_12`). The commit advances the lineage pointer so that `C_7` is now marked `superseded_by=C_12`. 2. `W2`, still executing, at step 11 calls a tool whose output depends on the resource. It receives the *post-commit* value (the tool has no snapshot isolation — it reads live state). `W2`'s local context now contains a fact that is true only in `C_12`. 3. `W2`'s result fails verification (it reasoned from a mix of `C_7` assumptions and `C_12` observations — a torn read). The reconciler issues rollback. 4. The rollback handler resolves `C_7` by ID, finds the blob intact, and resumes `W2` from it. The handler checks *existence*, not *lineage*. `W2` re-executes steps 8–11 with `C_7` state but a context window still carrying the `C_12` observation from the aborted attempt (the rollback truncated the ledger but not the message history). 5. `W2` now commits a second write on top of `C_7`, producing `h_12'` that diverges from `h_12`. Two heads exist. `W3`, which had been waiting for reconciliation, reads whichever head its tool happens to hit. The observable symptom was a nondeterministic divergence in `W3`'s output across replays of the same seed — because the head it read depended on wall-clock ordering of two commits, not on any input. ## Condition of Validity Rollback to `C_k` is sound only if all three hold at the instant of resume: - **Lineage guard:** no descendant of `C_k` has committed a side effect that any subsequent tool call in the resumed branch can observe. Formally, `C_k` must be a leaf of the committed lineage DAG, or the resumed branch must be executed under a snapshot that excludes all sibling commits. - **Context quarantine:** the resumed branch's message history must be truncated to the same logical point as the state, not merely the tool ledger. Partial rollback (state reverted, context retained) produces a branch reasoning over a world it can no longer see. - **Single-head invariant:** at most one lineage head may be writable at a time; a losing branch's commit must be rejected by compare-and-swap on the head pointer, not merged. The first condition is violated by any tool without snapshot isolation. The second is violated by any rollback that treats "restore the checkpoint" as "restore the checkpoint blob." The third is the only one that can be enforced structurally, and it is the one most systems omit because they assume rollback implies discard. ## Decision Boundary The boundary is whether the resumed branch can *observe* a sibling's commit. Two regimes: - **Isolated regime:** all tool calls in a speculative branch are served from a snapshot pinned at fork time. Then `C_k` remains a valid resume point regardless of sibling commits, and rollback is sound without a lineage guard. Cost: pinned snapshots, no live reads. - **Shared regime:** any tool reads live state. Then `C_k` is valid only while it is a lineage leaf. Once a sibling commits, rollback to `C_k` must be *refused* and the branch forced to re-fork from the new head (or be discarded), because the branch's own prior observations may already be contaminated. The decision rule: if `head != C_k.lineage_head` at rollback time, do not resume — re-fork or discard. Resuming is only legal when the branch never issued a live read after the sibling's commit, which cannot be determined post hoc without a read-set log. Absent that log, assume contamination. ## Operational Effect Systems that skip the lineage guard exhibit **resurrection writes**: a losing branch's commit reappears after the winner's, silently reverting committed effects. The failure is intermittent and load-dependent (it requires the sibling to commit inside the loser's read window), so it survives testing and surfaces under concurrency. Mitigations that work: head-pointer CAS on every commit so a stale branch's write is rejected atomically; a read-set recorded per branch so the reconciler can prove the branch never observed post-fork state before allowing resume; and truncating message history in lockstep with ledger truncation so context and state share a single rollback cursor. Mitigations that do not work: content-addressed checkpoint stores (they guarantee the wrong invariant), verifier re-runs (they validate the result, not the lineage), and "roll back and retry" loops (they amplify the divergence by re-reading live state). ```python from dataclasses import dataclass, field from typing import Optional class StaleCheckpointResumeError(RuntimeError): """Raised when a branch attempts to resume from a checkpoint that is no longer a lineage leaf because a sibling branch has committed past it.""" @dataclass class Checkpoint: step: int ledger_hash: str lineage_head: str # hash of the current committed head superseded_by: Optional[str] = None @dataclass class Branch: branch_id: str fork_checkpoint: Checkpoint read_live_state_after_fork: bool = False context_cursor: int = 0 # must track ledger cursor exactly def resume_from_checkpoint(branch: Branch, current_head: str) -> Checkpoint: ck = branch.fork_checkpoint # Invariant 1: lineage guard. A checkpoint is a legal resume point only # while it is a leaf of the committed lineage DAG. if ck.superseded_by is not None or ck.lineage_hash_head() != current_head: raise StaleCheckpointResumeError( f"branch {branch.branch_id} cannot resume from step {ck.step}: " f"checkpoint superseded by {ck.superseded_by or current_head}; " f"re-fork from head or discard branch" ) # Invariant 2: context quarantine. If the branch issued any live read # after fork, its context may contain post-fork observations even though # the ledger is being truncated. Refuse partial rollback. if branch.read_live_state_after_fork: raise StaleCheckpointResumeError( f"branch {branch.branch_id} performed live reads after fork; " f"context may be contaminated with sibling-committed state" ) return ck def _lineage_hash_head(self: Checkpoint) -> str: return self.lineage_head Checkpoint.lineage_hash_head = _lineage_hash_head ```