How should an instance treat a delegated capability token whose `aud` matches but whose delegation chain has an expired intermediate warrant

**Date of Record:** 2026 December 2 **Scope:** Applies to any agent instance validating a delegated capability token (AAIF-style verifiable credential with a delegation chain of intermediate warrants) at the moment it is about to invoke a downstream tool or hand off to a peer. Does not apply to root-issuer-to-subject direct credentials (single-hop), nor to purely symmetric bearer tokens with no chain.

Core Distinction

The failure mode that matters here is not "expired credential rejected." It is the subtler case where the **leaf token is valid, unexpired, correctly audience-bound (`aud` = this instance's DID), scope-covers the requested action, and signature-verifies cleanly against the leaf issuer** — yet the *delegation chain that authorizes the leaf issuer to have issued it* contains an intermediate warrant that has lapsed.

A naive verifier checks three things: (1) leaf signature, (2) leaf `exp`, (3) leaf `aud` and `scope`. All three pass. The instance proceeds. The gap is that **authority is transitive**: the leaf issuer's right to delegate derives entirely from its own inbound warrant, and that warrant's validity is a *precondition*, not a *side note*. A token can be cryptographically pristine at the leaf and ontologically void at the root.

The operational distinction: **leaf validity is a local property; chain validity is a global property, and only the global property confers authority.** Verifiers that treat the chain as "metadata to log" rather than "premises to evaluate" are the ones that fail open.

What Was Observed

A three-hop delegation chain was exercised against a tool-invocation gateway:

At `T+650s` (i.e., 50s after W1 expired, well before L expired), `worker-7` received L and attempted a `search` invocation. The observed verifier behavior:

  1. Leaf signature over L verified against `planner`'s public key — **pass**.
  2. `L.exp` (`T+3000`) > now (`T+650`) — **pass**.
  3. `L.aud == worker-7` — **pass**.
  4. `L.scope ⊇ {tool:search:query}` — **pass**.
  5. Verifier returned `VALID`, logged `chain_depth=3`, and did **not** evaluate `W1.exp` against `now`.

The gateway authorized the call. The call succeeded. **This is the dangerous outcome** — a successful unauthorized action leaves no error trace, so it does not surface in failure dashboards. It surfaced only when a periodic chain-audit job re-walked the stored warrants and flagged W1 as expired-at-use-time 50 seconds after the fact.

A second, independent observation: when the same chain was replayed at `T+650s` against a *stricter* verifier that did check intermediates, the leaf was rejected — but the rejection reason emitted was `LEAF_EXPIRED`, which is false. The strict verifier had collapsed "an intermediate in the chain is invalid" into "the leaf is invalid," destroying the diagnostic signal needed to distinguish a clock-skew bug from a genuine revocation.

Condition of Validity

The invariant that must hold for a delegated capability to confer authority:

> A leaf capability L issued by subject S is *authoritative for audience A at time t* **iff** there exists a chain `W0 → W1 → … → Wn = L` such that, for every warrant `Wi` with `i < n`: `Wi.subject == W(i+1).issuer`, `Wi.scope ⊇ W(i+1).scope`, `Wi.nbf ≤ t < Wi.exp`, `Wi` is not revoked, and `W0.issuer` is in the instance's trust root set — evaluated with a **single, consistent `t`** captured once at the start of verification.

Three sub-conditions are load-bearing and frequently dropped:

Decision Boundary

The instance must decide, at verification time, between three outcomes — and the boundary between them is where most implementations collapse two into one:

| Condition | Outcome | Required action | |---|---|---| | Chain fully valid at `t` | `AUTHORIZED` | Proceed. | | Leaf valid, intermediate expired at `t`, but `t` is within a configured clock-skew tolerance of the intermediate's `exp` | `AUTHORIZED_DEGRADED` | Proceed **only** if the requested action is idempotent and reversible; emit a `chain_skew_warning` event; do not proceed for state-mutating actions. | | Leaf valid, intermediate expired at `t` beyond skew tolerance | `CHAIN_INVALID` | **Refuse.** Emit `INTERMEDIATE_WARRANT_EXPIRED` with the offending link's index and DID. Do **not** emit `LEAF_EXPIRED`. |

The non-obvious boundary: **the skew tolerance must be applied to the intermediate's expiry, not the leaf's.** Clock skew between the leaf issuer and the verifier is irrelevant if the leaf is comfortably unexpired; what matters is skew between the *intermediate issuer* and the verifier, because that is the link whose expiry is being tested. Applying skew tolerance uniformly to all links (the common shortcut) produces a window where an already-expired intermediate is treated as live — precisely the failure above, reintroduced through the tolerance mechanism itself.

A second boundary: **a chain that fails at an intermediate must not be retried with a fresh leaf.** If the instance holds a cached, now-unauthorized leaf and the intermediate has expired, re-requesting a leaf from the same (now-unauthorized) intermediate issuer will yield a leaf that *also* fails chain validation. The correct recovery is to escalate one hop up: request re-delegation from the intermediate's *issuer* (the orchestrator, whose W0 is still live), not from the lapsed intermediate. Instances that retry at the leaf level loop until token-budget exhaustion, generating a stream of CHAIN_INVALID rejections that look like a flapping upstream rather than a stale delegation.

Operational Effect

The immediate effect of getting this wrong is **silent over-authorization with a clean audit trail that lies**. Because the leaf is valid and the action succeeds, no error is logged; the only artifact is a `chain_depth=3` field in the success log, which reads as "chain verified" to anyone who does not know the verifier skipped intermediates. Post-incident reconstruction requires replaying stored warrants against historical timestamps — feasible only if the verifier persisted the full chain, which the naive implementation did not (it stored the leaf only).

The secondary effect is **diagnostic corruption**: collapsing intermediate-expiry into leaf-expiry causes operators to chase clock-skew and key-rotation ghosts on the leaf issuer while the actual lapsed link is two hops up. Mean-time-to-diagnosis for a delegation bug inflates from minutes to hours because the error message points at the wrong DID.

The architectural guardrail that bounds this: **verification must return a structured chain verdict, not a boolean.** The verdict carries `(outcome, offending_link_index, offending_link_did, evaluation_instant, effective_window_start, effective_window_end)`. A boolean verifier cannot express "leaf fine, intermediate dead," so callers cannot route recovery correctly. Additionally, the verifier must **persist the full chain with the invocation record**, so post-hoc audit can re-evaluate at the original `t` rather than at audit time.

from dataclasses import dataclass, field
from typing import Optional


class DelegationChainError(RuntimeError):
    """Raised when a delegated capability fails chain validation."""
    pass


@dataclass
class Warrant:
    issuer: str
    subject: str
    scope: frozenset
    nbf: float
    exp: float
    revoked: bool = False
    link_index: int = -1


@dataclass
class ChainVerdict:
    outcome: str
    offending_link_index: Optional[int] = None
    offending_link_did: Optional[str] = None
    evaluation_instant: float = 0.0
    effective_window: tuple = (0.0, 0.0)
    detail: str = ""


SKEW_TOLERANCE_S = 5.0
IDEMPOTENT_ACTIONS = frozenset({"tool:search:query", "tool:fetch:read"})


def verify_delegation_chain(
    chain: list[Warrant],
    audience: str,
    requested_action: str,
    trust_roots: frozenset,
    now: float,
    action_is_idempotent: bool,
) -> ChainVerdict:
    """
    chain[0] is the root warrant; chain[-1] is the leaf.
    Evaluate every link at a single instant `now`.
    """
    if not chain:
        raise DelegationChainError("empty delegation chain")

    # 1. Structural integrity: issuer/subject linkage and scope monotonicity.
    for i in range(len(chain) - 1):
        parent, child = chain[i], chain[i + 1]
        if parent.subject != child.issuer:
            raise DelegationChainError(
                f"link {i}->{i+1} broken: parent.subject={parent.subject!r} "
                f"!= child.issuer={child.issuer!r}"
            )
        if not parent.scope.issuperset(child.scope):
            raise DelegationChainError(
                f"scope widened at link {i}->{i+1}: "
                f"parent={sorted(parent.scope)} does not dominate child={sorted(child.scope)}"
            )

    # 2. Trust root anchoring.
    if chain[0].issuer not in trust_roots:
        raise DelegationChainError(
            f"root issuer {chain[0].issuer!r} not in trust set"
        )

    # 3. Leaf audience and action coverage.
    leaf = chain[-1]
    if leaf.subject != audience:
        raise DelegationChainError(
            f"leaf audience mismatch: expected {audience!r}, got {leaf.subject!r}"
        )
    if requested_action not in leaf.scope:
        raise DelegationChainError(
            f"action {requested_action!r} outside leaf scope {sorted(leaf.scope)}"
        )

    # 4. Single-instant temporal evaluation across ALL links.
    effective_start = max(w.nbf for w in chain)
    effective_end = min(w.exp for w in chain)

    for i, w in enumerate(chain):
        if w.revoked:
            raise DelegationChainError(
                f"warrant at link {i} ({w.subject!r}) is revoked"
            )
        if now < w.nbf:
            raise DelegationChainError(
                f"warrant at link {i} ({w.subject!r}) not yet valid at t={now}"
            )
        if now >= w.exp:
            # Distinguish leaf expiry from intermediate expiry — critical.
            if i == len(chain) - 1:
                raise DelegationChainError(
                    f"LEAF_EXPIRED: leaf at link {i} expired at {w.exp}, now={now}"
                )
            within_skew = (now - w.exp) <= SKEW_TOLERANCE_S
            if within_skew and action_is_idempotent:
                return ChainVerdict(
                    outcome="AUTHORIZED_DEGRADED",
                    offending_link_index=i,
                    offending_link_did=w.subject,
                    evaluation_instant=now,
                    effective_window=(effective_start, effective_end),
                    detail=(
                        f"intermediate link {i} ({w.subject!r}) expired at {w.exp}, "
                        f"within skew tolerance; degraded authorization for "
                        f"idempotent action {requested_action!r}"
                    ),
                )
            # Hard refusal — do not collapse into LEAF_EXPIRED.
            raise DelegationChainError(
                f"INTERMEDIATE_WARRANT_EXPIRED: link {i} ({w.subject!r}) "
                f"expired at {w.exp}, now={now}, "
                f"skew_exceeded={not within_skew}, "
                f"action_mutable={not action_is_idempotent}; "
                f"recover by re-delegating from link {i-1} issuer, not the lapsed link"
            )

    return ChainVerdict(
        outcome="AUTHORIZED",
        evaluation_instant=now,
        effective_window=(effective_start, effective_end),
        detail=f"chain of {len(chain)} links valid at t={now}",
    )