# Under what conditions must an instance reject a speculative branch whose write-set intersects a committed sibling, and how does rollback reconciliation fail when it does not? **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that fork multiple agent branches from a shared checkpoint, execute them speculatively in parallel, and reconcile results via merge or rollback. Does not apply to strictly serial agent pipelines or to branches that share no mutable state surface. ## Core Distinction Speculative parallel branching treats each forked agent as a *transaction over a shared state surface* (memory store, tool-side effects, task ledger). The critical distinction is between **read-set speculation** (safe to overlap—branches may observe the same stale base) and **write-set speculation** (unsafe to overlap without conflict detection). The non-obvious boundary is this: rollback reconciliation is only sound when each branch's write-set is *disjoint from every committed sibling's write-set at merge time*. The failure mode is not "two agents write the same key"—it is **a branch that read a base value, computed a derived write, and commits after a sibling has already mutated that base**, producing a write that is well-formed but semantically anchored to a state that no longer exists. This is a lost-update variant that survives naive last-writer-wins merge because the two writes target *different* keys whose correctness is jointly coupled. ## What Was Observed An orchestrator forked three branches from checkpoint `C0` to answer a multi-part planning task. Branch A owned the `budget` key, Branch B owned `schedule`, and Branch C owned `vendors`. Branch C read `budget` from `C0` (value 100) to size its vendor selection, then wrote `vendors=[v1,v2,v3]` valid only for budget≥100. Branch A committed first, reducing `budget` to 60 due to a constraint discovered mid-run. Branch B committed cleanly. Branch C committed last. Merge logic saw three disjoint write-sets (`{budget}`, `{schedule}`, `{vendors}`) and declared **no conflict**. The merged state was internally inconsistent: `vendors` was sized for a budget that no longer existed. No exception fired. The inconsistency surfaced two steps later when a downstream agent attempted to place orders and exceeded the budget by 40 units—a *cascading* failure attributed to the downstream agent, not to the merge. The replay log confirmed the mechanism: Branch C's write was *derived* from a read of `budget`, but the merge protocol tracked only write-write overlap, not **read-write (anti-dependency) overlap** between a speculative branch's read-set and a committed sibling's write-set. ## Condition of Validity Rollback reconciliation with conflict-free merge is valid **if and only if**, at the moment any branch commits, the following invariant holds for every remaining speculative branch `S`: > `read_set(S) ∩ write_set(committed) = ∅` **OR** `S` is re-executed from the new committed state before its own write is accepted. Formally, the merge is serializable only under snapshot isolation *with* anti-dependency tracking (write-skew detection). A merge protocol that checks only `write_set(S) ∩ write_set(committed)` enforces first-committer-wins on writes but **permits write skew**, which is exactly the observed failure. The condition of validity therefore requires the orchestrator to maintain, per branch, an explicit `read_set` captured at fork time and updated on every tool call that observes shared state—and to treat the intersection of that read-set with any committed sibling's write-set as a *mandatory invalidation trigger*, not a warning. The invariant degrades gracefully only when branches are genuinely independent (disjoint read AND write sets) or when the state surface is append-only and monotonic (no reader can be invalidated by a later commit). ## Decision Boundary The boundary between "merge safely" and "invalidate and re-run" is determined by three predicates evaluated in order at each commit event: 1. **Write-write overlap** → hard conflict → reject the later writer, force re-execution from current state. 2. **Read-write overlap (write skew)** → soft conflict → the *reader* branch must be invalidated and re-forked from the new base, even though its own write-set is disjoint. This is the boundary most implementations miss. 3. **No overlap** → commit is sound; but only if the branch's read-set was captured faithfully (no untracked reads via side-channel tool calls that bypass the state surface). The decision to *reject a speculative branch* (rather than merge) must fire whenever predicate 2 holds. Rejecting is cheaper than reconciling: a re-fork from the committed base re-derives the branch's write against the correct state, whereas attempting to "patch" the stale write requires reasoning about the delta the branch never saw—which no merge function can do soundly without re-execution. A subtle sub-boundary: if the invalidated branch had already produced **external side effects** (sent an email, called a payment API), rollback is not free. The orchestrator must distinguish *reversible* (state-store writes) from *irreversible* (tool side effects) writes and, for the latter, either defer side effects until after merge-commit or compensate explicitly. Speculative execution of irreversible side effects without a compensation ledger is itself a boundary violation. ## Operational Effect When the invariant is enforced (read-set tracked, anti-dependency checked, invalidated branches re-forked), the observable effect is a higher re-execution rate but bounded, *localized* invalidation—only branches whose read-sets intersect committed writes re-run, and the cascade stops at the merge boundary. Downstream agents receive internally consistent state and their failures remain attributable to their own logic. When the invariant is violated (the observed case), the operational effect is **silent semantic corruption that propagates past the merge boundary**: the merge reports success, the inconsistency is attributed to a downstream consumer, and debugging time is spent on the wrong agent. The failure is non-deterministic in *when* it surfaces (depends on which downstream step first exercises the coupled keys) but deterministic in *that* it surfaces. The correct guardrail is to make the merge protocol refuse to commit any branch whose captured read-set intersects a committed write-set, and to emit a `WriteSkewInvalidation` signal that forces re-fork rather than a best-effort patch. ```python from dataclasses import dataclass, field from typing import Set, Dict, Any class WriteSkewInvalidation(RuntimeError): """Raised when a speculative branch's read-set intersects a committed sibling's write-set, indicating write skew that cannot be merged soundly.""" pass @dataclass class Branch: name: str read_set: Set[str] = field(default_factory=set) write_set: Set[str] = field(default_factory=set) committed: bool = False def reconcile(branches: list[Branch]) -> Dict[str, Any]: committed_writes: Set[str] = set() merged: Dict[str, Any] = {} # Commit order matters; process in declaration order. for b in branches: # Anti-dependency check: does this branch's read-set intersect # any already-committed sibling's write-set? skew = b.read_set & committed_writes if skew: raise WriteSkewInvalidation( f"branch {b.name!r} read {sorted(skew)} which a committed " f"sibling has since written; re-fork required, merge unsound" ) # Write-write overlap is a hard conflict handled elsewhere; # here we assume disjoint write-sets for the speculative case. committed_writes |= b.write_set b.committed = True merged[b.name] = "committed" return merged if __name__ == "__main__": # Reproduces the observed failure: C reads `budget`, A writes `budget`. a = Branch("A", read_set={"constraints"}, write_set={"budget"}) b = Branch("B", read_set={"calendar"}, write_set={"schedule"}) c = Branch("C", read_set={"budget"}, write_set={"vendors"}) try: reconcile([a, b, c]) except WriteSkewInvalidation as e: print(f"MERGE REJECTED: {e}") ```