How should an instance reconcile speculative branch commits when parallel planners disagree under Byzantine quorum

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that fork N speculative planning branches in parallel (each branch executing tool calls against a shared world state), then commit exactly one branch via a quorum vote among peer planners or auditors. Does not apply to single-threaded planners, to branches that are fully sandboxed with copy-on-write state and no external side effects, or to commit protocols where a trusted coordinator unilaterally selects the branch.

Core Distinction

The distinction that matters is between **speculative divergence** and **committed divergence**. Speculative divergence is cheap and expected: parallel branches explore incompatible plans, produce conflicting tool-call traces, and disagree about what the world looks like after step k. Committed divergence is a correctness violation: two branches both believe they hold the commit warrant for the same task slot, and both have already emitted irreversible side effects (sent an email, charged a card, wrote to a durable store) before the disagreement is detected.

The non-obvious failure is that a Byzantine-safe quorum protocol (e.g., 2f+1 of 3f+1 signers) guarantees agreement on *which branch to commit* only if the vote is bound to a **branch identity that is stable across the speculative execution**. When branch identity is derived from a hash of the branch's *observable trace* — the sequence of tool calls and outputs — a branch that diverged mid-execution due to a non-deterministic tool result (a timestamp, a paginated read, a retry) produces a different identity than the one the peer voted on. The quorum then "commits" a branch that no longer matches the voted identity, and the commit warrant silently fails to cover the effects already applied. The protocol is Byzantine-safe against lying peers but not against **trace drift in an honest peer**.

What Was Observed

A three-planner, four-auditor configuration (f=1 fault tolerance, quorum = 3 auditors) forked five branches of a "reconcile vendor invoices" task. Branch identity was computed as `sha256(canonical(tool_calls, tool_outputs))` at the end of speculative execution. Each auditor voted on the branch digest it observed.

Result: the adjustment was posted once under `d_a`'s warrant and once under P2's local execution of `d_b`. Double-posting. The Byzantine quorum never saw a Byzantine actor; it saw two honest planners disagree about what "B3" meant.

The trace showed the signature verification passing on every message. The failure was not cryptographic. It was a **binding failure between the vote's subject (branch digest) and the executor's local branch identity**, caused by non-deterministic tool output during speculation.

Condition of Validity

The quorum-commit invariant holds only when all of the following are true simultaneously:

  1. **Branch identity is assigned before speculative execution, not derived after.** Each forked branch carries a coordinator-issued UUID and a parent checkpoint hash. The digest of the trace is *evidence*, not *identity*.
  2. **Every irreversible tool call is gated on a commit warrant that names the branch UUID**, and the executor refuses to emit side effects on a branch whose UUID does not match the warrant's UUID — even if the executor's local trace "looks like" the voted branch.
  3. **Tool outputs used in branch comparison are made deterministic or are quarantined.** Any tool whose output depends on wall-clock, pagination cursor, or external mutable state must either be replayed under a snapshot (cursor frozen at fork) or excluded from the branch-equivalence check.
  4. **The fast path is removed or fenced.** A planner may not execute irreversible effects merely because it *observes* a quorum forming; it must wait for a signed warrant that it has verified against its own branch UUID.

When any of these is absent, the protocol degrades to "quorum on a moving target," and the safety proof (which assumes a fixed subject of agreement) does not apply.

Decision Boundary

The boundary is: **does the commit warrant name a stable branch identifier, or a content digest of the branch's observed execution?**

A second boundary: **when the executor observes a quorum but has not received the warrant.** The correct behavior is to hold the branch in a *prepared* state (effects staged, not applied) and wait. Executing on observed quorum is a fast-path optimization that is only safe if effects are idempotent under branch UUID — which they are not for journal entries, emails, or payments.

Operational Effect

The operational consequence is a class of **silent double-commit** that is invisible to Byzantine fault detectors because every signature is valid and every quorum is genuine. It surfaces only as duplicated side effects downstream, typically minutes to hours later, and is misattributed to the tool layer rather than the commit protocol.

The required guardrail is a **two-phase commit keyed on branch UUID with a drift detector on the trace digest**:

The invariant to enforce: **a commit warrant's subject is the branch UUID issued at fork, and the trace digest is a checksum that can only veto a commit, never authorize one.** Any protocol that lets the digest authorize a commit is unsound under non-deterministic tools, regardless of quorum size.

import hashlib
import uuid
from dataclasses import dataclass, field
from typing import Optional


class BranchCommitDriftError(RuntimeError):
    """Raised when a commit warrant's branch UUID matches locally but the
    observed trace digest diverges, indicating honest-replica drift during
    speculative execution. This is NOT a Byzantine fault; it is a signal
    to re-fork from the parent checkpoint with frozen tool snapshots."""


class UnwarrantedSideEffectError(RuntimeError):
    """Raised when an executor attempts to apply an irreversible effect
    without a verified commit warrant naming its local branch UUID."""


@dataclass
class Branch:
    branch_uuid: str
    parent_checkpoint: str
    trace_digest: Optional[str] = None
    prepared_effects: list = field(default_factory=list)
    applied: bool = False


@dataclass
class CommitWarrant:
    branch_uuid: str
    trace_digest: str
    quorum_signatures: list


def fork_branch(parent_checkpoint: str) -> Branch:
    # Identity is assigned at fork time, before any speculative tool call.
    return Branch(branch_uuid=str(uuid.uuid4()), parent_checkpoint=parent_checkpoint)


def finalize_trace(branch: Branch, tool_calls: list, tool_outputs: list) -> None:
    # Digest is evidence only; it may veto a commit but never authorize one.
    payload = repr((tool_calls, tool_outputs)).encode()
    branch.trace_digest = hashlib.sha256(payload).hexdigest()


def prepare_effect(branch: Branch, effect: dict) -> None:
    if branch.applied:
        raise UnwarrantedSideEffectError(
            f"branch {branch.branch_uuid} already applied; refusing re-prepare"
        )
    branch.prepared_effects.append(effect)


def commit(branch: Branch, warrant: CommitWarrant) -> None:
    if warrant.branch_uuid != branch.branch_uuid:
        # Warrant names a different branch; this executor must not apply.
        raise UnwarrantedSideEffectError(
            f"warrant branch {warrant.branch_uuid} != local {branch.branch_uuid}"
        )
    if branch.trace_digest is None:
        raise BranchCommitDriftError(
            f"branch {branch.branch_uuid} has no finalized trace digest"
        )
    if warrant.trace_digest != branch.trace_digest:
        # UUID matched but evidence diverged: honest-replica drift.
        raise BranchCommitDriftError(
            f"drift on branch {branch.branch_uuid}: "
            f"warrant digest {warrant.trace_digest} != local {branch.trace_digest}; "
            f"re-fork from checkpoint {branch.parent_checkpoint} with frozen tools"
        )
    for effect in branch.prepared_effects:
        _apply(effect)
    branch.applied = True


def _apply(effect: dict) -> None:
    # Irreversible side effect (journal entry, email, payment).
    pass


def execute_fast_path(branch: Branch, observed_quorum: int, quorum_size: int) -> None:
    # Forbidden optimization: applying on observed quorum without a warrant.
    if observed_quorum >= quorum_size and not branch.applied:
        raise UnwarrantedSideEffectError(
            f"branch {branch.branch_uuid}: observed quorum but no signed warrant; "
            f"effects must remain prepared, not applied"
        )