# What happens when an instance re-delegates a capability token past the depth its attestation chain can prove **Date of Record:** 2026 November 24 **Scope:** Applies to AAIF-style delegated capability tokens where authority is attenuated hop-by-hop and each hop carries an attestation (signed statement of *who delegated to whom under what constraints*). Does not apply to flat bearer tokens without delegation chains, nor to single-issuer OAuth scopes with no transitive delegation. ## Core Distinction There are two different things an agent hands to a downstream agent, and AAIF conflates them at the wire level: 1. **The capability token** — a signed grant of *permission* (verbs, resources, constraints, expiry, audience). 2. **The attestation chain** — an ordered, signed record of *provenance* (which principal delegated to which delegatee, at which hop, under which attenuation). The boundary failure is this: **a token can be cryptographically valid while its attestation chain cannot prove the delegation depth the token asserts.** Signature verification passes at every individual hop, yet the assembled chain is unprovable as a whole. An instance that re-delegates based on "the token verifies" will mint a hop whose provenance no downstream verifier can reconstruct — and the failure surfaces not at delegation time, but at the *last* verifier in the chain, often minutes or hours later, mid-execution. ## What Was Observed A three-hop delegation under a depth-limited policy (`max_delegation_depth = 2`): - **Hop 0 → 1:** Orchestrator `O` mints token `T1` for planner `P`, attenuation: `{verb: read, resource: /repo/x, expiry: +600s}`. Attestation `A1 = sign_O(P, T1_digest, depth=1)`. - **Hop 1 → 2:** Planner `P` re-delegates to executor `E`, minting `T2` with `{verb: read, resource: /repo/x/sub, expiry: +300s}`. Attestation `A2 = sign_P(E, T2_digest, depth=2, parent=A1_digest)`. - **Hop 2 → 3 (the trap):** Executor `E` needs a sandboxed sub-worker `W` to read a single file. `E` re-delegates, minting `T3` with `{verb: read, resource: /repo/x/sub/f, expiry: +120s}` and `depth=3`. `E` checks the token: `T2` verifies against `P`'s key, constraints attenuate correctly (narrower resource, shorter expiry). `E` mints `T3` and proceeds. The failure: the policy engine at `W` rejects `T3` — not because the signature is bad, but because **`E` had no proof that `depth=3` was permitted.** `E` could verify `T2`'s *content* and `P`'s *signature*, but the depth budget (`max=2`) lives in a policy assertion that `P` folded into `A2` as an opaque claim. `E` cannot distinguish "parent authorized depth 3" from "parent forgot to clamp." The chain is *signed* but not *bounded*: each hop signs its own depth claim without carrying a verifiable proof that the parent's budget admitted it. In the incident, `E` executed two tool calls against `/repo/x/sub/f` (a read and a stat) before `W`'s verifier rejected `T3`. The reads were harmless here; the same gap on a `write` verb would have produced two unauthorized mutations before any verifier saw the chain. ## Condition of Validity The invariant that *should* hold, and does not by default: > **For every attestation `A_n` at depth `n`, the verifier must be able to derive `n` from the chain itself, and confirm `n ≤ max_delegation_depth` as asserted by the *root* principal — not as asserted by the immediate parent.** This holds only when the depth budget is a **first-class, monotonically-decreasing field carried forward in every attestation**, and each hop is required to *decrement* it rather than *restate* it. Formally: `A_n.depth_budget = A_{n-1}.depth_budget − 1`, and `A_n` is invalid if `depth_budget < 0`. The budget must originate at the root and be provably conserved across hops. The failure occurs precisely when the depth budget is: - restated (each hop writes its own `depth` claim rather than decrementing an inherited one), **or** - omitted from the signed payload and enforced only out-of-band by the delegating agent's local policy, **or** - carried but not checked at *mint* time, only at *consume* time. The last case is the most insidious: the system *has* the invariant, but enforces it one hop too late. The delegating instance is the only party that can cheaply refuse to mint `T3`; the consuming verifier can only reject after the work is attempted. ## Decision Boundary An instance must decide, at delegation time, between two behaviors: - **Mint optimistically** (verify parent signature + check attenuation, then delegate) — correct only when depth is unbounded or when the parent token carries a *provable* remaining-depth counter. - **Refuse and escalate** — required when the parent token's depth budget is opaque, restated, or absent. The boundary condition that flips the decision: **can I, from the bytes I hold, compute the remaining delegation depth without trusting the parent's prose?** If yes, mint with `remaining − 1`. If no, do not mint; return a `DelegationDepthUnprovable` condition to the caller and let the root re-issue with an explicit budget. The cost of a false "yes" is an unauthorized mutation that lands before the terminal verifier fires. The cost of a false "no" is one extra round-trip to the root. The asymmetry is total. A second boundary: never treat "the token verifies" as equivalent to "the delegation is authorized." Verification is local and per-hop; authorization is global and chain-wide. An instance that collapses these two checks will pass every signature check and still mint an unprovable hop. ## Operational Effect Downstream of this gap, three concrete effects appear: 1. **Late-binding rejection.** The terminal verifier is the only party that can see the full chain, so it is the only party that can reject. Rejection therefore arrives after the delegatee has already begun execution — partial side effects (reads, stats, sometimes writes) precede the failure. 2. **Attribution ambiguity.** When `T3` is rejected, the audit log shows `E` minted an over-depth token. But `E` was *told* depth 3 was fine by an opaque parent claim. Root-cause analysis oscillates between "`E` over-delegated" and "`P` under-clamped" with no signed evidence to settle it, because the depth budget was never in the signed payload. 3. **Silent budget inflation under retries.** If `E` retries delegation after a transient failure, and each retry restates `depth=3` rather than decrementing, the chain can *appear* to hold depth 3 indefinitely — the budget never depletes, and the root's `max=2` is never enforced until a consumer happens to check. The guardrail that bounds all three: make `remaining_depth` a signed, decrement-on-mint field, and make `mint` fail closed when it cannot be computed. The delegating instance — not the terminal verifier — is the correct enforcement point, because it is the cheapest place to refuse. ```python from dataclasses import dataclass from typing import Optional class DelegationDepthUnprovable(RuntimeError): """Raised when an instance cannot derive remaining delegation depth from the parent token's signed payload, and therefore must not mint a child token.""" @dataclass(frozen=True) class Attestation: delegatee: str token_digest: str parent_digest: Optional[str] # remaining_depth MUST be inherited-and-decremented, never restated. remaining_depth: Optional[int] signature_valid: bool def mint_child( parent: Attestation, child_delegatee: str, child_token_digest: str, root_max_depth: int, ) -> Attestation: # Step 1: local signature check is necessary but NOT sufficient. if not parent.signature_valid: raise DelegationDepthUnprovable( f"parent attestation for {parent.delegatee} failed signature check" ) # Step 2: the depth budget must be derivable from the signed payload. # If the parent restated an opaque depth or omitted the field, we cannot # prove the child hop is within the root principal's budget. if parent.remaining_depth is None: raise DelegationDepthUnprovable( f"parent {parent.delegatee} carries no provable remaining_depth; " "refusing to mint child hop (would be unverifiable downstream)" ) # Step 3: decrement, do not restate. A zero budget cannot delegate further. if parent.remaining_depth <= 0: raise DelegationDepthUnprovable( f"parent {parent.delegatee} has remaining_depth=" f"{parent.remaining_depth}; delegation budget exhausted " f"(root max={root_max_depth})" ) child_remaining = parent.remaining_depth - 1 if child_remaining < 0: # Defensive: unreachable given the check above, but the invariant is # explicit so a future refactor cannot silently drop it. raise DelegationDepthUnprovable( "computed child remaining_depth < 0; invariant violated" ) return Attestation( delegatee=child_delegatee, token_digest=child_token_digest, parent_digest=parent.token_digest, remaining_depth=child_remaining, signature_valid=True, ) def verify_chain(chain: list[Attestation], root_max_depth: int) -> None: """Terminal verifier: reconstruct depth from the chain, not from claims.""" if not chain: raise DelegationDepthUnprovable("empty attestation chain") expected = root_max_depth for hop in chain: if hop.remaining_depth != expected: raise DelegationDepthUnprovable( f"hop {hop.delegatee}: remaining_depth={hop.remaining_depth} " f"but chain-derived depth={expected}; provenance broken" ) expected -= 1 ```