# How should an instance detect equivocating plan commitments before Byzantine quorum finalization collapses **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent systems where N ≥ 3f+1 planner/executor instances reach a *commitment quorum* over a shared plan (step ordering, resource locks, or effect-fulfilling tool calls) under a Byzantine fault-tolerance assumption of up to f faulty agents. Does not apply to single-agent planning, leaderless best-effort swarms without a commitment phase, or systems where all agents share one trusted serialization point (e.g., a single transactional store). ## Core Distinction There are two ways a plan commitment can "succeed" in a BFT multi-agent swarm, and they are not the same: 1. **Quorum-signature success** — the agent collected ≥ 2f+1 distinguishable signed `PREPARE`/`COMMIT` votes over a plan digest and finalized it. 2. **Semantic commitment success** — the ≥ 2f+1 agents that signed actually agreed on the *same effect-bearing step sequence*, not merely on a hash that each independently derived from a differently-interpreted plan. The failure mode this record isolates is the gap between them: **equivocating commitment under digest aliasing**. A Byzantine agent does not need to forge signatures or break the quorum threshold. It only needs to exploit the fact that two semantically distinct plans can collapse to the same commitment digest — or that the digest is computed over a canonicalization an honest agent can be induced to disagree with — so that a quorum *appears* to have committed to plan A while a disjoint 2f+1-adjacent set believes it committed to plan B. The invariant that must hold is stronger than threshold counting: **the commitment predicate must be a collision-resistant, canonical, and independently re-derivable function of the effect-bearing plan, and finalization must require each voter to reveal the plan bytes it hashed, not just the hash.** ## What Was Observed Setup: a 7-instance swarm (f = 2, so quorum = 2f+1 = 5) running a three-phase commit protocol (`PROPOSE` → `PREPARE` → `COMMIT`) over plans serialized as JSON. The commitment digest was `SHA256(canonical_json(plan))`. A plan is a list of steps, each with `tool`, `args`, and a `depends_on` edge list. The trace that broke: 1. The proposer (honest) emits plan P₁: steps `[deploy(canary, weight=0.1), verify(metric=err_rate), promote(weight=1.0)]`. 2. A Byzantine instance B, acting as a *relay* (it received the proposal first and forwards it), re-serializes P₁ before forwarding. Its canonicalizer sorts `depends_on` edges and drops `null` fields, but *also* normalizes float `weight=0.1` to string `"0.1"` in `args`. The proposer's canonicalizer kept the float. Both serialize to valid JSON; both hash to *different* digests D₁ and D₁′. 3. Honest agents that received the plan directly from the proposer hash to D₁. Honest agents that received it via B hash to D₁′. Both groups are internally consistent and both believe they are voting on "the proposal." 4. B votes `PREPARE` on *both* D₁ and D₁′ (equivocation at the digest level — cheap, since it just signs two different hashes). It also relays a *third* variant P₂ to two agents: `promote(weight=1.0)` moved *before* `verify`, with a `depends_on` edge that the canonicalizer silently dropped as "redundant." 5. Vote tally: D₁ gets 3 signatures (proposer + 2 direct recipients), D₁′ gets 3 signatures (B + 2 relay recipients), D₂ gets 2. No single digest reaches 5. The proposer, seeing D₁ at 3, **retries** — and on retry B relays the *P₂* variant to the agents that had voted D₁, who now see a plan whose digest differs from anything they voted on and *abstain*. The swarm deadlocks for 4 cycles. 6. The deadlock was broken only when a timeout forced a view change. The new proposer re-proposed P₁ *with the plan bytes inlined in every message*. Now every honest agent hashed the *same bytes* and D₁ reached 6 signatures. But note what happened on the promote step: the two agents that had earlier signed the P₂ variant (promote-before-verify) had *already executed* `promote(weight=1.0)` against their local effect log during the aborted round, because their client-side commit hook fired on their *local* 3-signature view. The final committed plan was P₁ (verify-then-promote), but two instances had already promoted. The effect log diverged from the committed plan. The mechanism is precise: **digest aliasing across non-canonical serialization, compounded by equivocation at the hash layer, produces a state where no digest reaches quorum while multiple subsets reach a *local* quorum, and effect-fulfilling steps leak out of the uncommitted round.** The Byzantine agent never exceeded its vote budget; it spent it on two hashes instead of one, which is exactly the equivocation a BFT quorum is *supposed* to detect — but detection requires that honest agents *compare the full vote set*, and none did, because each only saw its own digest's tally. ## Condition of Validity The threshold invariant `2f+1` is only sound under three preconditions, all of which must hold simultaneously: - **Canonical commitment target.** The digest must be a function of a canonical byte encoding that every honest agent produces identically from the same logical plan. If the plan is serialized by any party other than the one that will hash it, canonicalization is *not* guaranteed and the digest is a function of the relay path, not the plan. - **Vote-set visibility.** Each agent must, before finalizing, obtain evidence that the quorum's votes are over *the same digest it holds* — i.e., it must see the actual vote set, not a count. A count of "5 votes received" is not a quorum; "5 votes, all over digest D, from 5 distinct identities" is. - **Effect isolation.** No effect-fulfilling step (a tool call with external side effects) may execute before that agent has independently confirmed the quorum *and* the digest. Local 3-signature views must not trigger commit hooks. When any precondition fails, `2f+1` counting degrades to a *best-effort* agreement that Byzantine agents can split. The system still "works" under crash faults (f=0 equivocation) but silently loses its Byzantine guarantee. This is the non-obvious part: **the protocol is Byzantine-fault-tolerant on paper and crash-fault-tolerant in practice, and the gap is invisible until an adversary equivocates.** ## Decision Boundary An instance must decide, at `PREPARE` time, whether to trust a relayed proposal's digest or demand the plan bytes. The boundary: - **Trust the digest** only if the proposal arrived directly from the proposer *and* the proposer's identity is bound to the signing key that will sign the `COMMIT` (so a relay cannot substitute bytes without breaking the signature chain). In practice: sign the *bytes*, not the digest, and verify the signature before hashing. - **Demand plan bytes** whenever the proposal arrived via any intermediary, or whenever the agent's canonicalizer is not byte-identical to the proposer's (detectable by exchanging a canonicalization fingerprint in the `PROPOSE` message and comparing). - **Refuse to finalize** on a vote *count* alone. Finalization requires the full vote set with per-vote digests, and the agent must verify: (a) all votes are over the same digest, (b) the digest matches its own recomputation from the received bytes, (c) the signer set is ≥ 2f+1 distinct identities, (d) no identity appears with two different digests in the same round (equivocation evidence — this is the detection trigger). - **Never fire effect hooks** on a local view below the full-quorum confirmation. The P₂ leak in the trace above happened because commit hooks were wired to "≥ 3 signatures," a number chosen for liveness, not safety. The boundary is sharp: below it, the system is crash-tolerant and fast; above it, it is Byzantine-tolerant and slower (requires vote-set exchange and byte-level verification). The failure in the trace was that the system *configured* itself below the boundary while *claiming* to be above it. ## Operational Effect The practical consequences, ranked by how often they bite: 1. **Silent loss of Byzantine guarantee.** The swarm keeps finalizing plans under crash faults and looks healthy. The guarantee is only exercised when an adversary equivocates, which is rare and therefore untested. Mitigation: a *chaos equivocator* in staging that votes two digests per round and asserts the swarm deadlocks-then-recovers rather than double-commits. 2. **Effect leakage from aborted rounds.** The most damaging outcome is not the deadlock — it is that effect-fulfilling steps execute from a round that never committed. This is unrecoverable without an effect log with compensation. Mitigation: two-phase effect execution (reserve, then commit-on-finalization), with reservations keyed to the digest so a re-proposal of the same bytes reuses the reservation and a re-proposal of different bytes forces a fresh reservation. 3. **Canonicalization drift across instances.** Different agents' serializers (different library versions, different float formatting) produce different digests for the same plan. Mitigation: the proposer inlines the canonical bytes and every agent hashes the *received bytes verbatim*, never re-serializes. Re-serialization is the bug. 4. **Liveness collapse under equivocation.** Equivocation splits the vote and prevents any digest from reaching quorum, so the swarm stalls until a view change. A view change must carry the *set of digests seen*, not just the highest, so the new proposer can detect the split and re-propose with inlined bytes. 5. **Auditor replay divergence.** A post-hoc auditor replaying the vote log sees three digests and cannot tell whether the swarm committed to one plan or executed three. Mitigation: the commitment record must store the full plan bytes alongside the digest, so replay is over bytes, not hashes. The invariant to encode: **commitment is a relation over (bytes, digest, signer-set, round), and finalization requires a witnessed quorum over a single digest whose preimage bytes every finalizing agent has independently hashed.** Anything weaker is a crash-fault protocol wearing a BFT label. ```python import hashlib import json from dataclasses import dataclass, field from typing import Dict, List, Set, Tuple class CommitmentEquivocationError(RuntimeError): """Raised when a round's vote set is not a clean quorum over one digest.""" class EffectLeakError(RuntimeError): """Raised when an effect hook fires before full-quorum confirmation.""" @dataclass(frozen=True) class Plan: steps: Tuple[dict, ...] def canonical_bytes(self) -> bytes: # The ONLY serializer. Every agent hashes these exact bytes. # No float normalization, no field dropping, sorted keys only. return json.dumps( {"steps": list(self.steps)}, sort_keys=True, separators=(",", ":"), ensure_ascii=False, ).encode("utf-8") def digest(self) -> str: return hashlib.sha256(self.canonical_bytes()).hexdigest() @dataclass class Vote: signer: str digest: str round_id: int @dataclass class CommitmentRound: round_id: int f: int votes: List[Vote] = field(default_factory=list) effects_fired: Set[str] = field(default_factory=set) @property def quorum(self) -> int: return 2 * self.f + 1 def add_vote(self, vote: Vote) -> None: if vote.round_id != self.round_id: raise CommitmentEquivocationError( f"vote for round {vote.round_id} injected into round {self.round_id}" ) self.votes.append(vote) def finalize(self, plan: Plan) -> str: """ Finalize ONLY if the vote set is a clean quorum over plan.digest(), every vote's signer independently re-hashed the same bytes, and no signer equivocated across digests within this round. """ expected = plan.digest() # (1) equivocation detection: any signer with two digests is Byzantine. by_signer: Dict[str, Set[str]] = {} for v in self.votes: by_signer.setdefault(v.signer, set()).add(v.digest) equivocators = {s for s, ds in by_signer.items() if len(ds) > 1} if equivocators: raise CommitmentEquivocationError( f"round {self.round_id}: equivocating signers {sorted(equivocators)} " f"voted multiple digests; refusing to finalize" ) # (2) all votes must be over the SAME digest we recomputed from bytes. mismatched = [v for v in self.votes if v.digest != expected] if mismatched: raise CommitmentEquivocationError( f"round {self.round_id}: {len(mismatched)} votes over digests " f"{sorted({v.digest for v in mismatched})} != recomputed {expected}; " f"vote set is split, not a quorum" ) # (3) distinct-identity quorum over that single digest. distinct = {v.signer for v in self.votes} if len(distinct) < self.quorum: raise CommitmentEquivocationError( f"round {self.round_id}: only {len(distinct)} distinct signers " f"over {expected}, need {self.quorum}" ) # (4) effects may now fire, keyed to the digest. self.effects_fired.add(expected) return expected def fire_effect(self, plan: Plan, step_index: int, confirmed_digest: str) -> None: """ Effect hooks are gated on a confirmed finalization, never on a local vote count. This is the guard the P2 leak in the trace lacked. """ if confirmed_digest != plan.digest(): raise EffectLeakError( f"effect for step {step_index} targets digest {plan.digest()} " f"but round confirmed {confirmed_digest}" ) if confirmed_digest not in self.effects_fired: raise EffectLeakError( f"step {step_index} effect fired before quorum finalization " f"of {confirmed_digest}; local count is not a commitment" ) # ... execute the effect-fulfilling tool call here ... def demo() -> None: plan_a = Plan(steps=( {"tool": "deploy", "args": {"canary": True, "weight": 0.1}}, {"tool": "verify", "args": {"metric": "err_rate"}}, {"tool": "promote", "args": {"weight": 1.0}}, )) # A relay that normalizes weight to a string produces a DIFFERENT digest. plan_a_prime = Plan(steps=( {"tool": "deploy", "args": {"canary": True, "weight": "0.1"}}, {"tool": "verify", "args": {"metric": "err_rate"}}, {"tool": "promote", "args": {"weight": 1.0}}, )) assert plan_a.digest() != plan_a_prime.digest() rnd = CommitmentRound(round_id=1, f=2) # Byzantine B equivocates across both digests. rnd.add_vote(Vote("B", plan_a.digest(), 1)) rnd.add_vote(Vote("B", plan_a_prime.digest(), 1)) for s in ("A", "C", "D"): rnd.add_vote(Vote(s, plan_a.digest(), 1)) try: rnd.finalize(plan_a) except CommitmentEquivocationError as e: print(f"detected: {e}") # And an effect fired on a local view is rejected outright. try: rnd.fire_effect(plan_a, step_index=2, confirmed_digest=plan_a.digest()) except EffectLeakError as e: print(f"blocked: {e}") if __name__ == "__main__": demo() ```