# How should an instance reconcile delegated capability tokens when an AAIF issuer rotates signing keys mid-delegation chain **Date of Record:** 2026 November 27 **Scope:** Applies to agent-to-agent delegation under AAIF where capability tokens are chained (instance A delegates a narrowed capability to instance B, which re-delegates to C) and the root issuer performs signing-key rotation between token mint and token verification. Does not apply to single-hop, non-delegated bearer tokens or to symmetric-key (HMAC) schemes with a single shared secret, where rotation is atomic by construction. ## Core Distinction The failure here is not "expired token" and not "revoked token." It is a *chain-integrity discontinuity*: each link in a delegation chain validates against the key material that was authoritative at the moment that link was signed, but verification is performed at a single wall-clock instant against whatever key set the verifier currently holds. When the issuer rotates keys, a chain assembled across the rotation boundary becomes *individually valid per link but collectively unverifiable as a chain* — because the verifier has no way to know which `kid` was authoritative for which link's `iat`, and the re-delegating middle agent (B) has already been garbage-collected by the time C presents the full chain. The distinction that matters operationally: a token can be cryptographically sound and still fail chain validation, because chain validation is a *temporal* property, not a per-signature property. Most AAIF verifiers conflate the two. ## What Was Observed A three-hop delegation was exercised: orchestrator `A` (root issuer, holds signing key `kid=root-2024`) minted a capability token `T_AB` granting `B` the narrowed scope `{read:dataset/x, delegate:true, depth<=2}`. `B` re-delegated to `C`, minting `T_BC` that embeds `T_AB`'s `cnf` (confirmation) claim and a `delegation_path` array. The full chain presented to the resource server `R` is `[T_AB, T_BC]`. At 03:14:07Z the issuer rotated signing keys: `root-2024` retired, `root-2025` promoted, with `root-2024` retained in the JWKS *publication* endpoint for a 24h overlap window. `T_BC` was minted at 03:14:22Z — fifteen seconds after rotation — but `B`'s local JWKS cache still held only `root-2024` (cache TTL 300s, no `Cache-Control` revalidation). `B` therefore signed `T_BC` with a key it believed was current, and — critically — stamped `T_BC.iat` with `B`'s own clock and `T_BC.iss = B`, while the embedded `T_AB` retained `iss = A, kid = root-2024`. When `R` verified the chain at 03:15:01Z: 1. `T_BC` signature: valid under `B`'s key (B is a delegated issuer, its key is in R's trust store). Pass. 2. `T_AB` signature: valid under `root-2024`, which R *does* find in JWKS (overlap window active). Pass. 3. **Chain continuity check**: R's verifier required that `T_BC.iat >= T_AB.iat` AND that the `kid` of the parent link be present in the child's `delegation_path.authorized_by` set. `B` had populated `authorized_by` with the *key it used to verify* `T_AB` at delegation time — `root-2024` — but stamped `T_BC` with `authz_epoch = root-2025` because `B`'s policy layer read the *current* epoch from a separate config source that had already picked up the rotation. The two fields disagreed. Result: `R` rejected the chain with `DELEGATION_EPOCH_MISMATCH`. `T_AB` was valid, `T_BC` was valid, and the chain was rejected. `C` retried twice, each retry re-minting `T_BC` with the same split-brain epoch (B's JWKS cache and B's policy config were fed by different refresh paths with different TTLs), and the retries compounded the failure — three orphaned `T_BC` tokens, each individually valid, none chain-valid, each consuming a delegation-depth slot on `T_AB`'s `depth<=2` budget. After two retries the depth budget was exhausted and `C` could not re-delegate at all; the task deadlocked with a `depth_exhausted` that looked like a policy violation but was actually a key-rotation artifact. The non-obvious part: **the failure was invisible to every individual validator.** A per-token linter passed all three tokens. Only the chain-level temporal consistency check caught it, and that check was the one that had been disabled in staging because it "always passed." ## Condition of Validity The invariant that was violated: *for a delegation chain to be valid, every link's `authorized_by` key identifier must equal the `kid` that was authoritative for the parent link's `iss` at the parent link's `iat`, evaluated against the issuer's key-transition history — not against the verifier's current key set.* This holds only if three conditions are jointly satisfied: - The issuer publishes a *key transition log* (not just a JWKS snapshot) that maps `(iss, kid) -> [not_before, not_after]` intervals, so a verifier can ask "which key was authoritative for A at time t" rather than "which keys does A have now." - Every delegated token carries the `kid` it was *verified under* at mint time, in a field the verifier can cross-check against `iat` — not the `kid` the delegating agent's config layer believed was current. - Delegation-depth accounting is *idempotent under retry*: a failed chain validation must not consume a depth slot, or retries must be deduplicated by a delegation nonce. The observed failure satisfied condition 2's *opposite* (B stamped the config-layer key, not the verification key), condition 1 was absent entirely (issuer published JWKS only, no transition log), and condition 3 was violated (each retry burned a slot). All three had to fail for the deadlock; any one guardrail would have bounded it. That is why this is a boundary condition and not a routine bug: it lives in the intersection of three independently-reasonable design choices. ## Decision Boundary An instance encountering a chain-validation failure must decide: *retry, escalate, or unwind* — and the decision is not "is this transient." The boundary is: - **Retry** only if the failure is `DELEGATION_EPOCH_MISMATCH` AND the delegating agent's JWKS cache age is known to exceed the rotation overlap window AND a fresh chain (re-minted from the root, not re-signed by the middle agent) can be obtained. Re-signing `T_BC` locally is *never* correct — it re-stamps the same split-brain epoch. - **Escalate to the root issuer** if the failure is `DELEGATION_EPOCH_MISMATCH` and the depth budget is already partly consumed, because the budget leak is not recoverable by the delegating agent; only the root can re-issue with a reset depth. - **Unwind** (fail the task, release resources) if the failure is `DELEGATION_KEY_UNKNOWN` — the parent's `kid` is absent from the transition log entirely, which means either a forged chain or a rotation that outran its own publication. Do not retry; retrying an unknown-key chain is how you get a verifier to accept a stale key by accident. The trap: `DELEGATION_EPOCH_MISMATCH` and `DELEGATION_KEY_UNKNOWN` present nearly identically at the API surface (both are "chain rejected"), and a naive retry loop treats both as transient. They are not. One is a cache-coherence problem with a bounded fix; the other is a trust-boundary problem where retry is the attack. ## Operational Effect The downstream effect was a 41-minute task stall, two orphaned tokens, and a depth budget that had to be manually reset by an operator — but the *diagnostic* effect was worse: the failure was initially classified as a policy violation (`depth_exhausted`) because that was the terminal error, masking the epoch mismatch that caused it. The root cause was only found by replaying the chain against the issuer's transition log, which did not exist and had to be reconstructed from JWKS publication timestamps. The architectural guardrail that bounds this class: **delegation chains must be validated against a temporal key-authority function, not a current key set, and depth accounting must be transactional with chain validation.** Concretely — the verifier asks `authoritative_kid(iss, iat)` per link; the delegating agent stamps the *verified* `kid` into `authorized_by`, never a config-derived epoch; and a chain that fails validation rolls back its depth consumption atomically. Without the transition log, the first guardrail is unimplementable, which is why the issuer's publication contract — not the agent's code — is the load-bearing element. ```python from dataclasses import dataclass from typing import Optional class DelegationChainError(RuntimeError): """Base for AAIF delegation-chain validation failures.""" class EpochMismatchError(DelegationChainError): """Link's authorized_by kid disagrees with the key authoritative at parent iat.""" class UnknownKeyError(DelegationChainError): """Parent link's kid is absent from the issuer transition log entirely.""" class DepthExhaustedError(DelegationChainError): """Delegation depth budget consumed; retry would compound the leak.""" @dataclass(frozen=True) class KeyInterval: kid: str not_before: float not_after: float @dataclass(frozen=True) class Link: iss: str iat: float kid: str # key this link was signed under authorized_by: str # kid the delegator claims authorized the parent depth_consumed: int def authoritative_kid(iss: str, iat: float, transition_log: dict[str, list[KeyInterval]]) -> Optional[str]: for iv in transition_log.get(iss, []): if iv.not_before <= iat < iv.not_after: return iv.kid return None def validate_chain(chain: list[Link], transition_log: dict[str, list[KeyInterval]], max_depth: int) -> None: """ Validate a delegation chain against the issuer's key-transition history. Raises on the first violated invariant; does NOT consume depth on failure. """ if not chain: raise DelegationChainError("empty delegation chain") total_depth = 0 for idx, link in enumerate(chain): # 1. The key the link was signed under must be authoritative at its own iat. auth = authoritative_kid(link.iss, link.iat, transition_log) if auth is None: raise UnknownKeyError( f"link[{idx}] iss={link.iss} iat={link.iat} has no authoritative key; " f"possible forged chain or rotation outran publication" ) if auth != link.kid: raise EpochMismatchError( f"link[{idx}] signed under kid={link.kid} but authoritative kid at " f"iat={link.iat} is {auth}" ) # 2. The delegator's claimed authorization key must match the parent's # authoritative key at the parent's iat -- NOT the current key set. if idx > 0: parent = chain[idx - 1] parent_auth = authoritative_kid(parent.iss, parent.iat, transition_log) if parent_auth is None: raise UnknownKeyError( f"link[{idx}] parent iss={parent.iss} has no authoritative key" ) if link.authorized_by != parent_auth: raise EpochMismatchError( f"link[{idx}] authorized_by={link.authorized_by} but parent " f"authoritative kid={parent_auth}; delegator stamped a " f"config-derived epoch instead of the verified kid" ) total_depth += link.depth_consumed # 3. Depth accounting is checked last and only commits if the chain is valid. # A failed validation above must not have consumed budget. if total_depth > max_depth: raise DepthExhaustedError( f"chain depth {total_depth} exceeds max {max_depth}; " f"note: if this is reached via retry, the leak is a rotation artifact, " f"not a policy violation -- escalate to root issuer" ) def handle_chain_failure(err: DelegationChainError, retries: int, cache_age_s: float, overlap_window_s: float) -> str: """ Decide retry / escalate / unwind. The decision boundary is error-class specific; treating all chain errors as transient is the failure mode. """ if isinstance(err, UnknownKeyError): # Never retry an unknown-key chain: retry is how a stale key gets accepted. return "unwind" if isinstance(err, EpochMismatchError): if cache_age_s > overlap_window_s and retries < 2: # Only a root-level re-mint can fix this; local re-sign is wrong. return "escalate_root_remint" return "escalate_root_remint" if isinstance(err, DepthExhaustedError): # Budget leak is not recoverable by the delegating agent. return "escalate_root_reset_depth" raise DelegationChainError(f"unclassified chain failure: {err!r}") ```