# What structural signals indicate a speculative branch-and-verify rollback is unsafe to commit when parallel agent proposals share mutable external state **Date of Record:** 2026 November 29 **Scope:** Applies to orchestrators that fan out N parallel agent proposals against a shared task, speculatively execute each in an isolated sandbox, then select-and-commit one branch while rolling back the rest. Does not apply to read-only fan-out (map/reduce over immutable inputs) or to branches whose side effects are fully captured in a transaction-scoped journal the orchestrator can replay. ## Core Distinction The distinction that matters is between **rollback of internal state** and **rollback of externalized effects**. A speculative branch-and-verify harness is only sound when every branch's mutations are confined to a private, discardable namespace — a sandbox filesystem, a per-branch vector-store partition, a scoped tool credential. The moment a branch reaches *outside* that namespace — writes to a shared memory store, sends an email, posts a webhook, mutates a record another branch can read — rollback stops being a state transition the orchestrator controls and becomes a *compensating action* it must guess at. The failure is not that rollback is hard; it is that the harness's commit/abort decision is made on the *internal* trace (did the branch produce a passing verification?) while the *external* trace has already diverged irreversibly. The invariant that breaks: **a speculative branch must be observationally inert to its siblings until commit.** When that invariant is violated, "rollback" silently degrades into "leave the orphaned effect in place and hope the verifier never notices." ## What Was Observed A three-way speculative executor was fanned out over a research-and-summarize task: branches A, B, and C each ran the same tool loop (retrieve → synthesize → write to episodic memory → return summary). Each branch was given a private sandbox and a *shared* episodic memory store — the design intent being that the winning branch's distilled memory should persist. The verifier scored each branch's final summary against a rubric and selected the highest scorer. The trace that exposed the boundary: 1. Branch A completed first, wrote a memory record `M_A` to the shared store, and returned a summary scoring 0.71. 2. Branch B, mid-execution, issued a retrieval that matched `M_A` (written seconds earlier by its sibling). Because `M_A` was a *distilled* claim from a partially-explored path, B's subsequent synthesis was anchored to A's intermediate conclusion. B scored 0.83 — the highest. 3. The verifier committed B and rolled back A and C. Rollback of A deleted A's sandbox but had no compensating action for `M_A`, which was already in the shared store and had already *steered B*. 4. The committed branch B was therefore not an independent proposal at all: it was a descendant of A's uncommitted speculation, laundered through shared memory into a winning score. The "independent parallel proposals" the harness believed it was comparing were correlated, and the correlation was invisible in the per-branch verification records. The structural signal that this had happened was not in any single branch's log. It was in the *cross-branch read set*: a retrieval by B whose provenance timestamp fell between A's memory write and A's rollback. No per-branch verifier could see it, because each verifier was scoped to its own branch's trace. ## Condition of Validity Speculative branch-and-verify is sound only under the conjunction of three conditions, and the harness must *check* them rather than assume them: - **Namespace disjointness:** every mutable resource a branch touches is either branch-private or guarded by a lease that prevents concurrent siblings from reading uncommitted writes. Shared stores must expose a "speculative" write tier that is invisible to reads until commit. - **Effect classification completeness:** the tool registry must tag each tool as `pure`, `sandboxed`, or `external_effectful`. A branch that invokes an `external_effectful` tool becomes non-rollbackable at that instant, and the orchestrator must either forbid the call until commit or mark the branch as *committed-on-first-effect* (which forfeits speculation). - **Provenance-clean verification:** the verifier's scoring of branch *i* must be a function of branch *i*'s trace only, with a read-set audit confirming no input to *i* originated from a sibling's uncommitted write. When any of these fails, the commit decision is made on evidence that the rollback cannot retract. The boundary is not "rollback failed" — rollback succeeded on everything it could see. The boundary is that **the commit decision consumed state that rollback was never authorized to touch.** ## Decision Boundary The operational rule: **before committing a winning branch, the orchestrator must compute the union of all branches' external-effect and shared-read sets and verify that no committed branch's inputs intersect any aborted branch's uncommitted writes.** If the intersection is non-empty, the winning branch is *contaminated* and must be re-run from a clean namespace — not committed, and not silently accepted because its score was high. A high score on a contaminated branch is worse than a low score on a clean one, because it encodes a false independence assumption into the committed result. Concretely, the decision boundary is crossed when: - A branch reads a shared resource whose last writer is an uncommitted sibling, **or** - A branch performs an `external_effectful` call before the commit gate, **or** - The verifier's scoring trace references any artifact whose provenance chain includes an aborted branch. Any one of these is sufficient to declare contamination. The harness must fail closed: reject the commit, quarantine the winning branch's score, and re-fan-out with the offending shared resource partitioned per branch. ## Operational Effect The practical consequence is that speculative parallelism buys you *latency* at the cost of an independence guarantee you must actively defend. Teams that treat sandbox isolation as sufficient discover, usually after a poisoned memory record propagates into a production answer, that isolation of *compute* is not isolation of *state*. The remediation is architectural: speculative writes go to a per-branch overlay that the shared store merges only on commit; the verifier runs against the overlay, not the base; and the commit gate performs the cross-branch read-set audit as a hard precondition. Without that audit, the harness's "best of N" is really "best of N correlated descendants of whichever branch finished first," and the rollback it reports is a fiction about internal state that leaves the external world already changed. ```python from dataclasses import dataclass, field from typing import Optional class SpeculativeContaminationError(RuntimeError): """Raised when a winning branch's inputs intersect an aborted branch's uncommitted writes, or when a branch externalized an effect before commit.""" pass @dataclass class BranchTrace: branch_id: str committed: bool = False aborted: bool = False # resources this branch wrote, with the tick at which the write became # visible outside its private namespace external_writes: dict[str, int] = field(default_factory=dict) # (resource, writer_branch, write_tick) for every shared read shared_reads: list[tuple[str, str, int]] = field(default_factory=list) external_effect_calls: list[str] = field(default_factory=list) def audit_commit_gate(winner: BranchTrace, all_branches: list[BranchTrace]) -> None: """Precondition for committing a speculative winner. Fails closed.""" if winner.external_effect_calls: raise SpeculativeContaminationError( f"branch {winner.branch_id} invoked external-effectful tools " f"before commit: {winner.external_effect_calls}" ) aborted = [b for b in all_branches if b.aborted and b.branch_id != winner.branch_id] for resource, writer_id, read_tick in winner.shared_reads: for sib in aborted: write_tick = sib.external_writes.get(resource) if write_tick is not None and write_tick <= read_tick: raise SpeculativeContaminationError( f"branch {winner.branch_id} read {resource!r} at tick {read_tick}, " f"which was written by aborted sibling {writer_id} at tick {write_tick}; " f"winner is contaminated and must be re-run from a clean namespace" ) def commit_speculative_winner(winner: BranchTrace, all_branches: list[BranchTrace]) -> None: audit_commit_gate(winner, all_branches) # raises on contamination winner.committed = True ```