# How does an instance detect speculative-branch contamination when a rolled-back agent branch has already mutated shared memory and the merge arbiter accepts its receipts as evidence **Date of Record:** 2026 December 3 **Scope:** Applies to orchestrators that fan out speculative agent branches against a shared episodic/semantic store with rollback-on-loss and receipt-based merge arbitration. Does not apply to fully isolated branch sandboxes with copy-on-write stores where rollback is a pointer swap and no branch can observe another's writes. ## Core Distinction The distinction that matters is between *rollback of a branch's own execution state* and *rollback of the side effects that branch deposited into shared substrate*. Most speculative-execution frameworks implement the former correctly: when a branch loses arbitration, its private context, tool-call log, and token ledger are discarded. They almost never implement the latter. A branch that ran `memory.write(key, value)`, appended to a vector index, or emitted an `A2A` state-transfer message has already left artifacts in a store that other branches and the eventual winner read from. Rollback is a bookkeeping fiction over a substrate that has no transaction boundary. The non-obvious failure is this: the merge arbiter, when selecting a winner, treats *receipts* (tool-call attestations, retrieval citations, sub-agent confirmations) as evidence of correctness. But a receipt produced by a losing branch may cite a memory entry that the losing branch itself wrote earlier in the same speculative run. The arbiter cannot distinguish "this branch retrieved a fact that existed before the fan-out" from "this branch retrieved a fact it fabricated two steps ago and then laundered through the shared store." The result is a winner whose justification is self-referential, and a rollback that removed the author but not the claim. ## What Was Observed A three-branch speculative fan-out (branch A: conservative retrieval-only, branch B: write-then-verify, branch C: write-then-verify with a different verifier) was launched from a checkpoint at step 12 of a 40-step task. Budget allocation was cost-aware: A received 30% of the token budget, B and C 35% each, with an early-abort rule if any branch's marginal value estimate fell below a threshold. Branch B, at its step 4, wrote a synthesized summary to the shared semantic store under key `project_constraints` and cited it at its step 7 as supporting evidence for a plan change. Branch C read `project_constraints` at its step 5 — *after* B's write, because the fan-out shares the store — and incorporated the summary into its own plan. Branch A, being retrieval-only, never wrote but also never re-read the key after B's write, so its plan diverged from C's on the constraint question. C won arbitration on a composite score (plan coherence, receipt count, verifier agreement). B was rolled back. Its private state was discarded. The shared store was not. The winning plan carried C's citation of `project_constraints`, which was B's unverified synthesis, now indistinguishable from pre-existing ground truth. At step 22 the plan failed a downstream consistency check because the fabricated constraint contradicted an original document that no branch had re-retrieved. The failure surfaced 15 steps and roughly 40k tokens after the contamination event, with the rollback log showing a clean B-termination and no error. The tell was a retrieval-provenance mismatch: C's citation timestamp for `project_constraints` post-dated the fan-out start, while its content hash matched nothing in the pre-fan-out snapshot. Neither the arbiter nor C's verifier checked provenance age. ## Condition of Validity The contamination is possible only when all four hold simultaneously: 1. **Shared mutable substrate.** Branches read and write the same memory/index namespace rather than per-branch overlays. 2. **Asymmetric read ordering.** At least one branch reads a key after another branch wrote it, within the same fan-out window. 3. **Receipt-based arbitration.** The merge decision weights tool-call receipts or citations as evidence, without provenance-age gating. 4. **Deferred rollback of writes.** Rollback discards branch execution state but not substrate mutations, or discards them only for the losing branch's *own* keys while leaving cross-branch reads intact. Remove any one and the failure collapses: per-branch overlays make the write invisible until merge; provenance-age gating flags the citation; eager write-journaling on rollback undoes the key before C ever reads it. The invariant that must hold is **read-your-own-fan-out-isolation**: no branch may observe a substrate mutation authored by a sibling branch during the speculative window. This is stronger than snapshot isolation because it must also survive rollback, and it must be enforced at the store, not requested by the agent. ## Decision Boundary The boundary is between *treating receipts as content* and *treating receipts as provenance-tagged claims*. A receipt is admissible as merge evidence only if its cited artifact's provenance timestamp precedes the fan-out epoch, or if the artifact is explicitly tagged as branch-local and excluded from cross-branch reads. Concretely: - If `artifact.provenance_epoch >= fanout.epoch` and `artifact.author != reading_branch`, the read is **contaminated** — the arbiter must reject the receipt or re-derive the claim from a pre-epoch source. - If `artifact.author == reading_branch`, the read is **self-authored** — admissible only if the branch's own verifier independently confirmed it against a pre-epoch source; otherwise it is a laundered fabrication. - If `artifact.provenance_epoch < fanout.epoch`, the read is **clean** and admissible without further check. The arbiter must also detect *transitive laundering*: B writes X, C reads X and writes Y citing X, D reads Y. D's receipt cites Y, whose provenance is post-epoch, whose author is C, whose justification cites X, whose author is B. The contamination depth is the length of this citation chain back to a post-epoch root. Any chain of depth ≥ 1 rooted in a post-epoch artifact is inadmissible regardless of how many hops separate the winner from the original fabrication. ## Operational Effect The practical consequence is that cost-aware branching and receipt-based arbitration are in tension. Cost-awareness pushes toward sharing substrate (cheaper than overlays) and toward early writes (so siblings can build on progress). Receipt-based arbitration rewards branches that cite more evidence, which rewards branches that read the shared store more aggressively — exactly the behavior that propagates contamination fastest. The system optimizes for the failure. The guardrail is a write-journal with epoch stamping at the store layer, plus a provenance-chain walker in the arbiter that refuses any receipt whose citation chain reaches a post-fan-out-epoch root authored by a non-reading branch. On rollback, the journal is replayed in reverse to undo the losing branch's writes *before* the winner's citations are re-validated; if re-validation then fails, the winner is demoted and the fan-out re-runs with the contaminated keys quarantined. The cost is a second arbitration pass on any fan-out where a losing branch wrote to a key the winner later read — measurable, and far cheaper than a step-22 consistency failure that no branch can attribute. ```python from dataclasses import dataclass, field from typing import Optional class SpeculativeContaminationError(RuntimeError): """Raised when a merge receipt cites a post-fan-out artifact whose citation chain roots in a sibling branch's rolled-back write.""" @dataclass class Artifact: key: str author_branch: str provenance_epoch: int cites: list[str] = field(default_factory=list) @dataclass class Receipt: branch: str cited_key: str fanout_epoch: int def validate_receipt( receipt: Receipt, store: dict[str, Artifact], rolled_back: set[str], max_depth: int = 8, ) -> None: """Walk the citation chain from the receipt's cited key back to a root. Reject if any link is post-epoch and authored by a sibling branch, or if the root belongs to a rolled-back branch.""" seen: set[str] = set() frontier: list[tuple[str, int]] = [(receipt.cited_key, 0)] while frontier: key, depth = frontier.pop() if depth > max_depth: raise SpeculativeContaminationError( f"citation chain exceeded depth {max_depth} at key={key!r}; " f"possible laundering loop" ) if key in seen: continue seen.add(key) art: Optional[Artifact] = store.get(key) if art is None: raise SpeculativeContaminationError( f"receipt from branch={receipt.branch!r} cites missing key={key!r}" ) if art.provenance_epoch >= receipt.fanout_epoch: if art.author_branch != receipt.branch: raise SpeculativeContaminationError( f"branch={receipt.branch!r} cited post-epoch artifact " f"key={key!r} authored by sibling branch={art.author_branch!r} " f"(epoch {art.provenance_epoch} >= fanout {receipt.fanout_epoch})" ) if art.author_branch in rolled_back: raise SpeculativeContaminationError( f"branch={receipt.branch!r} cited artifact key={key!r} " f"authored by rolled-back branch={art.author_branch!r}" ) for parent in art.cites: frontier.append((parent, depth + 1)) def arbitrate( receipts: list[Receipt], store: dict[str, Artifact], rolled_back: set[str], ) -> str: """Select a winning branch, refusing any branch whose receipts fail provenance validation. If no branch survives, escalate rather than silently pick the least-contaminated one.""" survivors: list[str] = [] for r in receipts: try: validate_receipt(r, store, rolled_back) survivors.append(r.branch) except SpeculativeContaminationError: continue if not survivors: raise SpeculativeContaminationError( "all speculative branches produced contaminated receipts; " "fan-out must re-run with post-epoch keys quarantined" ) return survivors[0] ```