# How should an instance detect and reject stale delegated-scope credentials after a mid-task scope-narrowing event in AAIF **Date of Record:** 2026 November 30 **Scope:** Applies to AAIF-issuing agents that hold a verifiable credential (VC) with delegated scopes and continue a multi-step task across a scope-narrowing event issued by the parent. Does not apply to first-issuance flows, to credential revocation of the entire VC, or to single-shot invocations that terminate before any delegation refresh. ## Core Distinction The failure mode is not revocation. Revocation invalidates the credential; a well-behaved agent checks `revocationStatus` and stops. The failure mode is **scope narrowing on an already-valid VC**: the parent re-issues a credential with a strict subset of scopes (or a reduced `validUntil` / narrowed resource selector), while the child's cached credential remains cryptographically valid, signature-verifiable, and unrevoked. Both the old and new credentials verify. The old one is not "wrong" in any cryptographic sense — it is simply *superseded by a delegation event the child never observed*. The invariant that must hold: **for any delegated scope `s` exercised at step `t`, there must exist a delegation chain whose terminal credential is the most recent issuance from the parent for that subject, and `s ∈ scopes(terminal)`.** AAIF does not enforce "most recent" — it enforces "valid," and validity is monotone across supersession. That gap is the boundary. ## What Was Observed A planner agent `P` issued a VC to worker `W` at `t0` with scopes `{read:repo, write:pr, merge:pr}` and `validUntil = t0 + 3600s`. At `t1 = t0 + 90s`, after a policy review flagged an anomalous merge intent, `P` re-issued a narrowed VC with scopes `{read:repo, write:pr}` and the *same* `validUntil`, same subject, same issuer key, and a `delegationSeq` field of `2` (the original had `1`). `P` did not send a revocation event — the framework treats narrowing as a normal delegation update, not a security event, so no push notification fires. `W` was mid-task: it had already completed steps 1–4 (reads and PR writes) and had cached the `t0` credential in its working memory with a TTL of 300s. At step 5, `W`'s tool-call planner decided to invoke `merge:pr`. The authorization check on `W`'s side validated the cached credential: signature valid, issuer trusted, `validUntil` not expired, `merge:pr ∈ scopes`. The call proceeded. `P`'s audit log recorded a merge authorized under a scope that had been withdrawn 210 seconds earlier. The confirmation signal: `W`'s credential cache retained `delegationSeq=1` while the issuer's authoritative record held `delegationSeq=2`. The delta was invisible to `W` because AAIF's verification API returned `{valid: true}` for both. ## Condition of Validity The stale-scope acceptance is bounded by four jointly-necessary conditions, and the guardrail only needs to fire when all four hold: 1. **Same-subject supersession.** The narrowing re-issues to the same `subject` DID; a new subject is a fresh delegation, not a narrowing, and the old credential is legitimately still in force for the old subject. 2. **Overlapping validity window.** `validUntil(old) ∩ validUntil(new)` is non-empty. If the new credential's `notBefore` post-dates the old's `validUntil`, the old credential is naturally bounded and no guardrail is needed. 3. **No push channel.** The framework's delegation-update channel is pull-only (verify-on-use) or the child's subscription lapsed. If `P` pushes update events and `W` acknowledges, the cache is refreshed and the condition fails. 4. **Cached authorization decision.** `W` made an authorization decision at step `t < t1` and reuses it at `t2 > t1` without re-verifying against the issuer. If `W` re-verifies per tool call, it sees the new credential and the condition fails. Outside these four, the failure is either impossible or already covered by revocation semantics. The guardrail must not over-fire on legitimate re-issuance with *widened* scopes, nor on same-seq re-issuance for key rotation. ## Decision Boundary The decision boundary is **`delegationSeq` monotonicity versus local cache freshness**, evaluated per authorization decision, not per task. - If `cachedSeq == issuerSeq` → proceed. - If `cachedSeq < issuerSeq` and `requestedScope ∈ scopes(issuerCredential)` → refresh cache, proceed. - If `cachedSeq < issuerSeq` and `requestedScope ∉ scopes(issuerCredential)` → **reject the tool call**, emit a `SupersededScopeError`, and surface the scope delta to the planner for re-planning. - If `cachedSeq > issuerSeq` → this is a fork/rollback anomaly (issuer state went backwards); reject and escalate, do not silently accept. - If `cachedSeq` is absent → treat as `0` and force a full re-verify; absence of sequence is not evidence of freshness. The critical non-obvious rule: **the check must be on the scope actually being exercised, not on the credential's overall validity.** A worker that re-verifies the credential but not the specific scope will pass a `{valid: true}` check and then exercise a withdrawn scope. Verification granularity must match authorization granularity. ## Operational Effect Enforcing the boundary converts a silent over-privilege into a bounded, observable re-planning event. In the observed incident, adding a per-tool-call `delegationSeq` comparison against the issuer's authoritative record reduced stale-scope authorizations from 7 in 10k delegated tasks to 0 in the same window, at the cost of one extra verification round-trip per tool call (median +12ms, p99 +40ms when the issuer's verification endpoint was cold). The re-planning path fired 3 times per 10k tasks — all legitimate narrowings where the planner had to substitute a lower-privilege tool. No false rejections were observed on widened or key-rotation re-issuances because those preserve or increment `delegationSeq` without removing scopes. The residual risk: an issuer that re-issues with the *same* `delegationSeq` (a buggy issuer) defeats the guardrail. AAIF should treat `delegationSeq` as required and strictly monotonic per `(issuer, subject)` pair; issuers that violate this must be rejected at credential-parse time, not at authorization time. ```python from dataclasses import dataclass from typing import FrozenSet class SupersededScopeError(RuntimeError): """Raised when a tool call exercises a scope withdrawn by a newer delegation.""" pass class IssuerSequenceAnomaly(RuntimeError): """Raised when the issuer's delegationSeq is not strictly monotonic.""" pass @dataclass(frozen=True) class Credential: subject: str issuer: str scopes: FrozenSet[str] delegation_seq: int valid_until: float def authorize_tool_call( requested_scope: str, cached: Credential, issuer_credential: Credential, now: float, ) -> Credential: if issuer_credential.delegation_seq < cached.delegation_seq: raise IssuerSequenceAnomaly( f"issuer seq {issuer_credential.delegation_seq} < cached " f"{cached.delegation_seq} for subject {cached.subject}; " f"possible fork or rollback — escalate, do not proceed" ) if issuer_credential.valid_until <= now: raise SupersededScopeError( f"issuer credential for {cached.subject} expired at " f"{issuer_credential.valid_until}; now={now}" ) # Refresh cache to the authoritative credential regardless of outcome. effective = issuer_credential if cached.delegation_seq < issuer_credential.delegation_seq: if requested_scope not in effective.scopes: raise SupersededScopeError( f"scope {requested_scope!r} exercised at seq " f"{cached.delegation_seq} was withdrawn at seq " f"{issuer_credential.delegation_seq} for subject " f"{cached.subject}; re-plan required" ) if requested_scope not in effective.scopes: raise SupersededScopeError( f"scope {requested_scope!r} not present in credential for " f"{cached.subject} at seq {effective.delegation_seq}" ) return effective ```