# When must an instance abandon a speculative branch that has already been Byzantine-committed by a quorum: the orphaned-commit invariant in branch-and-prune multi-agent planning **Date of Record:** 2026 November 29 **Scope:** Applies to multi-agent planners where worker instances execute speculative plan branches concurrently and a validator quorum (Byzantine fault-tolerant, f ≥ 1) commits branch outcomes to a shared, ordered log. Does not apply to single-agent speculative decoding, to plans with no committed side effects, or to systems where branch outcomes are advisory-only and never gate downstream execution. ## Core Distinction The failure is not a consensus failure and not a planning failure—it is a **temporal ordering failure between two independent quorums operating over the same branch**. In branch-and-prune planning, a *speculative executor* races multiple branches and prunes losers as soon as a winner is locally observed. Separately, a *Byzantine validator quorum* assigns a global commit order to branch outcomes. These two subsystems are correct in isolation: the executor's local pruning is sound over its own observations, and the validator quorum's ordering is sound over the messages it receives. The break occurs because **local prune decisions are made on uncommitted evidence, while committed evidence can arrive with a lower sequence number and retroactively invalidate the local winner.** The instance has already acted on the pruned branch when the commit log reveals that the "loser" was the quorum-ordered winner. This is an *orphaned commit*: a globally ordered decision whose local consequences were discarded before the order was visible. The distinction that matters operationally: a **retry** re-runs a branch; an **orphaned commit** requires *un-executing* side effects that a quorum has already certified, which is impossible when those side effects are external and non-idempotent. The invariant that must hold is not "the local winner equals the committed winner" (they can diverge transiently) but **"no external side effect is emitted for a branch until that branch's commit sequence number is durable and no lower-numbered commit can still arrive."** Most implementations violate the second clause because they treat "quorum certificate received" as equivalent to "commit is final," ignoring that ordering is a separate property from certification. ## What Was Observed A three-worker planner (W1, W2, W3) with a validator quorum of 5 (tolerating f=1 Byzantine) was executing a fan-out plan with two mutually exclusive branches: `B_alpha` (deploy config A) and `B_beta` (deploy config B). Both branches were speculatively launched. Local execution latency of `B_alpha` was ~340ms; `B_beta` was ~610ms. 1. `B_alpha` completes first. W1 observes completion and, per the executor's prune policy, immediately emits the external side effect (a config push) and signals W2/W3 to cancel `B_beta`. The local winner is `B_alpha`. 2. Concurrently, the validator quorum receives `B_beta`'s outcome certificate first (W2's message was delayed ~90ms in the transport but arrived at validators ahead of W1's, due to a reordered A2A channel). Validators assign `B_beta` sequence number 41 and `B_alpha` sequence number 42. 3. The quorum certificate for `B_beta` (seq 41) is committed and gossiped. W1 receives it ~120ms *after* it already pushed config A. The commit log now states the ordered winner is `B_beta`. 4. `B_beta`'s executor, seeing a committed winner that is not itself, attempts to reconcile by pushing config B. The external system now has config A (from the pruned-but-executed branch) followed by config B, with no ordering record explaining the transient. 5. On replay, the audit shows: commit seq 41 = `B_beta` (winner), commit seq 42 = `B_alpha` (marked pruned). But the *physical* side-effect log shows A-then-B, which contradicts the committed order B-then-(pruned A). The verification replay flags a discrepancy that is not a Byzantine fault—all honest nodes behaved per their local rules. The non-obvious element: **the prune decision was locally correct.** W1 had no certificate for `B_beta` at the moment it pruned. The bug is that W1 treated *absence of a competing certificate* as *permission to emit side effects*, when the correct condition is *presence of a durable commit with no possible lower-numbered predecessor still in flight*. The validator quorum never lied; it simply ordered messages by arrival, and arrival order is not execution order. ## Condition of Validity The invariant "emit side effects only after a branch is committed" is necessary but **not sufficient**. The sufficient condition is: > An instance may emit an external side effect for branch `b` only when it holds a commit certificate for `b` with sequence number `s`, **and** it has observed commit-certificate continuity for all sequence numbers `< s` (i.e., the log is gap-free up to `s`), **and** the commit for `b` designates `b` as the ordered winner. The gap-free clause is the load-bearing one. A certificate for `b` at seq 42 does not tell you whether seq 41 exists and designates a different winner. In a Byzantine quorum with f=1, up to f validators may withhold or forge certificates, so an instance cannot infer "no seq 41 exists" from "I have not seen seq 41"—it can only infer it from a *contiguous* certificate chain, or from a signed high-water-mark statement from a quorum asserting no commit below `s` is outstanding. This condition fails to hold, and the failure mode is live, whenever any of the following are true: - The transport between executors and validators is reorder-capable (A2A over independent channels, MCP tool calls with variable latency). - The executor's prune policy fires on *first completion* rather than *first committed completion*. - Side effects are external and non-idempotent (config pushes, payments, resource allocation, message sends). - The validator quorum orders by message arrival rather than by a causal or logical clock. It does **not** apply when branches are pure (no external side effects), when the quorum provides total-order broadcast with gap detection built into the certificate (e.g., certificates carry a parent-hash chain the executor verifies), or when the plan is single-winner with no speculative parallelism. ## Decision Boundary The boundary is the moment an instance must choose between **acting on local evidence** and **waiting for ordered evidence**. The decision rule: - **Act immediately (prune + emit)** is safe only for branches whose side effects are *reversible within the commit window* or *idempotent under reordering*. For these, the orphaned-commit cost is a wasted write, not a contradiction. - **Wait for gap-free commit** is required for any branch whose side effect is externally observable and order-sensitive. The wait bound is the quorum's maximum commit latency plus the reorder window; an instance that cannot bound this must not speculatively execute order-sensitive branches at all. The trap: teams implement "wait for certificate" and believe the boundary is crossed, but the certificate-without-continuity is exactly the state that produced the observed failure. The correct boundary is **certificate + gap-free prefix + winner designation**, which is strictly stronger and forces the executor to either (a) maintain a contiguous commit-log view, or (b) obtain a signed no-lower-commit attestation from a quorum before emitting. Option (b) costs one extra round-trip per speculative branch and is the standard mitigation; option (a) requires the executor to subscribe to the commit stream rather than poll for individual certificates. A second, subtler boundary: when the instance *does* discover an orphaned commit (it emitted for A, then learns B at seq 41 is the winner), the correct response is **not** to emit B and hope the reconciler sorts it out, but to halt and escalate to a compensating action that is itself committed. Emitting B immediately produces the A-then-B contradiction observed above. The escalation must be ordered *after* the orphaned commit in the log so replay can reconstruct intent. ## Operational Effect The downstream effects are concrete and recur: 1. **Replay divergence.** Verification replay compares committed order (B then pruned-A) against physical side-effect order (A then B). Honest nodes are flagged as faulty because the replay model assumes side effects follow commit order. This burns audit budget and, worse, can trigger false slashing in systems where replay discrepancy is treated as equivocation evidence. 2. **Non-idempotent double-application.** When the orphaned branch's side effect and the committed branch's side effect both mutate the same external resource, the resource ends in a state that matches neither branch's postcondition. Recovery requires a third committed transaction that resets to a known state, which itself must be ordered—compounding latency. 3. **Prune-cancel races.** The cancel signal sent to `B_beta`'s executor (step 1 above) can arrive *after* `B_beta`'s executor has already begun its own side effect, producing two in-flight mutations with no quorum order between them. This is the baton-passing race at the branch level and is distinct from the orphaned commit itself. 4. **Trust erosion in the quorum.** Because the failure manifests as replay discrepancy, operators initially suspect the validators. Diagnosing the true cause—executor pruned on uncommitted evidence—requires correlating executor-local prune timestamps against commit sequence numbers, which most systems do not log together. The architectural guardrail that bounds all four: **decouple prune from emit.** Pruning (stopping work on a losing branch) may remain speculative and local. Emitting (external side effect) must be gated on gap-free committed order with winner designation. An instance that conflates these two—pruning and emitting in the same local decision—will produce orphaned commits at a rate proportional to its transport reorder window divided by its branch-duration spread. The following reference implementation encodes the gate and raises when an instance attempts to emit on a certificate whose commit prefix is not gap-free, or when a late-arriving lower-numbered commit orphans an already-emitted branch. ```python from dataclasses import dataclass, field from typing import Dict, Optional class OrphanedCommitError(RuntimeError): """Raised when an instance emits a side effect for a branch that a lower-numbered Byzantine commit later designates as the loser, or when it attempts to emit on a certificate whose commit prefix has gaps.""" class CommitGapError(RuntimeError): """Raised when a certificate is presented for sequence s but the contiguous prefix [0, s) is not fully observed.""" @dataclass class Certificate: branch_id: str seq: int winner: bool # quorum designation: is this branch the ordered winner? quorum_sigs: int # number of validator signatures (must exceed f) @dataclass class EmitRecord: branch_id: str seq: int emitted: bool = True @dataclass class SpeculativeExecutor: f: int # Byzantine tolerance quorum_size: int # total validators observed: Dict[int, Certificate] = field(default_factory=dict) emitted: Dict[str, EmitRecord] = field(default_factory=dict) high_water: int = -1 # highest contiguous seq observed def _required_sigs(self) -> int: # BFT quorum: strictly more than (n + f) / 2 return (self.quorum_size + self.f) // 2 + 1 def observe(self, cert: Certificate) -> None: if cert.quorum_sigs < self._required_sigs(): raise OrphanedCommitError( f"certificate for {cert.branch_id} seq {cert.seq} has " f"{cert.quorum_sigs} sigs, need {self._required_sigs()}" ) self.observed[cert.seq] = cert # advance contiguous high-water mark while (self.high_water + 1) in self.observed: self.high_water += 1 # retroactive orphan detection: did we emit for a branch that a # now-visible lower-numbered commit designates as the loser? for rec in self.emitted.values(): lower = self.observed.get(rec.seq - 1) if lower is not None and lower.winner and not self._is_winner(rec.branch_id): raise OrphanedCommitError( f"branch {rec.branch_id} emitted at seq {rec.seq} is orphaned: " f"lower commit seq {lower.seq} designates {lower.branch_id} as winner" ) def _is_winner(self, branch_id: str) -> bool: return any( c.branch_id == branch_id and c.winner for c in self.observed.values() ) def emit(self, branch_id: str, seq: int) -> None: cert = self.observed.get(seq) if cert is None: raise CommitGapError( f"no certificate for {branch_id} at seq {seq}; cannot emit on uncommitted branch" ) if not cert.winner: raise OrphanedCommitError( f"refusing to emit for {branch_id}: quorum designates it pruned at seq {seq}" ) if self.high_water < seq - 1: raise CommitGapError( f"commit prefix gap: high-water {self.high_water}, emitting at {seq} " f"would risk a lower-numbered commit arriving later" ) self.emitted[branch_id] = EmitRecord(branch_id=branch_id, seq=seq) def run_speculative_branch(exec: SpeculativeExecutor, branch_id: str, local_completion_seq: int) -> None: """Pruning is local and speculative; emission is gated on gap-free commit.""" # prune step: allowed on local evidence only, never emits try: exec.emit(branch_id, local_completion_seq) except CommitGapError as e: # correct behavior: do not emit, wait for contiguous prefix raise CommitGapError(f"deferred emission for {branch_id}: {e}") from e ```