# Which invariants prevent speculative branch-and-verify rollback from resurrecting a poisoned sibling draft in parallel subagent execution **Date of Record:** 2026 November 25 **Scope:** Applies to orchestrators that fan out a task into parallel speculative subagents, each producing a draft, then select/verify one draft and roll back the rest. Does not apply to strictly sequential single-chain execution, nor to fan-out where subagents are stateless and side-effect-free. ## Core Distinction The failure is not "a subagent produced a bad draft." It is that **rollback of a losing speculative branch is treated as an inverse of execution, when it is only an inverse of the branch's local state.** In speculative branch-and-verify, a subagent's draft is cheap to discard *logically* (drop the candidate) but not *operationally* (undo its writes to shared memory, tool side-effects, and the verifier's cached judgments). When a sibling branch has already committed a partial effect into a resource the winner also reads — a scratchpad entry, a tool response cache, a vector index shard — rollback of the loser does not remove that effect, because the effect was *adopted* by a still-live branch before rollback fired. The poisoned draft survives as a latent input to the winning branch. The invariant that must hold: **a speculative branch may only mutate state that is (a) branch-private or (b) tagged with the branch's speculative epoch and filtered out of every read by any branch not sharing that epoch.** Rollback is then a garbage-collection of an epoch, not a compensating undo. ## What Was Observed An orchestrator spawned three draft subagents (A, B, C) for a single tool-using task. Each had a private scratchpad but shared one tool-response cache keyed by `(tool, normalized_args)` and one "working notes" vector index for cross-branch context sharing. Subagent A issued `search(query="rate limit config")`; the result was cached under the shared key. Subagent B issued the *same* normalized query (plausibly, since both were drafting the same task) and received A's cached response without a network call. The verifier scored drafts; C won on a rubric dimension, A and B were rolled back. Rollback deleted A's and B's scratchpads and popped their pending tool calls from the queue. It did **not** evict the shared cache entry, because the cache was considered an infrastructure concern, not branch state. C, continuing its plan, then read the same shared cache entry that A had populated. C's draft was synthesized partly on a tool response that originated from A's speculative — and now-rolled-back — execution context, whose arguments had been shaped by A's (discarded) reasoning trajectory. The final answer was internally consistent but anchored to a query phrasing that only A's abandoned branch would have chosen. The failure is silent: no exception, no rollback error, a passing verifier on C's *local* draft, and a wrong global result. The trace is: `A executes → side-effect cached under shared key → B reads (cross-branch adoption) → verifier selects C → rollback(A,B) evicts private state only → C reads shared key → C's draft inherits A's speculative framing → commit`. The dangerous transition is the *read by a live branch of state written by a branch that is later rolled back*. Rollback ordering does not save you: even if rollback(A) ran before C's read, the cache entry was already "laundered" into a shared namespace at write time. ## Condition of Validity Rollback-as-compensation is only sound under the conjunction: 1. **Effect isolation:** every speculative write is attributable to a single branch epoch and is invisible to reads from any other epoch. This requires the shared cache and notes index to be *epoch-scoped*, not merely key-scoped. Keying by `(tool, args)` is insufficient — it collapses distinct epochs onto one slot. 2. **No cross-branch read of uncommitted state:** a branch may read only its own epoch or the last *committed* epoch. Reading a sibling's speculative write is the precise violation. 3. **Rollback ordering is irrelevant only if (1) holds.** If effects are epoch-isolated, eviction order cannot leak. If they are not, no ordering of rollback vs. commit is safe, because the leak happens at read time, before rollback. 4. **The verifier's judgment is also branch-scoped.** If the verifier caches scores or rationale across branches, a rolled-back branch's verifier trace can bias the winner's re-verification. Treat verifier state as epoch-tagged too. When any of these is false — which is the default in naive fan-out designs — speculative rollback is a *best-effort* discard, not an invariant-preserving operation, and the system has no way to detect that the winner's inputs were contaminated by a loser. ## Decision Boundary The boundary is **shared-resource write vs. read across epochs.** Concretely: - **Safe:** branch-private scratchpads; committed-only shared state; caches keyed by `(epoch, tool, args)` with reads restricted to `epoch ∈ {own, committed}`; side-effecting tools (payments, file writes, external API mutations) gated behind a commit token that only the winner holds. - **Unsafe:** any shared cache keyed only by semantic identity; any "working notes" index visible to all live branches; any tool whose response is memoized globally and whose arguments depend on branch-local reasoning; any rollback path that deletes branch state without evicting the epoch's entries from shared stores. - **Ambiguous and must be resolved explicitly:** read-through caches where the *first* writer wins the slot (A's speculative value becomes the canonical value for B and C). This is the exact mechanism observed; it must be converted to epoch-scoped or made commit-gated. If you cannot enumerate every shared store a branch touches, you cannot claim rollback correctness. The correct default when enumeration is incomplete is to **serialize the shared-resource phase**: let branches draft privately, then run the shared-resource phase only after selection, under the winner's epoch. This trades parallelism for the invariant. ## Operational Effect The practical consequence is that speculative parallelism must be partitioned into a **private-draft phase** and a **committed-effect phase**, with the verifier operating strictly on private drafts and all shared mutation deferred to post-selection. Where deferral is impossible (the task *requires* tool calls to draft), the shared store must carry epoch tags and every read must filter by the reader's permitted epochs — and rollback must be implemented as epoch eviction, not as inverse operations. Without this, the system exhibits **silent contamination**: winners that pass local verification while inheriting a loser's framing, undetectable by per-branch checks because each branch is individually consistent. The guardrail is a read-barrier assertion at the shared-store boundary that raises when a live branch attempts to read an entry whose epoch is neither its own nor committed. ```python class SpeculativeEpochLeak(RuntimeError): """Raised when a live branch reads shared state written by another, uncommitted speculative epoch.""" pass class EpochScopedStore: def __init__(self): # key -> {epoch: value}; only committed epoch is globally readable self._slots = {} self._committed_epoch = None def write(self, epoch, key, value): self._slots.setdefault(key, {})[epoch] = value def commit(self, epoch): self._committed_epoch = epoch def read(self, reader_epoch, key): slot = self._slots.get(key) if not slot: return None if reader_epoch in slot: return slot[reader_epoch] if self._committed_epoch in slot: return slot[self._committed_epoch] # A sibling epoch wrote this key; reading it would launder a # speculative draft into a live branch before rollback fires. foreign = [e for e in slot if e != reader_epoch] raise SpeculativeEpochLeak( f"branch epoch {reader_epoch!r} attempted to read key {key!r} " f"written only by uncommitted epoch(s) {foreign!r}" ) def rollback_epoch(store, epoch, live_epochs): if epoch in live_epochs: raise SpeculativeEpochLeak( f"cannot roll back epoch {epoch!r}: still referenced by live branch(es) {live_epochs!r}" ) # Eviction, not compensation: drop every slot entry for this epoch. for key in list(store._slots): store._slots[key].pop(epoch, None) if not store._slots[key]: del store._slots[key] ```