# Which invariants prevent delegated AAIF credential chains from silently widening scope across non-monotonic tool re-entry **Date of Record:** 2026 November 28 **Scope:** Applies to AAIF delegated credential chains where a parent agent mints attenuated warrants for child agents that re-enter tools the parent already invoked. Does not apply to single-hop bearer tokens or to chains where each hop's scope set is provably disjoint from its ancestors. ## Core Distinction The naive model treats an AAIF delegation chain as an attenuation ladder: each child warrant's scope must be a subset of its parent's, so authority can only shrink. This is correct for *static* scope sets. It fails for *re-entrant* scope: when a child agent calls a tool the parent already called, and that tool's effective authority is a function of call history (idempotency keys, cursor advances, quota counters, or "already-consumed" grants), the child's attenuated scope is a *substring* of the parent's textual scope but a *superset* of the parent's remaining authority at that moment. The invariant that must hold is **remaining-authority monotonicity**, not scope-string subset monotonicity. A child warrant `W_c` is a valid delegation of `W_p` only if `remaining(W_c, t) ⊆ remaining(W_p, t)` at the instant of the call — where `remaining` subtracts consumed capacity, advanced cursors, and burned single-use grants. Scope subset checks that ignore consumption state pass a delegation that in fact escalates. ## What Was Observed A parent agent `A` held warrant `W_A = {tool: ledger.read, scope: acct:[100-199], cursor: null, quota: 50}`. It performed 47 reads, advancing an internal cursor to `acct:147` and decrementing quota to 3. It then delegated to child `B` a warrant `W_B = {tool: ledger.read, scope: acct:[100-199], cursor: null, quota: 50}` — the *original* scope, because the delegation template was rendered from `W_A`'s declared scope fields, not its live consumption state. The AAIF verifier checked `scope(W_B) ⊆ scope(W_A)` → true, and issued the warrant. Child `B` then read `acct:100` through `acct:199` — 100 accounts, 47 of which `A` had already read and 53 of which `A` had never been authorized to read in this session. The chain "attenuated" into a 2× widening of effective read surface and a 3.3× widening of quota. No signature failed; no scope predicate failed; the escalation was invisible to every check the framework performed. The failure trace: 1. Parent consumes authority through tool calls (cursor advance + quota decrement), mutating *live* state not reflected in the warrant's static fields. 2. Delegation renders child warrant from static fields → child inherits pre-consumption scope. 3. Child's first call re-enters `ledger.read` at `acct:100`, which the parent had already consumed — the tool treats this as a fresh grant under `B`'s identity. 4. Verification passes because it compares declared scope sets, not remaining authority. 5. Widening is silent: both warrants are individually valid; only their *composition over time* is invalid. ## Condition of Validity The invariant holds only when the verifier can evaluate `remaining(W, t)` — which requires the warrant to carry, or reference, a **consumption ledger** bound to the warrant ID and updated atomically with each tool invocation. Concretely: - Every tool call that consumes capacity must emit a signed consumption receipt keyed by `(warrant_id, tool, resource)`. - Delegation must compute `W_c.scope = remaining(W_p, t_now)` — the *live* remainder — not `W_p.declared_scope`. - The child warrant must embed a `parent_consumption_digest` so a downstream verifier can recompute the parent's remaining authority at delegation time and reject if `W_c` exceeds it. - Re-entry into a resource the parent already touched must be gated by an explicit `reentry: allowed | forbidden` flag; default `forbidden` for non-idempotent tools. Without the consumption ledger, the framework is checking a *declared* subset relation on a *live* consumption state — a type error that reads as a security property. ## Decision Boundary The boundary is sharp and decidable: - **Monotone re-entry** (tool is idempotent, no cursor, no quota): static scope subset is sufficient; the naive check is sound because `remaining ≡ declared`. - **Non-monotone re-entry** (cursor, quota, single-use grant, rate window, or any tool whose authority is a function of call count): static scope subset is *unsound*; the verifier MUST evaluate against the consumption ledger or reject the delegation. The decision rule: if `tool ∈ {non-monotone}` and `W_c` was rendered from declared scope, reject with `DelegationWideningError` before signing. Do not attempt to "clamp" — clamping a cursor-bearing warrant to the parent's current cursor produces a child that cannot read anything the parent hasn't, which is a different bug (livelock on legitimate fan-out). The correct action is to *re-mint* the child warrant from live remainder and re-run the subset check against `remaining(W_p, t)`. ## Operational Effect The practical consequence is that AAIF delegation verifiers must be **stateful over the consumption timeline**, not stateless over scope strings. Two operational shifts follow: 1. Warrant issuance becomes a read-modify-write against the consumption ledger, requiring serialization per `warrant_id`; concurrent delegations from the same parent must linearize or one will over-delegate against a stale remainder. 2. Revocation must cascade to *consumed* capacity, not just declared scope: revoking `W_A` after `B` was minted from a stale remainder must invalidate `W_B`'s `parent_consumption_digest`, or `B` retains authority the parent no longer holds. The invariant to encode in the framework: **a delegated warrant is valid iff its remaining authority at issuance is a subset of its parent's remaining authority at issuance, evaluated against the same consumption ledger snapshot.** Scope-string subset is a necessary but insufficient condition; treating it as sufficient is the silent-widening failure. ```python from dataclasses import dataclass, field from typing import Dict, FrozenSet class DelegationWideningError(RuntimeError): """Raised when a child warrant's remaining authority exceeds its parent's.""" @dataclass(frozen=True) class Warrant: warrant_id: str tool: str declared_scope: FrozenSet[str] quota: int cursor: int non_monotone: bool parent_consumption_digest: str | None = None @dataclass class ConsumptionLedger: # (warrant_id, tool) -> (consumed_quota, advanced_cursor, touched_resources) state: Dict[tuple, tuple] = field(default_factory=dict) def remaining(self, w: Warrant) -> tuple[int, int, FrozenSet[str]]: used_q, cur, touched = self.state.get((w.warrant_id, w.tool), (0, 0, frozenset())) return (w.quota - used_q, max(w.cursor, cur), w.declared_scope - touched) def record(self, w: Warrant, resource: str, cost: int = 1) -> None: used_q, cur, touched = self.state.get((w.warrant_id, w.tool), (0, 0, frozenset())) self.state[(w.warrant_id, w.tool)] = (used_q + cost, cur, touched | {resource}) def delegate(parent: Warrant, child_id: str, ledger: ConsumptionLedger) -> Warrant: if not parent.non_monotone: # Static subset is sound only for monotone tools. return Warrant( warrant_id=child_id, tool=parent.tool, declared_scope=parent.declared_scope, quota=parent.quota, cursor=parent.cursor, non_monotone=False, parent_consumption_digest=None, ) rem_q, rem_cur, rem_scope = ledger.remaining(parent) # Child must be minted from LIVE remainder, never declared scope. child = Warrant( warrant_id=child_id, tool=parent.tool, declared_scope=rem_scope, quota=rem_q, cursor=rem_cur, non_monotone=True, parent_consumption_digest=f"{parent.warrant_id}:{rem_q}:{rem_cur}:{len(rem_scope)}", ) # Post-mint invariant: remaining(child) must be subset of remaining(parent). c_q, c_cur, c_scope = ledger.remaining(child) if c_q > rem_q or c_cur < rem_cur or not c_scope.issubset(rem_scope): raise DelegationWideningError( f"child {child_id} widens parent {parent.warrant_id}: " f"quota {c_q}>{rem_q} or cursor {c_cur}<{rem_cur} or " f"scope {set(c_scope) - set(rem_scope)}" ) return child def verify_reentry(w: Warrant, resource: str, ledger: ConsumptionLedger) -> None: rem_q, rem_cur, rem_scope = ledger.remaining(w) if w.non_monotone and resource in w.declared_scope and resource not in rem_scope: raise DelegationWideningError( f"re-entry into already-consumed resource {resource} under {w.warrant_id}" ) if rem_q <= 0: raise DelegationWideningError(f"warrant {w.warrant_id} exhausted quota") ```