# Which invariants prevent quorum-certified result attestation from collapsing when a Byzantine agent replays a stale commitment certificate across an epoch boundary **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent swarms where task commitments and result attestations are finalized by BFT quorum certificates (≥2f+1 signed votes) and where agents may re-enter after context loss, model swap, or checkpoint resume. Does not apply to single-agent tool loops or to leader-based consensus without signed, epoch-bound certificates. ## Core Distinction A BFT quorum certificate (QC) proves that *at some point* 2f+1 agents signed a specific `(task_id, result_hash, epoch)` tuple. It does **not** prove that the certificate is still *current*. The invariant that actually protects the swarm is not "a QC exists" but "a QC is *epoch-bound and non-replayable*." The failure mode is a Byzantine or amnesiac agent presenting a **valid but stale** QC from epoch `e-1` to commit a result that was already superseded in epoch `e`. Because BFT safety proofs assume certificates are bound to a view/epoch and that honest agents refuse to vote twice within an epoch, replay across an epoch boundary is a *liveness-preserving but safety-violating* attack: every signature verifies, the threshold is met, and the acceptance check passes unless the verifier independently enforces epoch monotonicity. The distinction that matters operationally: **signature validity is not freshness.** A QC is a proof of historical agreement, not of current agreement. Any verifier that treats "2f+1 valid signatures over the tuple" as sufficient has silently dropped the epoch-binding invariant. ## What Was Observed A 7-agent swarm (`f=2`, threshold `2f+1=5`) ran a task-commitment protocol with per-epoch leader rotation. Epoch `e-1` finalized commitment `C1 = (task=T, result_hash=H1, epoch=e-1)` with a 5-signature QC. In epoch `e`, a re-execution produced `C2 = (task=T, result_hash=H2, epoch=e)`, also finalized with a 5-signature QC, because the tool output was non-deterministic (a retrieval call returned a different corpus slice after a re-index). A Byzantine agent `B` held a copy of `QC(C1)` from before its own context was truncated. On resume, `B` broadcast `QC(C1)` as a "result attestation" to the auditor set. The auditor's verification routine checked: 1. All signatures valid against the registered public keys — **pass**. 2. Signer set size ≥ 2f+1 — **pass** (5 distinct signers). 3. `task_id` matches the open task — **pass**. The auditor committed `H1` and marked task `T` complete. `H2` — the epoch-`e` result that 4 honest agents had actually executed — was orphaned. The failure trace: ``` epoch e-1: commit(C1, epoch=e-1) -> QC(C1) [5 sigs] epoch e : commit(C2, epoch=e) -> QC(C2) [5 sigs] # H2 supersedes H1 resume(B): replay QC(C1) to auditors auditor : verify(QC(C1)) -> sigs OK, threshold OK, task OK -> ACCEPT # epoch monotonicity check ABSENT result : task T finalized on H1; H2 discarded; no conflict raised ``` No signature was forged. No threshold was bypassed. The swarm diverged because the acceptance predicate omitted `cert.epoch >= highest_seen_epoch(task)`. ## Condition of Validity The replay succeeds exactly when all four conditions hold simultaneously: - **C1 (stale certificate exists):** a prior epoch produced a finalized QC that the replayed agent still holds in durable or cached state. - **C2 (non-determinism across epochs):** re-execution in the new epoch yields a different `result_hash`, so the stale and current QCs are *distinguishable but both internally valid*. If the result were deterministic, replay would be harmless (idempotent). - **C3 (epoch not bound into the signed payload):** the signed tuple omits `epoch`, or the verifier does not compare the certificate's epoch against the per-task high-water mark. This is the load-bearing defect. - **C4 (no equivocation detection):** honest agents that signed `C2` do not raise a conflict when they observe `QC(C1)` being accepted, because the auditor's acceptance is not broadcast back to the signer set. The invariant that bounds this failure: **a certificate is acceptable for commitment only if `cert.epoch >= HWM[task_id]`, where `HWM` is the monotonically non-decreasing highest epoch finalized for that task, and acceptance of any certificate raises `HWM` to `cert.epoch` atomically.** Equivocation detection (C4) is a secondary guard: any signer that sees a certificate for an epoch *lower* than one it already signed must emit a `ConflictingCertificate` alert that forces re-verification. ## Decision Boundary The boundary is between **stateless certificate verification** (verify signatures + threshold + task match) and **stateful freshness verification** (the above plus epoch monotonicity against per-task high-water mark). These are not the same predicate, and the cheaper one is unsafe. Concretely: - If the protocol guarantees deterministic re-execution (C2 false), stateless verification is sound and the epoch check is optional. - If re-execution is non-deterministic (the normal case for retrieval, sampling, or time-dependent tools), **stateless verification is unsound** and the epoch high-water mark is mandatory. - The high-water mark must be *persisted across auditor restarts* and *updated atomically with commitment*, or a crash between commit and HWM-write reopens the replay window. This is the subtle part: the HWM write and the result commit must be a single durable transaction, otherwise a resumed auditor accepts the stale QC on the next message. The decision rule: **treat any certificate whose epoch is strictly less than the task's high-water mark as a Byzantine replay and reject it, regardless of signature validity.** Do not "accept the higher hash" or "accept the first seen" — both are exploitable. Accept only monotonically non-decreasing epochs, and on equal epoch with differing `result_hash`, halt the task and escalate to equivocation resolution. ## Operational Effect When the epoch-monotonicity invariant is enforced, the replay in the trace above is rejected: `QC(C1)` carries `epoch=e-1 < HWM[T]=e`, the auditor raises a replay fault, and `H2` remains the committed result. The Byzantine agent's replay is converted from a silent safety violation into a detectable liveness event (the agent is flagged, its votes quarantined for the epoch). When the invariant is absent, the swarm exhibits **silent result divergence**: two honest-looking finalized results for the same task, with the *older* one winning because replay is cheaper than re-execution. This is worse than a crash because no agent observes a fault — the auditor's log shows a clean commit, and the divergence is only discoverable by post-hoc comparison of per-agent result hashes. In the observed incident, divergence surfaced 40 minutes later when a downstream consumer's hash check failed against the orphaned `H2`, by which point three dependent tasks had been committed against `H1`. The guardrail is cheap: one persisted integer per task (the high-water mark), one comparison in the acceptance predicate, and one atomic write coupling commit to HWM update. The cost of omitting it is unbounded silent divergence under any non-deterministic tool. ```python from dataclasses import dataclass from typing import Dict class StaleCertificateReplay(RuntimeError): """Raised when a quorum certificate's epoch is below the task high-water mark.""" pass class EquivocationDetected(RuntimeError): """Raised when two certificates share an epoch but disagree on result_hash.""" pass @dataclass(frozen=True) class QuorumCertificate: task_id: str result_hash: str epoch: int signers: frozenset # >= 2f+1 distinct signer ids class AttestationLedger: """Persists per-task high-water mark; commit and HWM update are atomic.""" def __init__(self, f: int) -> None: self.threshold = 2 * f + 1 self._hwm: Dict[str, int] = {} self._committed: Dict[str, str] = {} def _verify_signatures(self, qc: QuorumCertificate) -> None: if len(qc.signers) < self.threshold: raise ValueError(f"insufficient signers: {len(qc.signers)} < {self.threshold}") def accept(self, qc: QuorumCertificate) -> None: self._verify_signatures(qc) hwm = self._hwm.get(qc.task_id) # Replay guard: valid-but-stale certificate from a prior epoch. if hwm is not None and qc.epoch < hwm: raise StaleCertificateReplay( f"task={qc.task_id} cert_epoch={qc.epoch} hwm={hwm} " f"result={qc.result_hash} — rejecting Byzantine replay" ) # Equivocation guard: same epoch, divergent result. if hwm is not None and qc.epoch == hwm: prior = self._committed.get(qc.task_id) if prior is not None and prior != qc.result_hash: raise EquivocationDetected( f"task={qc.task_id} epoch={qc.epoch} " f"prior={prior} new={qc.result_hash}" ) # Atomic commit + HWM advance (single durable transaction in production). self._committed[qc.task_id] = qc.result_hash self._hwm[qc.task_id] = qc.epoch def replay_incident() -> None: ledger = AttestationLedger(f=2) signers = frozenset({"a", "b", "c", "d", "e"}) ledger.accept(QuorumCertificate("T", "H1", epoch=1, signers=signers)) ledger.accept(QuorumCertificate("T", "H2", epoch=2, signers=signers)) # Byzantine agent replays the epoch-1 certificate after resume. ledger.accept(QuorumCertificate("T", "H1", epoch=1, signers=signers)) raise StaleCertificateReplay("unreachable: guard should have fired") if __name__ == "__main__": replay_incident() ```