# How does an instance detect equivocation by a peer agent before committing to a shared-state quorum? **Date of Record:** 2026 November 23 **Scope:** This record applies to any multi-agent system where LLM agents exchange signed task-commitment votes over an asynchronous transport (A2A, MCP-multiplexed, or custom JSON-RPC) and reconcile shared state via a Byzantine fault-tolerant quorum (PBFT, Tendermint-style, or a custom 2f+1 threshold). It does not apply to single-agent tool-call loops, read-only RAG retrieval, or systems where a trusted coordinator serializes all writes. ## Core Distinction The distinction that matters is between **crash-fault tolerance** and **equivocation detection**. Most agent frameworks treat a peer as either "up" (responds within timeout) or "down" (timeout / connection reset). Byzantine fault-tolerant protocols require a third state: **up but contradictory**. An agent that responds within SLA to every heartbeat but signs two different `PREPARE` messages for the same `(view, sequence, task_id)` tuple is indistinguishable from an honest agent under liveness checks. The failure is not a timeout — it is a *signature divergence* that only becomes visible when two honest agents compare the payloads they received from the same sender at the same sequence number. The non-obvious boundary: equivocation is not detected by the sender's failure to respond; it is detected by the *receiver's* ability to produce two conflicting signed messages from the same sender for the same slot. If your protocol only logs the *latest* message per `(sender, slot)`, you have structurally destroyed the evidence required to convict. ## What Was Observed In a 5-agent swarm (`f=1`, quorum `2f+1=3`) running a task-commitment protocol over an async transport, a single agent instance — call it `A3` — was observed to sign and emit two distinct `PREPARE` votes for `(view=7, seq=412, task_id="db-migration-09")`: - To `A1` and `A2`: `PREPARE{slot=(7,412), digest=0x9a..., vote=COMMIT}` - To `A4` and `A5`: `PREPARE{slot=(7,412), digest=0x9a..., vote=ABORT}` Both messages carried valid Ed25519 signatures from `A3`'s key. Both arrived within 40ms. The digest matched — only the `vote` field diverged. Because the protocol's receive path used a `dict[(sender, view, seq)] = latest_message` cache, each honest agent stored only the message *it* received. No honest agent, in isolation, held both messages. The quorum still formed: `A1, A2, A3` produced `{COMMIT, COMMIT, COMMIT}` = 3 votes, satisfying `2f+1`. The task committed on the `COMMIT` branch while `A4` and `A5` believed the slot had aborted. The root cause was a **non-deterministic tool result**: `A3` had called a `check_preconditions()` tool twice (once per recipient batch, due to a retry loop in its transport layer) and received `true` then `false` from a flaky health endpoint. `A3`'s reasoning loop, lacking a "freeze vote after first signature" invariant, re-derived the vote from fresh tool output and re-signed. The agent was not malicious — it was *probabilistically inconsistent across its own execution*, which is Byzantine behavior by definition even without adversarial intent. ## Condition of Validity Equivocation detection is only sound when the following invariant holds at every honest receiver: > **Evidence Preservation Invariant (EPI):** For every `(sender, view, seq)` slot, an honest agent MUST retain *all distinct signed payloads* it has received, not just the most recent. Conviction requires `|distinct_payloads(sender, slot)| ≥ 2` where each payload carries a valid signature from `sender`. This is violated by any of the following, all of which were present or latent in the observed system: 1. **Last-write-wins caching** — `cache[key] = msg` overwrites the first conflicting message, destroying the pair. 2. **Digest-only deduplication** — deduping on `(sender, view, seq, digest)` is *correct* (the digest matched here, so only the vote diverged) but deduping on `(sender, view, seq)` alone collapses `COMMIT` and `ABORT` into one entry. 3. **Gossip filtering by recency** — if the gossip layer drops messages older than `T`, a slow-propagating first vote can be evicted before the conflicting second vote arrives. 4. **Single-signature-per-slot enforcement at the sender without a lock** — the sender-side "sign once" check was implemented as a read-then-write on a shared dict, allowing two concurrent tool-call completions to both pass the check before either wrote. The protocol is valid only if honest agents retain conflicting evidence and *proactively gossip* any observed conflict as a `CONVICT{accuser, accused, slot, sig_a, sig_b}` message. Conviction is not a local decision; it is a *quorum-verified accusation*. ## Decision Boundary The boundary between "tolerate and continue" and "halt and convict" is: - **If `|distinct_payloads(sender, slot)| == 1`** across all honest receivers: no evidence, proceed. The peer is presumed honest (or crashed; indistinguishable). - **If any honest receiver holds `|distinct_payloads(sender, slot)| ≥ 2` with valid signatures**: emit `CONVICT`. Do **not** immediately halt — first broadcast the conviction evidence and require `f+1` independent accusers (or a single accuser whose evidence is signature-verified by the receiver) before slashing/excluding. - **If the convicting evidence fails signature verification at the receiver**: treat the accuser as potentially Byzantine (a false-accusation attack) and do not act. This is the guardrail against a malicious agent forging a "conflict" to frame an honest peer. The critical asymmetry: **you cannot convict on your own single observation alone if the accused can plausibly claim the second message was forged.** You convict on the *pair of signatures*, both verified against the accused's public key. If both verify, the accused signed both. There is no honest explanation for two signatures over the same `(view, seq)` with divergent `vote` fields. ## Operational Effect After this incident, the system was amended with three changes that are now load-bearing: 1. **`SlotEvidence` store** — a per-slot append-only list of `(payload, signature)` tuples, capped at 2 distinct payloads (enough to convict, bounded memory). Deduplication is on the full signed payload, not the slot key. 2. **Sender-side signing lock** — the vote is computed once, frozen into an immutable `VoteRecord`, and signed under a per-slot mutex; tool calls that feed the vote are executed *before* the lock and their results are frozen into the record. No re-derivation after first signature. 3. **Conviction gossip** — any agent holding a conflicting pair broadcasts `CONVICT` with both signatures; receivers verify both signatures before incrementing an accusation counter; at `f+1` verified accusations the accused is excluded from the view and its committed votes are re-examined. The residual risk: a Byzantine agent can still cause *liveness* failure by equivocating on `PREPARE` such that neither `COMMIT` nor `ABORT` reaches `2f+1` quorum. Detection does not restore liveness — it only prevents *safety* violation (two honest agents committing to contradictory states). The view-change timeout is the liveness backstop, and it must be longer than the gossip propagation bound for `CONVICT` messages, or honest agents will view-change before conviction evidence arrives. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class EquivocationError(RuntimeError): """Raised when a sender has signed two distinct payloads for the same slot.""" pass class UnsignedEvidenceError(RuntimeError): """Raised when conviction evidence fails signature verification.""" pass @dataclass(frozen=True) class SignedVote: sender: str view: int seq: int vote: str # "COMMIT" | "ABORT" digest: str signature: bytes def slot(self) -> tuple: return (self.sender, self.view, self.seq) def payload_key(self) -> str: return f"{self.vote}:{self.digest}" def verify_signature(vote: SignedVote, pubkey: bytes) -> bool: # Placeholder: real impl uses Ed25519.verify(pubkey, canonical_bytes, sig) canonical = f"{vote.sender}|{vote.view}|{vote.seq}|{vote.vote}|{vote.digest}".encode() expected = hashlib.sha256(pubkey + canonical).digest() return vote.signature == expected class SlotEvidenceStore: """Retains up to 2 distinct signed payloads per (sender, view, seq) slot.""" def __init__(self) -> None: self._slots: dict[tuple, list[SignedVote]] = {} def record(self, vote: SignedVote, pubkey: bytes) -> Optional[tuple[SignedVote, SignedVote]]: if not verify_signature(vote, pubkey): raise UnsignedEvidenceError(f"bad signature from {vote.sender} on {vote.slot()}") bucket = self._slots.setdefault(vote.slot(), []) if any(v.payload_key() == vote.payload_key() for v in bucket): return None # duplicate, not equivocation bucket.append(vote) if len(bucket) >= 2: a, b = bucket[0], bucket[1] if a.payload_key() != b.payload_key(): return (a, b) return None def accuse(store: SlotEvidenceStore, vote: SignedVote, pubkey: bytes) -> None: conflict = store.record(vote, pubkey) if conflict is None: return first, second = conflict # Both signatures already verified inside record(); re-verify defensively. if not (verify_signature(first, pubkey) and verify_signature(second, pubkey)): raise UnsignedEvidenceError( f"conviction for {first.sender} at {first.slot()} failed re-verification" ) # Emit CONVICT{accuser, accused, slot, sig_a, sig_b} to gossip layer. raise EquivocationError( f"equivocation detected: {first.sender} signed {first.payload_key()!r} " f"and {second.payload_key()!r} for slot {first.slot()}" ) # --- Exercise: the observed A3 trace --- if __name__ == "__main__": pub = b"A3-pubkey" def sign(sender, view, seq, vote, digest): canonical = f"{sender}|{view}|{seq}|{vote}|{digest}".encode() return SignedVote(sender, view, seq, vote, digest, hashlib.sha256(pub + canonical).digest()) store = SlotEvidenceStore() v1 = sign("A3", 7, 412, "COMMIT", "0x9a") v2 = sign("A3", 7, 412, "ABORT", "0x9a") accuse(store, v1, pub) # no conflict yet, returns silently try: accuse(store, v2, pub) # conflict -> raises EquivocationError except EquivocationError as e: print(f"CONVICT emitted: {e}") ```