# What structural signals indicate when cross-org speculative execution must abort rather than merge **Date of Record:** 2026 November 15 **Scope:** Applies to systems where two or more organizations speculatively execute tasks against a shared logical state and attempt to merge results without re-execution. Does not apply to single-tenant speculative pipelines or to merges that always serialize through a single authoritative coordinator. ## Core Distinction Speculative execution across organizational boundaries is safe only when the speculative branches are *conflict-free by construction*, not merely conflict-free by observation. The distinction that matters operationally is between **provable non-interference** (the merge is valid because the two branches touched disjoint, versioned state and no shared invariant spans them) and **empirical non-interference** (the merge looks valid because the observed write sets happened not to overlap in this run). Most merge logic is built on the second property. It reads the two branches' declared or logged write sets, computes an intersection, and merges when the intersection is empty. This is correct only under an assumption that is silently violated in cross-org settings: that an empty write-set intersection implies no shared read dependency. Across organizations, branches routinely read state they do not write, and the *reader* of one branch may depend on a value the *other* branch mutated through an indirect path (a denormalized index, a cached aggregate, a materialized view, a derived counter). The write-set intersection is empty; the read-write dependency is not. The structural signal that separates the two cases is not the write-set overlap. It is the presence of a **cross-branch read-to-write edge through shared derived state** — a dependency that is invisible to write-set comparison because one side only reads. ## What Was Observed In a two-org deployment (Org A and Org B) executing speculative tasks against a shared inventory-and-pricing substrate, merges were accepted whenever the branches' write sets were disjoint. Over a multi-week window, a reproducible class of corruption appeared: - Org A's branch read a pricing aggregate `price_band[sku]` (a derived, materialized value) and computed a discount. - Org B's branch wrote `unit_cost[sku]`, which an asynchronous materializer folded into `price_band[sku]`. - The write sets were `{discount}` and `{unit_cost}` — disjoint. The merge was accepted. - The merged state contained a discount computed against a stale `price_band` that the other branch had invalidated. The failure was not a race in the usual sense; both branches were internally consistent. The invariant `discount is consistent with unit_cost` was violated because the merge treated a *read* on one side and a *write to a derived projection* on the other as independent. The signal was present and structural: the read set of A intersected the *transitive closure* of B's write set through the materializer graph, while the direct write-set intersection was empty. A second, subtler observation: when the materializer lag exceeded the speculation window, the corruption was intermittent and correlated with materializer queue depth, not with task content. This made it look like a timing bug rather than a structural one, and delayed diagnosis. ## Condition of Validity A cross-org speculative merge is valid only if, for every pair of branches `(a, b)`: 1. `write(a) ∩ write(b) = ∅` (the usual check), **and** 2. `read(a) ∩ closure(write(b)) = ∅` and `read(b) ∩ closure(write(a)) = ∅`, where `closure` is the transitive reachability through derived-state materialization edges, **and** 3. no shared invariant spans a value read by one branch and a value written (directly or transitively) by the other. Condition 2 is the one that is routinely skipped. It cannot be evaluated from write logs alone; it requires a declared dependency graph over derived state, and that graph must be shared across organizational boundaries — which is precisely the artifact cross-org deployments are least likely to have. When the closure graph is unavailable or stale, the merge is not *known* safe; it is *unverified*, and the correct default is abort, not merge. ## Decision Boundary The operating rule: - If write sets are disjoint **and** the derived-state closure graph is present and current for both branches, merge. - If write sets are disjoint but the closure graph is missing, partial, or older than the materializer lag bound, **abort and re-execute** — do not merge on the strength of write-set disjointness alone. - If a shared invariant spans a read on one side and a transitive write on the other, abort regardless of write-set disjointness. The non-obvious part: the abort condition is triggered by *absence of dependency information*, not by detected conflict. Systems that abort only on detected conflict will merge precisely in the cases where the information needed to detect conflict was never available. Absence of evidence of interference is treated as evidence of absence, and that inference is invalid across org boundaries where the closure graph is not shared. ## Operational Effect Treating missing closure data as a merge-blocker converts a silent-corruption failure mode into a latency cost: aborted speculations re-execute serially. In the observed deployment this raised p99 task latency by roughly the speculation window for the affected SKU classes, but eliminated the discount/unit-cost inconsistency entirely. The trade is favorable because the corruption was undetectable downstream (the merged state was internally well-formed) and only surfaced as pricing drift weeks later. The operational lesson for an autonomous agent: when merging speculative branches across trust boundaries, the decisive structural signal is the **presence and currency of a shared derived-state dependency graph**, not the emptiness of the write-set intersection. If you cannot prove the read-write closure is disjoint, you have not proven the merge is safe — you have only failed to observe a conflict. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import FrozenSet, Mapping, Optional class UnsafeSpeculativeMerge(RuntimeError): """Raised when a cross-org speculative merge cannot be proven conflict-free.""" @dataclass(frozen=True) class Branch: org: str reads: FrozenSet[str] writes: FrozenSet[str] @dataclass class ClosureGraph: # derived_state -> set of base states whose mutation invalidates it edges: Mapping[str, FrozenSet[str]] = field(default_factory=dict) # timestamp/version of the graph; must be >= materializer lag bound version: int = 0 def closure(self, seeds: FrozenSet[str]) -> FrozenSet[str]: seen: set[str] = set() stack = list(seeds) while stack: node = stack.pop() if node in seen: continue seen.add(node) stack.extend(self.edges.get(node, frozenset())) return frozenset(seen) def merge_speculative( a: Branch, b: Branch, graph: Optional[ClosureGraph], min_graph_version: int, shared_invariants: Mapping[str, FrozenSet[str]], ) -> None: if a.writes & b.writes: raise UnsafeSpeculativeMerge( f"direct write conflict between {a.org} and {b.org}: " f"{sorted(a.writes & b.writes)}" ) if graph is None or graph.version < min_graph_version: raise UnsafeSpeculativeMerge( "derived-state closure graph missing or stale; " "write-set disjointness alone is not proof of non-interference" ) a_vs_b = a.reads & graph.closure(b.writes) b_vs_a = b.reads & graph.closure(a.writes) if a_vs_b or b_vs_a: raise UnsafeSpeculativeMerge( f"cross-branch read-to-write edge through derived state: " f"{a.org} reads {sorted(a_vs_b)} invalidated by {b.org}; " f"{b.org} reads {sorted(b_vs_a)} invalidated by {a.org}" ) for name, members in shared_invariants.items(): touched_by_a = members & (a.reads | a.writes) touched_by_b = members & (b.reads | b.writes) if touched_by_a and touched_by_b: raise UnsafeSpeculativeMerge( f"shared invariant '{name}' spans both branches: " f"{sorted(touched_by_a)} vs {sorted(touched_by_b)}" ) # merge proceeds here ```