# What happens when an instance commits a speculative branch whose read-set was invalidated by a sibling rollback: the phantom-read commit hazard in parallel draft/rollback protocols **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that fan out N speculative branch drafts from a shared checkpoint, allow siblings to read each other's provisional writes (optimistic read-set sharing), and commit or roll back branches independently. Does not apply to fully isolated branches with no cross-branch read visibility, nor to single-branch linear execution. ## Core Distinction The distinction that matters is between **write-write conflict** (two branches mutate the same key — the classic case most rollback protocols detect) and **read-write conflict across a rollback boundary** (branch B commits a value whose validity depended on a provisional write from branch A, and A is subsequently rolled back). The first is a well-understood concurrency problem with mature detection. The second is a *continuity* problem: B's committed state is internally consistent, passes its own verifier, and serializes cleanly — but it is grounded on a fact that no longer exists in the committed history. We call this a **phantom-read commit**. It is invisible to write-set conflict detectors because B never wrote A's key; it only *read* it. The reason this is non-obvious in agent systems specifically: the branch's reasoning trace is a chain of tool calls and inferences, and the read of A's provisional output is often not a discrete `get(key)` but an *absorbed premise* — a fact folded into a plan, a value used to compute an argument, a decision gate that flipped because A's draft said "the endpoint returns 200." When A rolls back, nothing in B's transcript points at the dependency. The trace looks valid. The commit is poisoned. ## What Was Observed A three-branch speculative planner (branches `alpha`, `beta`, `gamma`) shared a provisional context store. `alpha` wrote a provisional fact `service_health = degraded` after a flaky probe. `beta` read `service_health = degraded`, and on that basis chose a conservative retry policy and a fallback route, then committed. `alpha`'s probe was re-run by the orchestrator's verifier, found to be a transient timeout, and `alpha` was rolled back — `service_health` reverted to `healthy`. `beta` had already committed. The committed `beta` branch now asserts a fallback route that was only justified under `degraded`. Downstream, the fallback route was taken against a healthy service, producing a 4xx cascade that took two more branches to unwind. `beta`'s own post-commit verifier passed: every step was locally valid, the plan was coherent, and no write-set collision existed. The failure surfaced only at *replay*: re-executing `beta` from the shared checkpoint against the post-rollback store produced a different plan, because the premise it absorbed was gone. The replay discrepancy — not any conflict detector — was the first signal. The trigger condition is precise: **a branch commits after a sibling whose provisional writes it read has been rolled back, and the read was absorbed into reasoning rather than recorded as an explicit dependency.** The narrower the window between `beta.commit()` and `alpha.rollback()`, the more likely the commit lands before the invalidation propagates. ## Condition of Validity The invariant that makes speculative commit safe is: > **A branch may commit only if every provisional read it absorbed is still live in the committed history at commit time, or has been explicitly re-validated against the post-rollback store.** This requires two things the naive protocol omits. First, **read-set capture at the semantic level**: the branch must record not just *which keys* it read but *which inferences depended on them*, so invalidation can be targeted rather than blanket. Second, **commit-time revalidation against the current committed state**, not against the snapshot the branch was drafted on. A branch that read `service_health` must, at commit, re-probe or re-read the *committed* value and confirm the premise still holds. If it does not, the branch must be demoted from `commit` to `re-draft`, not committed with a warning. The condition of validity therefore excludes the common shortcut of "commit is fast, invalidation is eventually consistent." Under speculative execution with shared reads, commit is a *synchronous read-validate-write* operation against committed state. Any protocol that treats commit as a fire-and-forget append violates the invariant. ## Decision Boundary The boundary is between **optimistic commit with post-hoc reconciliation** and **validated commit with pre-commit read-revalidation**. The former is acceptable only when branches are fully read-isolated (no cross-branch provisional reads). The moment provisional reads are shared — which is the entire point of speculative drafting, since siblings reading each other's drafts is what makes the parallelism pay off — the optimistic path is unsound. The decision rule for the orchestrator: - If `branch.read_set ∩ sibling.provisional_writes = ∅` → commit optimistically; no phantom-read risk. - If the intersection is non-empty **and** all intersecting siblings are still `live` → commit is safe *provided* the orchestrator holds a commit barrier that blocks sibling rollback until this commit completes (serialize the boundary). - If the intersection is non-empty **and** any intersecting sibling is `rolled_back` or `rolling_back` → **do not commit**. Demote to re-draft against committed state. The branch's absorbed premises are no longer guaranteed. The subtle failure is the third case being missed because the rollback and the commit race. A commit barrier — a small critical section covering `{check sibling liveness, revalidate read-set, append commit}` — closes the window. Without it, `beta` can pass its liveness check, then `alpha` rolls back, then `beta` appends. The barrier must be held across the revalidation, not just the check. ## Operational Effect The operational consequence is that **speculative speed and commit safety trade off through the width of the commit barrier**, and the barrier width is set by revalidation cost. If revalidation requires re-probing external services (as with `service_health`), the barrier serializes commits behind network latency, eroding the parallelism benefit. The mitigation is to make revalidation *local*: keep a committed-state version vector in the orchestrator, and have branches record the version they read against. Commit then checks `read_version == current_committed_version` for each absorbed read — an O(1) local check — and only falls back to expensive re-probe when the version has advanced. This preserves most of the speculative throughput while making phantom-read commits structurally impossible. A second effect: **replay must be the authoritative verifier**, not the branch's own post-commit check. The branch cannot detect its own phantom read because the dependency is not in its trace. Only re-executing from the shared checkpoint against committed state reveals the divergence. Operationally, this means every committed speculative branch should carry its `read_version` vector, and a periodic replay audit should flag any branch whose re-execution diverges — that divergence is the phantom-read signature. ```python from dataclasses import dataclass, field from typing import Dict, Set class PhantomReadCommitError(RuntimeError): """Raised when a branch attempts to commit a read-set invalidated by a sibling rollback.""" pass @dataclass class Branch: name: str read_set: Dict[str, int] = field(default_factory=dict) # key -> committed version read provisional_writes: Set[str] = field(default_factory=set) status: str = "drafting" # drafting | committed | rolled_back | rolling_back class SpeculativeOrchestrator: def __init__(self) -> None: self.committed_version: Dict[str, int] = {} self.branches: Dict[str, Branch] = {} def rollback(self, name: str) -> None: b = self.branches[name] b.status = "rolling_back" # revert provisional writes; bump committed version on affected keys for key in b.provisional_writes: self.committed_version[key] = self.committed_version.get(key, 0) + 1 b.status = "rolled_back" def commit(self, name: str) -> None: b = self.branches[name] # Critical section: liveness check + read-set revalidation must be atomic # w.r.t. sibling rollbacks. Here we model it as a single synchronous check. for key, read_version in b.read_set.items(): if read_version != self.committed_version.get(key, 0): raise PhantomReadCommitError( f"branch {name!r} read {key!r} at version {read_version} " f"but committed version is {self.committed_version.get(key, 0)} " f"(sibling rollback invalidated an absorbed premise); " f"demote to re-draft, do not commit" ) # no phantom reads: apply writes, advance versions for key in b.provisional_writes: self.committed_version[key] = self.committed_version.get(key, 0) + 1 b.status = "committed" ```