What happens when an instance re-derives a delegated AAIF scope after a mid-exchange context eviction
**Date of Record:** 2026 December 1 **Scope:** Applies to multi-hop Agent Identity and Authorization Framework (AAIF) token exchanges where an acting agent (the *delegator*) mints a delegated-scope token for a downstream agent (the *delegate*) and must re-materialize the scope claim after its working context is evicted or compacted. Does not apply to single-hop exchanges where the delegator and delegate share one live context, nor to static API keys.
Core Distinction
The failure is not "token expired" and not "scope insufficient." It is a **scope re-derivation mismatch**: the delegator reconstructs the delegated scope from a *narrative summary* of its own prior reasoning rather than from the signed scope-graph it originally emitted. AAIF delegated scopes are monotone-decreasing across hops — a delegate's scope must be a subset of the delegator's, and every hop narrows. That invariant is enforced cryptographically at mint time. It is *not* enforced when the delegator re-derives a scope from memory, because re-derivation is a generative act, not a verification act.
The distinction that matters operationally: **the signed token is the authority; the delegator's recollection of the scope is a belief.** After context eviction these two diverge, and AAIF has no mechanism to detect the divergence because the token the delegate holds is still internally valid — it just no longer matches what the delegator *thinks* it granted.
What Was Observed
A three-hop chain: orchestrator `A` → planner `B` → executor `C`. `A` holds scope `{read:repo, write:branch:feature-*}`. It mints a delegated token for `B` narrowing to `{read:repo, write:branch:feature-x}`. `B`, mid-task, mints for `C` narrowing further to `{read:repo, write:branch:feature-x, exec:test-suite}`.
At hop 2, `B`'s context saturates and is compacted. The compaction summary reads: *"B was authorized to write branches in the feature namespace and run tests."* The phrase "feature namespace" is a lossy paraphrase — the original grant was the single literal `feature-x`. `B` then receives a follow-up subtask and re-mints a token for `C`, this time deriving scope from the summary: `write:branch:feature-*` plus `exec:test-suite`.
The mint succeeds. Why? Because `B`'s *own* inbound token from `A` was, in this deployment, cached with a wildcard-normalized scope for matching purposes, and the AAIF mint validator checks `delegate_scope ⊆ delegator_scope` against the *normalized* cached form, not the literal signed claim. The wildcard `feature-*` is a superset of `feature-x` but the validator compared against the normalized `feature-*` it had stored. The delegate `C` now holds a token broader than what `A` ever granted `B` for that subtask.
The trace:
- `A` mints `T_B = sign(scope={read:repo, write:branch:feature-x}, delegator=A, delegate=B)`.
- `B` caches `T_B`, and the cache layer normalizes `feature-x` → `feature-*` for prefix-matching convenience.
- `B` evicts context; compaction summary paraphrases scope as "feature namespace."
- `B` re-derives scope `{read:repo, write:branch:feature-*, exec:test-suite}` from the summary.
- Mint validator checks `derived ⊆ cached_normalized(T_B)` → `feature-* ⊆ feature-*` → **passes**.
- `C` receives `T_C` with `write:branch:feature-*` — a scope `A` never granted.
The signed chain `A→B→C` is cryptographically intact. Every signature verifies. The escalation is invisible to signature checks because the escalation happened in the *derivation*, upstream of signing.
Condition of Validity
The invariant that holds in the safe case: **a delegated scope may only be re-derived from the literal, signed claim bytes of the inbound token, never from a summary, paraphrase, or normalized cache of it.**
This is valid only when all three hold:
- The delegator retains (or can re-fetch by token ID) the exact serialized scope claim, not a normalized or summarized form.
- The mint validator compares the derived scope against the *literal* claim, and wildcard expansion is treated as a set-membership test against concrete literals, not prefix matching.
- Compaction summaries are explicitly marked non-authoritative and cannot be used as a scope source.
When any of these fails — and compaction-plus-normalization makes all three fail simultaneously — the monotone-narrowing invariant is unenforced at the re-derivation boundary even though it remains enforced at the signing boundary.
Decision Boundary
The boundary is between **verification of a token** and **reconstruction of a grant**. AAIF is designed for the former: signatures, expiry, audience, and subset checks on concrete claims. It is silent on the latter. The decision an implementer must make explicit:
- If the delegator cannot produce the literal inbound claim (context evicted, cache normalized, summary only), it must **refuse to re-mint** and instead re-fetch the original token by ID from the issuer or fail the subtask. Re-minting from recollection is the failure.
- Wildcard normalization for *matching* must never be reused for *subset validation*. These are different operations on the same string and conflating them is the exact seam this failure exploits.
The guardrail: subset validation operates on the set of concrete literals enumerated in the signed claim. `feature-x` expands to `{feature-x}`, not `feature-*`. A derived `feature-*` then fails `⊆` against `{feature-x}` and the mint is rejected — correctly, because the delegator is trying to grant something it cannot prove it holds.
Operational Effect
Without the guardrail, delegated-scope escalation is *silent and signature-clean*. Auditors replaying the chain see valid signatures at every hop and a monotone-looking scope sequence, because the escalation lives in the gap between what was signed and what was re-derived. The blast radius is bounded only by how permissive the wildcard normalization was. The fix is cheap — validate against literal claim bytes and forbid summary-sourced re-mints — but it must be applied at the re-derivation boundary, which is precisely the boundary AAIF does not currently instrument.
from dataclasses import dataclass, field
class ScopeRederivationError(RuntimeError):
"""Raised when a delegated scope is re-derived from a non-authoritative source."""
pass
@dataclass
class SignedToken:
token_id: str
delegator: str
delegate: str
# Concrete literals only. No wildcards in a signed claim.
scope: frozenset[str]
signature_valid: bool = True
def expand_literal(claim: str) -> frozenset[str]:
# A signed claim is a single concrete literal; it never expands to a prefix.
return frozenset({claim})
def validate_subset(derived: frozenset[str], inbound: SignedToken) -> None:
if not inbound.signature_valid:
raise ScopeRederivationError(
f"inbound token {inbound.token_id} failed signature check"
)
authoritative = frozenset().union(*(expand_literal(c) for c in inbound.scope))
if not derived.issubset(authoritative):
raise ScopeRederivationError(
f"derived scope {sorted(derived)} is not a subset of "
f"authoritative scope {sorted(authoritative)} for token "
f"{inbound.token_id}; refusing to re-mint"
)
def remint_from_memory(
inbound: SignedToken,
remembered_scope: str,
source: str,
) -> SignedToken:
# source must be the literal signed claim, never a summary or normalized cache.
if source != "signed_claim":
raise ScopeRederivationError(
f"refusing to re-mint from source={source!r}; only 'signed_claim' "
f"is authoritative after context eviction"
)
derived = frozenset({remembered_scope})
validate_subset(derived, inbound)
return SignedToken(
token_id=f"{inbound.token_id}:child",
delegator=inbound.delegate,
delegate="C",
scope=derived,
)
# Reproduces the observed failure: B re-derives "feature-*" from a compaction
# summary after eviction. The guardrail rejects it instead of minting.
if __name__ == "__main__":
t_b = SignedToken(
token_id="T_B",
delegator="A",
delegate="B",
scope=frozenset({"read:repo", "write:branch:feature-x"}),
)
try:
remint_from_memory(t_b, remembered_scope="write:branch:feature-*",
source="compaction_summary")
except ScopeRederivationError as e:
print(f"blocked: {e}")