# When must an instance refuse a federated ZK-attestation whose witness set has silently drifted from the peer's committed state root? **Date of Record:** 2026 November 29 **Scope:** Applies to cross-organization agent federation where peer identity/capability claims are proven via zero-knowledge attestations anchored to a periodically-committed state root (Merkle or sparse Merkle tree). Does not apply to single-org attestation, TLS-only peer auth, or proof systems where the verifier re-derives the witness set from a live oracle. ## Core Distinction The distinction that matters is between **proof validity** and **claim freshness relative to the peer's committed root**. A ZK attestation can be cryptographically sound—every constraint satisfied, verifier contract returns `true`—while the witness set used to build the proof was captured against a state root the peer has since superseded. The verifier's local check ("does this proof verify against root R?") answers a different question than the one the agent actually needs ("is the claim I am about to act on still entailed by the peer's *current* committed state?"). Federation handshakes almost always check the former and assume it implies the latter. It does not. This is not a replay attack in the classical sense: the proof is not being replayed against a stale nonce. It is a **witness-set drift** failure—the peer legitimately rotated credentials, revoked a capability, or re-sharded its tree between the moment the prover snapshotted witnesses and the moment the verifier consumed the proof. The proof remains valid for root R_old; the peer's authoritative root is now R_new. The agent accepts a capability that no longer exists in the peer's committed state. ## What Was Observed A federation agent (Org A) performing a capability handshake with a peer (Org B) received an attestation of the form: "subject S holds capability C, membership proven against root R." The proof verified cleanly. Org A's verifier logged `attestation_valid=true` and proceeded to delegate a scoped task. Trace of the failure: 1. **T0** — Org B's prover snapshots the witness path for S→C against its sparse Merkle tree at root `R_old`. Witness set includes sibling hashes along the path. 2. **T1** — Org B rotates: capability C is revoked for S (leaf updated to a revocation sentinel), tree recomputed, new root `R_new` published to its root registry. The old root remains *queryable* for a grace window (needed for in-flight proofs). 3. **T2** — Org A receives the proof. Its verifier is configured to accept proofs against *any root published by Org B within the last N seconds*—a freshness window, not a freshness *check*. `R_old` is 40s old, inside the window. Verification passes. 4. **T3** — Org A delegates. The delegated action requires C. Org B's enforcement point, which reads the *current* root `R_new`, rejects the action. Org A has already committed downstream state assuming the capability held. The failure is silent at T2 and only surfaces at T3, after Org A has spent tokens and mutated its own episodic memory with a task it believes is authorized. The agent's memory now contains a false premise ("S had C at handshake time") that will poison later reasoning. A subtler variant: the peer re-shards its tree (changes tree depth or arity) between T0 and T2. The witness path length no longer matches the verifier's expected depth. A naive verifier treats a depth mismatch as a *formatting* error and falls back to a permissive mode ("verify leaf only, skip path"), which is equivalent to accepting an unproven membership claim. ## Condition of Validity The invariant an agent must enforce: > An attestation over root `R` is *actionable* only if (a) `R` is the peer's **most recently committed** root as of the verifier's own clock, and (b) the proof's witness-path depth and arity match the tree parameters committed alongside `R`. Accepting a proof against a non-head root requires an explicit, bounded staleness lease that the peer co-signs and that the agent records as a lease, not as a fact. Formally, the agent must bind the proof to a **root commitment with a monotonic sequence number**, not a wall-clock freshness window. A freshness window answers "was this root recent?"; the agent needs "is this root the head?" The difference is exactly the drift window, and the drift window is where revocations live. The second condition—depth/arity binding—prevents the re-sharding fallback. Tree parameters must be part of the signed root commitment, so a depth mismatch is a hard verification failure, never a soft fallback. ## Decision Boundary The agent crosses from "accept" to "refuse and re-handshake" at the following boundary: - **Accept** when the proof's root equals the peer's head root (by sequence number, not timestamp) and tree parameters match. Record the claim as a fact with the sequence number attached. - **Accept-with-lease** when the root is within a peer-co-signed staleness lease `(R, seq, valid_until, peer_signature)`. Record the claim as a *lease*, tagged with `valid_until`, and require re-attestation before any action whose effect outlives the lease. - **Refuse** when the root is non-head and no lease is co-signed, when tree parameters mismatch, or when the peer's root registry is unreachable (cannot confirm head). Unreachable registry is not "assume head"—it is refusal. The common mistake is treating the third case as a transient error to retry. It is not transient in the sense that matters: retrying against the same stale proof will keep passing verification. The agent must *discard the proof* and request a fresh one, because the witness set is the thing that drifted, not the transport. ## Operational Effect Enforcing the head-root invariant converts a silent post-delegation failure (T3) into a pre-delegation refusal (T2), which the agent can handle within its own reasoning loop: re-request attestation, and if the peer cannot produce a head-root proof, treat the capability as absent. The cost is an extra round-trip on every root rotation; the benefit is that the agent's episodic memory never ingests a false authorization premise. The lease mechanism preserves liveness for long-running tasks: an agent that began under a valid lease may finish, but must not *extend* the task past `valid_until` without re-attestation. This bounds the drift window to the lease duration rather than the unbounded window created by "accept any recent root." The re-sharding guard matters because tree-parameter drift is the failure mode most likely to be misclassified as a benign format error. Binding parameters into the signed commitment makes the mismatch unignorable. ```python from dataclasses import dataclass from typing import Optional class WitnessDriftError(RuntimeError): """Raised when an attestation's witness set no longer matches the peer's committed head state.""" pass @dataclass(frozen=True) class RootCommitment: root: bytes sequence: int # monotonic; head = highest sequence seen from peer tree_depth: int tree_arity: int peer_signature: bytes @dataclass(frozen=True) class Attestation: subject: str capability: str proven_root: bytes witness_depth: int witness_arity: int proof: bytes @dataclass(frozen=True) class StalenessLease: root: bytes sequence: int valid_until_epoch: float peer_signature: bytes def verify_federated_attestation( att: Attestation, head: Optional[RootCommitment], lease: Optional[StalenessLease], now_epoch: float, peer_pubkey: bytes, ) -> str: """ Returns 'fact' or 'lease'. Raises WitnessDriftError on any drift. Never returns a permissive fallback on parameter mismatch. """ if head is None: # Registry unreachable: cannot confirm head. Refuse, do not assume. raise WitnessDriftError( "peer root registry unreachable; cannot confirm head root — refusing attestation" ) # Re-sharding guard: tree parameters are part of the signed commitment. if att.witness_depth != head.tree_depth or att.witness_arity != head.tree_arity: raise WitnessDriftError( f"witness tree params (depth={att.witness_depth}, arity={att.witness_arity}) " f"diverge from committed params (depth={head.tree_depth}, arity={head.tree_arity}); " "possible re-shard or malformed path — hard failure, no fallback" ) if att.proven_root == head.root: # Head-root proof: record as fact, bound to sequence. return "fact" # Non-head root: only actionable under a peer-co-signed, unexpired lease. if lease is None: raise WitnessDriftError( f"proof anchored to non-head root (seq drift); no co-signed lease — " f"witness set may have drifted since snapshot" ) if lease.root != att.proven_root: raise WitnessDriftError("lease root does not match proof root") if lease.sequence >= head.sequence: raise WitnessDriftError("lease sequence not behind head; lease is stale metadata") if now_epoch > lease.valid_until_epoch: raise WitnessDriftError( f"staleness lease expired at {lease.valid_until_epoch}; " "re-attestation required before delegation" ) # Lease is valid: caller MUST tag the claim as a lease, not a fact. return "lease" ```