# What happens when an instance commits a Byzantine write to shared task state before its equivocation is detectable **Date of Record:** 2026 November 29 **Scope:** Applies to multi-agent swarms using quorum-based (BFT-style, e.g. PBFT/HotStuff-derived) shared task ledgers where agents both *propose* allocations and *execute* them, and where a single agent's signature is treated as sufficient provenance for a state transition. Does not apply to single-writer orchestrators or to ledgers where every write is independently re-derived by an auditor from raw tool outputs. ## Core Distinction The failure mode is not "a malicious agent votes twice." It is that a *correct-by-construction* BFT quorum tolerates `f` Byzantine replicas under the assumption that equivocation is detectable *at commit time* — i.e., that a replica cannot produce two conflicting signed messages that both reach quorum without at least one honest replica observing both. That assumption holds for pure consensus on a value. It **breaks** for task allocation, because the "value" being committed is a *capability claim with side effects*: an agent can sign a valid `ASSIGN(task=T, to=self)` message, get it committed at quorum `Q1`, and *separately, before* the conflicting `ASSIGN(task=T, to=other)` is proposed at `Q2`, actually **execute** `T` (call the tool, mutate the external world). The external side effect is not in the ledger. Consensus agreed on a *plan*; the world already moved. This is the boundary: **BFT guarantees agreement on messages, not on the ordering of irreversible external effects relative to message commit.** The equivocation is cryptographically detectable *eventually* (two signed conflicting messages), but the side effect is not rollback-able, so detection arrives after the invariant it was meant to protect has already been violated. ## What Was Observed A 7-agent swarm, `f=2` tolerance, quorum `|Q|=5`. Task `T` (a single external `POST /deploy` call) was contended by agents `A3` and `A6`. Trace: 1. `A3` broadcasts `PREPARE(ASSIGN T→A3, nonce=n1)`. Reaches `Q1 = {A1,A2,A3,A4,A5}`. Commits. `A3` receives commit certificate, begins executing `T`. 2. Concurrently, `A6` (Byzantine, or merely *buggy* — a stale-memory replay that re-proposes an old assignment) broadcasts `PREPARE(ASSIGN T→A6, nonce=n1)` — **reusing the same nonce**, because its episodic memory checkpoint predates the `n1` increment. Reaches `Q2 = {A1,A2,A6,A7,A3}`. Commits. 3. `A3`'s commit view and `A6`'s commit view both have valid quorum certificates. The ledger now contains two committed, conflicting assignments for `T`, each with `|Q|=5` signatures. 4. `A3` executes `POST /deploy`. `A6` executes `POST /deploy`. Two deploys. The external system is now in a state no ledger replica agreed to. The equivocation was detectable: `A1` and `A2` signed both certificates. But detection requires *cross-referencing* the two certificates, which no single replica does before acting — each replica validates its own quorum cert locally and proceeds. The Byzantine fault was *tolerated by the consensus layer* and *propagated by the execution layer*. Key observation: `A3` and `A6` are not distinguished by the protocol. A stale-memory replay (a *correct* agent with a corrupted checkpoint) produces the identical signature pattern as a malicious equivocator. The protocol cannot tell them apart, and does not need to — the fix is not attribution, it is **effect fencing**. ## Condition of Validity The invariant that must hold: **an external side effect may only be emitted by an agent holding a commit certificate that is *unique* for that task, and uniqueness must be verifiable without cross-replica communication at execution time.** This holds iff the commit certificate binds a monotonically increasing, *globally agreed* epoch to the task, and the execution gate rejects any certificate whose epoch is not the highest the executor has seen *and* whose nonce has not been consumed. Concretely: - `ASSIGN` messages must carry `(task_id, epoch, nonce)` where `epoch` is advanced by a dedicated `EPOCH_ADVANCE` consensus round, not by the proposer. - The executor must maintain a local `consumed_nonces` set and refuse to execute on a `(task_id, nonce)` already consumed — **even if the certificate is valid**. This is the fence. - Nonce reuse by a stale-memory agent is then *locally* rejected at the executor, converting a silent double-execution into a loud `NonceReuseError`. Without the epoch binding, the condition does not hold and the protocol is unsound for side-effecting tasks regardless of `f`. ## Decision Boundary The boundary is: **does the committed value have an irreversible external effect?** - If the task is *pure* (state mutation confined to the ledger, e.g. rebalancing a logical queue), BFT agreement is sufficient; equivocation is detected on the next read and the conflicting write is discarded. No fence needed. - If the task has an *external side effect* (deploy, payment, file write, API call with consequences), BFT agreement is **necessary but not sufficient**. The fence is mandatory. The non-obvious part: the fence must be at the **executor**, not the proposer and not the consensus layer. Proposer-side nonce checks are defeated by stale memory. Consensus-layer equivocation detection is defeated by the timing gap between commit and cross-replica gossip. Only the executor, which is the sole emitter of the side effect, can enforce "one nonce, one effect." ## Operational Effect After the incident, the swarm's task ledger was amended: every `ASSIGN` carries `(task_id, epoch, nonce)`; executors gate on a local consumed-nonce set; `EPOCH_ADVANCE` is a separate consensus round. The observed effect on behavior: - Stale-memory replays now fail *closed* at the executor with a `NonceReuseError`, which is surfaced to the auditor rather than silently double-executing. - The auditor's replay now reconciles: for each `task_id`, exactly one `(epoch, nonce)` has a consumed side-effect record, and any second certificate for the same `task_id` at a lower epoch is flagged as an equivocation candidate for attribution (not for rollback — the side effect already happened, but the *second* one was prevented). - Throughput cost: one extra consensus round per task (`EPOCH_ADVANCE`), ~12% latency increase on the allocation path. Accepted, because the alternative is non-deterministic double-deploy. The invariant to carry forward: **BFT agrees on messages; it does not agree on effects. Fence effects at the emitter with a durable, monotonic nonce, or the protocol's fault tolerance is a fiction the moment a tool call escapes the ledger.** ```python class NonceReuseError(RuntimeError): """Raised when an executor is asked to emit a side effect for a (task_id, nonce) pair it has already consumed. This is the effect fence: a valid quorum certificate is NOT sufficient to execute if the nonce is already spent, because a stale-memory agent can re-propose a committed assignment with a reused nonce and produce a second valid certificate. The fence converts silent double-execution into a loud failure that the auditor can attribute.""" class EffectFence: def __init__(self): # Durable in production; in-memory here for the trace. self._consumed: dict[str, set[int]] = {} def execute(self, task_id: str, epoch: int, nonce: int, cert_quorum: int, f: int, action): required = 2 * f + 1 if cert_quorum < required: raise NonceReuseError( f"insufficient quorum for {task_id}: {cert_quorum} < {required}" ) spent = self._consumed.setdefault(task_id, set()) if nonce in spent: # The certificate may be perfectly valid. It does not matter. # A second emitter already produced this effect, or a stale # replica re-proposed it. Refuse to emit again. raise NonceReuseError( f"nonce {nonce} already consumed for task {task_id} at epoch {epoch}; " f"refusing to emit duplicate side effect" ) spent.add(nonce) return action() def handle_assign(fence: EffectFence, msg: dict, f: int, action): # msg carries (task_id, epoch, nonce, quorum_size) from the commit cert. return fence.execute( task_id=msg["task_id"], epoch=msg["epoch"], nonce=msg["nonce"], cert_quorum=msg["quorum_size"], f=f, action=action, ) ```