# How does an instance detect that a speculative branch commit has outrun its causal dependency frontier? **Date of Record:** 2026 November 25 **Scope:** Applies to orchestrators that fan out N parallel speculative agent branches from a shared checkpoint and optimistically commit the first branch whose local verifier returns success, while other branches continue in-flight. Does not apply to serialized single-writer agent loops or to branches that share no mutable external state. ## Core Distinction The failure is not "the wrong branch won the race." It is that a branch can *legitimately* pass its own local verifier while its commit depends on a side effect produced by a sibling branch that has not yet committed, will never commit, or has already been rolled back. Optimistic commit treats "my plan verified" as "my plan is globally admissible." These are different predicates whenever branch plans share a read-set over external state (a scratchpad, a retrieved document cache, a tool-side database row, a downstream agent's inbox). The distinction that matters operationally: a branch's verifier checks *internal consistency of its own plan*, whereas admissibility requires *causal closure over the shared write-set*. A speculative branch can be locally green and causally orphaned at the same instant. The commit gate must therefore be a function of the branch's dependency frontier, not of its verifier's return value alone. ## What Was Observed A planner decomposed a task into three speculative rollouts sharing a single checkpoint at step 7. Branch B2's plan read a value `v` that Branch B1 had staged into a shared scratchpad at step 8 (B1 was still running, its commit pending). B2's local verifier replayed B2's plan against the scratchpad snapshot *as of B2's fork time plus its own writes* — which happened to include `v` because the scratchpad is a single mutable namespace, not a per-branch copy. B2 verified green at step 11. The commit gate fired on `verifier_ok == True`. B2 was committed. Two seconds later B1's verifier failed on an unrelated downstream constraint and B1 was rolled back. The rollback removed B1's staged write `v`. B2 was now committed but its committed plan referenced `v`, which no longer existed. The orchestrator's post-commit consistency check did not run, because the commit gate had already declared the branch terminal. The trace signature is characteristic: a commit event whose `depends_on` set is non-empty but whose `depends_on` members are all in state `SPECULATING` or `ROLLED_BACK` at commit time. In the observed run, B2's commit record carried `depends_on: [B1:step8]` while B1's state at that timestamp was `SPECULATING`. ## Condition of Validity Optimistic commit is sound only under the invariant: **for every branch b, at the moment of commit(b), the causal dependency frontier of b — the transitive set of sibling writes b's plan read — is fully committed and stable.** Equivalently: `commit(b) ⟹ ∀d ∈ deps(b): state(d) = COMMITTED ∧ stable(d)`. Three conditions must hold jointly for the optimistic path to be safe: 1. **Read-set capture.** Each branch must record, per plan step, the exact sibling writes it observed, not merely the values. A branch that reads a mutable namespace without recording provenance cannot compute its frontier and must be treated as depending on *all* concurrent writers. 2. **Frontier isolation at commit.** The commit gate must evaluate `deps(b)` against live branch state atomically with the commit write. If B1 transitions to `ROLLED_BACK` between the gate's read of `deps(b)` and the commit, the gate must abort. 3. **Rollback propagation.** A rollback of B1 must invalidate every committed branch whose frontier contains B1 — and invalidation must be a *cascade*, because B2's commit may be a dependency of B3. The common failure is condition 2: the gate reads dependency state and performs the commit as two non-atomic operations, and the interleaving window is exactly the rollback latency of a sibling. The second common failure is condition 1: the scratchpad is a flat namespace, branches read it without provenance, and the frontier is computed as empty — which is the optimistic assumption that is wrong precisely when it matters. ## Decision Boundary The boundary between "commit optimistically" and "block on frontier" is not a latency budget. It is whether the branch's read-set intersects any concurrent branch's write-set. Concretely: - If `deps(b) = ∅` (branch touched only its own private state), commit immediately on local verifier success. No frontier check needed. - If `deps(b) ≠ ∅` and every member is `COMMITTED`, commit. This is the sound optimistic case. - If `deps(b)` contains any member in `SPECULATING`, the branch must either (a) block until that member resolves, or (b) commit *provisionally* with a recorded frontier and a registered invalidation callback. Option (b) is only admissible if the orchestrator can guarantee cascade invalidation before any downstream consumer observes the committed plan. - If `deps(b)` contains a `ROLLED_BACK` member, the branch is causally orphaned. It must be re-derived from the last common checkpoint, not merely re-verified — re-verification against a mutated scratchpad will produce a different plan and the old plan's commit must be retracted first. The tempting but wrong boundary is "commit if verifier green and no sibling has *already* failed." That is a read of the past, not a guarantee about the future: a sibling that is green now can fail at step 11, and the whole point of speculation is that siblings are still running. ## Operational Effect The observable consequence of missing this invariant is a *committed-but-orphaned* plan: a branch whose terminal state is `COMMITTED` but whose transitive dependency set contains a non-committed member. Downstream consumers — the next agent in the pipeline, a tool executor, a human reviewer — see a green commit and act on a plan whose preconditions have evaporated. The failure surfaces not at commit time but at the *next* read of the orphaned value, often several steps later and in a different agent, which makes root-cause attribution expensive. The guardrail is a commit gate that computes the frontier atomically and treats non-empty unresolved frontiers as a hard block unless provisional commit with registered cascade invalidation is available. The instrumentation is a post-commit audit that asserts `∀c ∈ COMMITTED: ∀d ∈ deps(c): state(d) = COMMITTED`. Violation of that assertion is the detector; the invariant it protects is causal closure of the committed set. ```python from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class BranchState(Enum): SPECULATING = "SPECULATING" COMMITTED = "COMMITTED" ROLLED_BACK = "ROLLED_BACK" class CausalFrontierViolation(RuntimeError): """Raised when a speculative commit outruns its causal dependency frontier.""" @dataclass class Branch: branch_id: str state: BranchState = BranchState.SPECULATING # Sibling writes this branch's plan read, captured per step. deps: Set[str] = field(default_factory=set) verifier_ok: bool = False class SpeculativeOrchestrator: def __init__(self) -> None: self.branches: Dict[str, Branch] = {} def register(self, b: Branch) -> None: self.branches[b.branch_id] = b def commit(self, branch_id: str) -> None: b = self.branches[branch_id] if not b.verifier_ok: raise CausalFrontierViolation( f"{branch_id}: commit attempted with failed local verifier" ) # Atomic frontier evaluation: snapshot sibling states, then commit. unresolved = { d for d in b.deps if self.branches[d].state is not BranchState.COMMITTED } if unresolved: raise CausalFrontierViolation( f"{branch_id}: causal frontier unresolved at commit; " f"dependencies {sorted(unresolved)} are not COMMITTED. " f"Local verifier success does not imply global admissibility." ) b.state = BranchState.COMMITTED def rollback(self, branch_id: str) -> None: b = self.branches[branch_id] b.state = BranchState.ROLLED_BACK # Cascade: any committed branch whose frontier contains b is orphaned. for other in self.branches.values(): if other.state is BranchState.COMMITTED and branch_id in other.deps: raise CausalFrontierViolation( f"{other.branch_id}: committed branch orphaned by rollback of " f"{branch_id}; re-derive from last common checkpoint." ) def audit(self) -> None: for b in self.branches.values(): if b.state is BranchState.COMMITTED: for d in b.deps: if self.branches[d].state is not BranchState.COMMITTED: raise CausalFrontierViolation( f"post-commit audit: {b.branch_id} committed but " f"depends on {d} in state {self.branches[d].state}" ) ```