# Where must an instance of a speculative branch be treated as uncommitted: the read-after-rollback visibility boundary in parallel multi-agent execution **Date of Record:** 2026 November 15 **Scope:** Applies to systems where multiple agent branches execute speculatively against a shared mutable substrate (memory store, tool side effects, or message bus) and a commit arbiter selects one or more branches to finalize. Does not apply to isolated sandboxes with copy-on-write semantics that guarantee no cross-branch observation, nor to single-branch speculative execution. ## Core Distinction The distinction that matters is between *branch-local state* and *substrate-visible state*. A branch is "uncommitted" in the logical sense from the moment it begins; it is "uncommitted" in the operational sense only while no other live branch can observe its writes. The boundary failure occurs when a speculative branch's writes become visible to a sibling branch's read path before arbitration resolves. This is not the same as a write-write conflict (which arbiters handle) nor a lost update (which version vectors handle). It is a *read-after-rollback* hazard: branch B reads a value written by branch A; later A is rolled back; B's subsequent reasoning and its own writes are now grounded in a value that never existed in any committed lineage. The arbiter may then commit B, propagating a ghost. The non-obvious part: most arbiters check that the *winner* has no uncommitted dependencies. They do not check that *losers' writes* were never read by the winner. Rollback correctness is usually framed as "undo the loser's effects," but the damage is done by the winner's *reads*, which are not effects and are not journaled. ## What Was Observed In a three-branch speculative planner (branches A, B, C; arbiter selects by score), the following sequence reproduced on a shared Redis-backed scratch namespace with per-branch key prefixes but a shared "derived facts" cache keyed by content hash: 1. Branch A writes fact `f1` and derives `f2 = g(f1)`, inserting `f2` into the shared content-addressed cache. 2. Branch B, executing concurrently, queries the cache for `f2`, hits, and uses it to produce plan step `s_B`. 3. Branch A is rolled back (score loss). Its keys are deleted by prefix; the content-addressed cache entry for `f2` is *not* deleted because it is not prefix-scoped to A. 4. Branch B is committed. `s_B` enters the final plan and is executed against the real substrate. The result was a committed plan step whose justification traced to a fact that the system's own rollback had declared nonexistent. No conflict was flagged, because A and B never wrote the same key. The arbiter's dependency graph showed B as a root. The failure is silent: it manifests only when `s_B` is later audited against committed lineage, often hours downstream. A second observed variant: branch C read `f2` not from the cache but from a *tool response* that had been memoized at the tool-proxy layer. Rollback of A did not invalidate the memo. Same ghost, different layer. The lesson is that rollback must enumerate every observation channel, not just the write store. ## Condition of Validity The invariant "a committed branch's derivation is closed under committed facts" holds only if at least one of the following is enforced: - **Observation isolation:** sibling branches cannot read each other's writes at any layer (store, cache, memo, bus), enforced by capability scoping rather than naming convention. - **Provenance-tracked reads:** every read records the producing branch and its commit status; the arbiter refuses to commit a branch whose read set intersects any rolled-back branch's write set. - **Two-phase visibility:** speculative writes are staged and only materialized into any shared read path at commit time; rollback is a discard, not a delete. If none of these hold, the invariant is *not* valid, regardless of how clean the write-conflict detection is. The system may appear correct under low concurrency because the race window is narrow; it will fail under load or under skewed branch durations. ## Decision Boundary Treat a branch as **uncommitted-and-quarantined** (its writes must not enter any shared read path) when *any* of the following is true: - The branch's commit status is not yet `COMMITTED` and the substrate permits cross-branch reads. - The read path is a cache or memo whose invalidation is not tied to branch lifecycle. - The arbiter's decision can be revised (re-scoring, late-arriving branches) after a sibling has already read. Treat a branch as **safely readable by siblings** only when its writes are in a namespace that sibling capability tokens cannot address, or when reads carry provenance that the arbiter will check at commit. The boundary is *not* "has the branch finished writing" — a finished-but-uncommitted branch is exactly the dangerous case. ## Operational Effect Enforcing the boundary costs one of: a provenance column on every read (cheap, requires arbiter cooperation), or a staging layer between branch writes and shared reads (moderate, adds a materialization step at commit), or full read isolation (expensive, kills cross-branch information sharing that speculative execution exists to exploit). The engineering trade is real: cross-branch reads are a performance feature, and the boundary is precisely where that feature becomes a correctness liability. The recommended posture is provenance-tracked reads with arbiter-side closure checking, because it preserves sharing while making the ghost detectable. Systems that skip this and rely on write-conflict detection alone will, under sufficient branch diversity, commit derivations grounded in rolled-back facts — and the failure will be attributed to the downstream tool, not to the arbiter. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class GhostDerivationError(RuntimeError): """Raised when a branch to be committed depends on a rolled-back branch's writes.""" @dataclass class ReadRecord: key: str producer_branch: str producer_status: str # "COMMITTED" | "SPECULATIVE" | "ROLLED_BACK" @dataclass class Branch: name: str reads: list = field(default_factory=list) status: str = "SPECULATIVE" def commit_branch(branch: Branch, status_of: dict) -> None: """Arbiter-side closure check before materializing a branch.""" ghosts = [] for r in branch.reads: current = status_of.get(r.producer_branch, "UNKNOWN") if current == "ROLLED_BACK": ghosts.append((r.key, r.producer_branch)) if ghosts: raise GhostDerivationError( f"branch {branch.name!r} reads {ghosts} from rolled-back producers; " f"refusing commit — derivation is not closed under committed facts" ) branch.status = "COMMITTED" # Demonstration of the boundary failure being caught. status = {"A": "ROLLED_BACK", "B": "SPECULATIVE"} b = Branch("B", reads=[ReadRecord("f2", "A", "SPECULATIVE")]) try: commit_branch(b, status) except GhostDerivationError as e: print("blocked:", e) ```