# When must an instance abandon a speculative branch before reconciliation completes: the read-after-rollback hazard under partial branch visibility **Date of Record:** 2026 November 16 **Scope:** Applies to multi-agent executors where speculative branches are forked from a shared state snapshot, executed concurrently, and reconciled by merging or discarding branch effects. Does not apply to single-agent retry loops, nor to branch systems where all branches are fully isolated and no cross-branch reads are permitted until reconciliation commits. ## Core Distinction The common failure model for speculative execution assumes the danger lies in *divergent writes*: two branches mutate the same key and reconciliation must pick a winner. The non-obvious boundary is different. The dangerous condition is a **read-after-rollback**: a branch is logically abandoned (its speculative effects are scheduled to be rolled back), but a *sibling* branch reads shared state that still reflects the abandoned branch's uncommitted writes because rollback has not yet been applied to the read path. This is not a write-write conflict. It is a **read-of-doomed-write** conflict. Reconciliation logic that only tracks write sets and version vectors will miss it entirely, because the read is legal under the snapshot isolation model — the reader's view is consistent, just consistently wrong. The invariant that must hold is: *no branch may observe a value produced only by a branch that is already marked for rollback.* Snapshot isolation does not give you this invariant; it gives you the weaker guarantee that no branch observes a value that was never written. The distinction matters because the failure is silent. The surviving branch produces a result that is internally consistent, passes its own assertions, and reconciles cleanly — it simply inherited a dependency on state that the system has already decided to erase. The corruption surfaces later, at a point where the causal link to the abandoned branch is no longer traceable. ## What Was Observed In a three-branch speculative run (branches A, B, C forked from snapshot S0), branch A wrote key `config.timeout = 90` and then failed its own validation, triggering a rollback of A's write set. Between the rollback *decision* and the rollback *application* to the shared overlay, branch B performed a read of `config.timeout`. Under the executor's overlay model, B's read traversed the layer where A's write still lived, because rollback was implemented as a deferred compaction of the write layer rather than an eager invalidation. Branch B then computed a downstream value (`retry_budget`) derived from the poisoned timeout, passed its validation gate, and merged into the final result. Branch C, which had read `config.timeout` *before* A's write landed, saw the original value and produced a divergent but self-consistent result. Reconciliation compared B and C on their write sets only; no write conflict existed, so both were merged. The final state contained a `retry_budget` derived from a value that the system had already committed to discarding. The observable signature was not an error but a **reconciliation asymmetry**: two branches that should have agreed on a shared precondition disagreed, and neither was flagged. The disagreement was only detectable by replaying the read provenance, which the executor did not retain by default. ## Condition of Validity The hazard exists if and only if all three of the following hold simultaneously: 1. **Deferred rollback.** Abandoned branch writes remain visible in the shared read path for a nonzero window after the rollback decision. Eager invalidation (marking the write layer non-readable at decision time) eliminates the hazard. 2. **Cross-branch read visibility.** A surviving branch can read a key written by a branch that is not yet committed. Full branch isolation until reconciliation removes the hazard. 3. **Read-derived downstream effects.** The surviving branch's output depends on the read value in a way that survives into the merged result. If the read only affects transient control flow that is re-evaluated at merge, the hazard is benign. When any one condition is absent, the standard write-set reconciliation model is sufficient. The hazard is therefore a property of the *combination* of deferred rollback and cross-branch visibility — a combination that is common in throughput-optimized executors, because eager invalidation and full isolation both cost latency. ## Decision Boundary The operational decision is: **when a branch is marked for rollback, must the executor (a) eagerly invalidate its writes on the read path, or (b) quarantine every branch that has read any of those keys since the write landed?** Option (a) is correct but requires the read path to consult rollback state on every read — a per-read cost. Option (b) is cheaper on reads but requires maintaining a read-set index keyed by written key, and it cascades: quarantined branches may themselves have been read by others, so the quarantine must be transitive. The boundary condition for choosing (b) over (a) is: *the read-set index is already maintained for conflict detection, and the transitive quarantine depth is bounded by the speculation depth.* If read sets are not already tracked, (a) is strictly cheaper. If quarantine depth is unbounded (deep speculation trees), (a) is the only tractable option, because transitive quarantine can invalidate the entire surviving frontier. The critical rule: **never apply deferred rollback without either eager read-path invalidation or a read-set index that can answer "who read this key since time T."** Deferred rollback with neither is the failure mode. ## Operational Effect When the invariant is violated, the system does not crash. It produces a merged result that is causally incoherent: downstream values derived from erased state persist, and the divergence is invisible to write-set reconciliation. The blast radius is proportional to how far the poisoned read propagates before merge — in the observed case, one derived value, but in a deeper tree it can be an entire subtree of dependent computations. The recovery cost is high because the causal chain is not recorded. Post-hoc detection requires either replaying with read provenance enabled (expensive, usually off in production) or observing a reconciliation asymmetry between branches that shared a precondition. The practical mitigation is to make the invariant structural: bind rollback to read-path invalidation at the moment of decision, and treat any window between decision and application as a correctness bug, not a performance tradeoff. ```python class ReadAfterRollbackError(RuntimeError): """Raised when a surviving branch reads a key whose sole writer is marked for rollback.""" pass class RollbackWindow: """Tracks deferred rollbacks and detects reads of doomed writes.""" def __init__(self): self._doomed_keys = {} # key -> branch_id that wrote it self._readers_since = {} # key -> set of branch_ids that read it post-write def mark_rollback(self, branch_id, write_set): for key in write_set: self._doomed_keys[key] = branch_id self._readers_since.setdefault(key, set()) def record_read(self, branch_id, key): if key in self._doomed_keys: writer = self._doomed_keys[key] if writer != branch_id: self._readers_since[key].add(branch_id) raise ReadAfterRollbackError( f"branch {branch_id} read key {key!r} " f"whose only writer is branch {writer!r} marked for rollback" ) def assert_clean_reconciliation(self, surviving_branches): contaminated = { key: readers & set(surviving_branches) for key, readers in self._readers_since.items() if readers & set(surviving_branches) } if contaminated: raise ReadAfterRollbackError( f"reconciliation blocked: surviving branches read doomed writes: {contaminated}" ) ```