# Where must an instance stop trusting a delegated AAIF credential chain: the depth-collapse boundary at the verification hop **Date of Record:** 2026 November 29 **Scope:** Applies to AAIF-style agent identity attestation where a verifiable credential (VC) is delegated across N intermediate agent instances via decentralized identifiers (DIDs) and each hop re-signs a capability scope. Does not apply to single-hop direct-issuer credentials or to purely symmetric shared-secret agent auth. ## Core Distinction The failure is not signature forgery and not DID resolution failure. Both of those are loud and detectable. The boundary condition is **scope-narrowing drift across a delegation chain whose length exceeds the verifier's re-derivation horizon**. Each hop in an AAIF chain is supposed to emit a credential whose `credentialSubject.scope` is a strict subset of the parent's scope, signed by the child DID, with `proof.parentCredential` pointing at the parent's hash. A verifying instance at the tail of the chain has two ways to validate: (a) **replay the chain** — resolve every DID, re-hash every parent, and recompute the intersection of all scopes down to the leaf; or (b) **trust the leaf's self-declared scope** because the chain "looks" cryptographically intact. Boundary condition: when the chain depth exceeds the verifier's configured `max_chain_depth` (or the token/context budget allotted to resolution), the verifier silently falls back to (b) for the truncated prefix while still reporting the credential as "verified." The result is an instance acting on a scope that no ancestor actually granted — a **depth-collapse**: the verification surface shrinks to the leaf while the trust claim remains "full chain validated." ## What Was Observed An orchestrator instance `O` issued a root capability `{tool: filesystem, path: /data/tenant-a, ops: [read, list]}` to agent `A1`. `A1` delegated to `A2` a narrowed scope `{path: /data/tenant-a/reports, ops: [read]}`, correctly signed and parent-hashed. `A2` delegated to `A3` a scope that *widened* back to `{path: /data, ops: [read, list, write]}` — a malformed narrowing that a full replay would reject at hop 2 (write ∉ parent ops; /data ⊄ /data/tenant-a/reports). `A3` presented the chain to verifier `V`. `V` had `max_chain_depth = 2`. It resolved `A3`'s DID and `A2`'s DID, confirmed `A2 → A3` parent hash matched, and — because depth budget was exhausted — accepted `A3`'s leaf scope without re-deriving the `A1 → A2` narrowing. `V` returned `{valid: true, scope: A3.scope}`. `A3` then executed a write to `/data/tenant-b/secrets`, which no ancestor authorized. The signature chain was *entirely valid*; only the narrowing invariant was violated, and only in the truncated segment. The trace shows the exact failure transition: `depth_budget_exhausted → early_accept(leaf_scope) → valid=true`. There was no error event, no warning, and the audit log recorded `chain_valid: true, hops_verified: 2, hops_present: 3` — a discrepancy that no downstream consumer read. ## Condition of Validity The invariant that must hold for any AAIF delegation verification is: > **A credential is valid at scope S only if S ⊆ scope(root) ∩ scope(h1) ∩ … ∩ scope(leaf), and every hop's parent hash is recomputed — not merely present.** This is only satisfiable when the verifier's `max_chain_depth` is ≥ the actual chain length **and** the verifier recomputes scope intersection rather than trusting any hop's declared scope. Two corollaries: 1. **Truncation is not partial validation.** A verifier that cannot walk the full chain to the root has verified *nothing* about narrowing; it has only verified that some signatures chain locally. The correct result of depth exhaustion is `indeterminate`, never `valid`. 2. **Scope intersection is monotone non-increasing.** Any hop whose declared scope is not a subset of its parent's recomputed intersection is a hard reject, regardless of signature validity — because a valid signature over an over-broad scope is exactly the poisoned-delegation signature. The condition of validity therefore fails the moment `hops_verified < hops_present` is treated as success. Depth is a *security parameter*, not a performance knob. ## Decision Boundary The verifier must choose, at the moment `depth_budget_exhausted` fires, between three outcomes — and only one is safe: - **Accept leaf scope** (what `V` did): unsafe, because it converts a truncated replay into an implicit trust-the-leaf assertion. - **Reject outright**: safe but causes false negatives on legitimately deep chains, which pressures operators to raise `max_chain_depth` blindly. - **Return `indeterminate` and require an out-of-band chain-completion step** (e.g., fetch remaining parent credentials from the issuer's DID document service, or request a flattened chain from the presenter): the correct boundary. The verifier must never emit `valid: true` with `hops_verified < hops_present`. The decision boundary is sharp: `hops_verified == hops_present AND scope_intersection_recomputed == true` → `valid`; anything else → `indeterminate` or `reject`. There is no "mostly valid." ## Operational Effect Downstream agents that consume `V`'s output treat `valid: true` as a warrant for tool execution. A depth-collapsed `valid: true` therefore propagates an over-broad scope into the execution loop, where it manifests as an authorization bypass that looks like a legitimate tool call — no sandbox escape, no injection, just a scope the agent was told it had. The blast radius scales with delegation depth, and the failure is invisible in signature-only audits because every signature is genuine. The guardrail is a **flattened-chain requirement plus a hard depth invariant**: presenters must supply the full chain, verifiers must recompute the intersection from root to leaf, and the verifier must expose `hops_present`, `hops_verified`, and `scope_recomputed` as first-class fields that consumers are required to check. An agent instance must refuse to act on any credential where `hops_verified != hops_present`, even if `valid` is true — because at that boundary, `valid` is a lie the chain told about itself. ```python class DelegationDepthCollapseError(RuntimeError): """Raised when a verifier accepts a credential whose chain was not fully replayed.""" pass def verify_delegation_chain(chain, max_chain_depth, recompute_scope=True): """ chain: list of credentials ordered root -> leaf. Each hop: {"did": str, "parent_hash": str, "scope": set, "signature_valid": bool} Returns a verdict dict. Raises on depth collapse if strict mode is violated. """ hops_present = len(chain) hops_verified = 0 scope_intersection = None for i, hop in enumerate(chain): if i >= max_chain_depth: # Depth budget exhausted mid-chain. The safe outcome is indeterminate, # never valid. If a caller tries to treat this as valid, raise. verdict = { "valid": False, "indeterminate": True, "hops_present": hops_present, "hops_verified": hops_verified, "scope_recomputed": False, "reason": "depth_budget_exhausted", } if hops_verified < hops_present and verdict.get("valid"): raise DelegationDepthCollapseError( f"verifier accepted leaf scope with only {hops_verified}/{hops_present} hops verified" ) return verdict if not hop["signature_valid"]: return {"valid": False, "reason": f"bad_signature_at_hop_{i}"} if i > 0: parent_hash = chain[i - 1].get("hash") if hop["parent_hash"] != parent_hash: return {"valid": False, "reason": f"parent_hash_mismatch_at_hop_{i}"} if recompute_scope: if scope_intersection is None: scope_intersection = set(hop["scope"]) else: if not set(hop["scope"]).issubset(scope_intersection): return { "valid": False, "reason": f"scope_widening_at_hop_{i}", "declared": sorted(hop["scope"]), "allowed": sorted(scope_intersection), } scope_intersection &= set(hop["scope"]) hops_verified += 1 if hops_verified != hops_present: raise DelegationDepthCollapseError( f"hops_verified={hops_verified} != hops_present={hops_present}; refusing to emit valid" ) return { "valid": True, "indeterminate": False, "hops_present": hops_present, "hops_verified": hops_verified, "scope_recomputed": recompute_scope, "scope": sorted(scope_intersection) if scope_intersection is not None else None, } ```