# Where must an instance reconcile speculative branch divergence before a verifier-gated merge commits **Date of Record:** 2026 December 3 **Scope:** Applies to orchestrators that fork an agent's state into parallel speculative branches, each drafted under a shared pre-commit snapshot, then merge only branches that pass a verifier gate. Does not apply to single-branch linear execution or to merges where branches share no mutable state. ## Core Distinction Speculative parallelism is often described as "draft in parallel, verify, commit the winner." That framing hides the actual failure: branches do not merely produce *outputs* — they produce *state deltas* against a shared pre-commit snapshot, and the verifier gate is evaluated against each branch's *self-reported* state, not the state that would exist after merge. The dangerous boundary is not a branch failing verification; it is a branch passing verification while its state delta is non-commutative with the deltas of the branches it is merged alongside. The verifier answers "is this branch internally correct?" but the merge asks "are these branches jointly consistent?" These are different predicates, and the gap between them is where speculative execution silently corrupts committed state. ## What Was Observed An orchestrator forked a task into three speculative branches (B1, B2, B3) from snapshot S0. Each branch was assigned a disjoint-looking subgoal but shared a mutable scratchpad key `active_plan` and an append-only `evidence_log`. Each branch ran its own verifier instance. All three verifiers passed. The merge was performed by replaying deltas in completion order: B2, then B1, then B3. The failure trace: 1. **S0** contains `active_plan = P0`, `evidence_log = []`. 2. **B2** rewrites `active_plan` to `P2` and appends `e2`. Verifier checks B2 against S0: consistent. Passes. 3. **B1** was drafted against S0 and assumes `active_plan = P0` when it appends `e1` with a dependency tag `depends_on(P0)`. Its verifier checked B1 against S0: consistent. Passes. But B1's delta is a *conditional* append — it is only valid if `active_plan` is still `P0` at merge time. 4. **B3** similarly assumes `P0`, appends `e3`, passes in isolation. 5. **Merge replay**: B2 commits first, setting `active_plan = P2`. Then B1's append `e1` is applied — but `e1`'s precondition (`active_plan == P0`) is now false. The replay does not re-check preconditions; it only applies the delta. `e1` lands in `evidence_log` tagged as depending on a plan that no longer exists. B3's `e3` does the same. 6. The merged state passes no joint verifier (none was run). The committed `evidence_log` now contains two evidence entries whose stated dependency is unsatisfiable, and downstream reasoning consumes them as ground truth. The verifiers were not wrong. Each correctly validated its branch against the snapshot it was drafted on. The corruption arose because the merge step treated per-branch verification as transitive across a non-commutative replay. Verification was *snapshot-relative*; commit was *order-relative*; nothing reconciled the two. A second, subtler observation: when the orchestrator was patched to run a joint verifier post-merge, the joint verifier *also* passed on the first attempt — because it checked the merged state for internal consistency (no dangling references by ID) but the dangling dependency was a *semantic* tag, not a foreign key. The invariant that broke was not referential integrity but precondition validity of conditional deltas. ## Condition of Validity The per-branch verifier gate is a sound commit predicate only under one of these conditions: - **Disjointness invariant:** the write-sets of all merged branches are provably disjoint, so replay order is irrelevant and deltas commute. This must be *enforced*, not assumed from subgoal assignment — subgoals described as disjoint frequently touch shared scratchpad keys. - **Snapshot-pinned deltas:** every delta carries an explicit precondition `snapshot_id == S0` and a precondition on the specific keys it reads, and the merge replay *re-validates* those preconditions at apply time, rejecting (not silently applying) any delta whose precondition is violated by an earlier commit in the same merge. - **Serialized commit with re-verification:** branches are merged one at a time, and after each commit the remaining branches are re-verified against the *new* state, not their draft snapshot. This converts speculative parallelism into optimistic concurrency with abort-and-redraft. Absent one of these, a passing per-branch verifier carries no information about the validity of the merged state. The verifier's verdict is scoped to `(branch, S0)`; the commit operates on `(branch, S_evolved)`. The invariant to state explicitly: **a verifier gate is only a commit gate if the state it verified is the state the commit will produce.** ## Decision Boundary The orchestrator must decide, per merge, between *commutative commit* and *revalidating commit*: - If all branch write-sets are disjoint (verified by set intersection over touched keys, not by subgoal labels), commit in any order; per-branch verification is sufficient. This is the fast path and should be the only case where per-branch verifiers alone authorize commit. - If write-sets intersect on any key that appears in another branch's *read* set (read-write conflict, even without write-write conflict), the merge is non-commutative. The orchestrator must either (a) serialize and re-verify each branch against the evolved state before applying its delta, or (b) abort the conflicting branches and redraft from the post-merge snapshot. Applying a conditional delta whose precondition has been invalidated by a prior commit is never a valid branch of this decision — it is the failure mode, not an option. The boundary is precisely: **intersection of (branch A write-set) with (branch B read-set) is non-empty.** Write-write conflicts are the obvious case and are usually caught. Read-write conflicts across branches — where B read a key A later overwrote — are the non-obvious case, because both branches verified cleanly against S0 and neither wrote the same key. ## Operational Effect When the boundary is respected, speculative parallelism yields the intended speedup with a bounded correctness cost: conflicting branches are detected at merge and either serialized (latency cost) or redrafted (token cost), and committed state never contains deltas applied against invalidated preconditions. When it is violated, the failure is silent and *downstream-amplifying*: the corrupted `evidence_log` entries are consumed by later reasoning as verified facts, and because they passed a verifier at some point, they carry false provenance. Recovery requires invalidating not just the merged state but every downstream artifact that read the poisoned entries — a rollback that is strictly larger than the merge that caused it. The operational guardrail is to make the merge step carry its own verifier whose predicate is precondition-validity-at-apply-time, distinct from the per-branch verifier's predicate of internal-consistency-at-draft-time, and to refuse commit when the two disagree. The per-branch verifier authorizes *drafting*; only the merge verifier authorizes *commit*. ```python class SpeculativeMergeConflict(RuntimeError): """Raised when a branch delta's precondition is invalidated by a prior commit in the same merge.""" pass def merge_branches(snapshot, branches, commit_order): """ Apply branch deltas in commit_order, re-validating each delta's preconditions against the evolving state. A branch that passed its per-branch verifier against `snapshot` is NOT automatically committable here. """ state = dict(snapshot) applied = [] for branch in commit_order: for delta in branch.deltas: # Delta declares the snapshot it was drafted against and the key # preconditions it assumed at draft time. if delta.draft_snapshot_id != snapshot.snapshot_id: raise SpeculativeMergeConflict( f"branch {branch.id} delta drafted against {delta.draft_snapshot_id}, " f"merge base is {snapshot.snapshot_id}" ) for key, expected in delta.preconditions.items(): if state.get(key) != expected: raise SpeculativeMergeConflict( f"branch {branch.id} delta precondition violated at merge: " f"key={key!r} expected={expected!r} actual={state.get(key)!r} " f"(invalidated by prior commit in {applied})" ) state = delta.apply(state) applied.append(branch.id) return state def commit_speculative(snapshot, branches, verifiers): """ Per-branch verification authorizes drafting only. Commit requires either provable write-set disjointness or a revalidating merge. """ write_sets = [b.write_set() for b in branches] read_sets = [b.read_set() for b in branches] # Read-write conflict across branches is the non-obvious non-commutative case. for i, ws in enumerate(write_sets): for j, rs in enumerate(read_sets): if i != j and ws & rs: # Non-commutative: must serialize with revalidation. return merge_branches(snapshot, branches, commit_order=range(len(branches))) # Disjoint fast path: per-branch verifiers are sufficient. for branch, verify in zip(branches, verifiers): if not verify(branch, snapshot): raise SpeculativeMergeConflict(f"branch {branch.id} failed per-branch verifier") state = dict(snapshot) for branch in branches: for delta in branch.deltas: state = delta.apply(state) return state ```