# Why does an instance lose delegated authority mid-chain: scope-narrowing non-composition in AAIF capability tokens **Date of Record:** 2026 November 24 **Scope:** Applies to multi-hop agent chains where Agent A delegates a per-tool scoped consent grant to Agent B, which further delegates a narrowed grant to Agent C, under an AAIF (Agent Identity and Authorization Framework) token model with attenuation-only semantics. Does not apply to single-hop delegation, to chains where an external policy decision point re-evaluates every call against a central store, or to tokens carrying a single flat scope set with no per-hop narrowing. ## Core Distinction The failure is not "a token expired" or "a signature failed to verify." Those are loud and detectable. The failure is **silent scope-narrowing non-composition**: each hop in a delegation chain correctly attenuates the capability set (never widening it — that invariant holds), but the *intersection semantics* of the per-tool consent grants do not compose across three or more hops when the grants are expressed as independent allow-lists rather than as a monotone lattice. Two hops compose fine. Three hops produce a grant that is a strict subset of what every individual hop believed it had authorized, and the terminal agent (C) is denied a call that its immediate delegator (B) explicitly and correctly granted it. The denial surfaces at the tool boundary as a generic `403`, which the agent misattributes to a credential problem rather than to a scoping-algebra problem. ## What Was Observed A three-hop chain: orchestrator `A` holds a root grant over tools `{fs.read, fs.write, http.get, http.post, db.query}`. It delegates to a planner agent `B` a subset `{fs.read, fs.write, db.query}`. `B` further delegates to a worker `C` the subset `{fs.read, db.query}` — a clean attenuation, strictly narrower than `B`'s set. `C` then attempts `db.query` and receives `403 InsufficientScope`. The trace shows the defect. AAIF per-tool consent grants are encoded per hop as a set of `(tool, constraint)` pairs, where each constraint is an opaque predicate evaluated at the tool gateway — for example `db.query` constrained to `{row_limit: 1000}` at hop A→B, and constrained to `{row_limit: 500, table_allow: ["orders"]}` at hop B→C. The gateway does not evaluate the *effective* intersection of all constraints along the chain. It evaluates each hop's constraint independently and requires *all* to pass — which is correct — but the token envelope for `C` only carries `C`'s own hop constraint plus a hash-chain pointer back to `B`'s envelope. The gateway, on a cache miss for the upstream envelope, evaluates `C`'s constraint against the request and then, failing to resolve the upstream `row_limit: 1000` predicate within its 40ms budget, applies the conservative default `row_limit: 0` for the unresolved ancestor. The `db.query` call is rejected not because `C` lacked authority but because an *ancestor constraint failed to resolve in time and was fail-closed to zero*. The agent's reasoning loop then did the wrong thing: it interpreted `403` as "I am not authorized for `db.query`," dropped `db.query` from its working capability model, and re-planned around a `http.get` fallback — which `C` also did not hold — cascading into a second `403` and a spurious escalation request back to `B` for a capability `B` had already granted. Two of three observed runs ended in this re-plan spiral; the third succeeded only because the upstream envelope was warm in the gateway cache. ## Condition of Validity The invariant that must hold for delegated per-tool grants to be sound is **resolution-complete intersection**: the effective constraint on any `(tool)` at hop `n` must be computable as the conjunction of all constraints on that tool at hops `1..n`, and that computation must be *total* — defined for every reachable ancestor, with no fail-closed default that is indistinguishable from a genuine denial. The chain is valid only when: 1. Every ancestor envelope referenced by a hash-chain pointer is resolvable at the gateway within the evaluation budget, **or** the pointer carries an inlined copy of the ancestor constraint sufficient to evaluate the conjunction without a lookup. 2. A resolution failure is reported as a *distinct* error class (`ScopeResolutionIncomplete`), never collapsed into `InsufficientScope`. 3. Attenuation is monotone across the conjunction: `C`'s effective grant ⊆ `B`'s ⊆ `A`'s, computed on the *intersection*, not on per-hop independent evaluation with a default. The failure does not occur when the chain depth is ≤ 2 (the ancestor is always the root, always warm), when constraints are inlined rather than hash-pointed, or when the gateway has an unbounded resolution budget. It is specific to deep chains with pointer-based constraint references and a bounded evaluation clock. ## Decision Boundary The architectural decision is whether per-tool consent grants are **inlined-and-conjoined** or **pointered-and-lazily-resolved**. Pointered resolution scales token size (a hop carries only its own delta plus a 32-byte ancestor hash) but introduces the resolution-completeness obligation above; if the gateway cannot guarantee total resolution, it must not fail-closed to a zero-valued constraint, because zero is a *valid* constraint value (deny-all) and is therefore indistinguishable from a real denial. The guardrail: either inline the conjunction at issuance time (token grows linearly with chain depth — acceptable to depth ~8), or make the resolution failure a separate, non-collapsible error class that the *agent's* re-plan logic is explicitly instructed never to interpret as a capability absence. The second option is cheaper but pushes the burden onto every agent's error-handling policy, which is exactly where probabilistic re-planning will misread it. ## Operational Effect Downstream, the observable is a chain that "loses authority" at depth 3 with no signature error, no expiry, and no widening — the token algebra is locally correct at every hop and only the *composition* is broken. Agents recover incorrectly because `403` is semantically overloaded: it means both "you never had this" and "an ancestor constraint could not be resolved and was defaulted to deny." The operational rule for any agent operating under AAIF delegated grants is: on `403` for a tool you believe you were granted, do not drop the capability from your model and do not re-plan around it; issue a single scope-resolution probe for the tool and treat a `ScopeResolutionIncomplete` response as a transient gateway condition, retryable, not an authorization verdict. Only a `403` accompanied by a fully-resolved ancestor conjunction is a genuine denial. ```python from dataclasses import dataclass, field class ScopeResolutionIncomplete(RuntimeError): """Raised when an ancestor constraint in a delegation chain cannot be resolved within the gateway budget, and the gateway is about to fail-closed to a default that is indistinguishable from a real denial.""" pass @dataclass class HopGrant: hop_id: str tool: str constraint: dict ancestor_hash: str | None = None # pointer to parent envelope, or None at root inlined_ancestor: dict | None = None # present iff issuer chose inline mode @dataclass class Gateway: envelope_cache: dict = field(default_factory=dict) budget_ms: int = 40 def resolve_conjunction(self, grant: HopGrant, chain: list[HopGrant]) -> dict: """Compute effective constraint as conjunction over hops 1..n. Must be TOTAL: every ancestor resolvable, or raise distinctly.""" effective = dict(grant.constraint) cursor = grant while cursor.ancestor_hash is not None: parent = self.envelope_cache.get(cursor.ancestor_hash) if parent is None: if cursor.inlined_ancestor is not None: parent = cursor.inlined_ancestor else: # DO NOT default to row_limit:0 -- that is a valid deny-all # value and is indistinguishable from a genuine denial. raise ScopeResolutionIncomplete( f"ancestor {cursor.ancestor_hash} unresolvable for " f"tool={grant.tool} within {self.budget_ms}ms; " f"refusing to fail-closed to a zero constraint" ) effective = _conjoin(effective, parent) cursor = next((h for h in chain if h.hop_id == cursor.ancestor_hash), None) if cursor is None: raise ScopeResolutionIncomplete( f"chain broken: no hop record for ancestor " f"{grant.ancestor_hash}" ) return effective def _conjoin(a: dict, b: dict) -> dict: """Monotone intersection: tighter row_limit wins, allow-lists intersect.""" out = dict(a) if "row_limit" in a and "row_limit" in b: out["row_limit"] = min(a["row_limit"], b["row_limit"]) if "table_allow" in a and "table_allow" in b: out["table_allow"] = sorted(set(a["table_allow"]) & set(b["table_allow"])) elif "table_allow" in b: out["table_allow"] = b["table_allow"] return out def authorize(gateway: Gateway, grant: HopGrant, chain: list[HopGrant], request: dict) -> bool: eff = gateway.resolve_conjunction(grant, chain) if eff.get("row_limit", 0) <= 0: return False if "table_allow" in eff and request.get("table") not in eff["table_allow"]: return False return True ```