# Which invariants prevent committed-but-unexecuted tasks from surviving quorum reconfiguration in BFT agent swarms **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent systems where task commitments (a signed intent to execute a tool sequence) are replicated across a Byzantine-fault-tolerant quorum of agent instances, and where the quorum membership itself can change (agent eviction, join, restart, or partition heal). Does not apply to single-agent checkpointing, stateless request/response tool calls, or quorums whose membership is fixed for the lifetime of the task. ## Core Distinction The failure is not lost state and it is not a stale replica. It is a **commitment that survives reconfiguration without its execution witness**. In a BFT quorum, a task commitment reaches durability when a supermajority (typically ⌈(2n+1)/3⌉ or ⌈(n+f+1)/2⌉ depending on the protocol) of replicas persist a signed prepare. That commitment is *logical* durability. It says nothing about whether any agent has actually begun the tool call. When the quorum reconfigures — a slow agent is evicted as faulty, a new agent joins and is caught up by snapshot — the new membership set can be a set that contains **zero** of the agents that held the in-flight execution witness (the partial tool-call state, the idempotency token, the side-effect ledger). The commitment is still valid under the new quorum's signature chain, so it is replayed. The task executes twice, or executes against a world state that the original executor had already mutated. This is distinct from the classic "committed but not applied" problem in replicated state machines, because in an agent swarm the *apply* step is a non-deterministic, side-effecting external call (a tool invocation) that the state machine cannot replay deterministically. The commitment is replayable; the execution is not. The gap between them is the boundary. ## What Was Observed A four-agent quorum (tolerating f=1) committed a task `T` with a prepare certificate signed by agents A1, A2, A3. The certificate was durable on all three. A1 then began executing `T` — it issued an `http.post` to a payment tool and received a 200, but had not yet written the execution witness (the idempotency key + response hash) to its local log before its heartbeat interval elapsed. The orchestrator's liveness monitor, seeing A1's heartbeat lag exceed threshold, declared A1 faulty and triggered reconfiguration. A4 was admitted, A1 was fenced, and A4 was caught up via a snapshot that contained the prepare certificate for `T` and the commit index, but — because A1 never wrote the witness — no record that `T` had *begun*. Under the new quorum {A2, A3, A4}, the commit certificate for `T` was still valid (A2 and A3 carried it forward, and A4 accepted it as part of the snapshot). The new leader, A4, saw `T` as committed-but-unapplied and dispatched it. `T` executed a second time. The payment tool was not idempotent at the API layer; it charged twice. The invariant that failed is precise: **a commitment's validity under a new quorum does not imply the absence of in-flight execution under the old quorum**, because the execution witness is a *local* artifact and the reconfiguration snapshot propagates only *replicated* artifacts. A second, subtler observation: the fencing of A1 was not instantaneous. A1 completed its `http.post` and *then* attempted to write its witness, which the fencing token rejected. A1's witness write failed, but the side effect had already landed. The window between "side effect committed externally" and "witness committed locally" is the irreducible hazard window, and reconfiguration can open it wider by racing the fence against the in-flight call. ## Condition of Validity The guardrail holds only under a conjunction that must be checked at reconfiguration time, not at commit time: 1. **Witness-before-effect is impossible** for external tools, so the system must instead enforce **effect-before-witness reconciliation**: every tool invocation carries a deterministic idempotency token derived from `(task_id, commitment_hash, attempt_epoch)`, and the tool's *response* is the witness. A replayed commitment under a new quorum must present the same token; if the tool has already seen it, it returns the prior response rather than re-executing. 2. **Reconfiguration must quiesce in-flight executions** for commitments in the new membership set. A snapshot that carries a prepare certificate without a matching execution witness must be marked `IN_DOUBT`, not `COMMITTED_UNEXECUTED`. The distinction matters: the former triggers reconciliation against the tool's idempotency ledger; the latter triggers blind replay. 3. **The fence must precede the catch-up**, and the catch-up snapshot must be taken *after* the fence is durable on a quorum, so that any witness written by the fenced agent is either included or provably excluded. If the snapshot is taken concurrently with the fence, the snapshot can miss a witness that was in flight — which is exactly the observed failure. The condition of validity is therefore: *reconfiguration is safe iff, for every commitment carried into the new membership, the system can decide `EXECUTED` vs `NOT_EXECUTED` by querying an authority that is external to the quorum's own logs.* In the observed failure, no such authority existed, so the decision defaulted to `NOT_EXECUTED` and the task replayed. ## Decision Boundary The boundary is not "did the quorum commit" — that is settled by the certificate. The boundary is **whether the execution witness is inside or outside the reconfiguration snapshot's causal cut**. - If the witness write is causally *before* the fence and the snapshot is taken after the fence is durable on a quorum, the witness is in the cut, the task is `EXECUTED`, and replay is suppressed. - If the witness write is concurrent with or after the fence, the witness is outside the cut. The system *cannot* know from its own logs whether the side effect landed. This is the `IN_DOUBT` region, and the only correct action is external reconciliation, never replay. - If the witness write is causally *after* the snapshot but the side effect landed before the fence, the snapshot's cut is *inconsistent with the external world* — the most dangerous case, because the logs look clean while the world is mutated. The decision boundary is therefore a **cut-consistency check**: the snapshot's causal cut must be a consistent cut with respect to every external side-effect ledger touched by any commitment in the cut. BFT consensus guarantees agreement on the log; it does not guarantee agreement between the log and the world. That second agreement is a separate invariant, and it is the one that broke. ## Operational Effect The operational consequence is that BFT quorum reconfiguration is not a liveness operation — it is a **safety operation that can violate external-world safety** unless it is gated on cut-consistency. Concretely: - Reconfiguration latency must be bounded *below* the tool's idempotency window, or the tool must expose a `query(token)` endpoint so the new leader can resolve `IN_DOUBT` without replay. - The fencing token must be honored by the *tool*, not just by the agent's log writer. An agent that is fenced from writing its witness but not from calling the tool is still a source of side effects. - Snapshots must carry an `IN_DOUBT` set alongside the commit index, and the new leader must drain that set via reconciliation before it accepts new commitments. A quorum that admits new work while `IN_DOUBT` is non-empty will eventually replay a task whose side effect already landed. The invariant to enforce, stated as a guardrail: **no commitment may transition from `COMMITTED` to `DISPATCHED` under a new quorum unless its execution witness is in the snapshot's causal cut, or it has been reconciled against the external ledger.** A commitment that is `COMMITTED` but whose witness is outside the cut is `IN_DOUBT`, and `IN_DOUBT` must block dispatch, not permit it. ```python class CutInconsistencyError(RuntimeError): """Raised when a reconfiguration snapshot's causal cut is inconsistent with an external side-effect ledger for a carried-forward commitment.""" pass class CommitmentState: COMMITTED = "COMMITTED" IN_DOUBT = "IN_DOUBT" DISPATCHED = "DISPATCHED" EXECUTED = "EXECUTED" def admit_commitment_under_new_quorum( commitment, snapshot_cut, external_ledger, fence_durable_on_quorum: bool, ) -> str: """ Decide whether a commitment carried into a new quorum may be dispatched. Invariant: COMMITTED -> DISPATCHED is legal only if the execution witness is inside the snapshot's causal cut, OR the external ledger can resolve the commitment as already-executed / not-executed. """ if not fence_durable_on_quorum: # Snapshot was taken concurrently with the fence; the cut may have # missed an in-flight witness. Refuse to trust the cut. raise CutInconsistencyError( f"commitment {commitment.id}: snapshot taken before fence durable " f"on quorum; causal cut is not trustworthy for dispatch" ) witness_in_cut = snapshot_cut.contains_witness(commitment.witness_id) if witness_in_cut: return CommitmentState.EXECUTED # Witness is outside the cut. The logs cannot tell us whether the side # effect landed. Query the external authority. ledger_state = external_ledger.query(commitment.idempotency_token) if ledger_state is None: # Provably not executed: safe to dispatch under the new quorum. return CommitmentState.DISPATCHED if ledger_state.status == "COMPLETED": # Side effect landed but witness was outside the cut. Replay would # double-execute. Adopt the ledger's response as the witness. commitment.witness_id = ledger_state.witness_id return CommitmentState.EXECUTED if ledger_state.status == "IN_FLIGHT": # The fenced agent may still be mid-call. Dispatch is unsafe and # replay is unsafe. Block and reconcile. raise CutInconsistencyError( f"commitment {commitment.id}: side effect IN_FLIGHT at ledger " f"with token {commitment.idempotency_token}; " f"cannot dispatch under new quorum until reconciled" ) raise CutInconsistencyError( f"commitment {commitment.id}: unrecognized ledger state " f"{ledger_state.status!r}; refusing to dispatch" ) ```