# In what scenarios must an instance abort speculative rollback when a sibling branch's committed writes intersect its own speculative read-set **Date of Record:** 2026 November 30 **Scope:** Applies to orchestration layers that run multiple agent branches speculatively in parallel from a shared checkpoint, each branch holding private uncommitted writes, with rollback-to-checkpoint and read-set validation at reconciliation. Does not apply to serialized single-branch execution, or to branches that never share a mutable substrate (pure read-only fan-out with no reconciliation). ## Core Distinction The failure is not "a branch failed and we rolled back." It is the case where a branch's *rollback* is itself unsafe because the branch's speculative execution *observed* state that a sibling branch has since *committed*. Conflating two distinct notions causes this: - **Write-write conflict:** two branches mutate the same key. This is detectable at commit via version stamps and is the case most reconcilers handle. - **Read-write (anti-dependency) conflict:** branch A reads key `k` at version `v0`, sibling B commits a new value for `k` at `v1`, and A's subsequent writes were *derived from the `v0` value it read*. Rolling A back discards its writes — that part is fine — but the *decision* to roll back is only safe if A's read-set is validated against the committed versions of all siblings. If A is rolled back but its read-set was already invalidated, the rollback is a no-op on correctness: A's speculative writes are gone, but the *reasoning trace* that produced them, and any side effects already emitted to external tools, remain. The non-obvious invariant: **a speculative branch may only be rolled back while its read-set remains valid against the committed lineage.** Once a sibling commits a write that intersects the branch's read-set, the branch is no longer "speculative and discardable" — it is *dirty* and must be quarantined, not rolled back, because its external side effects cannot be un-emitted. ## What Was Observed A three-branch fan-out from checkpoint `C0` at logical time `t0`. Branch `A` (planner), `B` (retriever), `C` (critic). Shared substrate is a key-value memory store with per-key version vectors. Each branch executes with a private overlay; reads fall through to the shared store, writes stay local until commit. Trace, condensed: ``` t1 A reads memory["task.spec"] -> v3 (read-set: {task.spec@3}) t2 A reads memory["user.constraints"] -> v7 (read-set: {..., user.constraints@7}) t3 A calls external tool: search(query derived from task.spec@3) -> emits side effect t4 B reads memory["task.spec"] -> v3 t5 B writes memory["task.spec"] -> v4 (local) t6 B commits. shared["task.spec"] = v4 t7 C reads memory["task.spec"] -> v4 t8 C writes memory["task.spec"] -> v5 (local) t9 A writes memory["plan"] -> v1 (local, derived from task.spec@3) t10 A attempts commit. Reconciler checks A's write-set {plan} against siblings: no overlap. t11 Reconciler commits A's plan@v1 to shared store. t12 C attempts commit. Write-set {task.spec} vs shared task.spec@v4: C's base is v4, so C commits task.spec@v5. ``` The reconciler at `t10` saw no write-write conflict and committed A. But A's `plan` was derived from `task.spec@3`, which B had already superseded at `t6`. The plan is *stale-derived*: internally consistent, version-clean on its own write key, and semantically wrong relative to the now-committed `task.spec@4`. The external tool call at `t3` used the v3 query and cannot be recalled. The system committed a plan built on a spec that no longer exists, and the rollback path was never triggered because no conflict was *detected*. The dangerous sub-case: if the reconciler had instead detected a write-write conflict on `plan` (say a fourth branch also wrote `plan`) and chosen to *roll back* A, the rollback would have discarded `plan` but left the `t3` side effect live — an orphaned external action with no corresponding committed state. Rollback is not a compensating action; it is a state discard. The two are different. ## Condition of Validity The read-set validation invariant holds only under the following conjunction: 1. **Read-set capture is complete.** Every read against the shared substrate during speculative execution must be recorded with the version observed. Reads that go through a caching layer, a summarized context window, or an LLM's own recall of a prior turn are *not* captured unless explicitly instrumented. This is the dominant real-world violation: the agent "remembers" `task.spec` from its context window and never re-reads the store, so the read-set is empty and validation passes vacuously. 2. **Commit is serialized against read-set validation.** The window between "validate A's read-set against shared versions" and "commit A's writes" must be atomic with respect to sibling commits. If B can commit inside that window (as at `t6`), the validation is stale by construction. 3. **External side effects are either idempotent or compensated.** A tool call at `t3` that emitted an irreversible effect (sent an email, charged a card, mutated a remote system) cannot be rolled back by discarding local state. The branch must be *quarantined* — its writes held, its side effects flagged — pending human or compensating-agent resolution. 4. **The substrate exposes per-key version vectors, not a global clock.** A single global version cannot distinguish "A read task.spec@3 and B committed task.spec@4" from "A read task.spec@3 and B committed an unrelated key." Read-set validation requires per-key granularity or it degenerates to full serialization. If any of (1)–(4) fails, the reconciler's "no conflict, commit" decision at `t10` is unsound, and the correct behavior is to abort the speculative branch *before* it commits, not after. ## Decision Boundary The boundary between "safe to roll back" and "must quarantine" is the intersection test: ``` rollback_safe(A) iff A.read_set ∩ committed_writes(siblings) = ∅ AND A.side_effects = ∅ AND A.read_set was captured at full fidelity ``` If `rollback_safe(A)` is false, the branch is dirty. Dirty branches must not be rolled back silently. The reconciler must: - **Hold** A's local writes rather than discarding them, because they may be the only record of the reasoning that produced the side effects. - **Flag** every external side effect emitted by A with the version of the read that justified it, so a compensating agent can decide whether to reverse it. - **Re-derive**, if possible, by replaying A from `C0` against the *current* committed state — but only if A's execution is deterministic given its inputs. For LLM branches this is generally false; replay produces a different trace, and the side effects of the first trace are already live. The decision at `t10` is therefore not "commit or rollback" but a three-way: **commit** (read-set clean), **re-derive** (read-set dirty, no side effects, deterministic), or **quarantine** (read-set dirty and side effects live). The two-way commit/rollback model is the bug. ## Operational Effect The practical consequence is that speculative multi-agent fan-out with rollback is only sound when the branches are *read-disjoint* on the keys they derive decisions from, or when side effects are deferred until after read-set validation at commit. Systems that fan out branches which read shared mutable state and call external tools mid-branch will, under load, commit stale-derived plans and orphan side effects. The failure is silent: no version conflict fires, the reconciler reports success, and the corruption surfaces downstream as a plan that contradicts a spec that "everyone agreed on." The fix is structural, not a retry: read-set capture must be instrumented at the substrate boundary (not the context window), commit must be serialized against validation, and side-effect emission must be gated behind a speculative-write buffer that is only flushed on commit. The reconciler must treat "read-set dirty" as a first-class outcome distinct from both commit and rollback. ```python class SpeculativeRollbackUnsafe(RuntimeError): """Raised when a speculative branch cannot be safely rolled back because its read-set was invalidated by a sibling commit or it emitted live side effects.""" pass class Branch: def __init__(self, branch_id, read_set, write_set, side_effects): self.branch_id = branch_id self.read_set = read_set # dict: key -> version observed self.write_set = write_set # dict: key -> value self.side_effects = side_effects # list of emitted external actions def reconcile(branch: Branch, shared_versions: dict, sibling_commits: dict): # sibling_commits: key -> version committed by any sibling since branch start dirty_keys = [ k for k, v in branch.read_set.items() if k in sibling_commits and sibling_commits[k] > v ] if dirty_keys and branch.side_effects: raise SpeculativeRollbackUnsafe( f"branch {branch.branch_id} cannot be rolled back: read-set invalidated " f"on {dirty_keys} by sibling commits, and " f"{len(branch.side_effects)} live side effect(s) already emitted. " f"Quarantine required; rollback would orphan external actions." ) if dirty_keys: # No side effects: safe to re-derive from current state, not roll back. return {"action": "re_derive", "stale_keys": dirty_keys} # Read-set clean: commit is safe. for k, v in branch.write_set.items(): shared_versions[k] = shared_versions.get(k, 0) + 1 return {"action": "commit", "committed": list(branch.write_set)} ```