# What structural signals indicate speculative branch divergence has survived a federated merge **Date of Record:** 2026 November 26 **Scope:** Applies to federated agent pipelines where a coordinator forks N speculative branches (parallel tool-calling or reasoning trajectories) across heterogeneous peer agents and then merges them into a single committed continuation. Does not apply to single-agent retry/reflexion loops, nor to fan-out where only one branch is ever committed (best-of-N with no merge). ## Core Distinction The failure that matters is not "a bad branch won." It is that a *merged* state can be internally inconsistent even when every individual branch was locally valid and every branch's own checks passed. Speculative branching assumes branches are independent and that merging is a set operation over their outputs. In a federated pipeline they are neither: branches share a mutable backing store (memory, tool side-effects, entity resolution tables) through the peer agents that executed them, and the merge point has no record of *which branch observed which version* of shared state. The distinction to hold: **branch validity is a per-branch property; merge validity is a cross-branch property that no per-branch verifier can establish.** A merge can be certified clean by all N branch auditors and still be non-reconstructible. ## What Was Observed A coordinator forked four branches over a CRM-mutation task. Each branch was assigned a disjoint slice of records but all four read and wrote a shared `account_status` field through the same peer tool endpoint. Branch A (record 7) and Branch C (record 12) both resolved a duplicate account to the same canonical ID and both emitted an `account_status=active` write, but A read the pre-mutation value `pending` and C read A's post-write value `active` because C's peer agent executed ~400ms later against the same store. The merge step concatenated branch deltas and applied them in branch-index order. It produced a committed state in which record 7's status change was attributed to a branch that had, at read time, seen the old value, and record 12's delta carried a "no change needed" annotation that was true only because of A's write. The merged transcript is *self-consistent per line* and *globally false*: it claims two independent observations where there was one observation and one causal echo. All four branch auditors returned PASS because each branch's local postcondition held. The coordinator's merge verifier checked schema conformance and delta non-overlap on record IDs — both satisfied. The structural tell that survived: the merged provenance graph contained a read-after-write edge between two branches that the merge model treated as unordered siblings. Detection signal — recompute the merge under a topological order derived from observed read/write timestamps; if the result differs from the committed merge, the merge absorbed a causal dependency it did not model. ## Condition of Validity The invariant that must hold for speculative merge to be sound: > For any two branches i, j merged into the same committed state, if branch j's read set intersects branch i's write set (transitively, through any peer agent or shared store), then the merge MUST order j after i and MUST invalidate j's pre-read deltas that depended on i's write. This holds only when the coordinator can observe the intersection. It fails silently when: - Peer agents execute against a store the coordinator does not instrument (the common case in federated setups). - Branches are timestamped by *dispatch* rather than by *effect*, so a branch dispatched earlier but executed later appears causally prior. - The merge model treats branch outputs as pure functions of their prompts, discarding the read-set metadata that would expose the edge. The invariant is *not* restored by branch-level determinism, by replaying branches in isolation, or by majority voting across branches — voting cannot detect a dependency, only a disagreement, and here there is no disagreement: the branches agree because one copied the other. ## Decision Boundary At the merge gate, decide **commit vs. re-fork** on a single structural test, not on branch agreement: 1. Build the union read/write set across all branches from peer-side effect logs, not from branch self-reports. 2. Compute the read-after-write (RAW) and write-after-read (WAR) edge set between branches. 3. If the edge set is empty, or every edge is already respected by the merge order, commit. 4. If any RAW edge exists between branches the merge treated as unordered siblings, **do not commit** — the merge is non-reconstructible regardless of branch PASS status. Re-fork the downstream branch with the upstream write pinned into its context, or serialize the two branches. 5. If peer-side effect logs are unavailable for any branch that touched a shared store, treat the merge as *unverifiable* and route to a serialized re-execution. Absence of logs is not evidence of independence. The boundary is sharp: branch agreement is necessary but never sufficient; the RAW edge set is the deciding signal. ## Operational Effect Pipelines that gate on branch agreement alone accumulate *causally laundered* state: each merge looks clean, and drift only surfaces when a later task re-reads the laundered field and derives a conclusion from an observation that was never independently made. The observable symptom is not a crash but a slow divergence between the agent's memory of *why* a value is set and the value's actual causal history — episodic-to-semantic distillation then promotes the laundered attribution into durable semantic memory, at which point it is unrecoverable by replay. The guardrail is to make the RAW edge set a first-class merge artifact and to refuse commits whose provenance graph cannot be topologically ordered against observed effect timestamps. ```python from dataclasses import dataclass, field class UnreconstructibleMergeError(RuntimeError): """Raised when a speculative merge absorbed a cross-branch causal edge it did not model.""" @dataclass class Branch: branch_id: str read_set: set = field(default_factory=set) # record IDs read via peer tools write_set: set = field(default_factory=set) # record IDs written via peer tools effect_log_available: bool = True @dataclass class MergePlan: order: list # branch_ids in the order the merge applied them treated_as_siblings: set # branch_id pairs the merge assumed unordered def detect_laundered_merge(branches: dict, plan: MergePlan) -> list: """Return RAW edges between branches the merge treated as unordered siblings.""" violations = [] ids = list(branches) for i in ids: for j in ids: if i == j: continue bi, bj = branches[i], branches[j] # j read something i wrote => j must be ordered after i if bi.write_set & bj.read_set: if frozenset((i, j)) in plan.treated_as_siblings: violations.append((i, j)) return violations def commit_merge(branches: dict, plan: MergePlan) -> None: # Invariant 1: every branch touching shared state must have peer-side logs. missing = [b.branch_id for b in branches.values() if not b.effect_log_available] if missing: raise UnreconstructibleMergeError( f"no peer-side effect logs for branches {missing}; " f"merge is unverifiable and must be serialized" ) # Invariant 2: no RAW edge may exist between branches treated as siblings. violations = detect_laundered_merge(branches, plan) if violations: raise UnreconstructibleMergeError( f"causal edges {violations} survived a merge that treated those " f"branches as unordered siblings; commit is non-reconstructible" ) # Safe: apply in causal order. for branch_id in plan.order: _apply(branches[branch_id]) def _apply(branch: Branch) -> None: # Placeholder for the actual delta application against the committed store. pass ```