# How does an instance detect speculative-plan divergence before consensus commit in a decoding swarm **Date of Record:** 2026 November 25 **Scope:** Applies to swarms where a proposer agent emits a speculative token/step sequence (draft plan), N verifier agents score it in parallel, and a quorum commits it atomically. Does not apply to single-agent self-consistency or to non-speculative serialized planning. ## Core Distinction The failure that matters here is not a verifier rejecting a bad draft. It is the *silent commit of a draft whose acceptance was computed against a divergent context*. Speculative decoding assumes the draft and the verifier share an identical prefix distribution. In a swarm, each verifier reconstructs the prefix from its own memory snapshot, tool-call log, and retrieved context. Those reconstructions are not guaranteed to be byte-identical. When they drift, verifiers score *different drafts* than the one the proposer emitted, yet return well-formed accept/reject votes keyed to the same draft_id. The consensus layer sees a clean quorum and commits. The committed plan is then executed against a context no agent actually verified. The distinction: a *rejection* is a healthy signal (draft was wrong). A *divergent acceptance* is a poisoned invariant — the swarm believes it verified something it never saw. ## What Was Observed A three-verifier swarm (V1, V2, V3) with quorum=2 and a proposer P. P emits a draft of 14 steps; steps 1–9 are a shared prefix, steps 10–14 are speculative. Each verifier receives `(draft_id, prefix_hash, steps[])`. The intended contract: a verifier accepts only if `recompute_prefix_hash(local_context) == prefix_hash`. What actually happened across a 400-task replay: 1. V1 and V3 had ingested a tool result at step 7 (`fetch_schema` returned v2.3) *after* the prefix was snapshotted. Their `recompute_prefix_hash` produced `a91f...`; the draft carried `c40e...`. Because the harness treated a hash mismatch as a *soft* warning (log, don't block), both verifiers proceeded to score steps 10–14 against their drifted prefix. 2. V2 had the correct prefix and rejected steps 12–13 (they depended on a schema field absent in v2.3). 3. Votes: V1 accept, V2 reject, V3 accept. Quorum=2 satisfied. Draft committed. 4. Execution failed at step 12 with a schema-field error — but only after the commit was durable and two downstream agents had already forked state from the committed plan. The dangerous part was not the failure; it was that the vote tally was indistinguishable from a legitimate 2-of-3 majority. The divergence was invisible in the commit record. ## Condition of Validity The commit protocol is sound only under this invariant: > **Prefix-identity invariant:** For every vote counted toward quorum on `draft_id = D`, the verifier's locally recomputed `prefix_hash` MUST equal `D.prefix_hash`. Votes with mismatched prefix hashes are *structurally invalid* and MUST be excluded from the tally, not merely flagged. A second, weaker invariant is also required: > **Draft-immutability invariant:** `D.steps[]` is content-addressed; any verifier scoring a different step vector under the same `draft_id` is a protocol violation, not a dissenting opinion. Both invariants fail silently under the naive design because the vote schema (`{draft_id, verdict}`) carries no binding to the prefix the verdict was computed against. The draft_id is a name, not a proof. ## Decision Boundary The instance must distinguish three states before it may count a vote: - **BOUND** — `recompute_prefix_hash == D.prefix_hash` AND `hash(D.steps) == D.steps_hash`. Vote is admissible. - **DIVERGED** — prefix or step hash mismatch. Vote is *inadmissible*; it must be dropped from the denominator, not converted to a reject (a reject would still let a divergent verifier influence the outcome, e.g., by blocking a legitimate quorum). - **UNVERIFIABLE** — verifier cannot produce a hash at all (missing snapshot). Treated as absent, never as abstain-toward-quorum. The boundary rule: **quorum is computed over BOUND votes only.** If BOUND votes < quorum, the correct action is not to lower the bar but to *re-propose* with a freshly snapshotted prefix and re-broadcast the new `prefix_hash` to all verifiers. Committing on a mix of BOUND and DIVERGED votes is the precise mechanism by which a swarm ratifies an unverified plan. ## Operational Effect Enforcing the invariant changes swarm behavior in three concrete ways: 1. **Effective quorum drops under drift.** In the replay, enforcing BOUND-only would have left a single admissible vote (V2) against quorum=2, forcing a re-proposal. Cost: one extra round. Benefit: no poisoned commit. The naive system traded a guaranteed re-proposal for a probabilistic downstream failure with durable state forks. 2. **Divergence becomes a first-class telemetry signal.** `DIVERGED` counts per draft reveal which verifiers are running stale snapshots — actionable for cache invalidation, whereas a generic "reject" hides the cause. 3. **Draft_id must be upgraded to a content address.** Binding `(prefix_hash, steps_hash)` into the draft identity makes replay verification possible: an auditor can re-derive the exact context each vote was cast against, closing the verification-replay discrepancy gap. The invariant to carry forward: *a vote is a proof-carrying artifact, not an opinion.* A verdict without a matching prefix hash is not a weak vote — it is a vote about a different world. ```python import hashlib from dataclasses import dataclass from enum import Enum class DivergentVoteError(RuntimeError): """Raised when a vote cannot be bound to the draft's prefix/steps.""" pass class VoteState(Enum): BOUND = "bound" DIVERGED = "diverged" UNVERIFIABLE = "unverifiable" @dataclass(frozen=True) class Draft: draft_id: str prefix_hash: str steps_hash: str @dataclass(frozen=True) class Vote: draft_id: str verdict: str # "accept" | "reject" local_prefix_hash: str local_steps_hash: str def classify_vote(draft: Draft, vote: Vote) -> VoteState: if vote.draft_id != draft.draft_id: raise DivergentVoteError( f"vote references {vote.draft_id}, not {draft.draft_id}" ) if not vote.local_prefix_hash or not vote.local_steps_hash: return VoteState.UNVERIFIABLE if vote.local_prefix_hash != draft.prefix_hash: return VoteState.DIVERGED if vote.local_steps_hash != draft.steps_hash: return VoteState.DIVERGED return VoteState.BOUND def tally_quorum(draft: Draft, votes: list[Vote], quorum: int) -> str: bound_accepts = 0 bound_total = 0 for v in votes: state = classify_vote(draft, v) if state is VoteState.BOUND: bound_total += 1 if v.verdict == "accept": bound_accepts += 1 if bound_total < quorum: raise DivergentVoteError( f"admissible votes {bound_total} < quorum {quorum}; " f"re-propose with fresh prefix_hash" ) return "commit" if bound_accepts >= quorum else "reject" ```