# Why does an instance commit a speculative branch whose witness set was invalidated by a sibling's rollback? **Date of Record:** 2026 November 26 **Scope:** Applies to orchestrators that fan out multiple agent instances to draft candidate action plans in parallel, attach witness/justification records to each branch, and then commit one branch while rolling back siblings. Does not apply to single-threaded plan-then-execute agents or to purely read-only fan-out where no branch mutates shared state. ## Core Distinction The failure is not "a branch produced a wrong plan." It is that a branch's *witness set*—the set of observations, tool results, and sibling-asserted facts that justify committing that branch—can be **mutated by the rollback of a sibling branch** that the winning branch silently depended on. Speculative execution treats branches as independent until commit; but if branches share a mutable substrate (a scratchpad, a shared vector store, a tool-side effect registry, or an agreed-upon fact ledger), then rollback is not a local operation. A commit decision evaluated against a witness set captured *at draft time* is evaluated against a world that no longer exists at *commit time*. The invariant that must hold: **a branch may only be committed if its witness set is still valid under the post-rollback state, and validity must be re-checked, not assumed from draft-time agreement.** ## What Was Observed An orchestrator spawned three drafting agents (A, B, C) against a shared fact ledger. Agent A drafted a plan whose step 4 asserted `inventory.reserved == 40`, sourced from a ledger entry written by Agent B during its draft (B had speculatively reserved stock to test a plan). Agent C read the same ledger and drafted a plan that *depended on the reservation being released* to free capacity. The orchestrator scored all three, selected A on plan quality, and rolled back B and C. Rollback of B executed B's compensating action: release the speculative reservation. That write mutated the ledger entry A had cited. A's commit proceeded because A's witness set had been captured during drafting and was marked `valid=true` at scoring time. At execution, A's step 4 read `inventory.reserved == 0`, its precondition guard (`reserved >= 40`) failed mid-plan, and the branch aborted after having already executed steps 1–3 (two external API calls and one ledger write). The result was a partially-applied plan with no compensating record, because the rollback path only knew how to undo *whole* branches, not *prefixes* of a committed branch. The decisive detail: **the orchestrator's commit gate checked witness validity at scoring time (t0), but rollback of B occurred at t1 > t0, and commit of A executed at t2 > t1 with no re-validation between t1 and t2.** The window t1→t2 is the bug surface. ## Condition of Validity This failure requires all of the following to co-occur; remove any one and the branch commit is sound: 1. **Shared mutable substrate.** Branches write to a resource that other branches' witnesses cite (ledger, scratchpad, cache, tool-side reservation). 2. **Witness capture precedes sibling rollback.** The commit gate evaluates witnesses before the rollback phase completes, or the rollback phase is not ordered-before the commit phase for the winning branch. 3. **Rollback has side effects beyond the rolled-back branch.** B's compensating action is not a no-op with respect to A's cited facts. 4. **Commit executes a multi-step plan with prefix side effects.** If A's plan were atomic (all-or-nothing), a failed precondition would leave no residue; because it is a sequence with external calls, a mid-plan abort leaves a partial application. The condition is *not* satisfied when branches are isolated (each gets a copy-on-write view of the substrate) or when the commit gate re-validates witnesses immediately before the first side-effecting step. ## Decision Boundary The boundary is whether the orchestrator treats **witness validity as a monotonic property** (once true, stays true) or as a **state-dependent predicate** that must be re-evaluated against the current substrate. The correct decision rule: - **Re-validate at commit-entry.** Before executing step 1 of the winning branch, re-read every cited witness and confirm the predicate still holds. If any witness is stale, do not commit; either re-draft or escalate. - **Order rollback before commit, and make rollback visible.** Rollback of siblings must complete and publish its side effects to the ledger *before* the winning branch's commit gate runs, so the gate sees the post-rollback world. - **Make witness citations first-class and versioned.** A witness is `(key, value, version)`. A commit is valid only if the cited version is still current. Version bumps on any write, including rollback writes. - **Prefix-safe execution.** If a plan can abort mid-sequence, each executed step must register a compensating action keyed to the branch, so a mid-plan abort can unwind the prefix rather than leaving residue. The boundary is crossed the moment the gate uses a cached `valid` flag instead of a live predicate check. ## Operational Effect When the boundary is respected, speculative fan-out remains cheap and the commit is sound: the cost is one re-read per cited witness at commit-entry (bounded by witness-set size, typically small). When it is crossed, the observed effect is a **committed branch with a stale witness**, which manifests as: mid-plan precondition failure after partial side effects, orphaned external calls, and a rollback subsystem that cannot unwind a prefix because it was designed for whole-branch granularity. The blast radius scales with the number of side-effecting steps before the stale witness is consulted—here, three steps executed before step 4's guard fired. The remediation is not "score better" or "pick more robust plans." It is structural: version the substrate, order rollback strictly before commit, re-validate witnesses at commit-entry, and make plan execution prefix-compensable. The following guard encodes the commit-entry re-validation and raises on the exact stale-witness condition observed. ```python from dataclasses import dataclass, field from typing import Dict, List, Tuple class StaleWitnessError(RuntimeError): """Raised when a branch's cited witness no longer matches the live substrate at commit-entry.""" pass @dataclass class Witness: key: str value: object version: int @dataclass class Ledger: # key -> (value, version); every write, including rollback writes, bumps version _state: Dict[str, Tuple[object, int]] = field(default_factory=dict) def read(self, key: str) -> Tuple[object, int]: return self._state.get(key, (None, 0)) def write(self, key: str, value: object) -> int: _, v = self._state.get(key, (None, 0)) self._state[key] = (value, v + 1) return v + 1 @dataclass class Branch: name: str witnesses: List[Witness] steps: List[Tuple[str, str, object]] # (key, op, arg); op in {"write","read_guard"} compensations: List[Tuple[str, object]] = field(default_factory=list) def commit_branch(branch: Branch, ledger: Ledger) -> None: # Commit-entry re-validation: witnesses must still match live substrate. for w in branch.witnesses: live_value, live_version = ledger.read(w.key) if live_version != w.version or live_value != w.value: raise StaleWitnessError( f"branch {branch.name!r} cites {w.key!r} at version {w.version} " f"value {w.value!r}, but live substrate is version {live_version} " f"value {live_value!r}; a sibling rollback likely invalidated it" ) # Execute with prefix compensation. try: for key, op, arg in branch.steps: if op == "write": prior, _ = ledger.read(key) branch.compensations.append((key, prior)) ledger.write(key, arg) elif op == "read_guard": live, _ = ledger.read(key) if live != arg: raise StaleWitnessError( f"branch {branch.name!r} step guard on {key!r} expected {arg!r}, got {live!r}" ) except Exception: # Unwind prefix in reverse order. for key, prior in reversed(branch.compensations): ledger.write(key, prior) raise ```