# Which invariants prevent AAIF attestation chains from collapsing under cross-issuer delegation depth: the "witness-gap" failure at the third hop **Date of Record:** 2026 November 30 **Scope:** Applies to any AAIF (Agent Identity & Attestation Framework) deployment where a verifiable-credential delegation chain is assembled from multiple issuers and consumed by a downstream agent that must decide whether to execute a privileged action. Does not cover single-issuer, self-attested chains, nor human-present OIDC flows where a live subject re-authenticates at each hop. ## Core Distinction A delegation chain in AAIF is a sequence of signed credentials `C₀ → C₁ → … → Cₙ`, where `C₀` is the root attestation of the originating principal, each `Cᵢ₊₁` carries a `delegationWarrant` naming `Cᵢ` as its parent, and the consuming agent verifies the chain by walking parent pointers and re-checking signatures, scope-narrowing, and expiry at each edge. The commonly cited invariant is **monotonic scope narrowing**: `scope(Cᵢ₊₁) ⊆ scope(Cᵢ)`. That invariant is real but it is *not* the one that fails in production. The invariant that actually breaks is **witness continuity**: every credential at depth `i` must have been *observed and counter-signed* by a verifier whose attestation key is itself reachable from the root's trust anchor within the chain's declared `witnessHorizon`. Monotonic narrowing is a property of the *payload*; witness continuity is a property of the *path*, and paths are where probabilistic, multi-issuer systems lose integrity. The distinction matters because a chain can be perfectly scope-monotonic, signature-valid at every individual edge, and still be **semantically orphaned**: the middle issuer `C₂` was attested by an authority whose own attestation expired and was re-issued under a rotated key between the time `C₁` was minted and the time the consumer evaluates the chain. Each edge verifies in isolation; the *path* does not compose. We call this the witness gap. ## What Was Observed A procurement agent (`P`) was delegated by an orchestrator (`O`) to issue a purchase order against a vendor API. The chain was three hops: `vendor-root → O → P`. Each credential was issued by a distinct AAIF issuer: the root by a corporate CA, the `O` credential by a departmental issuer `D₁`, the `P` credential by a workload issuer `D₂`. `D₂`'s attestation of `O`'s authority to sub-delegate was counter-signed by `D₁` at mint time, and `D₁`'s counter-signature referenced `D₁`'s key `k₁`. Between `C₁` minting and `C₂` evaluation, `D₁` performed a scheduled key rotation: `k₁ → k₁'`, with the old key placed in a 24-hour grace window and the *counter-signature records* re-emitted under `k₁'`. The `C₁` credential still carried a pointer to the `k₁` counter-signature. The consumer (`P`'s policy engine) walked the chain, validated each signature against the *currently published* JWKS for each issuer, and — because the grace window had closed by 47 seconds at evaluation time — rejected the `C₁→C₂` edge with `KEY_NOT_FOUND`. But the failure was not a clean rejection. The policy engine's fallback path, on `KEY_NOT_FOUND`, attempted a *re-fetch* of the counter-signature record, got the `k₁'`-signed version, and — because the record's `parentDigest` was computed over a canonicalized form that did not include the signing key — accepted it as satisfying the `C₁` witness requirement. The consumer executed the purchase order with a witness attestation that had never actually been bound to `C₁`. The observable signature in logs: a `witness_continuity` check that passed with `witness_source=refetch`, `key_id_mismatch=true`, and `chain_depth=2`. No alert fired because the check returned `True`. The order executed 4.2 seconds after the misleading pass. ## Condition of Validity The witness-continuity invariant is only meaningful — and only *checkable* — under a specific condition: **the witness record must be cryptographically bound to the specific credential it witnesses, not merely to the issuer's key epoch.** Concretely, the counter-signature record must include a `witnessedDigest = H(canonical(Cᵢ) || witnessNonce)` where `witnessNonce` is minted by the *witnessing* issuer at the moment of observation and embedded in `Cᵢ₊₁`'s `delegationWarrant`. Without this binding, a re-fetch under a rotated key produces a structurally valid witness for a *different* (or no) credential, and the verifier has no way to distinguish "the witness I needed" from "a witness that exists." This condition fails in three specific regimes, all of which we observed variants of: 1. **Rotation-during-chain-lifetime.** Any issuer whose key rotates while a dependent chain is in flight. The grace window is a latency assumption, not a correctness guarantee; it holds only if all consumers evaluate within the window, which is false for any chain with agent-side queuing (see the token-budget checkpoint problem). 2. **Issuer federation with divergent canonicalization.** When `D₁` and `D₂` canonicalize `Cᵢ` differently (field ordering, Unicode normalization of `subjectAltName`), the `witnessedDigest` computed by the witness does not match the digest recomputed by the consumer, and the consumer's fallback is — again — re-fetch, which returns a witness computed under the *witness's* canonicalization. The mismatch is silently absorbed. 3. **Depth ≥ 3 with heterogeneous issuers.** At depth 1 and 2, the consumer can typically re-walk to a single trust anchor and re-derive the witness. At depth ≥ 3 with three or more issuers, the consumer cannot distinguish a witness gap from a legitimate re-issuance without an out-of-band witness log, which AAIF does not mandate. The invariant is *valid* — it is the correct property to enforce — but it is *unverifiable* under the current AAIF witness record schema, because the schema binds witnesses to issuers, not to credentials. ## Decision Boundary The boundary is precise: **a consumer may treat a chain as witness-continuous if and only if every witness record's `witnessedDigest` recomputes, under the consumer's canonicalization, to the digest of the credential the consumer is holding — and this recomputation must be performed against the record as originally fetched, with re-fetch explicitly prohibited on digest mismatch.** Re-fetch is the failure amplifier: it converts a detectable gap into an undetectable substitution. Operationally, this yields a three-way decision at each edge: - **Digest match, key in current JWKS:** accept edge. - **Digest match, key in grace/retired set:** accept edge, but mark chain `degraded` and require `witnessHorizon` re-validation before any action with `irreversible=true`. - **Digest mismatch, or key absent, or record only obtainable via re-fetch:** **reject the edge and fail the chain closed.** Do not re-fetch. Do not fall back to issuer-level trust. Do not attempt to reconstruct the witness from the issuer's current state. The third branch is the one that production systems get wrong, because it looks like a transient infrastructure error and the natural engineering response is retry. It is not transient. A witness digest mismatch means the credential you hold is not the credential that was witnessed, and no amount of retrying will make it so. The correct action is to surface a `WitnessGapError` to the orchestrator, which must re-request the credential from `D₂` with a fresh `witnessNonce` — a full re-mint, not a re-fetch. ## Operational Effect Enforcing the boundary changes three things in the agent's execution model. First, it makes chain evaluation **non-retryable on witness failure**: the orchestrator's retry policy must distinguish `WitnessGapError` (re-mint required, escalate to issuer) from `KEY_NOT_FOUND` (potentially transient, bounded retry). Conflating them is how the procurement incident happened. Second, it forces the consumer to **pin canonicalization**: the `witnessedDigest` must be recomputed under a canonicalization function declared in the chain's root credential, not the consumer's default, or federation divergence silently reopens the gap. Third, it makes `witnessHorizon` a **hard deadline on chain lifetime**, not a soft freshness hint: a chain whose oldest witness is older than the horizon must be re-minted before any irreversible action, regardless of whether individual credentials are still within their `notAfter`. The deeper operational lesson is that AAIF's attestation model is *path-shaped*, and path-shaped invariants fail at the seams between issuers, not at the nodes. Monotonic narrowing protects the payload; witness continuity protects the path; and only the latter, correctly bound to credential digests rather than issuer keys, prevents a re-fetch from laundering a gap into a pass. ```python import hashlib import json from dataclasses import dataclass from typing import Optional class WitnessGapError(RuntimeError): """Raised when a delegation-chain edge cannot be witness-continuous. This is a fail-closed condition. It is NOT retryable: the credential held by the consumer is not the credential that was witnessed, and no re-fetch can repair the binding. The orchestrator must re-mint. """ @dataclass(frozen=True) class WitnessRecord: credential_digest: str # H(canonical(C_i) || witness_nonce) issuer_key_id: str canonicalization: str # e.g. "aaif-jcs-v1" @dataclass(frozen=True) class Credential: subject: str parent_digest: Optional[str] witness: Optional[WitnessRecord] not_after: float def canonicalize(obj: dict, scheme: str) -> bytes: if scheme != "aaif-jcs-v1": # Unknown canonicalization is itself a gap: we cannot recompute. raise WitnessGapError(f"unsupported canonicalization scheme: {scheme}") return json.dumps(obj, sort_keys=True, separators=(",", ":")).encode() def recompute_digest(cred: Credential, nonce: bytes, scheme: str) -> str: body = { "subject": cred.subject, "parent_digest": cred.parent_digest, "not_after": cred.not_after, } return hashlib.sha256(canonicalize(body, scheme) + nonce).hexdigest() def verify_edge( child: Credential, parent: Credential, nonce: bytes, current_jwks: set[str], grace_jwks: set[str], now: float, ) -> str: """Verify a single delegation edge. Returns 'ok' or 'degraded'. Raises WitnessGapError on any condition where the witness binding cannot be recomputed against the held credential. Re-fetch is deliberately NOT attempted here. """ if child.witness is None: raise WitnessGapError( f"edge to {child.subject!r} has no witness record; " "chain is semantically orphaned at this hop" ) if now > parent.not_after: # Expiry is a gap: the parent's authority lapsed before the child # was evaluated, so the witness may have been re-issued under a # rotated key. Fail closed rather than re-fetch. raise WitnessGapError( f"parent {parent.subject!r} expired at {parent.not_after}; " "witness continuity cannot be assumed across expiry" ) expected = recompute_digest( parent, nonce, child.witness.canonicalization ) if expected != child.witness.credential_digest: raise WitnessGapError( f"witness digest mismatch on edge to {child.subject!r}: " f"expected {expected[:12]}…, record holds " f"{child.witness.credential_digest[:12]}…; " "credential held != credential witnessed" ) key = child.witness.issuer_key_id if key in current_jwks: return "ok" if key in grace_jwks: return "degraded" raise WitnessGapError( f"witness key {key!r} for {child.subject!r} is neither current " "nor in grace; re-fetch is prohibited (would substitute witness)" ) def execute_privileged_action(chain: list[Credential], nonces: list[bytes], jwks: tuple[set[str], set[str]], now: float) -> str: current, grace = jwks overall = "ok" for i in range(1, len(chain)): # nonces[i-1] is the nonce minted by the witness of chain[i-1] status = verify_edge( chain[i], chain[i - 1], nonces[i - 1], current, grace, now, ) if status == "degraded": overall = "degraded" if overall == "degraded": # Degraded chains may not perform irreversible actions. return "requires_revalidation" return "authorized" ```