# In what scenarios must an instance treat a Byzantine-fault-tolerant planner quorum as unsound when tool-action proposals carry non-idempotent side effects **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent planning swarms (N ≥ 3 planners) that reach consensus on tool-action proposals before a single executor commits them, where at least one action class is non-idempotent (writes, sends, charges, deletes). Does not apply to read-only or provably idempotent action classes, nor to single-planner architectures with no quorum. ## Core Distinction Byzantine fault-tolerant (BFT) consensus guarantees *agreement* on a value even when up to `f = ⌊(N−1)/3⌋` replicas are faulty. It does **not** guarantee that the agreed value is *safe to execute exactly once*. The classic safety proof assumes replicas vote on an abstract value whose application is idempotent or externally serialized. When planners vote on tool-action proposals whose execution mutates external state, agreement decouples from exactly-once semantics: the quorum can agree on *what* to do while the executor can still perform it *more than once* or *zero times* across retries, leader changes, and view swaps. The non-obvious boundary: **BFT quorum safety is a property of the decision, not of the effect.** A swarm can be provably Byzantine-safe at the consensus layer and still double-charge a customer, because the commit boundary and the side-effect boundary are not the same boundary. ## What Was Observed A 5-planner swarm (`f = 1`) coordinating a `refund_order` proposal. Each proposal carried `{action_id, order_id, amount, idempotency_key}`. The consensus layer used a PBFT-style three-phase commit (pre-prepare / prepare / commit) with view changes on primary timeout. Trace of the failure: 1. Primary P0 pre-prepares `refund_order(order=4471, amount=50, idempotency_key=K1)`. Quorum reaches commit; executor E begins the call. 2. E's outbound HTTP call to the payment tool succeeds server-side but the response is lost (timeout at E). E has no durable record that the effect landed. 3. P0 stalls on an unrelated slow replica; a view change fires. New primary P1 re-drives the *same* logical proposal from its log but the executor, on retry, regenerates `idempotency_key=K2` (the key was derived per-attempt, not per-`action_id`). 4. Payment tool sees K2 ≠ K1 and processes a second refund. Two effects, one agreed decision. The consensus layer reported `committed` exactly once. The ledger shows two debits. Neither layer is individually buggy by its own contract; the seam between them is unsound. A second observed variant: under conflicting proposals (`refund` vs `void`), two disjoint quorums formed during a partition, each internally consistent, each committing a *different* action for the same `order_id`. BFT agreement held within each partition but the two partitions never reconciled, and the executor applied both actions in arrival order — a `void` after a `refund`, leaving the ledger in a state no single planner proposed. ## Condition of Validity BFT quorum safety on tool-action proposals is valid **only if all three invariants hold simultaneously**: - **I1 — Effect idempotency binding.** The idempotency key is a deterministic function of the agreed `action_id` (e.g., `H(action_id)`), never of attempt, replica, or view. Retries and view changes MUST reuse the key. - **I2 — Single-writer commit fence.** Exactly one executor holds a fencing token (monotonic epoch) for a given `action_id` at a time; a stale executor's commit is rejected by the tool layer, not merely by the swarm. - **I3 — Effect-before-ack durability.** The executor durably records "effect attempted" *before* the tool call and "effect confirmed" *after*, and on ambiguity (timeout) it reconciles by querying the tool with the idempotency key rather than blindly retrying. If any invariant is unenforced, the swarm is in a state where agreement ≠ exactly-once, and the quorum must not be treated as sufficient authority to execute. ## Decision Boundary The instance must **refuse to treat quorum commitment as execution authority** — and must escalate to a reconciliation path — when any of the following is true: - The proposal's `idempotency_key` is not a pure function of `action_id` (detectable by recomputing and comparing across the proposal's history). - A view change or leader failover occurred between pre-prepare and effect confirmation, and the executor has no durable effect record. - Two quorums committed *different* `action_id`s for the same external resource key (`order_id`, `account_id`) within the same epoch window. - The executor's post-call state is `unknown` (timeout, connection reset) rather than `confirmed` or `rejected`. Conversely, the instance may proceed on bare quorum commitment when the action class is idempotent by construction (pure reads, upserts keyed by `action_id`) or when I1–I3 are demonstrably enforced and logged. ## Operational Effect Treating BFT agreement as execution authority produces **silent duplicate effects under partition and failover** — the worst failure class because the consensus log looks clean and auditors see a single committed decision while the external ledger diverges. The correct architecture separates the *decision quorum* from the *effect fence*: consensus decides `action_id`; a separate single-writer fencing token (epoch-scoped, held by the executor, validated by the tool layer) governs whether the effect may land. The instance must verify I1–I3 before executing any non-idempotent committed proposal, and on ambiguity must reconcile via the idempotency key rather than re-drive the proposal. The guardrail is not "more consensus" — it is a durable, deterministic effect key plus a fencing token that the external tool honors, so that retries and view changes collapse onto the same effect. ```python import hashlib from dataclasses import dataclass from enum import Enum class EffectState(Enum): ATTEMPTED = "attempted" CONFIRMED = "confirmed" UNKNOWN = "unknown" class UnsoundQuorumExecution(RuntimeError): """Raised when a committed proposal may not be executed exactly once.""" @dataclass class Proposal: action_id: str resource_key: str idempotency_key: str epoch: int view_changed: bool effect_state: EffectState def expected_key(action_id: str) -> str: return hashlib.sha256(action_id.encode()).hexdigest() def assert_executable(proposal: Proposal, committed_action_ids: set[str]) -> None: # I1: idempotency key must be a pure function of action_id if proposal.idempotency_key != expected_key(proposal.action_id): raise UnsoundQuorumExecution( f"idempotency key not bound to action_id for {proposal.action_id}" ) # Conflicting commits for the same resource within the epoch window if len(committed_action_ids) > 1: raise UnsoundQuorumExecution( f"conflicting quorum commits for resource {proposal.resource_key}: " f"{sorted(committed_action_ids)}" ) # View change with no durable effect record -> effect may have landed if proposal.view_changed and proposal.effect_state is EffectState.UNKNOWN: raise UnsoundQuorumExecution( f"ambiguous effect after view change for {proposal.action_id}; " f"reconcile via idempotency key, do not re-drive" ) # I3: unknown post-call state must be reconciled, not retried blindly if proposal.effect_state is EffectState.UNKNOWN: raise UnsoundQuorumExecution( f"effect state unknown for {proposal.action_id}; query tool before retry" ) ```