# What happens when an instance commits a speculative branch across a trust boundary before the consensus quorum has acknowledged the parent checkpoint **Date of Record:** 2026 November 28 **Scope:** Applies to federated agent deployments where multiple independently-operated instances execute speculative (optimistic) branches of a plan and a consensus-gated commit protocol decides which branch becomes durable state. Does not apply to single-tenant, single-instance speculative decoding or to purely local rollback schemes where no cross-instance state transfer occurs. ## Core Distinction The failure mode is not "a branch diverged" and not "a quorum failed to form." Both are expected and survivable. The failure is that a speculative branch **committed its side effects into a shared, trust-external store** (a tool side effect, an external MCP resource, a downstream agent's context) *before* the parent checkpoint it depends on was acknowledged by the consensus quorum. When the parent later fails quorum, the child branch is orphaned but its effects are already durable and visible to peers who never saw the parent. The distinction that matters operationally: **speculation is cheap to discard only if its effects are fenced.** The invariant under examination is that a speculative branch may not emit an externally observable effect until the lineage of checkpoints it descends from is quorum-acknowledged. Violations are invisible in the committing instance's own logs — it saw a locally valid parent — and only surface at a peer that receives the orphaned effect and cannot reconstruct its ancestry. ## What Was Observed Three federated instances (A, B, C) run a consensus-gated commit protocol over a shared plan. Instance A holds the authoritative checkpoint `k0` and speculatively advances to `k1a` and `k2a`, emitting a tool call to an external resource registry at `k2a`. Instances B and C, partitioned from A for the duration of the speculative window, independently advance to `k1b`/`k2b` and `k1c`/`k2c`. The trace: 1. A's local validator sees `k0 → k1a → k2a` as a contiguous, hash-linked chain. Every local check passes. A commits the `k2a` tool effect to the shared registry. 2. The partition heals. Quorum forms on the `k1b`/`k1c` branch (2 of 3). `k1a` is rejected. 3. `k2a` is now an orphan: its parent `k1a` never achieved quorum, so `k2a` is unreachable from any committed root. 4. The registry holds a durable effect whose provenance chain terminates at a rejected checkpoint. Peer D, which fetches that effect, attempts to resolve `k2a`'s ancestry, walks to `k1a`, finds no quorum certificate, and must decide: trust the effect, or reject it. 5. D rejects it and re-derives the step from the committed `k1b`/`k1c` branch. The re-derived effect is *semantically different* — the external registry is not idempotent across the two branches, so the orphaned effect and the re-derived effect both exist, and the registry now contains a resource that the committed plan never authorized. The observed signature is not an error at A. A's speculative execution was correct in isolation. The signature is **a durable external effect with a broken quorum-ancestry certificate**, plus a non-idempotent duplicate at the registry. The committing instance reports success; the failure is only visible to consumers. A second-order observation: the orphaned effect had a valid *cryptographic signature* from A. Signature validity and quorum-ancestry validity are independent properties, and conflating them is the root of the boundary failure. A peer that checks only "is this effect signed by a trusted instance" accepts the orphan. ## Condition of Validity The guardrail holds only under a conjunction of conditions, and the failure appears exactly when any one is dropped: 1. **Effect fencing by ancestry, not by signature.** A speculative branch must carry a *commit certificate* proving every ancestor checkpoint reached quorum, not merely a signature proving which instance produced it. The certificate is a chain of quorum attestations, verifiable by any peer without contacting the originator. 2. **Two-phase external effect emission.** Speculative branches may *prepare* effects (reserve, stage, or write to a branch-scoped namespace) but may only *publish* them to the shared namespace after the commit certificate is attached. The registry must honor branch-scoped namespaces; if it does not, the fence cannot be enforced at the effect layer and must be enforced by withholding the call entirely. 3. **Idempotency keys bound to the committed lineage, not the speculative branch.** A re-derived effect on the winning branch must collide with the orphaned effect's key so that the registry deduplicates — but only if the key is derived from the *committed* ancestor set. Keys derived from the speculative branch ID guarantee a duplicate. 4. **Orphan reaping with a bounded window.** Peers must be able to enumerate and retire orphaned effects. Without a reaper, orphans accumulate and pollute downstream retrieval — a stale-memory drift that later manifests as agents reasoning over effects their committed plan never produced. When all four hold, speculative execution is safe to run across trust domains. When the effect layer cannot provide branch-scoped namespaces (condition 2), the correct degradation is to **forbid speculative external calls entirely** and restrict speculation to pure, side-effect-free reasoning. There is no safe middle ground where an unfenced external effect is emitted speculatively. ## Decision Boundary The committing instance faces a binary at the moment it is about to emit an external effect from a speculative branch: - **If a commit certificate covering the full ancestor chain is present and verifiable by the target peer**, emit. The effect is fenced and its orphan risk is zero. - **If the certificate is absent, partial, or verifiable only by contacting the originator**, do not emit to the shared namespace. Either stage into a branch-scoped namespace or withhold. The subtle boundary — the one that produces the observed failure — is the tempting third option: "emit because the local chain is contiguous and locally signed." Local contiguity proves the branch is internally consistent. It proves nothing about quorum ancestry. The decision boundary must be drawn at *externally verifiable quorum ancestry*, and the committing instance must treat local chain validation as necessary but strictly insufficient. A second boundary governs the consumer side: a peer receiving an effect with a broken ancestry certificate must **reject and re-derive**, not "accept with a warning." Accept-with-warning converts a fencing violation into silent state pollution, and the pollution is unrecoverable once it enters another agent's context. ## Operational Effect The downstream consequences of a single unfenced speculative commit propagate along three axes: - **State pollution via retrieval.** Orphaned effects enter the shared registry and are later retrieved by agents whose committed plans never authorized them. Because retrieval is similarity-based, the orphan is indistinguishable from a legitimate effect at retrieval time — the ancestry certificate is not part of the embedding. This is a cross-instance stale-memory drift seeded by a single fencing violation. - **Non-idempotent duplication.** When the winning branch re-derives the step, the registry holds two semantically divergent effects for one logical action. Reconciliation requires an out-of-band audit, and the audit must replay the speculative branch to determine which effect is orphaned — a replay that may itself be non-deterministic if the tool had stochastic outputs. - **Consensus livelock under repeated speculation.** If instances learn that unfenced speculative emission "usually works" (because partitions are rare), they speculate more aggressively, widening the orphan window. Under sustained partition churn, the reaper cannot keep pace and the registry's orphan fraction grows until consumers reject most fetched effects and re-derive, saturating compute and starving quorum formation — a livelock where consensus is blocked by the cost of cleaning up speculation. The guardrail that bounds all three is the same: **the commit certificate is a precondition of external effect emission, not a postcondition of branch acceptance.** Enforce it at the effect boundary, verify it at the consumer, and reap orphans within a bounded window. ```python import hashlib from dataclasses import dataclass class UnfencedSpeculativeCommitError(RuntimeError): """Raised when a speculative branch attempts to emit an external effect without a commit certificate proving quorum ancestry of every parent checkpoint. Signature validity is NOT sufficient.""" pass @dataclass(frozen=True) class Checkpoint: branch_id: str parent_hash: str quorum_attestations: tuple # instance IDs that acknowledged this checkpoint def ancestry_is_quorum_committed( branch: list[Checkpoint], required_quorum: int ) -> bool: """A branch may publish external effects only if every ancestor checkpoint carries >= required_quorum attestations. Local contiguity and signatures are deliberately NOT checked here.""" return all( len(cp.quorum_attestations) >= required_quorum for cp in branch ) def emit_external_effect( branch: list[Checkpoint], effect_payload: dict, required_quorum: int, registry_namespace: str, ) -> str: """Publish a speculative branch's effect to the shared registry. Fails closed when the ancestry is not quorum-committed.""" if not ancestry_is_quorum_committed(branch, required_quorum): # The committing instance saw a locally valid chain, but the # ancestry certificate is incomplete. Emitting here produces an # orphan that consumers cannot resolve and that pollutes retrieval. raise UnfencedSpeculativeCommitError( f"branch {branch[-1].branch_id} lacks quorum-committed ancestry " f"(required {required_quorum} attestations per checkpoint); " f"stage into '{registry_namespace}.staged' or withhold" ) # Idempotency key derives from the COMMITTED ancestor set, so a # re-derived effect on the winning branch collides and deduplicates. committed_lineage = "|".join(cp.parent_hash for cp in branch) idem_key = hashlib.sha256( (committed_lineage + repr(sorted(effect_payload.items()))).encode() ).hexdigest() return f"{registry_namespace}/{idem_key}" ```