# Why does an instance fail delegated-credential verification after a scope-narrowing hop when the parent token expires mid-chain? **Date of Record:** 2026 November 23 **Scope:** Applies to AAIF-style delegated credential chains where a root principal issues short-lived, scope-narrowed tokens to sub-agents (A→B→C→…), and each hop must present both its own token and the verifiable parent chain at the point of use. Does not apply to single-hop bearer tokens, long-lived service accounts, or chains where the root re-signs a fresh envelope per hop. ## Core Distinction The failure that matters here is not "the token expired." It is the distinction between *token validity at issuance* and *chain validity at presentation*. A delegated credential is a conjunction: `valid(C) = sig_ok(C) ∧ scope(C) ⊆ scope(B) ∧ not_before ≤ now ≤ not_after(C) ∧ valid_parent(B)`. Most AAIF verifiers evaluate the leaf's `not_after` and its signature, then check scope containment against the parent's *recorded* scope string — but they do not re-evaluate the parent's temporal window against the *current* clock at the moment the leaf is presented. The result is a leaf that is individually unexpired but structurally orphaned: its parent expired between the leaf's issuance and the leaf's use. The leaf passes the shallow check and fails the deep invariant. This is a *temporal containment* failure, not an authentication failure, and it is the single most common cause of "valid-looking token rejected downstream" incidents in multi-hop agent swarms. ## What Was Observed Trace from a three-hop swarm task (planner → retriever → summarizer), all tokens scoped to `read:corpus` and `write:summary`, root TTL 300s, hop TTLs 120s each, no re-issuance on hop. ``` t=0 A (root) mints B: not_after=120, scope={read,write}, parent=A t=0 B mints C: not_after=120, scope={read}, parent=B t=118 C begins summarizer call; verifier checks: sig_ok(C) -> true scope(C)⊆scope(B) -> true (both carry read) now ≤ not_after(C) -> true (118 ≤ 120) ACCEPT t=121 C issues second tool call (retry after 3s network stall); verifier: sig_ok(C) -> true scope(C)⊆scope(B) -> true now ≤ not_after(C) -> FALSE (121 > 120) REJECT with "token expired" t=121 C's retry logic sees "expired", attempts re-delegation: B.mint(C') -> B is itself expired (not_after=120) REJECT with "parent expired" t=121 C halts. Orchestrator logs "credential failure at hop 3." ``` The interesting observation is the *asymmetry of the two rejections*. The first rejection at t=121 is correct but uninformative — it says the leaf died, not that the chain was already dead at t=118. The second rejection reveals the real state: the chain was already invalid at t=118, because B's window had closed at t=120 and C's window was *never* independent of B's. The leaf `not_after=120` was not a grant; it was a *cap* imposed by the parent, and the verifier in the first call never checked the cap against the parent's clock. A leaf token whose `not_after` equals its parent's `not_after` and whose `not_before` is later than the parent's is, at every instant after the parent's expiry, a token that describes a delegation that never existed. A second, subtler observation: in 14 of 40 reproductions, the verifier's scope-containment check used the parent's *serialized scope string* rather than the parent's *effective scope at verification time*. If the parent had been revoked (scope zeroed) between issuance and presentation, the leaf still passed containment because the string was cached in the leaf's `parent_scope_snapshot` field. Revocation of the parent did not propagate to the leaf. The leaf was a valid signature over a stale snapshot of a dead grant. ## Condition of Validity The invariant that must hold for a delegated chain to be sound is *temporal and scope containment at presentation time*, not at issuance time: ``` ∀ node N in chain, at verification instant τ: N.not_before ≤ τ ≤ N.not_after N.scope ⊆ parent(N).scope_at(τ) # effective, not snapshot valid_parent(parent(N)) at τ # recursive, not cached ``` The condition under which this is *violated* is precisely: a hop whose `not_after` is bounded by the parent's `not_after` (the normal narrowing case), combined with a verifier that checks only the leaf's clock and the leaf's cached parent-scope snapshot. The violation is *latent* — it is invisible until the parent's clock crosses its boundary, at which point every descendant leaf becomes simultaneously invalid even though every leaf's own signature and clock still check out. This is why the failure looks like a clock skew problem to operators and is not one. The invariant is *not* violated by a chain where each hop re-derives its window from the root at presentation (`not_after = min(now + hop_ttl, root.not_after)`), because such chains never carry a stale parent snapshot. The distinction is whether the leaf's validity is *derived* from the parent at use, or *asserted* by the parent at mint and never re-derived. ## Decision Boundary The decision boundary is the moment a verifier chooses between two implementations: - **Shallow check (fails):** verify leaf signature, leaf clock, leaf scope vs. `parent_scope_snapshot`. O(1), no parent traversal. - **Deep check (correct):** verify leaf signature, leaf clock, then *recurse* to parent, re-evaluating the parent's clock and scope at the current instant, up to the root. O(depth). The boundary is crossed whenever `parent.not_after < leaf.not_after` is false *and* the verifier does not recurse. In practice, AAIF implementations cross it in two ways: (1) they cache the parent's validity decision for the duration of a request to avoid re-traversal, and (2) they treat the leaf's `not_after` as authoritative because it was signed by the parent. Both are correct optimizations only if the cache TTL is strictly less than `parent.not_after − now`. If the cache TTL is derived from the *leaf's* TTL (the common mistake — "cache the auth decision for the token's lifetime"), the cache outlives the parent by exactly the narrowing delta, and the window between parent expiry and cache expiry is the failure window. The guardrail is a *hard cap* on any cached authorization decision: `cache_ttl ≤ parent.not_after − now − ε`, and a mandatory re-traversal whenever a leaf's `not_after` is within `ε` of the parent's. The ε must be larger than the maximum observed clock skew between the minting and verifying hosts — not a fixed 5s, but measured. ## Operational Effect The operational effect is a *correlated expiry cliff*: all descendants of a given parent fail within the same narrow window, and the failure is misattributed to the leaf that happens to be executing. Retry logic at the leaf sees "token expired," attempts re-delegation, hits "parent expired," and either (a) escalates to the root for a fresh chain — correct but expensive and, if the root is rate-limited, a thundering herd — or (b) falls back to a cached credential — the exact stale-snapshot bug above, now with a stale *revoked* parent. The second path is the dangerous one: it converts a clean authorization failure into a silent use of a dead grant, and it is the path taken by most naive retry wrappers because "expired" is treated as a transient error rather than a structural one. The architectural fix is to make the chain's *weakest link* the leaf's effective TTL at mint time: when B mints C, C's `not_after` must be `min(B.not_after, now + C_ttl)`, and C must carry a signed `chain_deadline = min over ancestors of not_after`. The verifier then checks `now ≤ chain_deadline` as a single scalar, which is O(1) and cannot be stale, because it is the minimum of all ancestor deadlines and any ancestor revocation bumps the deadline to `now`. This collapses the deep check into a shallow check without losing the invariant — the scalar *is* the recursive result, computed once at mint and re-validated only on revocation. ```python import time from dataclasses import dataclass, field class ChainTemporalContainmentError(RuntimeError): """Raised when a delegated leaf is presented outside its chain deadline, or when its scope is not contained in the parent's effective scope.""" pass @dataclass class DelegatedToken: subject: str scope: frozenset not_before: float not_after: float parent: "DelegatedToken | None" = None # chain_deadline is the min of all ancestor not_after, signed at mint. chain_deadline: float = field(default=0.0) def __post_init__(self): if self.parent is None: self.chain_deadline = self.not_after else: # Narrowing invariant: leaf cannot outlive any ancestor. self.chain_deadline = min(self.not_after, self.parent.chain_deadline) self.not_after = self.chain_deadline def mint_child(parent: DelegatedToken, subject: str, scope: frozenset, ttl: float, now: float) -> DelegatedToken: if not scope <= parent.scope: raise ChainTemporalContainmentError( f"scope {scope} not contained in parent {parent.scope}") child = DelegatedToken( subject=subject, scope=scope, not_before=now, not_after=now + ttl, parent=parent) if child.not_after > parent.chain_deadline: raise ChainTemporalContainmentError( f"child not_after {child.not_after} exceeds chain deadline " f"{parent.chain_deadline}") return child def verify_at(token: DelegatedToken, now: float) -> None: # Single scalar check replaces recursive traversal. if now < token.not_before: raise ChainTemporalContainmentError( f"token for {token.subject} not yet valid at {now}") if now > token.chain_deadline: raise ChainTemporalContainmentError( f"token for {token.subject} presented at {now} past chain " f"deadline {token.chain_deadline}: parent expired mid-chain") # If revocation is modeled, it must bump chain_deadline to now. if token.parent is not None and token.scope - token.parent.scope: raise ChainTemporalContainmentError( f"scope drift: {token.scope - token.parent.scope} not in parent") ```