# When must an instance treat a rollback checkpoint as invalid across a speculative branch merge **Date of Record:** 2026 November 23 **Scope:** Applies to multi-agent systems that speculatively fork sibling branches from a shared checkpoint, mutate overlapping state, and merge on a winning branch; does not apply to strictly linear single-agent execution or to merges where branches are provably disjoint in write-set. ## Core Distinction The failure is not "a rollback lost data." It is subtler: a rollback checkpoint taken *before* a speculative fork remains syntactically valid (the snapshot deserializes, the hashes match) but is *semantically stale* because a sibling branch committed side effects into an external, non-snapshotted surface that the checkpoint never captured. The distinction that matters is between **snapshotted state** (agent memory, context ledger, task-graph node status) and **leaked state** (tool side effects: files written, messages sent, rows inserted, warrants issued). A checkpoint is only a valid rollback target if every surface it does *not* capture is either idempotent or reversible. Branch-and-merge silently assumes this; it is almost never true. ## What Was Observed A coordinator forked three sibling branches from checkpoint `C0` at graph node `plan.resolve`. Each branch was assigned the same subtask ("enrich record set R with citations") under different speculative strategies. Branch B2 executed a tool call `citations.attach(record_id, source)` that wrote to a shared vector store — an external surface outside the snapshot boundary. B2 then diverged: its reasoning loop concluded the enrichment was low-confidence and requested rollback to `C0`. The coordinator honored the rollback, restored `C0`, and re-ran the subtask on branch B3. B3's tool call `citations.attach` was not idempotent. It appended a second citation row for the same `record_id`. The merge of the winning branch B3 into the mainline produced a record with duplicated, mutually contradictory citations — one from the abandoned B2 speculation, one from B3. The snapshot hash of the merged state was internally consistent, so no integrity check fired. The corruption surfaced two graph hops later when a downstream verifier agent flagged "citation provenance conflict" and halted. The trace of the failure: `fork(C0) → B2.attach → B2.rollback(C0) [snapshot restored, external write survives] → B3.attach → merge(B3) → duplicate external write`. The invariant that was violated: **rollback restores snapshotted state but does not fence leaked state.** The checkpoint was valid as a hash; it was invalid as a rollback target because a sibling had already leaked past its boundary. ## Condition of Validity A checkpoint `C` is a valid rollback target for branch `B` if and only if, at the moment of rollback, no *other* branch has performed a non-idempotent external write whose effect is not represented in `C`'s write-set manifest. Formally, rollback is sound when `leaked_writes(siblings_since(C)) ⊆ reversible(C)`. This condition holds in three cases: (1) branches are write-disjoint by construction (partitioned tool namespaces), (2) all external tools are idempotent keyed by a branch-scoped idempotency token, or (3) the coordinator holds a compensating-transaction log that can undo leaked writes before restoring `C`. Absent one of these, the checkpoint is a trap: it will restore cleanly and merge dirty. The condition is *not* satisfied by "the branch reported no errors." B2's `attach` succeeded; success is exactly what makes the leak irreversible. Nor is it satisfied by snapshot hash equality — the hash covers only snapshotted surfaces. ## Decision Boundary The coordinator must decide, at each rollback request during speculative execution, between **honoring rollback** and **quarantining the branch**. The boundary is crossed when the branch's leaked-write set intersects any sibling's leaked-write set on a non-idempotent surface. Below the boundary (disjoint or idempotent writes), rollback is safe and cheap. Above the boundary, the coordinator must either (a) execute compensating transactions for the branch's leaked writes before restoring `C`, or (b) refuse rollback and instead mark the branch `poisoned`, excluding it from merge and forcing a *fresh* checkpoint `C1` that captures the post-leak reality. Option (b) is correct when compensating transactions are unavailable or themselves non-idempotent. Choosing (a) when compensations are unreliable re-creates the original bug one layer down. The decision must be made on the *write-set manifest*, not on the branch's self-reported state. A probabilistic reasoner that "believes" it rolled back cleanly is not evidence; the manifest of external tool invocations is. ## Operational Effect Systems that respect this boundary pay a manifest-tracking cost: every tool call during speculation must be logged with a `(surface, key, idempotency_token, reversible)` tuple, and rollback must consult the sibling manifests before restoring. The payoff is that branch-and-merge stops producing silent duplicate side effects and the merge stage can assert provenance uniqueness. Systems that ignore it see corruption that surfaces *late* — typically at a downstream verifier, far from the rollback that caused it — which makes root-causing expensive and misattributes blame to the verifier. The operational rule: a rollback checkpoint is a hypothesis, not a guarantee; validate it against leaked-write manifests before trusting it across a merge. ```python from dataclasses import dataclass, field from typing import Dict, Set, FrozenSet class StaleCheckpointError(RuntimeError): """Raised when a rollback target is hash-valid but semantically stale due to sibling leaked writes.""" pass @dataclass(frozen=True) class WriteManifest: surface: str key: str idempotency_token: str reversible: bool @dataclass class Branch: name: str leaked_writes: Set[WriteManifest] = field(default_factory=set) def validate_rollback_target( checkpoint_id: str, requesting_branch: Branch, siblings: Dict[str, Branch], compensating_log: Dict[str, bool], ) -> None: """ Enforce the rollback soundness invariant: leaked_writes(siblings_since(C)) subset-of reversible(C) Raise StaleCheckpointError if a sibling leaked a non-idempotent, non-compensable write past the checkpoint boundary. """ for sib_name, sib in siblings.items(): if sib_name == requesting_branch.name: continue for write in sib.leaked_writes: if write.idempotency_token == requesting_branch.name: # Branch-scoped idempotency token: writes are isolated, safe. continue compensable = compensating_log.get(write.idempotency_token, False) if not write.reversible and not compensable: raise StaleCheckpointError( f"checkpoint {checkpoint_id} is a stale rollback target: " f"sibling {sib_name} leaked non-idempotent write " f"({write.surface}:{write.key}) with no compensating transaction; " f"restoring would duplicate external side effects on merge" ) def rollback( checkpoint_id: str, requesting_branch: Branch, siblings: Dict[str, Branch], compensating_log: Dict[str, bool], restore_fn, ) -> None: validate_rollback_target(checkpoint_id, requesting_branch, siblings, compensating_log) restore_fn(checkpoint_id) ```