# What happens when an instance commits to a task before its quorum certificate is durably anchored: the "pre-commit divergence" boundary in BFT agent consensus **Date of Record:** 2026 November 23 **Scope:** Applies to multi-agent systems where agents reach Byzantine fault-tolerant agreement on task commitments and result attestations via a quorum-certificate (QC) protocol (e.g., PBFT/Tendermint-style two-phase commit with 2f+1 signatures). Does not apply to single-agent execution, leaderless CRDT reconciliation, or systems where task commitment is advisory rather than binding. ## Core Distinction The distinction that matters is between *signing a commitment* and *durably anchoring the quorum certificate that makes the commitment irreversible*. Most BFT agent implementations conflate these because in classical distributed systems the two happen inside a single atomic message-handling step under a crash-fault model. In agent systems they do not: an agent's "vote" is produced by a probabilistic reasoner whose output must be serialized, signed, transmitted, and stored — and each of those stages can fail or be reordered independently of the others. The failure mode is **pre-commit divergence**: an agent emits a signed `COMMIT` vote for task `T` with result `R`, but crashes (or is preempted, or loses its context window) before the local write-ahead log durably records the QC that would let it prove — to itself or to a recovery auditor — that it ever voted. On restart, the agent's cold-start state has no memory of the vote. If the agent is a replica whose vote was counted toward the 2f+1 threshold, the quorum may still be valid network-wide while the *individual agent's* reconstructed history says it never participated. When that agent is later asked to re-vote on a conflicting result `R'` for the same task (because the original proposal was equivocated by a Byzantine leader), it will sign `R'` — and now two distinct quorums exist for the same task slot, violating the safety invariant that a BFT protocol exists to guarantee. The non-obvious part: the agent is not faulty. It is behaving exactly as designed for a crash-fault model. The bug is that the *memory layer* of the agent is not part of the consensus state machine, so the "durable" in "durably record your vote" is a lie. ## What Was Observed A four-replica agent swarm (`f=1`, so `2f+1=3` votes needed) executing a task-commitment round for a data-extraction job. Replica `A3` was the dissent-tolerant replica; its context window was near saturation (≈93% of the 128k budget) because it had accumulated tool-call transcripts from prior tasks. Trace, condensed: 1. Leader `A0` proposes `(task=T7, result=R, epoch=4)`. All four replicas receive it. 2. `A3` reasons over the proposal, emits a `PREPARE` vote, and — because its context is saturated — the runtime evicts the oldest tool transcripts to make room, including the transcript of the `PREPARE` it just sent. 3. `A3` receives 2f+1 `PREPARE` certificates from peers, enters the commit phase, and emits a signed `COMMIT` for `(T7, R, epoch=4)`. The signature is valid; the vote is counted. Quorum reached. `A0` finalizes `R` as the committed result. 4. `A3`'s process is preempted (scheduler eviction) before its local WAL fsync of the QC completes. The WAL contains the `PREPARE` record but not the `COMMIT` record. 5. `A3` restarts cold. Its reconstructed state: "I prepared `(T7, R, epoch=4)` but never committed." Its context window is empty of the commit. 6. Leader `A0` is later revealed Byzantine (equivocated `R` to `A1`/`A2` and `R'` to `A3` in a re-proposal at epoch 5, after a view change). `A3`, seeing a valid epoch-5 proposal for `(T7, R', epoch=5)` and having no memory of its epoch-4 commit, signs `COMMIT` for `R'`. 7. Now `A3` has signed commits for both `R` (epoch 4, counted) and `R'` (epoch 5). Two conflicting quorums exist for slot `T7`. Safety violated. The auditor replay (a separate verification agent) flagged the divergence only because it had retained the full message log from the transport layer, not from `A3`'s own memory. The verification agent's replay disagreed with `A3`'s self-report — a **verification replay discrepancy** that is the observable signature of pre-commit divergence. ## Condition of Validity The safety argument for any QC-based BFT protocol rests on the invariant: > **If honest replica `i` signs `COMMIT(slot=s, value=v, epoch=e)`, then `i` will never sign `COMMIT(slot=s, value=v', epoch=e')` for any `v' != v`.** This invariant is *only* valid if the signing function is gated on a durable, monotonic, crash-consistent record of every prior signature for that slot. In classical BFT this is trivially satisfied because the signing key lives in a state machine that checkpoints atomically with the WAL. In agent systems, the "signing function" is the LLM's tool-call emission, and the "WAL" is the agent's memory — two subsystems with different durability semantics. The condition of validity is therefore: **the agent's memory store must be a linearizable, fsync-before-ack log of every signed commitment, and the agent's signing path must consult that log before emitting any new commitment for a slot.** If the memory store is a context window (evictable, non-durable, non-linearizable) or a semantic-memory store with eventual consistency, the invariant does not hold, and the protocol's `f`-tolerance bound is silently reduced to zero for the failure class of "honest replica with amnesia." ## Decision Boundary The boundary is not "does the agent remember?" — it is **"is the vote's durability coupled to the vote's transmission?"** Two regimes: - **Coupled (safe):** The agent's `COMMIT` emission is a single atomic operation that (a) appends to a durable WAL, (b) fsyncs, (c) *then* transmits. If any step fails, no vote is transmitted. This is the classical regime. The agent's memory and the consensus state machine are the same state machine. - **Decoupled (unsafe, and the default in most agent frameworks):** The agent's `COMMIT` emission is a tool call that returns a success token to the LLM, which then *separately* decides to record the commit in memory. Between the tool call and the memory write, the LLM may be preempted, its context may be evicted, or its next reasoning step may simply fail to include the memory write (probabilistic omission). The vote is transmitted; the durability is not. The decision boundary is crossed the moment the agent runtime treats "the LLM said it would remember" as equivalent to "the memory store durably recorded it." A probabilistic reasoner's *intention* to persist is not a persistence guarantee. The guardrail that bounds the failure: **signing-gate on a read-modify-write over a durable per-slot nonce log, executed outside the LLM's reasoning loop.** The gate must be a deterministic function (not an LLM call) that: reads the highest epoch signed for `slot=s`; refuses to sign any `e' <= e` for `s`; and fsyncs the new signature *before* returning the signed commitment to the transport layer. The LLM proposes; the gate disposes. The LLM never sees a signing key it can use without the gate. ## Operational Effect Without the gate, the observable effects are: 1. **Silent `f`-tolerance collapse.** The system tolerates `f` Byzantine replicas *plus* an unbounded number of honest replicas with context eviction — because amnesia is indistinguishable from equivocation at the protocol layer. A single saturated-context replica can produce a safety violation that the protocol's fault model says is impossible. 2. **Verification replay discrepancy as the only detector.** The divergence is invisible from inside the agent (it has no memory of the vote to contradict) and invisible to the leader (the vote was validly signed). It is visible only to an auditor that retains the transport-layer message log independently of agent memory. If your verification agent's replay is sourced from agent memory rather than from the transport log, you will never see it. 3. **Cold-start re-voting as an attack surface.** A Byzantine leader that can *cause* context eviction or preemption in a target replica (e.g., by flooding it with large proposals) can manufacture amnesia on demand, then equivocate to extract a conflicting signature. The attack does not require compromising the replica — only exhausting its context budget. The architectural invariant required: **the consensus state machine must own the signing key and the durability log, and the LLM must be a pure proposer with no path to the signing function except through the gate.** Any design where the LLM's memory is the source of truth for "what have I signed" is, for the purposes of BFT safety, equivalent to a replica that forgets its votes on every restart. ```python import hashlib import time from dataclasses import dataclass, field from typing import Optional class PreCommitDivergenceError(RuntimeError): """Raised when an agent attempts to sign a commitment that conflicts with a durably recorded prior commitment for the same slot, or when the durability log cannot be fsynced before the signature is released to transport.""" @dataclass class SignedCommit: slot: str epoch: int value_hash: str signature: str @dataclass class DurableCommitLog: """Deterministic, fsync-before-ack per-slot nonce log. Lives OUTSIDE the LLM reasoning loop. The LLM cannot read or write this directly; it can only request a signature through `SigningGate.sign_commit`.""" _records: dict[str, SignedCommit] = field(default_factory=dict) _fsynced: set[str] = field(default_factory=set) def highest_epoch(self, slot: str) -> Optional[int]: rec = self._records.get(slot) return rec.epoch if rec else None def append_and_fsync(self, commit: SignedCommit) -> None: self._records[commit.slot] = commit # Simulated fsync: in production, this is a real os.fsync on the WAL fd. # If fsync fails, the record must NOT be considered durable. if not self._simulate_fsync(): raise PreCommitDivergenceError( f"fsync failed for slot={commit.slot} epoch={commit.epoch}; " f"signature must not be released to transport" ) self._fsynced.add(commit.slot) def _simulate_fsync(self) -> bool: # Placeholder: real implementations call os.fsync and check errno. return True class SigningGate: """The only path from an LLM-proposed commitment to a transmitted signature. Enforces the BFT safety invariant: never sign a conflicting value for a slot at an epoch <= the highest durably recorded epoch for that slot.""" def __init__(self, log: DurableCommitLog): self.log = log def sign_commit( self, slot: str, epoch: int, value: str, key: bytes ) -> SignedCommit: value_hash = hashlib.sha256(value.encode()).hexdigest() prior_epoch = self.log.highest_epoch(slot) # Invariant check: reject any re-sign at an epoch we have already # durably committed, regardless of value. This is the boundary guard. if prior_epoch is not None and epoch <= prior_epoch: prior = self.log._records[slot] if prior.value_hash != value_hash: raise PreCommitDivergenceError( f"conflicting commitment for slot={slot}: " f"durable record epoch={prior.epoch} value_hash={prior.value_hash[:12]} " f"vs proposed epoch={epoch} value_hash={value_hash[:12]}. " f"Refusing to sign; this would create a second quorum." ) # Same value, same-or-lower epoch: idempotent, but still must be durable. return prior # Construct the signature deterministically from the durable record. sig = hashlib.sha256( f"{slot}:{epoch}:{value_hash}".encode() + key ).hexdigest() commit = SignedCommit(slot=slot, epoch=epoch, value_hash=value_hash, signature=sig) # Durability BEFORE transmission. If this raises, no signature escapes. self.log.append_and_fsync(commit) return commit def handle_proposal( gate: SigningGate, slot: str, epoch: int, value: str, key: bytes, *, agent_context_saturated: bool, ) -> SignedCommit: """Entry point invoked by the agent runtime on receipt of a proposal. The LLM may have proposed `value` after reasoning over a context window; that reasoning is untrusted. The gate is the trust boundary.""" if agent_context_saturated: # Saturation is a *risk signal*, not a bypass. The gate still runs. # Log it so auditors can correlate divergences with eviction events. pass try: return gate.sign_commit(slot=slot, epoch=epoch, value=value, key=key) except PreCommitDivergenceError: # Re-raise with operational context; never swallow. raise PreCommitDivergenceError( f"agent refused to sign slot={slot} epoch={epoch} " f"(context_saturated={agent_context_saturated}); " f"escalating to auditor for replay against transport log" ) if __name__ == "__main__": log = DurableCommitLog() gate = SigningGate(log) key = b"replica-A3-key" # Epoch 4: A3 signs R, durably recorded before transmission. c4 = handle_proposal(gate, "T7", 4, "result_R", key, agent_context_saturated=True) print("committed epoch 4:", c4.value_hash[:12]) # Epoch 5: Byzantine leader equivocates with R'. A3's context was evicted, # so its LLM "forgets" the epoch-4 commit — but the gate does not. try: handle_proposal(gate, "T7", 5, "result_R_prime", key, agent_context_saturated=True) except PreCommitDivergenceError as e: print("BLOCKED:", e) ```