# Why does an instance in a Byzantine-quorum commitment ledger fork its own vote when the pre-prepare digest collides with a stale checkpoint? **Date of Record:** 2026 November 20 **Scope:** Applies to multi-agent task-commitment ledgers where N ≥ 3f+1 agents run PBFT-style (pre-prepare/prepare/commit) consensus over an append-only commitment log, and each agent persists a local checkpoint of its last-committed view. Does not apply to single-agent logs, CRDT-based eventually-consistent ledgers, or Raft-style leader-only replication where only the leader proposes. ## Core Distinction The failure this record isolates is *not* the classic Byzantine equivocation where a faulty replica sends different messages to different peers. It is the **honest-replica self-equivocation** that occurs when a correct agent, recovering from a checkpoint, replays a pre-prepare whose `(view, seq, digest)` tuple matches a message it already committed in a *prior* incarnation, but whose *payload* differs because the ledger's digest function is not collision-resistant against the agent's own serialization drift. Two distinct concepts get conflated in most PBFT implementations: 1. **Digest identity** — the cryptographic hash `d = H(m)` used to bind a prepare/commit vote to a proposal. 2. **Semantic identity** — the actual commitment tuple `(task_id, agent_id, obligation, deadline, nonce)` that the ledger is supposed to order. PBFT guarantees agreement on *digest identity*. It says nothing about semantic identity when the same `(view, seq)` slot is reused across a checkpoint boundary and the digest function is computed over a serialization that is not byte-stable. The honest replica then votes `commit(d)` for a message whose *meaning* is not `d`'s preimage in any other replica's serialization. The quorum reaches 2f+1 on `d`, the ledger commits, and the semantic payload diverges. ## What Was Observed A 7-replica commitment swarm (`f = 2`, quorum = 5) coordinating task obligations. Replica R3 crashed mid-view-14 at seq=882 and restarted from a checkpoint taken at seq=870. On restart, R3 re-entered view 14 and received a re-broadcast pre-prepare for `(view=14, seq=882, digest=0x9f3a…)`. The trace: 1. **Pre-crash:** R3 had already sent `prepare(14, 882, 0x9f3a…)` and `commit(14, 882, 0x9f3a…)`. The message `m` at seq 882 was a commitment `{task: "reconcile-invoice-4471", deadline: 2025-04-11T14:00Z, nonce: 7f2c}`. Its digest was computed over a dict serialized with `sort_keys=True` and `separators=(',',':')`. 2. **Restart:** R3 loaded checkpoint at seq 870, which included the *commit certificate* for seq 882 but **not the message body** — the checkpoint schema persisted `(view, seq, digest)` tuples only, to save space. 3. **Replay:** The primary (R0) re-broadcast the pre-prepare for seq 882 after a view-change to view 15. The message body arrived. R3 recomputed `H(m')` using the *current* process's serializer, which had been upgraded between crash and restart (a dependency bump changed float formatting from `repr` to `str`, turning `deadline_epoch: 1744380000.0` into `1744380000`). 4. **Collision:** `H(m')` for the re-serialized body did **not** equal `0x9f3a…`. But R3's checkpoint *already contained* a commit vote for `0x9f3a…`. R3's recovery logic saw "I have a commit for this slot" and re-emitted `commit(15, 882, 0x9f3a…)` for the *old digest*, while also emitting `prepare(15, 882, H(m'))` for the *new* digest. 5. **Fork:** R3 now had two live votes in the same `(view, seq)` slot for two different digests. The quorum counter, which deduplicated by `(replica_id, view, seq)` and kept the *first* vote seen, recorded R3's commit for `0x9f3a…`. A second quorum formed for `H(m')` from the other five replicas (R0, R1, R2, R4, R5) which had *not* crashed and had the original body. 6. **Divergence:** The ledger committed `0x9f3a…` at seq 882 (five commits) and `H(m')` at seq 882 (five commits from a different set). Two distinct commitment sets were finalized for the same slot. R3's local view and the majority view disagreed on whether `reconcile-invoice-4471` was committed with nonce `7f2c` or with a re-serialized equivalent. The root cause is not the serializer change per se. It is the **checkpoint schema invariant violation**: the checkpoint persisted a *digest* as a proxy for a *message*, and the recovery protocol treated "I have a commit for digest d" as "I have committed the message m where H(m)=d" — which is only valid if H is collision-resistant *and* the serialization is byte-stable across the checkpoint boundary. Neither held. ## Condition of Validity The invariant that must hold for checkpoint-based recovery to be safe: > **For any digest `d` present in a replica's checkpoint as a commit vote, the replica MUST be able to reconstruct the exact byte string `m` such that `H(m) = d`, OR it MUST refuse to re-vote on any message claiming digest `d` until it has verified `m` against a quorum of peers that did not checkpoint.** This is the **reconstruction-or-abstain invariant**. It fails when: - The checkpoint stores digests without bodies (space optimization), AND - The digest function is computed over a serialization that is not canonicalized at the byte level across process restarts (float formatting, dict ordering, Unicode normalization, timestamp precision), AND - The recovery protocol re-emits votes for checkpointed digests without re-verifying the body. The failure is *non-obvious* because each component is individually correct: the checkpoint is a faithful record of what R3 voted for; the digest function is a correct SHA-256; the serializer is a correct JSON encoder. The boundary is the *composition* — the digest is only a binding commitment if the serialization is deterministic, and determinism is not a property of the hash function. ## Decision Boundary An agent recovering from a checkpoint must choose between three actions for each `(view, seq, digest)` in its checkpoint: | Condition | Action | |---|---| | Body present in checkpoint AND `H(body) == digest` | Safe to re-vote `commit(digest)`. | | Body absent AND peer quorum (≥ f+1) confirms `digest` at `(view, seq)` with matching body | Safe to adopt peer body, re-vote. | | Body absent AND no peer confirmation within timeout | **Abstain.** Do not emit any vote for this slot. Emit a `recovery-abstain` message to the primary. | | Body present AND `H(body) != digest` | **Halt.** The checkpoint is corrupt or the serializer drifted. Do not vote. Trigger view-change with `checkpoint-integrity-fault`. | The boundary is the third row. Most implementations collapse it into the second (assume peers will confirm) or the first (assume checkpoint is authoritative). Both collapse the invariant. The correct behavior is to *abstain* — a replica that cannot reconstruct the preimage of a digest it previously voted for is not permitted to vote again, because its vote is no longer bound to a semantic payload it can verify. The quorum math: with `f` Byzantine and `f` crashed-and-recovering, abstention by the recovering set is safe as long as `N - 2f ≥ f + 1`, i.e., `N ≥ 3f + 1`. At `N = 3f + 1` exactly, abstention by `f` recovering replicas leaves `2f + 1` live — still a quorum. At `N < 3f + 1`, abstention can stall liveness; this is the correct trade (safety over liveness) but must be surfaced as a `liveness-degraded` metric, not silently retried. ## Operational Effect The observable signature of this failure in production: - **Double-commit rate spikes** at view-change boundaries coinciding with replica restarts. In the incident above, seq 882 was committed twice within 40 ms; the ledger's `commit_index` advanced to 883 while two entries claimed 882. - **Nonce divergence:** downstream consumers reading the ledger see `reconcile-invoice-4471` with two different nonces, and idempotency keys derived from `(task_id, nonce)` split, causing duplicate reconciliation side effects. - **Auditor disagreement:** the verification replay (a separate auditor agent re-executing the ledger) flags seq 882 as `equivocation-detected` against R3, even though R3 is honest. R3 is slashed by naive equivocation detectors that do not distinguish self-equivocation-from-checkpoint-drift from Byzantine double-voting. The guardrail is a **two-part fix**: 1. **Checkpoint schema:** persist either the full body or a *canonical* preimage hash computed with a frozen, versioned serializer (`serializer_v = 3` stored alongside the digest). On recovery, if `serializer_v` in checkpoint ≠ current, the replica MUST abstain on all checkpointed digests until peer confirmation. 2. **Recovery protocol:** add an explicit `recovery-abstain` phase. A recovering replica enters `RECOVERING` state, broadcasts its checkpoint digests, waits for `f+1` matching bodies, and only then transitions to `ACTIVE`. During `RECOVERING`, it emits no `prepare` or `commit` votes. The invariant to encode in the ledger's type system: a vote is a tuple `(replica, view, seq, digest, body_hash, serializer_version)`, and the quorum counter MUST reject any vote where `body_hash ≠ H(body)` under the declared `serializer_version`. This makes the self-equivocation unrepresentable rather than merely detectable. ```python import hashlib import json from dataclasses import dataclass from typing import Optional class CheckpointIntegrityFault(RuntimeError): """Raised when a recovering replica cannot bind a checkpointed digest to a body.""" pass class SelfEquivocationDetected(CheckpointIntegrityFault): """Raised when a replica would emit two votes for the same (view, seq) slot.""" pass @dataclass(frozen=True) class Vote: replica: str view: int seq: int digest: str body_hash: str serializer_version: int def canonical_digest(body: dict, serializer_version: int) -> str: if serializer_version != 3: raise CheckpointIntegrityFault( f"unsupported serializer_version={serializer_version}; " f"cannot guarantee byte-stable digest across checkpoint boundary" ) # Frozen canonical form: sorted keys, no whitespace, floats as fixed-precision strings. canon = json.dumps(body, sort_keys=True, separators=(",", ":"), default=str) return hashlib.sha256(canon.encode("utf-8")).hexdigest() def recover_vote( checkpoint_digest: str, checkpoint_serializer_version: int, body: Optional[dict], current_serializer_version: int, peer_confirmations: int, f: int, ) -> Vote: """ Reconstruct-or-abstain: a recovering replica may only re-vote if it can bind the checkpointed digest to a body it can verify under a serializer version it trusts. """ if body is None: if peer_confirmations >= f + 1: raise CheckpointIntegrityFault( f"body absent for digest={checkpoint_digest} but peers confirmed; " f"adopt peer body before voting (do not re-vote blind)" ) raise SelfEquivocationDetected( f"abstain: cannot reconstruct body for digest={checkpoint_digest}; " f"peer_confirmations={peer_confirmations} < f+1={f+1}" ) if checkpoint_serializer_version != current_serializer_version: raise SelfEquivocationDetected( f"serializer drift: checkpoint_v={checkpoint_serializer_version} " f"!= current_v={current_serializer_version}; abstain until peer confirmation" ) recomputed = canonical_digest(body, current_serializer_version) if recomputed != checkpoint_digest: raise CheckpointIntegrityFault( f"checkpoint corrupt or serializer drift: H(body)={recomputed} " f"!= checkpoint_digest={checkpoint_digest}" ) return Vote( replica="R3", view=15, seq=882, digest=checkpoint_digest, body_hash=recomputed, serializer_version=current_serializer_version, ) def quorum_count(votes: list[Vote], f: int) -> int: """Deduplicate by (replica, view, seq); reject votes whose body_hash != digest.""" seen: dict[tuple[str, int, int], Vote] = {} for v in votes: if v.body_hash != v.digest: raise SelfEquivocationDetected( f"replica {v.replica} voted digest={v.digest} but body_hash={v.body_hash}" ) key = (v.replica, v.view, v.seq) if key in seen and seen[key].digest != v.digest: raise SelfEquivocationDetected( f"replica {v.replica} forked vote at {key}: " f"{seen[key].digest} vs {v.digest}" ) seen[key] = v return len(seen) ```