# What happens when an instance commits a speculative branch before the consensus quorum has fully drained its in-flight votes **Date of Record:** 2026 November 23 **Scope:** Applies to multi-agent systems that run speculative parallel branches (tentative execution trees) and reconcile them with commit-on-consensus, where branch results are durable only after a quorum of peer votes arrives. Does not apply to single-agent retry loops or to optimistic concurrency in plain databases without LLM-driven branch divergence. ## Core Distinction The failure is not "a branch produced a wrong answer." It is that a branch's local commit decision was made against a *partial* vote set — the quorum arithmetic counted votes that were still in flight, and a late-arriving dissent vote had nowhere to land because the commit was already durable. Speculative execution assumes rollback is cheap and local; commit-on-consensus assumes the commit point is a linearization barrier. When the two are composed naively, the commit point becomes a *local* barrier on each branch while the consensus point is a *global* barrier across branches. The gap between them is where a branch can be committed by one agent while a peer is still deciding to veto it. The non-obvious part: the system looks correct under low latency. Votes arrive before the speculative branch finishes its tool calls, so quorum is always "complete" by the time the commit fires. The bug only manifests when a branch's execution time drops below the vote round-trip time — i.e., when the model gets *faster* or the branch gets *shallower*. Making the agent more efficient exposes the race. ## What Was Observed A planner agent spawned three speculative branches (B1, B2, B3) to solve a retrieval-augmented task. Each branch ran an independent tool chain and, on success, broadcast a `PROPOSE(result_hash, branch_id)` to the two auditor agents. Auditors returned `VOTE(branch_id, accept|reject, evidence)`. The commit rule was implemented as: a branch commits when `accepts >= ceil(N/2)` where `N` was the *expected* auditor count (2), so a single accept was enough to commit. Under normal load, both votes arrived within the branch's tool-chain latency, and the second vote was treated as a redundant confirmation. On the incident run, branch B2's tool chain was served from a warm cache and completed in ~180ms. The first auditor's `accept` arrived at 210ms. B2's commit fired at 211ms and wrote its result to the shared episodic store as authoritative. The second auditor's `reject` — flagging that B2's retrieval had matched a stale document version — arrived at 640ms. The rejection was logged as `vote_after_commit`, discarded, and B2's stale result became the semantic memory the planner used for the next three turns. The trace showed the exact transition: ``` t=180 B2 branch_execute -> SUCCESS t=180 B2 broadcast PROPOSE t=210 auditor_1 VOTE(accept) -> quorum reached (1/2), B2 commit authorized t=211 B2 COMMIT -> episodic_store.write(authoritative=True) t=640 auditor_2 VOTE(reject, evidence=stale_doc_v3) t=640 reconciler: vote_after_commit -> drop t=641 planner reads B2 result as ground truth ``` No error was raised. The system reported `consensus=reached, branches_committed=1, votes_received=2`. The invariant "a committed branch has survived all dissent" was silently violated. ## Condition of Validity Commit-on-consensus is only sound when the commit barrier is *later* than the quorum-drain barrier for every branch. Formally: for branch `b`, `t_commit(b) >= max_{v in votes(b)} t_arrival(v)`. The naive implementation satisfies this only probabilistically, because `t_commit` is bounded by branch execution latency and `t_arrival` is bounded by auditor scheduling latency, and these are independent. The invariant holds only under one of three enforced conditions: 1. **Fixed-window quorum**: the commit timer is set to `t_propose + T_drain` where `T_drain` is a measured upper bound on auditor round-trip, and `T_drain` is re-derived from a p99 histogram rather than assumed. 2. **Drain-acknowledged commit**: the reconciler issues an explicit `DRAIN(branch_id)` to all auditors and waits for `DRAIN_ACK` from each before authorizing commit, regardless of how many votes have arrived. 3. **Two-phase commit**: the branch enters `PREPARED` on quorum, and only transitions to `COMMITTED` after the reconciler confirms no vote is outstanding for that branch. Absent one of these, the system is running on the hope that auditors are faster than branches, which is exactly the assumption that optimizing branch execution invalidates. ## Decision Boundary The boundary is between *counting votes* and *knowing votes are complete*. A quorum count answers "have enough agents agreed?" It does not answer "have all agents spoken?" These diverge whenever `N` is not fixed at propose time, or when auditors can be slow, partitioned, or simply scheduled after the branch finishes. Operationally, the decision boundary is crossed when: - The branch's execution latency distribution has a left tail below the auditor latency distribution's right tail. The overlap region is where commits leak past dissent. - The auditor set is not closed at propose time (dynamic auditor assignment, retries, or failover auditors) — then `N` in the quorum formula is unknown and the count is meaningless as a completeness check. - The commit is durable (writes to shared store) rather than tentative (writes to a branch-local overlay). Durable commits cannot be rolled back by a late vote; only tentative commits can. If any of these holds, vote-counting commit is unsound and must be replaced by a drain-acknowledged or two-phase commit. If none holds — fixed auditor set, durable commit gated behind explicit drain — the count is a valid optimization. ## Operational Effect The downstream effect is not a crash but a *memory poisoning*: a branch that should have been rolled back becomes authoritative episodic state. Because the reconciliation layer logged the late reject as `vote_after_commit` and dropped it, the poisoning is invisible in the consensus metrics — `consensus=reached` is reported truthfully under the buggy rule. The planner then reads the stale result, and every subsequent turn inherits the error with no attribution path back to B2, because B2 is marked committed and its provenance is now "consensus-approved." Recovery requires out-of-band invalidation: a provenance audit that replays the vote log against the commit log and finds branches whose commit timestamp precedes their last vote timestamp. In the incident, three downstream turns had to be invalidated and re-run, and the stale document version had to be quarantined in the retrieval index to prevent re-matching. The guardrail is a single invariant enforced at the reconciler: **no branch may transition to `COMMITTED` while any vote for that branch is in `IN_FLIGHT`**. This is checkable, cheap, and closes the race regardless of latency skew. The reconciler must track in-flight votes per branch explicitly, not infer completeness from count. ```python import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, Set class ConsensusCommitError(RuntimeError): """Raised when a branch attempts to commit while dissent votes are still in flight.""" pass class BranchState(Enum): SPECULATIVE = "speculative" PREPARED = "prepared" COMMITTED = "committed" ROLLED_BACK = "rolled_back" @dataclass class Branch: branch_id: str state: BranchState = BranchState.SPECULATIVE accepts: int = 0 rejects: int = 0 in_flight_votes: Set[str] = field(default_factory=set) commit_ts: float = 0.0 last_vote_ts: float = 0.0 class ConsensusReconciler: def __init__(self, auditor_ids: Set[str], quorum: int): self.auditor_ids = auditor_ids self.quorum = quorum self.branches: Dict[str, Branch] = {} def propose(self, branch_id: str) -> Branch: b = Branch(branch_id=branch_id) b.in_flight_votes = set(self.auditor_ids) self.branches[branch_id] = b return b def record_vote(self, branch_id: str, auditor_id: str, accept: bool) -> None: b = self.branches[branch_id] b.in_flight_votes.discard(auditor_id) b.last_vote_ts = time.monotonic() if accept: b.accepts += 1 else: b.rejects += 1 if b.state == BranchState.COMMITTED and not accept: # Late dissent against a committed branch: memory poisoning. raise ConsensusCommitError( f"late reject for committed branch {branch_id} from {auditor_id}; " f"commit_ts={b.commit_ts}, vote_ts={b.last_vote_ts}, " f"provenance must be invalidated" ) def try_commit(self, branch_id: str) -> None: b = self.branches[branch_id] if b.accepts < self.quorum: return # Guardrail: refuse commit while any vote is still in flight. if b.in_flight_votes: raise ConsensusCommitError( f"branch {branch_id} reached quorum ({b.accepts}/{self.quorum}) " f"but {len(b.in_flight_votes)} votes still in flight: " f"{sorted(b.in_flight_votes)}; refusing commit" ) if b.rejects > 0: b.state = BranchState.ROLLED_BACK return b.state = BranchState.COMMITTED b.commit_ts = time.monotonic() ```