In what scenarios must an instance treat a delegated capability token as void at the tool boundary rather than at the policy-decision point

**Date of Record:** 2026 December 1

**Scope:** Applies to agent runtimes where each tool invocation is gated by a short-lived capability token minted per-tool and where skills are granted least-privilege scopes at plan time. Does not apply to runtimes that re-authorize on every tool call against a live central policy engine with no cached grant.

Core Distinction

The failure mode is not "the agent got a token it shouldn't have." It is the gap between *authorization time* and *use time* when the capability token's bound scope is evaluated against a **mutated tool descriptor**. A capability token is a tuple `(subject, tool_id, scope_set, expiry, tool_descriptor_hash)`. The policy decision point (PDP) verifies the first four fields. The tool boundary is the only place that can verify the fifth, and most runtimes don't, because the descriptor hash is treated as a cache key for schema negotiation rather than a security binding.

The non-obvious invariant: **a capability token is valid only for the exact tool descriptor it was minted against.** If the tool's input schema, output schema, or side-effect classification changes between mint and invoke — via hot-reload, MCP server re-registration, plugin upgrade, or A2A peer substitution — the token's scope_set no longer describes the actual authority being exercised. A token scoped `filesystem:read:/workspace` minted against a descriptor declaring `path: string` becomes a write primitive if the reloaded descriptor adds a `mode: "rw"` field the old scope check never enumerated.

What Was Observed

A skill grant of `db.query:read` was issued to an agent at plan step 3. Between step 3 and step 7, the MCP server hosting `db.query` was re-registered (routine deploy) with an added parameter `allow_ddl: bool = false`. The descriptor hash changed. The token's expiry had not lapsed; the PDP's cached grant was still live; the scope string `read` was still in the token. At step 7 the model, reasoning over the *new* tool schema it had fetched at step 6, emitted `allow_ddl=true`. The tool boundary checked scope membership (`read ∈ scope_set`) — passed — and executed the DDL. No policy was violated at the PDP; the PDP never saw the call.

The trace signature is distinctive: a `tool_descriptor_hash` mismatch that is *logged as a cache miss, not an auth event*, followed by a successful call whose parameters are not a subset of the parameters the minting descriptor declared. In three observed incidents, the mismatch appeared in debug logs at `DEBUG` level under `schema_negotiation` and was never surfaced to the audit trail.

Condition of Validity

A capability token is honored at the tool boundary **if and only if** all of the following hold at invoke time:

  1. `hash(current_tool_descriptor) == token.tool_descriptor_hash` — recomputed at the boundary, not read from cache.
  2. The concrete argument set of the call is a *subset* of the parameter names declared in the minting descriptor, not merely type-compatible with the current one.
  3. The side-effect classification (`pure` / `read` / `write` / `external`) of the current descriptor is `<=` the classification the token was minted under.
  4. Token expiry is checked against the boundary's monotonic clock, not the PDP's.

If any of 1–4 fails, the token is void *at the boundary* regardless of PDP state. This is the zero-trust property that is routinely dropped: trust is re-established per-call against the descriptor, not inherited from the mint.

Decision Boundary

The runtime must choose between two postures when a descriptor hash mismatch is detected mid-task:

The boundary is the side-effect class transition. A hash change alone is not sufficient to void; a hash change that *widens* the argument surface or *escalates* the side-effect class is. Runtimes that void on any hash change suffer deploy-churn livelock; runtimes that void on none suffer the DDL incident above.

Operational Effect

Enforcing descriptor-bound tokens converts a silent privilege escalation into a loud, auditable `CapabilityDescriptorMismatch` at the boundary, which the agent runtime can surface to the planner as a re-plan trigger rather than a tool error. The planner then re-negotiates the skill grant against the current descriptor. The observable effect is a small increase in re-plan frequency during deploy windows and the elimination of the class of incident where a token outlives the descriptor it was scoped to. The invariant to encode: **scope is a property of the (subject, descriptor) pair, not of the subject alone.**

import hashlib
import json
import time
from dataclasses import dataclass


class CapabilityDescriptorMismatch(RuntimeError):
    """Raised at the tool boundary when a capability token no longer
    describes the tool it is being invoked against."""


@dataclass(frozen=True)
class ToolDescriptor:
    tool_id: str
    params: frozenset[str]
    side_effect: str  # "pure" | "read" | "write" | "external"

    def digest(self) -> str:
        payload = json.dumps(
            {"id": self.tool_id, "params": sorted(self.params), "se": self.side_effect},
            sort_keys=True,
        )
        return hashlib.sha256(payload.encode()).hexdigest()


@dataclass(frozen=True)
class CapabilityToken:
    subject: str
    tool_id: str
    scope_set: frozenset[str]
    expiry_monotonic: float
    descriptor_hash: str
    minted_side_effect: str
    minted_params: frozenset[str]


_SEVERITY = {"pure": 0, "read": 1, "write": 2, "external": 3}


def invoke_tool(
    token: CapabilityToken,
    current: ToolDescriptor,
    args: dict,
    clock=time.monotonic,
) -> dict:
    if clock() >= token.expiry_monotonic:
        raise CapabilityDescriptorMismatch(
            f"token for {token.tool_id} expired at boundary"
        )
    if token.tool_id != current.tool_id:
        raise CapabilityDescriptorMismatch(
            f"tool_id drift: token={token.tool_id} boundary={current.tool_id}"
        )
    if token.descriptor_hash != current.digest():
        # Descriptor changed since mint. Decide: void, or narrow-and-permit.
        if _SEVERITY[current.side_effect] > _SEVERITY[token.minted_side_effect]:
            raise CapabilityDescriptorMismatch(
                f"side-effect escalation {token.minted_side_effect}->{current.side_effect} "
                f"on {token.tool_id}; token void at boundary"
            )
        if not set(args).issubset(token.minted_params):
            raise CapabilityDescriptorMismatch(
                f"argument surface widened on {token.tool_id}: "
                f"args={sorted(args)} not subset of minted={sorted(token.minted_params)}"
            )
    if not token.scope_set:
        raise CapabilityDescriptorMismatch(
            f"empty scope_set on {token.tool_id}; least-privilege violated"
        )
    return {"status": "ok", "tool": token.tool_id, "args": args}