# How does an instance detect equivocation in a Byzantine tool-call commitment quorum before committing side effects? **Date of Record:** 2026 November 29 **Scope:** Applies to multi-agent quorums (n ≥ 3f+1) where each replica proposes a deterministic tool-call commitment (hash of tool name, arguments, and pre-state) and a leader broadcasts an ordered batch for commit. Does not apply to single-agent tool loops, non-replicated execution, or quorums where tool calls are idempotent and side-effect-free. ## Core Distinction The failure mode is not "a replica lies." It is that a correct replica cannot distinguish **equivocation by the leader** from **message reordering by the transport** using only the per-batch payload it receives. Both present identically at the receiver: two conflicting commitment hashes for the same `(batch_id, slot)` arriving from the same leader identity. The distinction that matters is whether a replica has enough *signed, causally ordered* evidence to prove the leader signed both — because a Byzantine leader that sends `commit(H_A)` to replicas {1,2} and `commit(H_B)` to replicas {3,4} produces a state where each honest replica locally sees a consistent history and will happily execute its tool call. The side effect fires on both halves of the partition before any replica learns the quorum was split. Detection therefore cannot be local; it must be a property of the *commit certificate*, not the *message*. The invariant that bounds this: **no replica may execute a tool call until it holds a commit certificate containing ≥ 2f+1 distinct signed `prepare` messages for the exact same commitment hash, where the signatures bind the batch_id, slot, and hash together.** A bare `commit` message from the leader is never sufficient, no matter how many arrive, because the leader is the party under suspicion. ## What Was Observed A four-replica quorum (f=1, so 2f+1=3) running a leader-driven commit protocol over a tool-call batch. Leader L sent `prepare(H_A)` to R1 and R2, and `prepare(H_B)` to R3 and R4, where H_A and H_B are commitments to *different* argument sets for the same tool invocation (e.g., `transfer(amount=100)` vs `transfer(amount=1000)`). Each replica collected 2 prepares — one short of the 3 required — so none should have committed. The bug: replicas counted the leader's own `prepare` as a signature and additionally accepted a `commit` message as implicit endorsement of whatever hash it had locally prepared. R1 received `prepare(H_A)` from L and from R2, plus a `commit` from L referencing "the batch." R1 tallied 3 endorsements for H_A and executed. R3 did the same for H_B. Both tool calls fired. The two halves of the quorum executed mutually exclusive side effects against the same pre-state, and the divergence was only caught at the next checkpoint when R1 and R2's post-state hash disagreed with R3 and R4's. The tell — visible in logs after the fact — was that no replica ever held a certificate with three *distinct signers* over the *same* hash. R1's third "endorsement" was the leader's commit message, which carried no hash binding and was interpreted against local state. The equivocation was real but each replica's local view was internally consistent, which is exactly why local validation passed. ## Condition of Validity The guardrail holds only under three conditions, and fails silently if any is dropped: 1. **Signature binding.** Each `prepare` signature must cover `(batch_id, slot, commitment_hash, view)`. A signature over just `batch_id` lets a leader reuse one replica's signature across two hashes by changing the payload after the fact. 2. **Distinct-signer counting.** The certificate must be a set keyed by replica identity, not a message count. The leader's own `prepare` counts as at most one signer, and a `commit` message never counts as a prepare endorsement. 3. **View monotonicity.** Certificates from a stale view must be rejected. A Byzantine leader can replay a valid 2f+1 certificate from view `v-1` for hash H_A while running view `v` with H_B; without view-binding in the signature and a local `current_view` check, the old certificate is accepted and the stale tool call executes. If signatures are bound but the replica accepts a certificate whose `view` is behind its local view, the equivocation window reopens across view changes — this is the most common regression, because it looks like a liveness fix ("accept late certificates to avoid stalls"). ## Decision Boundary The replica must draw a hard line between *collecting* and *committing*: - On receiving a `prepare` for a hash differing from one already prepared in the same `(batch_id, slot, view)`: do **not** overwrite. Retain both, mark the slot `CONFLICTING`, and broadcast both signed prepares as equivocation evidence. A replica that silently takes the latest prepare is the one that gets split. - On receiving a `commit`: treat it as a *hint to fetch the certificate*, never as authority. If the accompanying certificate has < 2f+1 distinct signers over the exact bound tuple, reject and do not execute. - On conflict evidence from any peer (a pair of leader-signed prepares over different hashes for the same slot): halt execution of that slot unconditionally and enter view change. This is the only path where a single peer's report is sufficient — because the evidence is self-authenticating (two signatures, one leader, one slot, two hashes). The boundary is: **execute iff certificate valid; halt iff conflict evidence present; otherwise wait.** There is no "execute optimistically and reconcile" branch. ## Operational Effect With the invariant enforced, the split-quorum scenario degrades from *double side effect* to *liveness stall*. Neither R1 nor R3 reaches 2f+1 distinct signers over a single hash, both time out, and the view-change protocol elects a new leader that proposes a single hash with a valid certificate. The tool call executes exactly once. The cost is a latency spike bounded by the view-change timeout; the benefit is that mutually exclusive side effects never both fire. The residual risk is evidence propagation latency: a replica that has already collected a valid certificate for H_A may execute before the conflict evidence from the other partition arrives. This is why the certificate must be *quorum-intersecting* — any two 2f+1 quorums in an n=3f+1 system share at least one honest replica, so at most one hash can ever reach certificate threshold. The invariant is not "detect equivocation fast"; it is "make equivocation unable to produce two certificates." Detection is a fallback for the case where the counting logic itself is buggy, and the code below is the last line of that defense. ```python from dataclasses import dataclass, field from typing import Dict, Set, Tuple, Optional @dataclass(frozen=True) class Commitment: batch_id: str slot: int view: int hash: str @dataclass class Prepare: commitment: Commitment signer: str # replica id signature: bytes # binds (batch_id, slot, view, hash) class EquivocationDetected(RuntimeError): """Raised when a leader has signed conflicting commitments for one slot.""" pass class InsufficientCertificate(RuntimeError): """Raised when a commit is attempted without 2f+1 distinct signers.""" pass class CommitGuard: def __init__(self, n: int, f: int, local_view: int): self.n, self.f = n, f self.local_view = local_view self.prepares: Dict[Tuple[str, int], Dict[str, Prepare]] = {} self.conflicts: Set[Tuple[str, int]] = set() def _key(self, c: Commitment) -> Tuple[str, int]: return (c.batch_id, c.slot) def on_prepare(self, p: Prepare) -> None: c = p.commitment if c.view < self.local_view: return # stale view: ignore, never execute key = self._key(c) slot_map = self.prepares.setdefault(key, {}) existing = slot_map.get(p.signer) if existing is not None and existing.commitment.hash != c.hash: # Same signer, same slot, different hash -> self-authenticating equivocation. self.conflicts.add(key) raise EquivocationDetected( f"signer {p.signer} signed {existing.commitment.hash} and {c.hash} " f"for {key} in view {c.view}" ) slot_map[p.signer] = p def certificate_signers(self, c: Commitment) -> Set[str]: key = self._key(c) if key in self.conflicts: raise EquivocationDetected(f"slot {key} is conflicted; refusing certificate") return { signer for signer, p in self.prepares.get(key, {}).items() if p.commitment.hash == c.hash and p.commitment.view == c.view } def try_commit(self, c: Commitment) -> bool: if self._key(c) in self.conflicts: raise EquivocationDetected(f"cannot commit conflicted slot {self._key(c)}") signers = self.certificate_signers(c) if len(signers) < 2 * self.f + 1: raise InsufficientCertificate( f"hash {c.hash} for {self._key(c)} has {len(signers)} distinct " f"signers, need {2 * self.f + 1}" ) return True # caller may now execute the tool call exactly once ```