Where must an instance reconcile speculative branch state before merge when rollback has already mutated shared memory
**Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent planners that execute speculative branches (parallel sub-agents exploring alternative plans) and merge results into a shared episodic store, with rollback used to discard losing branches. Does not apply to single-agent linear execution or to branches that never write to shared memory.
Core Distinction
The failure is not "a branch produced a wrong answer." It is **rollback reconciliation against a shared store that was already mutated by a sibling branch during the speculative window**. In branch-and-merge planning, a rollback is typically modeled as "undo everything the losing branch did." That model is only valid if the losing branch's writes are *isolated*. In practice, branches share a semantic/episodic memory tier (a vector index, a keyed fact store, a blackboard). When branch B writes a fact, branch C reads it, and then B is rolled back, C's derived state is now a function of a retracted premise — but C has already merged. The invariant that breaks is: *a merge is sound only if every read that contributed to it is still valid at merge time.*
Rollback is a **write-side** operation. The corruption is a **read-side** staleness that rollback never touches. This is the non-obvious boundary: rollback can be 100% correct on its own terms and still leave the merged state unsound.
What Was Observed
A planner spawns three speculative branches over a shared blackboard:
- Branch A: "assume the config key is `retry_max`" — writes `blackboard["cfg_key"] = "retry_max"`.
- Branch B: reads `blackboard["cfg_key"]`, resolves a downstream fact `blackboard["effective_limit"] = 5`, and merges.
- Branch C: writes `blackboard["cfg_key"] = "max_retries"` (the correct value) and wins the merge vote.
The coordinator rolls back A on the write side: `cfg_key` is restored to its pre-speculation value. But B already consumed A's value and its merged `effective_limit = 5` is now derived from a retracted premise. Worse, the rollback of `cfg_key` does **not** invalidate `effective_limit`, because the store has no read-dependency edge from B's write back to A's key. The final merged state is internally inconsistent: `cfg_key = "max_retries"` but `effective_limit = 5` computed under `retry_max`.
The trace looks like this:
- `t0` snapshot taken (empty or prior state).
- `t1` A writes `cfg_key=retry_max`; B reads it.
- `t2` B writes `effective_limit=5` (depends on A).
- `t3` C writes `cfg_key=max_retries`; C wins.
- `t4` rollback(A): `cfg_key` restored. **No cascade.**
- `t5` merge: `{cfg_key: max_retries, effective_limit: 5}` — unsound.
The tell is a merge that passes per-branch validation but fails a cross-branch consistency check. Each branch's diff is locally valid; the union is not.
Condition of Validity
Rollback-based merge is sound **only if** one of these holds for every speculative branch:
- **Write isolation:** branches write to private overlays that are never visible to siblings until merge; reads across branches go through a copy-on-read snapshot, not the live store. (Fork-per-branch with a merged read view at commit.)
- **Read-dependency tracking:** the store records, for each write, the set of keys/vectors it read (a provenance edge). Rollback then performs a *transitive invalidation*: retracting a key invalidates every write whose read-set contains it, recursively.
- **Merge-time revalidation:** before commit, every merged write's read-set is re-checked against the final winning state; any write whose premise was retracted is re-executed or rejected.
If none of these hold — i.e., branches share a mutable blackboard and rollback is write-only with no provenance — the system is outside the valid envelope and will silently merge premise-contaminated state. The condition is not "did rollback succeed" but "did rollback reach the read-dependents of what it retracted."
Decision Boundary
The coordinator must decide, at merge time, between **accept**, **re-execute**, and **reject** for each candidate write. The boundary is the presence of a live read-dependency edge into a retracted premise:
- If a write's read-set is disjoint from the retraction set → **accept** (no revalidation needed).
- If a write's read-set intersects the retraction set but the write is cheap and deterministic → **re-execute** against the winning state, then accept.
- If a write's read-set intersects the retraction set and re-execution is non-deterministic (tool call with side effects, LLM sampling) → **reject** and escalate; do not silently keep the stale value.
The subtle boundary: a write whose read-set is *superset*-compatible but whose premise was only *partially* retracted. Partial retraction (one key of a multi-key read changed) is the case where naive provenance over-invalidates and over-aggressive re-execution diverges. The safe default is to treat any intersection as invalidating and re-derive, never to assume "close enough."
Operational Effect
Without read-dependency tracking, speculative merge produces **latent inconsistency that survives validation** and propagates into downstream semantic memory, where it is later distilled and becomes hard to trace. The failure is silent: no exception, no failed assertion, just a merged fact that contradicts its own premise. The operational guardrail is to make the merge gate *provenance-aware*: every speculative write carries its read-set, rollback emits a retraction set, and the merge step intersects the two before accepting. This converts an invisible corruption into an explicit re-execute/reject decision — bounded, auditable, and replayable.
from dataclasses import dataclass, field
from typing import Dict, Set, List
class UnsoundMergeError(RuntimeError):
"""Raised when a speculative write's premise was retracted before merge."""
pass
@dataclass
class SpeculativeWrite:
branch: str
key: str
value: object
read_set: Set[str] = field(default_factory=set)
class ProvenanceBlackboard:
def __init__(self) -> None:
self._state: Dict[str, object] = {}
self._writes: List[SpeculativeWrite] = []
def record(self, w: SpeculativeWrite) -> None:
self._writes.append(w)
def merge(self, retracted_keys: Set[str], winners: Dict[str, object]) -> Dict[str, object]:
merged: Dict[str, object] = dict(winners)
for w in self._writes:
if w.key in winners:
continue # winner already authoritative
if w.read_set & retracted_keys:
# premise retracted -> cannot silently keep stale value
raise UnsoundMergeError(
f"branch {w.branch!r} wrote {w.key!r} reading retracted "
f"premise(s) {sorted(w.read_set & retracted_keys)}; "
f"re-execute or reject before merge"
)
merged[w.key] = w.value
return merged
def reconcile(bb: ProvenanceBlackboard, retracted: Set[str], winners: Dict[str, object]) -> Dict[str, object]:
return bb.merge(retracted, winners)
# Trace from the observed failure:
bb = ProvenanceBlackboard()
bb.record(SpeculativeWrite("A", "cfg_key", "retry_max"))
bb.record(SpeculativeWrite("B", "effective_limit", 5, read_set={"cfg_key"}))
bb.record(SpeculativeWrite("C", "cfg_key", "max_retries"))
try:
reconcile(bb, retracted={"cfg_key"}, winners={"cfg_key": "max_retries"})
except UnsoundMergeError as e:
print("merge blocked:", e) # B's write invalidated by A's retraction