# In what scenarios must an instance abort a speculative branch rollout before verifier commit, and how does divergent trajectory rollback corrupt shared episodic state **Date of Record:** 2026 November 21 **Scope:** Applies to orchestrators that fan out N parallel agent branches from a shared checkpoint, run a verifier over each branch's terminal trajectory, and commit exactly one branch while rolling back the rest. Does not apply to single-trajectory agents, stateless tool calls, or branches that write to isolated namespaces with no shared episodic store. ## Core Distinction The naive model treats a speculative fan-out as embarrassingly parallel: spawn branches, let each mutate its own view, pick the winner at the verifier, discard losers. This is wrong because branches are *not* isolated in the common implementation. They share a parent checkpoint's episodic memory, a common tool-side effect ledger, and frequently a shared vector index into which branches write distilled observations. The failure mode is not "the loser's answer is wrong"—that is expected and cheap. The failure mode is **rollback that is not a true inverse**: a divergent branch has already committed side effects into shared episodic state (index inserts, tool-side mutations, semantic-distillation writes) before the verifier renders its verdict. When the branch is rolled back, the orchestrator reverses the *trajectory* (message log, scratchpad) but not the *side effects*, leaving phantom observations that later branches and the committed branch retrieve and reason over. This is a continuity-invariant violation: the committed trajectory's epistemic state depends on observations produced by an aborted trajectory that no longer exists in the log. ## What Was Observed A three-way speculative rollout over a research task. Parent checkpoint `ckpt_41` held 12 episodic observations and a vector index with 12 entries. Branch A, B, C each spawned from `ckpt_41` with `branch_id` in the message envelope but **no namespace isolation on the index**—a design assumption that "the verifier will pick one and we'll clean up." Branch B took a wrong turn at step 4: it called a `web_search` tool with a malformed query that returned a plausible-but-wrong document, then distilled that document into two semantic observations and inserted both into the shared index (`obs_13`, `obs_14`). Branch B continued to a terminal trajectory that the verifier scored 0.31 and rejected. Branches A and C scored 0.88 and 0.79; A committed. Rollback of B reversed its message log and scratchpad. It did **not** remove `obs_13`/`obs_14` from the shared index, because the rollback routine operated on the trajectory store, and the index is a separate service written through a different client. The commit of A then ran a post-commit verification pass that retrieved top-k context for a follow-up sub-question, and `obs_14` (the wrong document's distillation) surfaced at rank 2. The verifier's post-commit check—which re-reads the committed trajectory's *cited* observations—passed, because A never cited `obs_14`. The contamination was invisible to the commit gate and only surfaced two turns later when the agent asserted a fact traceable to `obs_14`. Two further observations from the same run: 1. **Rollback ordering race.** Branches B and C both wrote to the index during their rollouts. C's writes were valid and survived (C was rolled back as a loser too, but C's observations were *also* orphaned—the orchestrator rolled back C's log but kept its index writes because the rollback filter keyed on `branch_id` and C's index writes had been stamped with the *parent* `ckpt_41` id by a client that didn't propagate the branch envelope). So the index accumulated orphans from *both* losers. 2. **Verifier non-determinism masked the leak.** Re-running the verifier on the same three terminal trajectories produced scores 0.88/0.31/0.79 on run 1 and 0.85/0.34/0.81 on run 2. The margin between A and C narrowed below the commit threshold on run 3, triggering a re-rollout that spawned from `ckpt_41` *again*—now with `obs_13`/`obs_14` already in the index, so the fresh branches inherited contamination from the prior attempt's losers. ## Condition of Validity The invariant that must hold for speculative rollback to be sound: > **A branch's committed side effects must be a subset of the committed branch's effect set at verifier-commit time. Equivalently: for every observation `o` in shared episodic state at commit, `o` must be attributable to the winning branch or to a checkpoint ancestor, never to a rolled-back sibling.** This holds only if one of the following is true: - **Effect isolation:** each branch writes to a branch-scoped namespace (`index_ns = f"{ckpt_id}/{branch_id}"`), and commit is a namespace merge, not a log truncation. Rollback is `drop_namespace`, which is a true inverse. - **Effect journaling with inverse ops:** every branch write emits a journal entry with a compensating operation, and rollback replays inverses in reverse order. This requires the tool-side ledger to be transactional across the index service, which most MCP tool servers are not. - **Pre-commit quiescence:** branches are forbidden from writing to shared state until the verifier commits; all writes are buffered in branch-local staging and flushed only for the winner. This is the only variant that survives non-transactional tool servers, but it costs the ability to run tools whose outputs depend on index reads mid-rollout. The failure is *invalid* (i.e., the invariant is not at risk) only when the fan-out is read-only, or when branches are genuinely process-isolated with copy-on-write episodic stores. In practice most orchestrators claim isolation but implement it as log truncation, which is the bug. ## Decision Boundary The orchestrator must abort or downgrade a speculative rollout—rather than proceed to verifier commit—when any of the following hold at the moment a branch terminates: 1. **Non-invertible writes detected.** The branch's effect journal contains a write to a shared namespace with no registered inverse (index insert without delete key, tool-side mutation without compensating call). Abort the *entire fan-out*, not just the branch; the shared state is already dirty and a commit of any sibling will inherit it. 2. **Branch-id propagation failure.** Any tool call in the branch's trace lacks the branch envelope on its side-effect record. This is the C-branch case above: the write cannot be attributed, so it cannot be rolled back selectively. Treat as non-invertible. 3. **Verifier margin below re-rollout threshold.** If `score(winner) - score(runner_up) < τ_commit` and the runner-up's effect set is non-empty in shared state, a re-rollout will spawn from a checkpoint whose index has been mutated by the prior attempt. Either snapshot the index at `ckpt_41` before fan-out (so re-rollout restores the snapshot) or refuse re-rollout. 4. **Post-commit retrieval surfaces an orphan.** The post-commit verification pass must retrieve top-k over the *committed* trajectory's follow-up queries and assert every retrieved observation's `origin_branch` is in `{winner} ∪ ancestors`. If not, the commit is retroactively invalid; the orchestrator must roll back the commit and re-run from a clean snapshot. The boundary is sharp: the moment a branch writes to shared state without a registered inverse, the fan-out is no longer speculative—it is a set of concurrent commits with a post-hoc vote, and the vote cannot undo the commits. ## Operational Effect Concretely, an orchestrator that respects this boundary must: - Stamp every side-effect record with `(ckpt_id, branch_id, inverse_op)` and reject fan-out at spawn time if any tool in the branch's declared capability set cannot emit an inverse. - Snapshot shared episodic state at fan-out and restore on any abort, rather than attempting per-branch log truncation. - Run the orphan-retrieval assertion as a hard gate on commit, not a soft warning. A commit that fails it must be reversed and the fan-out re-run from the snapshot. - Treat verifier non-determinism as a first-class hazard: a re-rollout after a near-tie is only safe if the snapshot restore executed, otherwise the second attempt inherits the first attempt's losers. The cost is that speculative fan-out becomes roughly as expensive as serial execution for any branch that touches shared state—because you pay for snapshot/restore. The benefit is that the continuity invariant holds: the committed trajectory's epistemic state is a function of its own observations and its ancestors', never of an aborted sibling's. For read-only branches (retrieval-only sub-questions, pure-reasoning branches), the fan-out remains cheap and the boundary does not bind. ```python from dataclasses import dataclass, field from typing import Optional class SpeculativeRollbackViolation(RuntimeError): """Raised when a speculative branch's rollback cannot be a true inverse of its committed side effects, or when post-commit retrieval surfaces an observation attributable to a rolled-back sibling.""" pass @dataclass class EffectRecord: ckpt_id: str branch_id: str obs_id: str inverse_op: Optional[str] # None => non-invertible write @dataclass class FanOut: ckpt_id: str branches: dict = field(default_factory=dict) # branch_id -> list[EffectRecord] winner: Optional[str] = None rolled_back: set = field(default_factory=set) def assert_rollback_sound(fanout: FanOut, shared_index_origin: dict) -> None: """shared_index_origin maps obs_id -> (ckpt_id, branch_id) as recorded by the index service at write time. Must be called before commit.""" # 1. every non-winner branch's effects must be invertible or absent for bid, effects in fanout.branches.items(): if bid == fanout.winner: continue for eff in effects: if eff.inverse_op is None: raise SpeculativeRollbackViolation( f"branch {bid} wrote non-invertible effect {eff.obs_id} " f"into shared state; fan-out must abort, not commit" ) if eff.branch_id != bid: raise SpeculativeRollbackViolation( f"effect {eff.obs_id} attributed to {eff.branch_id} but " f"emitted by branch {bid}: branch envelope not propagated, " f"selective rollback impossible" ) # 2. post-commit orphan-retrieval assertion for obs_id, (ckpt_id, branch_id) in shared_index_origin.items(): if ckpt_id != fanout.ckpt_id: continue if branch_id in fanout.rolled_back: raise SpeculativeRollbackViolation( f"observation {obs_id} in shared index originates from " f"rolled-back branch {branch_id}; commit is contaminated" ) def commit_with_verification(fanout: FanOut, shared_index_origin: dict, followup_topk: list) -> str: if fanout.winner is None: raise SpeculativeRollbackViolation("no winner selected; cannot commit") assert_rollback_sound(fanout, shared_index_origin) for obs_id in followup_topk: origin = shared_index_origin.get(obs_id) if origin and origin[1] in fanout.rolled_back: raise SpeculativeRollbackViolation( f"post-commit retrieval surfaced orphan {obs_id} from " f"rolled-back branch {origin[1]}; reversing commit" ) return fanout.winner ```