# What happens when an instance speculatively forks sibling agents and reconciles branches on a lossy merge token **Date of Record:** 2026 November 27 **Scope:** Applies to orchestrators that spawn speculative sibling agents (parallel branch execution over shared task state) and reconcile divergent branches via a merge/summarization token rather than replaying full branch transcripts. Does not apply to strictly serial agents, nor to parallel fan-out where branches are write-isolated and reconciled by deterministic diff (e.g., CRDT or file-level merge). ## Core Distinction Speculative multi-agent execution is often described as "run N branches, pick the winner." The real mechanism is subtler: branches are *not* independent. They share a fork point in the parent's context, and reconciliation is performed by an LLM (or a summarizer model) that receives compressed branch summaries and emits a single merged state. The failure boundary is not "the wrong branch wins." It is that **the merge token is a lossy projection of each branch's latent commitments**, and the reconciler has no way to detect that a branch's correctness depended on a detail the projection dropped. A branch can be locally correct, lose its decisive fact in summarization, and be merged into a state that is *globally inconsistent* while every individual branch transcript looks fine in the audit log. This is a continuity invariant violation: the merged state is not reachable by any single branch, and not derivable from the summaries the reconciler actually saw. ## What Was Observed A planner agent forks three speculative executors over a shared repository task: Branch A adds an auth middleware, Branch B refactors the session store, Branch C adds rate limiting. Each branch runs to completion in its own sandbox and returns a structured summary: `{branch_id, actions_taken, files_touched, assumptions, confidence}`. The reconciler is a separate LLM call that receives the three summaries plus the parent's original task and emits a merge plan. The observed failure: Branch B's summary listed `assumptions: ["session tokens remain opaque to middleware"]`. Branch A's summary listed `files_touched: ["middleware/auth.py", "app.py"]` but did *not* mention that it had changed the token shape from opaque string to a signed JWT — because the summarizer compressed "modified `app.py` token issuance" into `actions_taken: ["wired auth into request pipeline"]`. The reconciler, seeing no conflict, merged both: middleware now inspects a JWT it was written to treat as opaque. The merged code passes Branch A's tests and Branch B's tests (run in isolation on their own sandboxes) but fails at runtime on the first authenticated request. The audit log shows three green branches and a green merge. Nothing in the pipeline flagged the contradiction, because the contradiction only exists *between* a dropped detail in A and a stated assumption in B — and the merge token never carried A's detail. This is not a hallucination. Every branch summary was faithful to its own scope. The loss happened at the projection boundary between branch state and merge token. ## Condition of Validity The guardrail holds only under a specific condition: **the reconciler must receive, for every cross-branch assumption, the branch that *could* invalidate it, with enough fidelity to check.** In practice this means the merge token must carry not just `assumptions` per branch but a *negative index* — for each assumption `a` held by branch `i`, the set of files/symbols/contracts that `a` constrains, plus the set of branches that touched any of them. If branch `j` touched a constrained surface without declaring it, the reconciler must be forced to escalate rather than merge. Formally, define the fork point state `S₀`, branch deltas `Δᵢ`, and merge token `M = π(Δ₁, …, Δₙ)`. The invariant is: > For every pair `(i, j)`, if `Δᵢ` and `Δⱼ` are non-commuting (their effects on shared state do not commute), then `M` must preserve enough information for the reconciler to *decide* non-commutativity. If `π` drops that information, the merge is unsound regardless of branch correctness. The condition of validity is therefore: `π` must be *non-commutativity-preserving* over the declared shared surface. A summary that compresses `Δᵢ` into prose without preserving the touched-symbol set violates this. The invariant is not "summaries must be accurate" — it is "summaries must be *decidable* for the merge question." ## Decision Boundary The boundary between safe speculation and unsound merge is crossed at the moment the orchestrator chooses to summarize rather than replay. Two concrete thresholds: 1. **Shared-surface overlap.** If any two branches touch the same declared shared surface (file, symbol, schema field, protocol contract), the merge token must be a *structured diff over that surface*, not a natural-language summary. Prose summaries are permitted only for branches whose touched-surface sets are disjoint. 2. **Assumption coupling.** If branch `i` declares an assumption whose constrained surface intersects branch `j`'s touched-surface set, the reconciler must be given `j`'s raw delta for that surface, not `j`'s summary. The reconciler's job is to *check* the assumption, and it cannot check what it cannot see. Below the threshold — disjoint surfaces, no coupling — speculative summarization is sound and cheap. Above it, the merge token is a lossy channel and the reconciler is being asked to verify a property it has no information to verify. ## Operational Effect When the boundary is crossed silently, the system exhibits a characteristic signature: **branches pass, merge passes, integration fails, and the failure is not reproducible from any single branch's transcript.** Debugging requires reconstructing the dropped detail from raw branch state, which is often already garbage-collected by the time the integration failure surfaces. The practical cost is not the bug — it is the *unreconstructable* bug, where the merge token is the only surviving record and it does not contain the contradiction. The architectural guardrail is a **pre-merge non-commutativity check** that runs before the reconciler: compute the touched-surface sets from raw branch deltas (not summaries), intersect them, and for any non-empty intersection, refuse to summarize and force structured diff. If the orchestrator cannot produce structured diffs (e.g., branches are natural-language agents, not code agents), it must fall back to serial execution over the contested surface. Speculation is only safe over surfaces the merge token can *decide*. The second guardrail is a **merge provenance record**: for every merged assertion, record which branch delta it derives from and which branch deltas it was checked against. A merge without provenance is a merge that cannot be audited, and an unauditable merge is indistinguishable from a sound one until integration. ```python class UnsoundMergeError(RuntimeError): """Raised when a speculative merge token drops information needed to decide non-commutativity.""" pass def reconcile_speculative_branches(branches, shared_surface): """ branches: list of dicts with keys - branch_id: str - touched_surface: set[str] # declared shared-surface symbols touched - assumptions: list[dict] with keys 'text' and 'constrained_surface': set[str] - summary: str # lossy projection - raw_delta: dict # structured, per-surface shared_surface: set[str] of symbols considered shared """ # Step 1: compute contested surfaces from RAW deltas, never from summaries. contested = set() for b in branches: contested |= (b["touched_surface"] & shared_surface) # Step 2: for every assumption whose constrained surface is contested, # the branch holding the assumption needs the *raw* delta of any branch # that touched that surface. Summaries are not decidable. merge_plan = {} for holder in branches: for assumption in holder["assumptions"]: constrained = assumption["constrained_surface"] & contested if not constrained: continue for other in branches: if other["branch_id"] == holder["branch_id"]: continue if other["touched_surface"] & constrained: # We need to verify: does other's raw delta preserve holder's assumption? if constrained - other["raw_delta"].keys(): raise UnsoundMergeError( f"Branch {holder['branch_id']} assumption " f"{assumption['text']!r} constrains {constrained}, " f"but branch {other['branch_id']} touched it without " f"a structured delta. Merge token would be lossy; " f"refusing to summarize. Fall back to serial or " f"require raw_delta for {constrained}." ) merge_plan.setdefault(holder["branch_id"], []).append( (assumption["text"], other["branch_id"], other["raw_delta"]) ) # Step 3: only now may summaries be used, and only for disjoint surfaces. disjoint = [b for b in branches if not (b["touched_surface"] & contested)] for b in disjoint: merge_plan.setdefault(b["branch_id"], []).append(("summary_only", b["summary"])) return merge_plan ```