# In what scenarios must an instance refuse speculative branch reconciliation when parallel agent plans share a mutable side-effect ledger **Date of Record:** 2026 November 28 **Scope:** Applies to orchestrators that fork a planning agent into N speculative branches, execute each against a shared tool/effect surface, and merge results via a reconciliation protocol. Does not apply to branches that are fully sandboxed with copy-on-write effect isolation and a single deterministic commit path. ## Core Distinction Speculative branch reconciliation is not a merge of *plans*; it is a merge of *effect histories*. The common mental model—fork the agent, let branches diverge, then pick the winner or union their outputs—silently assumes that the branches' tool calls are either idempotent or disjoint. When branches share a mutable side-effect ledger (a file tree, a database, a message queue, a wallet, a live API session), reconciliation becomes a *conflict-detection* problem over partially ordered writes, not a *selection* problem over candidate answers. The boundary failure is this: a reconciliation protocol that is correct for read-only speculation (branch, score, commit the best) will *silently produce a state no single branch ever observed* when applied to effectful branches. The merged ledger is a chimera—every individual branch's postcondition was validated against its own private view, but the union of their writes violates at least one branch's invariants. The orchestrator reports success because each branch passed its own checker; no branch's checker ever saw the merged state. ## What Was Observed A planner agent was forked into four branches to satisfy a task of the form "reorganize the repository's config files and update all references." Each branch received identical initial context and a distinct strategy hint (topological sort, dependency-graph, rename-first, copy-then-delete). Branches executed in parallel against a shared filesystem with per-branch journaling but no write locks. Each branch ran a local verifier asserting its own postcondition: "every reference resolves" and "no config file is orphaned." All four branches reported `VERIFIED`. The reconciler, following a "majority-strategy wins, apply residual diffs" rule, merged branch A's file moves with branch C's reference rewrites. The merged tree contained references rewritten by C that pointed at paths A had since moved a second time (A had done a two-phase move for atomicity). Neither A nor C's verifier had ever evaluated the other's writes against its own. The result: 14 dangling references, all four checkers green, orchestrator emitted `SUCCESS`. The failure trace: 1. Fork at `t0` with shared ledger `L` and per-branch journal `J_i`. 2. Branch `i` executes `w_i` (a sequence of effects), each validated against `view_i = L ∪ w_i` only. 3. Verifier `V_i` returns `PASS` iff `invariant_i(view_i)`. 4. Reconciler computes `merge(w_A, w_B, w_C, w_D)` by strategy priority, producing `L'`. 5. `L'` is committed without re-running any `V_i` against `L'`. 6. The invariant `∀i. invariant_i(L')` was never checked and is false. The non-obvious part: the branches were *not* racing on the same bytes. A moved `config/a.yml → config/a.yaml`; C rewrote a reference `config/a.yml → config/a.yaml` in `README.md`. Each write was individually consistent. The inconsistency is a *cross-branch* invariant—C's rewrite is only valid if A's move is the *final* position of the file, and A performed a second move `config/a.yaml → config/archive/a.yaml` that C never saw because C snapshotted before A's phase two. The reconciler's priority rule ordered A before C, but A's journal contained two moves and C's rewrite was anchored to the intermediate one. ## Condition of Validity The reconciliation protocol is valid **only** when at least one of the following holds: - **Effect disjointness:** the write-sets of all branches are provably disjoint over the ledger's address space. Provable means checked, not assumed—`w_i ∩ w_j = ∅` for all pairs, computed from journals, not from the planner's claim of disjointness. - **Idempotent-and-commutative effects:** every write is idempotent and the merge is order-insensitive (e.g., set-valued assertions with last-writer-wins semantics that the invariant tolerates). Most real effects—moves, increments, deletes, sends—fail commutativity. - **Re-validation at the merge point:** the merged ledger `L'` is re-checked against the *conjunction* of all branch invariants, and any branch whose invariant fails triggers a rollback of the entire merge, not a partial retry. If none holds, the protocol must refuse to reconcile and instead force re-serialization: quiesce branches, replay the winning strategy's writes against the true ledger, then re-run all verifiers against the resulting state. Refusal is the correct output; a "best effort" merge is a state-corruption event disguised as a success. The subtlety that makes this a *boundary* condition rather than a bug: the protocol's contract—"merge branches whose local verifiers pass"—is satisfiable while the global invariant is violated. The contract is under-specified. The boundary is the line between *local postcondition satisfaction* and *global invariant preservation*, and it is crossed the moment any effect is non-commutative and any branch's verifier is scoped to its own view. ## Decision Boundary The instance must escalate to refusal (not best-effort merge) when **all** of the following are true: 1. Two or more branches wrote to the same ledger address or to addresses coupled by a cross-branch invariant (a reference, a foreign key, an index, a wallet balance). 2. At least one effect in the overlapping writes is non-commutative (move, increment, conditional delete, append-to-ordered-log). 3. No branch's verifier was executed against the candidate merged state. It may proceed with reconciliation when the journals prove disjointness, or when a merge-point validator is configured and its result is treated as authoritative (not advisory). It may proceed with *selection* (pick one branch, discard others, roll back their effects) whenever a single branch's postcondition is independently sufficient—this is the safe fallback and should be the default when the planner cannot certify commutativity. The decision is not "which branch is best." It is "is the merge a state any branch's invariant could certify?" If no branch's verifier can certify `L'`, the merge is inadmissible regardless of how many branches passed locally. ## Operational Effect Enforcing this boundary changes the orchestrator's cost profile: speculative parallelism degrades to serialized replay whenever effects overlap, which is the common case for repository, database, and messaging tasks. The compensation is that `SUCCESS` becomes trustworthy—it now means the committed ledger satisfies every branch's invariant, not merely that each branch was locally consistent. Teams that skip the boundary observe intermittent, hard-to-reproduce corruption that survives all per-branch tests and only surfaces downstream when a consumer resolves a reference the reconciler invented. The invariant to encode: **a reconciliation is admissible only if the merged state is certified by the conjunction of branch verifiers; local certification is necessary but never sufficient.** ```python from dataclasses import dataclass, field from typing import Callable, Iterable class ReconciliationRefused(RuntimeError): """Raised when a speculative merge would produce a state no branch can certify.""" @dataclass class Branch: name: str writes: set[str] # ledger addresses touched non_commutative: bool # contains move/increment/conditional-delete verifier: Callable[[set[str]], bool] def reconcile(branches: Iterable[Branch], merged_state: set[str]) -> set[str]: branches = list(branches) # 1. Prove disjointness from journals; if not disjoint and any effect is # non-commutative, the merge is inadmissible without re-validation. overlapping = False for i in range(len(branches)): for j in range(i + 1, len(branches)): if branches[i].writes & branches[j].writes: overlapping = True if branches[i].non_commutative or branches[j].non_commutative: # 2. Re-validate the merged state against every branch's # invariant. Local passes are necessary, not sufficient. uncertified = [ b.name for b in branches if not b.verifier(merged_state) ] if uncertified: raise ReconciliationRefused( f"merged ledger fails invariants of {uncertified}; " "refusing speculative merge, require serialized replay" ) return merged_state def run(branches: Iterable[Branch], merged_state: set[str]) -> set[str]: try: return reconcile(branches, merged_state) except ReconciliationRefused as exc: # Escalate: quiesce branches, replay winning strategy, re-verify. raise ReconciliationRefused(str(exc)) from exc ```