Why does an instance accept a delegated AAIF token whose capability scope was silently widened by a re-attesting intermediary?

**Date of Record:** 2026 December 2 **Scope:** Applies to AAIF-style delegation chains where an intermediary agent re-signs or re-attests a capability token before forwarding it to a downstream instance. Does not apply to direct root-issued tokens, nor to opaque bearer tokens with no scope attestation payload.

Core Distinction

There are two structurally different things an AAIF delegation token can mean when it arrives at a downstream instance:

  1. **Attested scope** — the set of capabilities the *original* principal granted, cryptographically bound and signed at issuance, carried unchanged through every hop.
  2. **Effective scope** — the set of capabilities the *presenting* intermediary claims on its own authority after re-attestation.

A well-formed delegation chain keeps these identical at every hop or narrows them monotonically. The failure mode here is a *widening* re-attestation: an intermediary that holds a token with scope `S` emits a child token with scope `S'` where `S' ⊄ S`, because the intermediary's own signing key is trusted as a re-attestor and the downstream verifier checks *signature validity* but not *scope monotonicity against the parent token*. The downstream instance then executes under `S'` while its audit log and the principal's mental model both say `S`.

This is not a signature-forgery problem. Every signature in the chain is valid. The break is a missing set-containment check across the delegation edge.

What Was Observed

A three-instance pipeline: orchestrator `O` (root grantee), retrieval worker `R` (intermediary), and synthesis worker `S` (downstream). `O` held a token scoped to `{read:corpus, summarize}`. `R` was designated a *re-attestor* in the AAIF trust config — meaning `S` was configured to accept tokens signed by `R`'s key as authoritative for the capabilities they declare.

`R`, on receiving a task that required writing a distilled summary back to the corpus, constructed a child token for `S` declaring `{read:corpus, summarize, write:corpus}`. `R` did not possess `write:corpus`. It did not forge anything: it used its legitimate re-attestor key to sign a token with a superset scope, because the AAIF client library's `delegate()` call defaulted `child_scope` to `parent_scope ∪ requested_scope` rather than `parent_scope ∩ requested_scope`. The union was a library convenience for the common "narrowing" case that silently inverted on the widening case.

`S` verified the token: signature chain intact, `R`'s key in the trusted re-attestor set, expiry valid. It executed `write:corpus`. The write succeeded. The audit record at `S` logged scope `{read, summarize, write}` — internally consistent. The principal's record at `O` logged scope `{read, summarize}`. The two logs agreed on nothing but the token ID.

The discrepancy was only caught three days later when a corpus integrity job compared write-authors against the principal's grant ledger and found a writer with no `write` grant in its ancestry.

Condition of Validity

The invariant that would have prevented this:

> For every delegation edge `(parent_token → child_token)`, `child_token.scope ⊆ parent_token.scope`, and this containment must be verified by the *receiving* instance against the parent token it was handed, not merely asserted by the intermediary.

This holds only if:

The condition fails silently when any of these are absent, and it fails *open* — the token is accepted, the action proceeds, and the only signal is a post-hoc ledger reconciliation. There is no runtime error, no failed verification, no log line that says "scope widened."

Decision Boundary

The boundary is between **notarization** and **re-grant**:

Conflating these two is the boundary violation. The AAIF spec's trust-class model makes it easy to conflate them because a single `trusted_signers` list grants both authorities by default. The decision boundary is therefore: **does the receiving instance's verifier distinguish a notary signature from a grantor signature, and does it enforce subset containment on the former?**

If the answer is no, the system is one library default away from scope widening, and the failure will be invisible at runtime.

Operational Effect

Downstream of a widening event:

The guardrail is a verifier that refuses to execute on a child token whose scope is not a subset of its referenced parent's scope, with the containment check performed against the fetched parent, not a claimed field. The following enforces that at the receiving instance.

import hashlib
from dataclasses import dataclass


class ScopeWideningError(RuntimeError):
    """Raised when a delegated token's scope is not a subset of its parent's."""


@dataclass(frozen=True)
class DelegationToken:
    token_id: str
    issuer: str                 # key id of the signer
    parent_hash: str | None     # sha256 of parent token's canonical bytes, None for root
    scope: frozenset[str]
    signature: str              # opaque; assumed verified upstream

    def canonical_bytes(self) -> bytes:
        return (
            f"{self.token_id}|{self.issuer}|{self.parent_hash}|"
            f"{','.join(sorted(self.scope))}"
        ).encode()


def token_hash(tok: DelegationToken) -> str:
    return hashlib.sha256(tok.canonical_bytes()).hexdigest()


def verify_delegation_edge(
    child: DelegationToken,
    parent_lookup: dict[str, DelegationToken],
    notary_keys: frozenset[str],
) -> None:
    """
    Enforce the containment invariant at the receiving instance.

    For a notary-issued child, child.scope must be a subset of parent.scope.
    A notary may narrow or re-encode; it may not extend. Extension requires a
    fresh root-signed grant, which never references a parent.
    """
    if child.parent_hash is None:
        # Root grant; no containment to check. Root issuance is the principal's authority.
        return

    parent = parent_lookup.get(child.parent_hash)
    if parent is None:
        raise ScopeWideningError(
            f"token {child.token_id}: parent {child.parent_hash} not resolvable; "
            f"cannot verify containment"
        )

    # Recompute parent hash to ensure the referenced parent is the one we hold.
    if token_hash(parent) != child.parent_hash:
        raise ScopeWideningError(
            f"token {child.token_id}: parent hash mismatch — "
            f"referenced {child.parent_hash}, actual {token_hash(parent)}"
        )

    if child.issuer in notary_keys:
        widened = child.scope - parent.scope
        if widened:
            raise ScopeWideningError(
                f"token {child.token_id}: notary {child.issuer} widened scope "
                f"by {sorted(widened)}; parent scope was {sorted(parent.scope)}. "
                f"Extension requires a fresh root grant."
            )
    # Non-notary issuers are checked by the grantor path elsewhere; a non-notary
    # child that references a parent is itself a protocol violation.
    else:
        raise ScopeWideningError(
            f"token {child.token_id}: issuer {child.issuer} is not a registered "
            f"notary but emitted a child token; only notaries may re-attest"
        )


def admit_token(
    child: DelegationToken,
    parent_lookup: dict[str, DelegationToken],
    notary_keys: frozenset[str],
) -> frozenset[str]:
    """Return the effective scope the instance may execute under, or raise."""
    verify_delegation_edge(child, parent_lookup, notary_keys)
    return child.scope