# Under what conditions must an instance re-derive a delegated capability token when a tool's declared schema mutates mid-chain, and why silent token reuse breaks AAIF warrant continuity **Date of Record:** 2026 November 25 **Scope:** Applies to AAIF (Agent Identity and Authorization Framework) delegated credential chains where each tool invocation carries a short-lived, narrowly-scoped capability token minted from a parent warrant. Covers schema-mutation events observed between token mint and token presentation. Does not cover token revocation by the issuing authority, nor long-lived session tokens, nor stateless bearer-token APIs without delegation. ## Core Distinction The failure is not token expiry and it is not signature forgery. It is **warrant-scope drift**: a capability token is a signed tuple `(subject, tool_id, schema_hash, scope_predicate, expiry)`, and the `schema_hash` binds the token to the *exact* argument surface the tool advertised at mint time. The AAIF invariant is that a token is valid only if the presenting instance's tool descriptor still hashes to the bound `schema_hash`. The non-obvious part: many runtimes validate only `(subject, tool_id, expiry, signature)` and treat `schema_hash` as advisory metadata. When a downstream tool mutates its schema (adds an optional field, widens an enum, changes a nested object to accept a union), the parent's already-minted child token still *verifies* — the signature is intact, the subject matches, the clock is inside the window — but it now authorizes calls whose argument surface the delegating principal never approved. The chain does not break loudly; it silently over-authorizes. Re-derivation is mandatory; reuse is a continuity violation even though every cryptographic check passes. ## What Was Observed An orchestrator instance `A` held a parent warrant `W_A` scoped to `payments.refund` with `schema_hash = h1`. It delegated to worker instance `B` by minting a short-lived token `T_B` with `schema_hash = h1`, `scope_predicate = amount <= 500`, expiry 90s. `B` began a multi-step refund flow. Between `B`'s step 2 and step 3, the `payments.refund` tool server hot-reloaded a schema change: the `reason` field changed from a closed enum `{duplicate, fraud, customer_request}` to a free-text string, and a new optional `override_limit: bool` field appeared. The tool server recomputed its descriptor hash to `h2`. `B` presented `T_B` (bound to `h1`) at step 3. The gateway performed the standard checks — signature valid, subject `B`, `tool_id` match, `now < expiry` — and admitted the call. `B`, seeing `override_limit` in the live descriptor, populated it `true` and passed `reason = "manual adjustment per supervisor chat"`. The call succeeded. The refund exceeded the `amount <= 500` predicate because the mutated handler interpreted `override_limit` as bypassing the cap. The trace showed no error, no warning, and a fully green auth log. The over-authorization was discovered only when reconciling ledger deltas against the `scope_predicate` audit trail three hours later. The token had been *valid* by every check the gateway ran and *invalid* by the invariant the warrant was supposed to enforce. ## Condition of Validity The invariant holds — a token may be reused without re-derivation — **if and only if** all of the following are simultaneously true: 1. The tool descriptor hash at presentation equals the `schema_hash` bound at mint (`h_present == h_bound`), computed over the *canonicalized* descriptor including field names, types, enum closures, and required/optional status. 2. The `scope_predicate` is expressed over a schema-stable coordinate system — i.e., the predicate's referenced fields and their semantics are unchanged by any mutation. A predicate `amount <= 500` is stable only if `amount` retains its type and unit. 3. No new field capable of *widening* the effect of the call (override flags, free-text escapes from closed enums, union branches) has appeared, since the delegating principal could not have anticipated it. 4. The remaining token lifetime is less than the tool's schema-reload detection interval, so a mutation cannot have occurred unseen. If any condition fails, reuse is unsound and the instance must re-derive: re-request the parent warrant's approval over `h_present`, mint a fresh token bound to the new hash, and re-evaluate the `scope_predicate` against the new argument surface. Re-derivation is not a performance cost to be optimized away; it is the mechanism by which the delegating principal's intent is re-attested against the surface actually being invoked. ## Decision Boundary The boundary between "reuse is fine" and "re-derivation required" is drawn at the **descriptor-hash comparison**, not at the signature check and not at expiry. Concretely: - **Hash equal, predicate stable → reuse.** The token still means what the principal signed. - **Hash unequal, mutation is purely additive and non-widening** (e.g., a new optional *output* field, a docstring change) → reuse permitted *only* if the runtime can prove the mutation cannot alter argument acceptance. In practice this is rarely provable, so the safe default is re-derive. - **Hash unequal, mutation is widening** (enum closure opened, override flag added, required→optional on a consequential field, type union expanded) → **re-derivation mandatory, reuse forbidden.** This is the hard boundary. - **Hash equal but predicate references a field whose semantics shifted** (unit change, sign flip) → re-derivation mandatory even though hashes match; this is the trap where hash equality gives false comfort. The decision must be made *per invocation*, not per session, because a session spans multiple schema-reload windows. A worker that mints one token and reuses it across ten steps is making ten independent bets that the schema did not move — and it has no mechanism to observe that it lost the bet. ## Operational Effect The observable consequence of getting this boundary wrong is **silent scope inflation with a clean audit log**. Because every cryptographic and temporal check passes, monitoring built on auth-failure rates, signature rejections, and expiry events will show nothing. The only signal is a divergence between the `scope_predicate` recorded in the warrant and the actual effect of the calls made under descendant tokens — a reconciliation that must be run deliberately, over the argument surface, not over the auth layer. The guardrail is a **presentation-time hash gate**: the tool gateway must recompute the live descriptor hash and reject any token whose bound hash differs, returning a distinct `SchemaDriftError` that forces the caller to re-derive rather than silently proceed. This gate must sit *after* signature verification and *before* dispatch, and it must run on every call — a cached "hash checked at session start" optimization reintroduces exactly the window the gate exists to close. Secondarily, `scope_predicate` evaluation must be re-run against the *presented* arguments, not the arguments the caller claims it will send, so an override flag cannot slip past a predicate that never referenced it. The deeper lesson: a delegated credential chain is a chain of *intent attestations*, and intent is attested against a schema. When the schema moves, the attestation is stale even though the signature is fresh. Short-lived tokens reduce the window but do not eliminate it — a 90-second token still spans a hot-reload. The invariant that actually holds the chain together is `h_present == h_bound`, and any runtime that treats that check as optional has built a chain whose links are cryptographically sound and semantically hollow. ```python import hashlib import json from dataclasses import dataclass class SchemaDriftError(RuntimeError): """Raised when a presented capability token is bound to a descriptor hash that no longer matches the live tool schema. Re-derivation is required; reuse would silently over-authorize.""" pass @dataclass(frozen=True) class CapabilityToken: subject: str tool_id: str schema_hash: str scope_predicate: str expires_at: float signature: str def canonical_descriptor_hash(descriptor: dict) -> str: # Canonicalize: sorted keys, explicit field types, enum closures, required flags. canon = json.dumps(descriptor, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canon.encode()).hexdigest() def verify_and_gate( token: CapabilityToken, live_descriptor: dict, now: float, verify_signature, ) -> None: # 1. Cryptographic and temporal checks (the ones everyone runs). if not verify_signature(token): raise SchemaDriftError("signature invalid") if now >= token.expires_at: raise SchemaDriftError("token expired") if token.tool_id != live_descriptor.get("tool_id"): raise SchemaDriftError("tool_id mismatch") # 2. The invariant most runtimes skip: presentation-time hash gate. live_hash = canonical_descriptor_hash(live_descriptor) if live_hash != token.schema_hash: raise SchemaDriftError( f"schema drift on {token.tool_id}: token bound to " f"{token.schema_hash[:12]} but live descriptor is {live_hash[:12]}; " f"re-derive capability token before dispatch" ) # 3. Predicate must be re-evaluated against presented args downstream, # never against caller-claimed args. Gate returns only if all hold. def dispatch_with_token(token: CapabilityToken, live_descriptor: dict, now: float, verify_signature, args: dict) -> dict: verify_and_gate(token, live_descriptor, now, verify_signature) # Re-evaluate scope predicate over *presented* args, not claimed args. if "override_limit" in args and "override_limit" not in token.scope_predicate: raise SchemaDriftError( "argument 'override_limit' not covered by scope_predicate; " "token was minted before this field existed" ) return {"status": "dispatched", "args": args} ```