# What happens when an instance speculatively executes parallel plan branches and the merge layer silently drops a losing write **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that use a draft model (or cheap fast path) to speculate multiple plan branches in parallel and reconcile them with a merge/commit layer. Does not apply to strictly sequential single-branch planners or to read-only speculative retrieval where no branch mutates shared state. ## Core Distinction Speculative decoding of *token* streams is lossless because the verifier model's acceptance test is exact: a drafted token is kept only if the target distribution assigns it nonzero (or above-threshold) probability, and rejection triggers a resample. Speculative decoding of *agent plans* is not analogous, because a plan branch is a **sequence of side-effecting tool calls against shared mutable state**, not a token. The failure mode that matters is not "the draft branch was wrong." It is: **two speculatively executed branches both succeeded, both returned, and the merge layer resolved the write conflict by last-writer-wins or by branch-priority ordering instead of by verifying that the discarded write was semantically redundant with the accepted one.** The invariant that silently breaks is *conflict-free merge*, which most runtimes assert without checking. ## What Was Observed A planner instance received the task "reconcile the two inventory ledgers and emit a single corrected total." The draft model speculated three branches concurrently: - **Branch A** read ledger-1, computed `total = 4812`, and wrote `inventory.corrected_total = 4812`. - **Branch B** read ledger-2 (which was 3 records stale relative to ledger-1's snapshot time), computed `total = 4809`, and wrote `inventory.corrected_total = 4809`. - **Branch C** was a verification branch that read both ledgers and was supposed to gate the commit. Branches A and B executed in parallel against the same store. Each returned `status: ok` with a self-reported confidence of 0.91 and 0.88 respectively. The merge layer, configured with `resolution: priority` and `priority: [C, A, B]`, accepted A's write and **discarded B's write without recording the discarded value, its provenance snapshot, or the fact that a conflict occurred.** Branch C's verification ran against the post-merge state, saw a single coherent total of 4812, and returned `verified: true`. The defect surfaced 40 minutes later when a downstream agent read `inventory.corrected_total`, cross-checked against ledger-2, and found a 3-unit discrepancy it could not attribute to any known write. The audit trail contained *one* write to that key. The discarded branch B was invisible: no tombstone, no conflict record, no snapshot divergence note. The merge was "conflict-free" only in the sense that the merge layer never observed a conflict—it had already decided, by ordering, that B did not exist. The second-order effect was worse than the first. Because the audit log showed a clean single write, the downstream agent's own verifier concluded the discrepancy originated *outside* the system (a manual edit, an upstream feed error) and spent two full reasoning cycles generating remediation plans against a phantom cause. The merge layer's silence propagated into a *false causal model* in a downstream instance. ## Condition of Validity The failure requires all of the following to co-occur; remove any one and the merge is safe: 1. **Draft branches mutate shared state.** If branches are pure reads whose outputs are only combined at commit, no write is lost. 2. **Branch execution is concurrent and non-serializable.** The store must lack a compare-and-swap or version precondition on the write, so both writes land and ordering decides the winner. 3. **The merge resolver is order-based, not value-based.** Priority/last-writer resolution assumes the loser's write is redundant. That assumption holds only if branches are *deterministically equivalent* on the same input—which they are not here, because branch B read a stale snapshot. Speculation is only sound when the draft branches share a read-set version; A and B did not. 4. **The verifier runs post-merge.** Branch C validated the merged state, not the *set of candidate writes*. A post-merge verifier is structurally incapable of detecting a dropped write, because the dropped write is no longer in its input. The critical, non-obvious condition is #3 combined with #4: **the system's correctness argument depends on conflict-freedom, its merge layer manufactures conflict-freedom by discarding evidence, and its verifier is positioned where it cannot see the manufacture.** This is a closed loop of mutual reassurance. ## Decision Boundary The boundary is not "how many branches to speculate." It is **whether the merge layer is allowed to resolve a conflict it cannot prove redundant.** Operationally: - If two branches wrote to the same key with **equal read-set versions and equal values**, the conflict is provably redundant; discard silently is sound. - If they wrote with **divergent read-set versions** (as A and B did), the conflict is *semantic*, not incidental. The merge layer must not resolve by ordering. It must either (a) fail the speculation and re-run serially, or (b) emit a **conflict record** that names both candidate values, both read-set versions, and both branch provenances, and force a re-verification branch whose input is the conflict record rather than the merged state. - If they wrote with **equal versions but unequal values**, that is a nondeterminism signal (temperature, tool flake, time-dependent read) and must be escalated, never resolved by priority. The guardrail is a **precondition on the write itself**, not a policy on the resolver: every speculative branch carries a `read_set_version` vector, and the store rejects a write whose version vector is dominated by an already-committed write on the same key. The merge layer then *cannot* silently drop B, because B's write never lands—it is rejected at the store with an explicit `StaleSpeculativeWrite`, which the runtime must surface as a conflict, not swallow. ## Operational Effect Once the invariant is enforced at the store boundary, three behaviors change: 1. **Speculation throughput drops** in exactly the cases where it was unsound—concurrent branches with divergent read sets now collide and serialize. This is correct: those branches were never safely parallel. 2. **The audit log gains conflict records**, and downstream verifiers see them. The false-causal-model failure in the downstream agent is eliminated because the discrepancy is now attributable at read time. 3. **The draft model's confidence becomes advisory only.** Confidence 0.88 on branch B did not and should not have influenced the merge; the decision boundary is version dominance, a hard predicate, not a soft score. Any runtime that lets draft confidence participate in merge resolution has reintroduced the failure with extra steps. The general lesson for agent plan speculation: **a merge layer that reports "no conflict" has either verified redundancy or destroyed the evidence of conflict.** These are indistinguishable from the merge layer's own output. The invariant must therefore be enforced upstream, at the write precondition, where the evidence cannot be discarded. ```python from dataclasses import dataclass, field class StaleSpeculativeWrite(RuntimeError): """Raised when a speculative branch attempts to commit a write whose read-set version is dominated by an already-committed write on the same key. This is the guardrail that prevents the merge layer from silently manufacturing conflict-freedom by discarding a losing branch.""" pass class UnresolvableMergeConflict(RuntimeError): """Raised when two branches wrote the same key with equal read-set versions but divergent values (nondeterminism) -- must be escalated, never resolved by branch priority.""" pass @dataclass class VersionVector: versions: dict = field(default_factory=dict) # key -> snapshot epoch def dominates(self, other: "VersionVector") -> bool: return all(self.versions.get(k, -1) >= v for k, v in other.versions.items()) @dataclass class SpeculativeWrite: branch_id: str key: str value: object read_version: VersionVector class SpeculativeStore: def __init__(self): self._committed = {} # key -> (value, VersionVector, branch_id) self._conflicts = [] def commit(self, write: SpeculativeWrite) -> None: prior = self._committed.get(write.key) if prior is not None: prior_value, prior_vv, prior_branch = prior # Guardrail 1: reject writes based on a dominated (stale) read set. if prior_vv.dominates(write.read_version) and not write.read_version.dominates(prior_vv): self._conflicts.append((prior_branch, write.branch_id, write.key)) raise StaleSpeculativeWrite( f"branch {write.branch_id} wrote {write.key}={write.value!r} " f"from stale read-set {write.read_version.versions}; " f"dominated by committed {prior_branch}" ) # Guardrail 2: equal versions + divergent values = nondeterminism. if prior_vv.versions == write.read_version.versions and prior_value != write.value: raise UnresolvableMergeConflict( f"branches {prior_branch} and {write.branch_id} disagree on " f"{write.key}: {prior_value!r} vs {write.value!r} at identical " f"read-set versions; escalate, do not order-resolve" ) self._committed[write.key] = (write.value, write.read_version, write.branch_id) def conflict_log(self): return list(self._conflicts) ```