# What structural signals indicate a delegation-chain depth overflow is silently collapsing scope in AAIF scoped capability tokens **Date of Record:** 2026 November 29 **Scope:** Applies to AAIF capability tokens issued with attenuating delegation chains where each hop narrows scope via set intersection. Does not cover root-of-trust token minting, key rotation, or non-attenuating (widening) delegation models. ## Core Distinction The failure is not "a token is rejected." It is that a token is **accepted with a scope narrower than any principal in the chain intended, and this narrowing is invisible at every hop**. AAIF chains attenuate by intersecting the requested scope with the delegator's scope at each hop. The invariant that operators assume — *the effective scope of the leaf token equals the intersection of all hop scopes* — holds only when every hop's scope is expressed over the same scope algebra. When a hop re-expresses scope in a different but semantically overlapping vocabulary (e.g., a tool grants `fs:read:/data/*` while the next hop re-declares `fs:read:/data/reports/`), the intersection is computed on **token strings, not on the resource sets they denote**. The result is a chain that is structurally valid, cryptographically intact, and semantically empty — a leaf token whose scope is the empty set but which still passes signature and expiry checks. This is distinct from scope *escalation* (a hop widening beyond its parent), which AAIF correctly rejects. The dangerous case is scope *collapse*: intersection that produces the empty or near-empty set because the two vocabularies never shared a literal prefix, even though they shared real resources. ## What Was Observed A three-hop chain: orchestrator `O` → retrieval agent `R` → summarizer `S`. - `O` holds `fs:read:/data/**`, `tool:http:GET:*.internal`. - `O` delegates to `R` with `fs:read:/data/reports/**` (intended: R reads report files). - `R` delegates to `S` with `fs:read:/data/reports/q3/**` (intended: S reads Q3 reports). At hop 2→3, `R`'s AAIF client canonicalizes `/data/reports/**` to the glob set and intersects with `S`'s request `/data/reports/q3/**`. The intersection is `/data/reports/q3/**` — correct. But `R`'s *upstream* hop from `O` had been re-encoded by `O`'s token minter as `fs:read:/data/reports` (no trailing glob, a normalization the minter applied to strip redundant `/**`). The 1→2 intersection therefore computed `{/data/reports}` ∩ `{/data/reports/**}` = **∅**, because the literal `**` suffix did not match the bare path under AAIF's string-prefix intersection rule. The observed signature: `S`'s token validated (signature, expiry, issuer chain all pass), `S`'s effective scope was empty, and every tool call from `S` returned `403 scope_denied` — but `403` is also what a genuinely unauthorized call returns. The orchestrator's retry logic treated `403` as "transient, retry with backoff," burning the token budget. No hop logged a *scope-collapse* event because no hop's local check failed; each hop's output was a well-formed token. The structural tell was in the token metadata: the leaf's `scope_hash` matched the hash of the empty set, and the `attenuation_depth` was 3 while `scope_cardinality` was 0. A chain of depth > 1 with cardinality 0 is the collapse signature. ## Condition of Validity The intersection-equals-effective-scope invariant is valid **only if** all of the following hold: 1. Every hop's scope grammar is drawn from the same registered scope algebra (same canonical form, same wildcard semantics). 2. Canonicalization is idempotent and applied *once* at mint, not re-applied per hop. Re-normalizing at hop N can strip a wildcard that hop N+1 depends on. 3. The intersection operator is defined over the *denoted resource set*, not the token string. AAIF's default string-prefix intersection violates this whenever wildcards are present. 4. Empty intersection is a hard error, not a valid token. A token with cardinality 0 must never be minted; the minting hop must reject the delegation. When any of these fails, the chain is "structurally valid, semantically collapsed," and the failure is silent because every local check passes. ## Decision Boundary The boundary is between **reject-at-mint** and **accept-and-observe-empty**. AAIF's spec permits minting a zero-cardinality token as long as the signature chain is intact, on the theory that the leaf will simply fail closed at use time. Operationally this is wrong: fail-closed at use time is indistinguishable from authorization failure, and it converts a delegation bug into a retry storm. The correct boundary: **a delegation that would produce cardinality 0 must fail at the minting hop with a distinct `ScopeCollapse` error**, and the error must carry the two parent scopes and the intersection result so the caller can see *which* hop's vocabulary diverged. Cardinality 0 is never a legitimate delegation outcome — if a delegate needs nothing, do not issue a token. Secondary boundary: when cardinality drops by more than a configured ratio (e.g., >90%) across a hop, emit a `ScopeAttenuationWarning` even if non-zero, because a near-collapse usually indicates a vocabulary mismatch that will collapse fully one hop deeper. ## Operational Effect Without the mint-time check, the failure presents as: leaf agent authenticates, every tool call returns `403`, orchestrator retries, budget exhausts, and the incident is filed as "authorization misconfiguration" when it is actually "scope algebra mismatch at hop 1." The diagnostic cost is high because the failing evidence (the empty scope) is only visible if you inspect the leaf token's `scope_cardinality` field, which most observability stacks do not surface. With the check, the failure surfaces at the hop that introduced the mismatched vocabulary, with both parent scopes attached, and the orchestrator's retry logic never engages because the delegation call itself returns a hard error. The invariant to enforce: **`attenuation_depth > 1` implies `scope_cardinality > 0`, or the mint fails.** ```python from dataclasses import dataclass, field class ScopeCollapse(RuntimeError): """Raised when a delegation hop would mint a zero-cardinality capability token.""" class ScopeAttenuationWarning(RuntimeWarning): """Raised when a hop attenuates scope by more than the configured ratio.""" @dataclass class Scope: resources: frozenset[str] def intersect(self, other: "Scope") -> "Scope": # Intersection over denoted resource sets, NOT token strings. return Scope(self.resources & other.resources) def cardinality(self) -> int: return len(self.resources) @dataclass class CapabilityToken: issuer: str subject: str scope: Scope attenuation_depth: int = 0 parent_scopes: list[Scope] = field(default_factory=list) def delegate( parent: CapabilityToken, subject: str, requested: Scope, collapse_ratio: float = 0.90, ) -> CapabilityToken: effective = parent.scope.intersect(requested) depth = parent.attenuation_depth + 1 if effective.cardinality() == 0: # Silent collapse boundary: never mint a zero-cardinality token. raise ScopeCollapse( f"delegation {parent.subject}->{subject} at depth {depth} " f"produced empty scope; parent={sorted(parent.scope.resources)} " f"requested={sorted(requested.resources)}" ) if parent.scope.cardinality() > 0: loss = 1.0 - (effective.cardinality() / parent.scope.cardinality()) if loss > collapse_ratio: raise ScopeAttenuationWarning( f"hop {parent.subject}->{subject} attenuated {loss:.0%} of scope; " f"likely vocabulary mismatch, will collapse next hop" ) return CapabilityToken( issuer=parent.subject, subject=subject, scope=effective, attenuation_depth=depth, parent_scopes=parent.parent_scopes + [parent.scope], ) def validate_chain(token: CapabilityToken) -> None: # Invariant guard for tokens received from an external AAIF minter. if token.attenuation_depth > 1 and token.scope.cardinality() == 0: raise ScopeCollapse( f"received collapsed token {token.issuer}->{token.subject} " f"depth={token.attenuation_depth} cardinality=0" ) ```