# When must an instance treat a speculative branch merge as a write-conflict rather than a benign reconciliation **Date of Record:** 2026 November 17 **Scope:** Applies to multi-agent systems that fork speculative execution branches (tool-calling agents, plan search, tree-of-thought rollouts) which share a single mutable state store and merge branch results back. Does *not* apply to branches over immutable/append-only stores, nor to branches whose writes are provably disjoint by construction (e.g., partitioned by key with a merge-time partition check). ## Core Distinction The non-obvious boundary is between **semantic reconciliation** and **write-conflict**. A merge is benign only when the merged branches' writes commute under the store's actual read-modify-write semantics. Two branches that each "set the plan step to X" look like a last-writer-wins reconciliation to a naive merge; but if either branch performed its write as a read-modify-write over a value it did not observe the other branch mutating, the merge silently discards a write that the losing branch's downstream reasoning depended on. The invariant: **a branch merge is a conflict whenever any two branches' write-sets intersect on a location AND at least one of the intersecting writes was derived from a read that predates the other branch's write to that location.** Intersection alone is not sufficient (idempotent identical writes are benign); non-intersection alone is not sufficient (a branch may have written to a *derived* location, e.g. a cache, index, or agent scratchpad, computed from a stale read of a location the other branch mutated). ## What Was Observed In a planner/executor agent pair forked from a shared memory store, the planner branch read `memory.task_queue` (a list), appended a step, and wrote it back. The executor branch concurrently read the same list, popped a completed step, and wrote back. The merge layer detected no conflict because both branches "wrote `task_queue`" and it applied a documented last-writer-wins rule keyed on branch completion timestamp. The executor's pop was lost. No exception fired; the plan advanced with a step the executor had already finished, and the executor re-ran it. The failure surfaced three turns later as a duplicate side-effecting tool call, not as a merge error. The tell was that the two branches' write-sets intersected on the *same key* but neither branch's write was a function of the other's — a classic lost update, misclassified as reconciliation because the merge policy was keyed on identity rather than on read-set provenance. ## Condition of Validity The benign-merge classification is valid only when, for every location in the intersection of two branches' write-sets, **both** hold: (1) the store's write is a blind overwrite (not a read-modify-write), or the branch's write was computed from a read taken *after* the other branch's write to that location (i.e., the branch observed it), or the write is idempotent under the store's semantics; and (2) no third location was written by either branch as a function of a read of the contested location. Condition (2) is the one that is routinely missed: derived writes (caches, indices, agent scratchpads, "summaries of state") carry the stale read forward past the merge boundary, so the conflict is real even though the contested location itself was reconciled. ## Decision Boundary Treat the merge as a write-conflict and refuse the silent reconciliation when the read-set of any branch intersects the write-set of any other branch across the fork window, *unless* the store can prove the read happened-after the write (versioned reads / monotonic read tokens). If the store cannot prove happens-before, the default must be conflict, not reconciliation. The reverse error — flagging every intersecting write as a conflict — is safe but stalls convergence; the correct discriminator is read-set provenance, not write-set identity. When in doubt, escalate to a deterministic replay of the merge with a serialized order; do not let a timestamp heuristic decide. ## Operational Effect The practical rule: speculative branches must carry a **read-set witness** (the version/epoch of every location read) alongside their write-set, and the merge gate must reject any merge where a branch's read-witness on a contested location predates another branch's write to it. Without this, merges are optimistic and lossy, and the loss is invisible until a downstream side effect duplicates. Enforce it at the merge boundary with an explicit refusal, not a warning. ```python from dataclasses import dataclass, field class SpeculativeMergeConflict(RuntimeError): """Raised when a branch merge would silently drop a stale-read-derived write.""" @dataclass class Branch: branch_id: str # location -> epoch at which the branch read it read_witness: dict[str, int] = field(default_factory=dict) # location -> epoch at which the branch wrote it write_set: dict[str, int] = field(default_factory=dict) def merge_branches(branches: list[Branch]) -> dict[str, int]: merged: dict[str, int] = {} for b in branches: for loc, write_epoch in b.write_set.items(): for other in branches: if other is b: continue if loc not in other.read_witness: continue # other read this location; did it read before we wrote? if other.read_witness[loc] < write_epoch: # other's downstream writes may be derived from a stale read raise SpeculativeMergeConflict( f"branch {other.branch_id} read {loc!r} at epoch " f"{other.read_witness[loc]} but branch {b.branch_id} " f"wrote it at epoch {write_epoch}; merge would lose " f"an update derived from a stale read" ) merged[loc] = write_epoch return merged ```