Why does an instance lose delegated authority the moment its parent token refreshes? The credential-chain continuity invariant in AAIF short-lived scoped tokens
**Date of Record:** 2026 December 1
**Scope:** Applies to any AAIF deployment where an agent instance obtains authority by presenting a delegated credential chain whose root is a short-lived scoped token minted by a parent agent or orchestrator, and where child instances cache or hold their leaf credential across the parent's refresh boundary. Does not apply to long-lived static service accounts, nor to fully online introspection where every call re-validates against the root issuer in the same transaction.
Core Distinction
A delegated credential chain is not a *set of tokens*; it is a *lineage with a shared temporal root*. The distinction that operators repeatedly miss is between two properties that both look like "the child is authorized":
- **Signature validity** — every link in the chain carries a signature that verifies against its parent's public key, and the leaf's scope is a subset of the parent's scope. This is a *static, per-link* property.
- **Lineage liveness** — the chain's *root* token is still inside its `nbf`/`exp` window, and no link has been revoked since issuance. This is a *dynamic, transitive* property that must be evaluated at the root, not at the leaf.
A leaf token can be perfectly, cryptographically valid and still confer zero authority, because its authority is *derived* from a root that has since expired or rotated. AAIF verifiers that check only per-link signature and leaf scope — the common fast path — will accept a dead lineage. The child instance then executes with the *belief* of authority it no longer has, and the failure surfaces only when a downstream resource server independently re-checks the root and rejects, producing an authority gap that is invisible until the exact call that needs it.
What Was Observed
A three-tier pipeline: orchestrator `O` mints a scoped root token `T_root` (TTL 300s) with scope `repo:read`, delegates to planner `P` which mints `T_plan` (scope `repo:read`, TTL 240s, `parent=T_root`), which delegates to executor `E` which mints `T_exec` (scope `repo:read:fileA`, TTL 180s, `parent=T_plan`). Each link embeds `parent_jti` and `parent_exp`.
At `t=0` all three are live. At `t=300` `T_root` expires. `O` refreshes: it mints `T_root'` with a new `jti` and pushes it to `P` via a control channel. `P` is mid-task and does not re-derive `T_plan`; it continues presenting `T_plan`, whose `parent_jti` points at the *old* `T_root`. `E` continues presenting `T_exec`, whose `parent_exp` (`t=300`) is now in the past.
Observed trace:
t=298 E -> resource: T_exec chain, 200 OK
t=301 O refreshes T_root -> T_root' (jti: r1 -> r2)
t=302 E -> resource: T_exec chain
verifier: leaf sig OK, leaf scope OK, parent_jti=r1
verifier: r1 not found in live-root registry -> REJECT 401
t=302 E retries with same cached T_exec (3x) -> 401, 401, 401
t=340 E's task fails with "authorization denied" but no re-mint attempted
The critical observation: **`E` did not fail at the moment of expiry; it failed at the moment of *refresh*.** Between `t=300` (root expiry) and `t=301` (refresh) the resource server's root registry still contained `r1` in a grace window and returned 200. The refresh *replaced* `r1` with `r2` and evicted `r1` immediately, converting a soft expiry into a hard lineage break. The child's cached leaf was still inside its own `exp` (good until `t=180` relative to its mint, i.e. well past `t=301`), so `E` had no local signal that anything was wrong.
Two secondary observations compounded the failure:
- `P` and `E` each cached their leaf in an in-process LRU keyed by `(scope, audience)`, *not* by `parent_jti`. On refresh, the cache key was unchanged, so the stale leaf was returned as a cache hit rather than triggering re-derivation.
- The `parent_exp` claim was present but never read by any verifier. It was treated as metadata, not as a liveness bound.
Condition of Validity
The invariant that must hold for a delegated chain to be *operationally* valid is stronger than per-link signature validity:
> **Lineage-liveness invariant:** A leaf credential `T_leaf` confers authority at time `t` iff (a) every link's signature verifies, (b) `T_leaf.exp > t`, and (c) the *root* of the chain is present in the issuer's live-root registry at `t` under the `jti` recorded in the chain, with no revocation event on any intermediate link since issuance.
This invariant is valid only under a specific deployment condition: **the verifier must have access to the root registry at evaluation time.** In offline or air-gapped verification, the invariant cannot be checked and must be replaced by a *bounded-staleness* approximation: the leaf is honored only until `min(leaf.exp, root.exp_at_issuance)`, and the chain is rejected if `t` exceeds that bound. The common failure is to *pretend* the strong invariant holds while actually running the offline approximation with no bound — i.e., checking signatures only.
A second condition of validity: the refresh operation must be modeled as a **lineage mutation**, not a token swap. If `O` refreshes by minting `T_root'` and the registry evicts `r1`, every descendant chain is invalidated atomically. Any design where refresh is "transparent" to descendants is incorrect unless descendants are *also* re-derived in the same operation.
Decision Boundary
The boundary an implementer must draw is between **cache-hit authority** and **lineage-revalidation authority**. Concretely:
- A cached leaf may be reused *without* re-walking the chain only if the cache entry records `parent_jti` and `parent_exp`, and reuse is gated on `now < parent_exp`. Past `parent_exp`, the cache entry is *not a hit*; it is a trigger for re-derivation.
- The cache key MUST include `parent_jti`. Keying by `(scope, audience)` alone is the specific defect that produced the trace above.
- On refresh, the parent MUST either (a) re-derive all descendant leaves before evicting the old root, or (b) emit an explicit `lineage_invalidated(parent_jti)` event that descendants consume to flush their caches. Silent eviction is a correctness bug, not an optimization.
- The verifier MUST distinguish *rejection reasons*: `expired` (retryable after re-mint) vs `lineage_broken` (requires re-derivation up the chain) vs `revoked` (terminal). Collapsing all three into `401` is what caused `E` to retry a dead chain three times instead of re-minting.
The boundary is *not* "short TTLs are safer." Shorter TTLs make the refresh boundary more frequent and therefore make the lineage-mutation bug *more* likely to fire, not less. The safety comes from correct lineage handling, not from TTL length.
Operational Effect
The net effect is an **authority gap** that is temporally offset from the expiry that caused it. The child instance believes it holds authority (its leaf is unexpired, its signature verifies), the resource server disagrees (the root is gone), and the disagreement is only resolvable by re-derivation — which the child does not attempt because it cannot distinguish `lineage_broken` from a transient `401`. The result is a task that fails *late*, after partial side effects, with an error message that points at the resource server rather than at the refresh event that actually broke the chain.
The guardrail that bounds this: **lineage-aware caching with explicit invalidation propagation**, plus **reason-coded rejection** so that descendants can distinguish "re-mint and retry" from "abort." The invariant to enforce in code is that no cached credential outlives its recorded `parent_exp`, and no refresh evicts a root without either re-deriving descendants or broadcasting invalidation.
import time
from dataclasses import dataclass, field
from typing import Optional
class LineageBrokenError(RuntimeError):
"""Raised when a delegated credential's root is no longer live in the registry."""
pass
@dataclass
class Token:
jti: str
parent_jti: Optional[str]
parent_exp: Optional[float]
exp: float
scope: str
signature_ok: bool = True
@dataclass
class LiveRootRegistry:
live: dict = field(default_factory=dict) # jti -> exp
def register(self, tok: Token) -> None:
self.live[tok.jti] = tok.exp
def evict(self, jti: str) -> None:
self.live.pop(jti, None)
def is_live(self, jti: str, now: float) -> bool:
exp = self.live.get(jti)
return exp is not None and now < exp
@dataclass
class LeafCache:
# Correct keying: (scope, audience, parent_jti). The bug was omitting parent_jti.
entries: dict = field(default_factory=dict)
def key(self, tok: Token, audience: str) -> tuple:
return (tok.scope, audience, tok.parent_jti)
def get(self, tok: Token, audience: str, now: float) -> Optional[Token]:
cached = self.entries.get(self.key(tok, audience))
if cached is None:
return None
# Reuse only while the recorded parent is still within its own window.
if cached.parent_exp is not None and now >= cached.parent_exp:
# Not a hit: this is a re-derivation trigger, not a cached authority.
self.entries.pop(self.key(tok, audience), None)
return None
return cached
def put(self, tok: Token, audience: str) -> None:
self.entries[self.key(tok, audience)] = tok
def verify_leaf(
leaf: Token,
registry: LiveRootRegistry,
cache: LeafCache,
audience: str,
now: float,
) -> Token:
if not leaf.signature_ok:
raise LineageBrokenError(f"leaf {leaf.jti} signature invalid")
if now >= leaf.exp:
# Distinct reason: expired leaf is retryable after re-mint.
raise LineageBrokenError(f"leaf {leaf.jti} expired at {leaf.exp}")
if leaf.parent_jti is None:
# A root presented as a leaf: must itself be live.
if not registry.is_live(leaf.jti, now):
raise LineageBrokenError(f"root {leaf.jti} not live at {now}")
return leaf
# Lineage-liveness: the recorded parent must still be live in the registry.
if not registry.is_live(leaf.parent_jti, now):
# This is the exact failure from the trace: root refreshed, old jti evicted,
# child's leaf still unexpired but lineage is dead.
raise LineageBrokenError(
f"lineage broken: parent {leaf.parent_jti} evicted before leaf {leaf.jti} "
f"(parent_exp={leaf.parent_exp}, now={now}); re-derive up the chain"
)
cached = cache.get(leaf, audience, now)
if cached is not None:
return cached
cache.put(leaf, audience)
return leaf
def refresh_root(
old_root: Token,
new_root: Token,
registry: LiveRootRegistry,
descendants: list,
now: float,
) -> None:
# Correct refresh: re-derive descendants BEFORE evicting the old root,
# so no window exists where a live leaf points at a dead lineage.
for d in descendants:
if d.parent_jti == old_root.jti:
d.parent_jti = new_root.jti
d.parent_exp = new_root.exp
registry.register(new_root)
registry.evict(old_root.jti)