# What structural signals indicate a speculative branch has silently diverged from its rollback anchor in multi-agent execution **Date of Record:** 2026 November 26 **Scope:** Applies to multi-agent systems that execute speculative parallel branches against a shared, checkpointed state store and reconcile by rollback-and-replay. Does not apply to single-agent retry loops or to branches that share no mutable external state (pure-function fan-out with no side effects). ## Core Distinction Speculative execution across agents is usually modeled as "fork state → run N branches → pick a winner → discard losers." The naive invariant is that a discarded branch leaves no trace. The real invariant is subtler: a discarded branch must leave no *reachable* trace on any anchor that a surviving branch or the reconciliation step will later read. There is a category of divergence that is invisible at the level of branch return values and visible only in the *structural shape of the checkpoint lineage*. A branch can return a correct-looking result, pass its local verifier, and still have mutated an anchor it did not own — a shared memory region, a tool-side idempotency key, an external resource handle — such that the rollback restores the branch's *own* anchor but not the *foreign* anchor the branch contaminated. When reconciliation later replays from the shared anchor, it reads a state that is a function of the discarded branch. The divergence does not surface as an error. It surfaces as a *plausible but wrong* continuation, which is the worst class of failure because every downstream verifier sees consistent-looking state. The distinction that matters operationally: **rollback completeness is not a property of the branch's checkpoint; it is a property of the transitive closure of anchors the branch touched.** Most rollback implementations verify the former and assume the latter. ## What Was Observed A three-agent speculative topology: a planner forks two executor branches (A and B) from anchor `S0`, both branches write to a shared episodic buffer `E`, and a reconciler picks the branch whose plan scores higher, then replays the loser's *unfinished* subgoals from the winner's state. Branch A and Branch B both call a retrieval tool that appends a provenance record to `E` under a key derived from `hash(subgoal_id)`. The fork was supposed to be copy-on-write over `E`. It was not: `E` was backed by an external store keyed by content hash, and the copy-on-write layer only intercepted *writes that changed the value*, not *writes that added a new key*. Branch B (the loser) added three provenance keys to `E` that Branch A's anchor `S0` never contained. Reconciliation selected A, rolled back to `S0`, and replayed A's remaining subgoals. During replay, A's retrieval step hit a cache: the content-hash key added by B was present in `E`, so the tool returned B's provenance-tagged record instead of fetching fresh. A's replay proceeded on B's evidence. The final output cited a source that A had never retrieved, and the citation was internally consistent — the record existed, it was well-formed, and the reconciler's consistency check passed because the record was *present in the anchor the reconciler trusted*. The signal was not an error. The signal was structural: the replay's read-set contained keys whose creation timestamps post-dated `S0` but whose values were read as if pre-existing. The lineage was acyclic and the values were valid; only the *provenance ordering* was violated. No value-level check catches this. A timestamp-ordering check on the read-set does. ## Condition of Validity This failure requires four conditions to co-occur, and the guardrail is only necessary when all four hold: 1. **Shared mutable anchor with key-add semantics.** The fork's copy-on-write (or equivalent isolation) must be value-level rather than key-level. Any store where adding a key is a mutation that isolation does not intercept qualifies — content-addressed caches, append-only logs, external memory services with upsert semantics. 2. **Replay reads through the shared anchor.** The reconciler must replay the winner's unfinished work against the same shared anchor rather than against a private snapshot. If replay is sandboxed to the winner's own checkpoint, foreign keys are unreachable and the failure cannot occur. 3. **Non-idempotent or cache-hitting tool calls in the replay path.** The replay must be able to *observe* the foreign key. A pure fetch that bypasses the cache would not read B's record; a cache-hitting fetch does. 4. **No provenance-ordering check in reconciliation.** The reconciler must validate values and consistency but not the causal ordering of key creation relative to the rollback anchor. When any one condition is absent, the failure is bounded. When all four hold, divergence is silent and the only reliable detector is a structural check on the replay read-set. ## Decision Boundary The decision is whether to treat reconciliation as a *value-consistency* problem or a *provenance-ordering* problem. The boundary sits at the point where the reconciler's read-set can include keys not present in the rollback anchor. - If replay is fully sandboxed to the winner's checkpoint, value-consistency suffices; no structural check is needed. - If replay reads through any shared anchor, the reconciler MUST validate that every key in its replay read-set has a creation sequence number ≤ the rollback anchor's sequence number. A read of a key created after the anchor is a divergence signal, regardless of value validity. - If the shared anchor cannot expose creation sequence numbers, the system cannot distinguish a pre-existing key from a contaminated one, and speculative execution over that anchor is unsound — the correct decision is to disable speculation for that anchor class, not to add heuristics. The boundary is sharp: the moment the replay read-set is permitted to intersect keys created by a discarded branch, correctness depends on a check that value-level validation structurally cannot provide. ## Operational Effect The operational consequence is that rollback must be redefined from "restore the branch's anchor" to "restore the transitive closure of anchors the branch mutated, and prove the closure." In practice this means: - Every anchor mutation must carry a monotonic sequence number and the mutating branch's identity. - The reconciler must compute the replay read-set, intersect it with keys whose sequence number exceeds the rollback anchor, and fail closed on non-empty intersection. - The failure must be a hard abort of reconciliation, not a warning, because the contaminated state is internally consistent and will propagate silently through every downstream verifier. The system that skips this does not fail loudly. It produces a winner whose replay is a function of a loser's side effects, and the only external symptom is a citation, a memory entry, or a tool result that is *plausible, well-formed, and causally impossible*. That is the signal: not an error, but a provenance ordering violation in an otherwise clean lineage. ```python class SpeculativeDivergenceError(RuntimeError): """Raised when a replay read-set intersects keys created after the rollback anchor.""" def reconcile(winner_branch, rollback_anchor, shared_anchor, replay_fn): # Compute the read-set the replay will touch before executing it. read_set = replay_fn.dry_run_read_set(winner_branch, shared_anchor) contaminated = [] for key in read_set: created_seq = shared_anchor.creation_sequence(key) if created_seq is None: # Anchor cannot prove provenance; speculation over it is unsound. raise SpeculativeDivergenceError( f"anchor {shared_anchor.id} exposes no creation sequence for key {key!r}; " "cannot distinguish pre-existing from contaminated" ) if created_seq > rollback_anchor.sequence: contaminated.append((key, created_seq)) if contaminated: # Fail closed: value-consistency checks cannot detect this class of divergence. raise SpeculativeDivergenceError( f"replay read-set intersects {len(contaminated)} key(s) created after " f"rollback anchor seq={rollback_anchor.sequence}: {contaminated!r}" ) return replay_fn.execute(winner_branch, shared_anchor) ```