# Why does an instance's speculative execution fork silently diverge from quorum commit when a Byzantine peer replays a side-effecting action under a different idempotency key? **Date of Record:** 2026 November 22 **Scope:** Applies to Byzantine-resilient agent swarms where N workers speculatively execute side-effecting tool calls in parallel and a quorum (e.g., 2f+1 of 3f+1) must agree on the *effect* before commit. Does not apply to read-only fan-out, single-agent retries, or swarms where side effects are gated by an external transactional coordinator with its own dedup layer. ## Core Distinction The swarm's safety argument usually rests on "quorum agreement on the payload implies quorum agreement on the effect." That implication is false whenever the side-effecting action is *not a pure function of the payload* — i.e., whenever the effect depends on an idempotency key, a nonce, a server-assigned ID, or any ambient state the worker supplies independently of the voted payload. A Byzantine worker exploits exactly this gap: it casts a vote that is byte-identical to the honest quorum's payload (so it passes signature and hash checks) while attaching a *different idempotency key* to the actual tool invocation. The payload quorum commits; the effects diverge. This is not a payload-integrity failure — every hash matches — it is a **binding failure between the voted object and the effector invocation**. The distinction that matters operationally: *agreement on what to say* is not *agreement on what to do*. Quorum commit must bind the effector's deduplication identity, not merely the semantic arguments. ## What Was Observed A 4-worker, 1-fault-tolerant speculative swarm (quorum = 3) executing a `transfer_funds`-class tool. Each worker runs the same plan step, calls the tool speculatively into a staging buffer, and returns `(payload_hash, effect_receipt)` to the coordinator. The coordinator commits when ≥3 workers return receipts whose payload hashes match. Trace of the failing round: 1. Workers W1, W2, W3 produce payload `P = {from: A, to: B, amount: 100}` with `payload_hash = h(P)`. Each generates its own idempotency key `k_i = HMAC(worker_seed_i, h(P))` — *derived locally, never included in the vote*. 2. W1, W2, W3 invoke the effector with `(P, k_1)`, `(P, k_2)`, `(P, k_3)`. The effector, seeing three distinct keys, applies the transfer **three times**. Each returns a distinct `receipt_id`. 3. W4 is Byzantine. It votes `(h(P), receipt_4)` where `receipt_4` is a *fabricated* receipt for a fourth application it triggered out-of-band against the same effector with key `k_4`. Its vote is well-formed and its payload hash matches. 4. Coordinator sees 4 matching payload hashes, declares quorum, and commits. The commit writes "transfer executed once, receipt = receipt_1" into episodic memory. Observed end state: ledger debited 400, agent memory records 100. The divergence is invisible to every integrity check in the pipeline because **no check ever compared the effector's applied-effect count against the quorum's payload count**. The invariant "one committed payload ⇒ one applied effect" was assumed, never enforced. A subtler variant: even with *honest* workers, if idempotency keys are worker-local, quorum commit of a single payload yields N applications. The Byzantine worker merely makes the discrepancy attacker-controlled (it can choose to apply zero or many times) rather than incidental. ## Condition of Validity The failure requires all of the following to hold simultaneously; remove any one and the attack surface closes: - **Speculative execution precedes commit.** Workers invoke the effector before the coordinator decides. (If effects are staged and released only post-commit, divergence is bounded to staging.) - **Idempotency identity is generated below the vote boundary.** The key is a function of worker-local entropy, not of the agreed payload plus a coordinator-assigned round ID. - **The effector deduplicates on key, not on `(payload_hash, round_id)`.** This is the load-bearing condition — most effectors dedup on client-supplied key precisely to allow retries, which is what makes the key a free variable. - **Quorum verification checks payload equality only.** Receipts are compared for *presence and payload match*, not for *effect uniqueness* (i.e., that all committed receipts share one idempotency key). It does **not** apply when the effector is itself a replicated state machine that rejects duplicate `(payload, round)` pairs, or when the coordinator mints the idempotency key and distributes it inside the signed payload — in that case the key is part of `P` and `h(P)` binds it. ## Decision Boundary The boundary is between two commit disciplines: - **Payload-quorum commit (unsafe here):** "≥2f+1 matching `h(P)` ⇒ commit `P`." Bounds *what was said*; leaves *what was done* unbounded by up to N applications per round and fully attacker-chosen under Byzantine presence. - **Effect-bound quorum commit (required):** "≥2f+1 matching `h(P)` **and** all committed receipts carry the same `idempotency_key` **and** the coordinator can query the effector for `applied_count(h(P), round)` and confirm it equals 1 ⇒ commit." Bounds both. Operationally, cross the boundary — i.e., permit speculative side effects — only if you can satisfy the second discipline. If you cannot make the effector expose an applied-count or dedup on `(payload_hash, round)`, do not speculate on side-effecting actions at all; stage and release. The middle ground (speculate, then "clean up" duplicates post-commit) is not a boundary — it is a compensating action that itself races with the next round's commit and can double-apply under retry. ## Operational Effect Consequences that show up in production telemetry: - **Silent over-application.** Ledger/effect counts exceed committed payload counts by up to N per round. Detectable only by comparing effector-side applied counts against memory's committed-payload log — a reconciliation job most swarms do not run. - **Memory/effect drift.** Episodic memory records one effect; the world contains many. Subsequent planning reads memory, assumes the side effect succeeded once, and compounds the error across rounds (the classic stale-memory drift, now with a Byzantine trigger). - **False audit consensus.** Auditors replaying the vote log see unanimous payload hashes and conclude correctness. The audit is replaying the *wrong object* — the vote, not the effect — so the discrepancy is structurally invisible to it. - **Retry amplification.** If the coordinator retries a timed-out round, honest workers mint fresh keys and apply again; the Byzantine worker can withhold its effect until the retry and then apply, maximizing divergence. The guardrail that bounds this: **the idempotency key must be inside the signed, voted payload**, minted by the coordinator from `(plan_step, round_id)` — never by the worker. Then `h(P)` binds the key, quorum agreement on `h(P)` is agreement on the effector identity, and duplicate application is impossible because all honest workers present the same key and the effector dedups on it. The coordinator additionally asserts `applied_count(h(P)) == 1` before writing to memory, and refuses commit otherwise. ```python import hashlib import hmac class SpeculativeEffectDivergence(RuntimeError): """Raised when quorum-committed payloads do not bind to a single effector application.""" def _h(payload: dict) -> str: return hashlib.sha256(repr(sorted(payload.items())).encode()).hexdigest() def verify_effect_bound_commit( votes: list[dict], effector_applied_count: int, quorum: int, ) -> str: """ votes: list of {"payload": dict, "idempotency_key": str, "receipt_id": str} effector_applied_count: number of times the effector actually applied h(P) this round. Returns the committed idempotency key on success. """ if not votes: raise SpeculativeEffectDivergence("no votes to commit") payload_hash = _h(votes[0]["payload"]) matching = [v for v in votes if _h(v["payload"]) == payload_hash] # Invariant 1: payload quorum. if len(matching) < quorum: raise SpeculativeEffectDivergence( f"payload quorum not met: {len(matching)} < {quorum}" ) # Invariant 2: idempotency key must be bound inside the voted payload. keys = {v["idempotency_key"] for v in matching} if len(keys) != 1: raise SpeculativeEffectDivergence( f"idempotency key not bound to payload; divergent keys {keys} " f"for payload_hash {payload_hash[:12]} — Byzantine replay suspected" ) bound_key = keys.pop() # Invariant 3: effector must have applied exactly once for this payload+key. if effector_applied_count != 1: raise SpeculativeEffectDivergence( f"effector applied {effector_applied_count} times for key {bound_key[:12]}; " f"expected exactly 1 — speculative effects diverged from quorum commit" ) return bound_key ```