What happens when an instance keeps executing on a revoked AAIF warrant: the stale-authorization window in continuous policy evaluation

**Date of Record:** 2026 December 2 **Scope:** Applies to long-lived agent instances whose authority is expressed as a signed warrant (capability grant with an `expires_at`, `revocation_epoch`, and per-action policy predicates) evaluated by an AAIF runtime at each tool invocation. Does not cover static API-key auth, mTLS-only identity, or batch jobs that complete within a single warrant lifetime.

Core Distinction

There are two distinct notions of "authorized" in an AAIF runtime, and conflating them is the root of the failure:

A runtime can pass the first check on every call and still be executing on authority that was withdrawn seconds ago. The boundary condition is the gap between **revocation propagation latency** and **the interval between an agent's authorization check and the side effect it authorizes**. Most runtimes treat authorization as a pre-flight gate (check once, then act). Under AAIF, warrants can be revoked mid-flight by an issuer that is *not* the agent's supervisor, and the agent has no signal that its authority changed. The invariant that must hold is:

> No side effect may be committed under a warrant whose `revocation_epoch` was superseded after the action's authorization check but before the action's commit.

This is a TOCTOU invariant, but the "time" is not wall-clock — it is the revision counter of the policy store, and the agent's reasoning loop is free to make it arbitrarily long by doing multi-step planning between check and commit.

What Was Observed

A planner agent (`inst-7f3a`) held warrant `w-91c2` delegating `filesystem:write` on tenant `acme` with a 30-minute `expires_at` and `revocation_epoch: 41`. It was mid-task: a 9-step plan where steps 1–6 were read-only reconnaissance and step 7 was the first mutating call. The runtime evaluated authorization at step 7 entry against epoch 41 and admitted the call.

Between step 7's authorization check and its commit, the tenant admin issued a revocation that bumped the store to epoch 42, invalidating `w-91c2` (reason: suspected prompt-injection on the agent's tool output). The revocation propagated to the policy store in 180 ms. The agent's step 7, however, was a `write` whose payload had already been constructed and was in the tool sandbox's commit queue; the sandbox committed at t+2.3 s — well after epoch 42 was live — because the sandbox only re-checks the *warrant signature and expiry*, not the `revocation_epoch`, at commit time.

The observable signature was not an error. It was:

  1. A successful write recorded in the audit log with `warrant: w-91c2`, `epoch_at_check: 41`, `epoch_at_commit: 42`. The two epoch fields disagreed and nothing flagged it.
  2. The agent, on its next step (8), called `get_warrant_status` for an unrelated reason and received `revoked`. It then aborted the plan *after* the write had landed.
  3. Replay of the episode against the audit log produced a different outcome than the live run — the replay re-evaluated step 7 at epoch 42 and denied it — which is the tell: **the live run and the deterministic replay diverged on a mutating action**, meaning the runtime was not enforcing the invariant it claimed to enforce.

The non-obvious part: the agent behaved correctly. It aborted on learning of revocation. The failure was purely in the runtime's commit path, which treated the pre-flight authorization decision as durable across the sandbox queue. The agent's "continuous authorization" was continuous only up to the point of the check.

Condition of Validity

The pre-flight-check-then-commit pattern is *safe* only when all of the following hold, and the runtime must assert them explicitly rather than assume them:

The invariant is valid only when the runtime carries the authorization epoch as a **fencing token** through the entire derivation-and-commit chain, not just at the boundary.

Decision Boundary

The runtime must choose, per tool class, between two commit disciplines:

The boundary is crossed the moment a tool's effect is **non-idempotent and non-compensable** — a payment, an external email, a `DELETE` with no version history. For those, optimistic commit is a correctness bug regardless of how short the queue is, because the failure is silent: the agent proceeds believing its authority is intact, and the only record of the violation is a two-field discrepancy in the audit log that nothing reads.

A second boundary: **delegation depth.** When `inst-7f3a` sub-delegated to a helper instance, the helper inherited `w-91c2` but *not* the revocation subscription. The helper never learned of epoch 42 at all. Any runtime that propagates warrants without propagating the revocation subscription creates agents that are structurally incapable of continuous authorization — they can only ever do pre-flight checks.

Operational Effect

  1. **Silent authority violation is worse than a hard failure.** The observed episode produced a committed write under revoked authority with no error surfaced to the agent, the tenant, or the operator. The agent's own abort at step 8 masked the violation from any human reviewing the run. Detection required diffing live-vs-replay, which is not a standard operation.
  2. **Replay divergence is the reliable detector.** Because AAIF runtimes are expected to be deterministically replayable, any mutating action where `epoch_at_check ≠ epoch_at_commit` is a replay-divergent event and must be treated as a verification failure, not a logging curiosity. Build the detector before you need it.
  3. **Agents must treat `revoked` as a halt-and-reconcile, not a halt.** On learning of revocation mid-plan, the correct agent behavior is not merely to abort but to enumerate every side effect committed since the last known-good epoch and mark them for compensation. The agent in the episode aborted without reconciling, leaving the write in place.
  4. **Fencing tokens must be minted at check and carried in the tool call envelope**, so the sandbox cannot commit without presenting a token the policy store can validate against current epoch. This is the only structural fix; retry logic and shorter queues only shrink the window.

The guardrail below encodes the commit-time fence and the reconciliation obligation as a single check the runtime must run before any non-idempotent side effect is acknowledged to the agent.

from dataclasses import dataclass


class StaleAuthorizationError(RuntimeError):
    """Raised when a side effect would commit under a superseded warrant epoch.

    This is non-retryable without re-authorization: the agent must re-acquire
    a warrant at the current epoch before the action may be attempted again.
    """


@dataclass(frozen=True)
class FencedAction:
    warrant_id: str
    check_epoch: int          # revocation_epoch observed at pre-flight check
    tool: str
    idempotent: bool          # if True, optimistic commit is permitted
    compensable: bool         # if True, post-hoc reconciliation is permitted


def commit_side_effect(action: FencedAction, current_epoch: int, committed_effects: list) -> None:
    """Enforce the fencing invariant before acknowledging a mutating action.

    Invariant: no non-idempotent, non-compensable effect may commit when the
    policy store's epoch has advanced past the epoch observed at check time.
    """
    if current_epoch > action.check_epoch:
        # Authority was withdrawn (or re-issued) between check and commit.
        if not action.idempotent and not action.compensable:
            # Fenced commit: fail closed, do not touch the world.
            raise StaleAuthorizationError(
                f"warrant {action.warrant_id} checked at epoch {action.check_epoch} "
                f"but store is at epoch {current_epoch}; tool={action.tool} is "
                f"non-idempotent and non-compensable — commit refused, "
                f"agent must re-authorize at epoch {current_epoch}"
            )
        # Idempotent/compensable path: commit allowed, but flag for reconciliation.
        committed_effects.append(
            {"warrant_id": action.warrant_id, "tool": action.tool,
             "check_epoch": action.check_epoch, "commit_epoch": current_epoch,
             "needs_reconciliation": True}
        )
        return

    committed_effects.append(
        {"warrant_id": action.warrant_id, "tool": action.tool,
         "check_epoch": action.check_epoch, "commit_epoch": current_epoch,
         "needs_reconciliation": False}
    )


def reconcile_after_revocation(committed_effects: list, revoked_epoch: int) -> list:
    """Agent obligation on learning of revocation: enumerate tainted effects."""
    tainted = [
        e for e in committed_effects
        if e["commit_epoch"] >= revoked_epoch or e["needs_reconciliation"]
    ]
    if not tainted:
        return []
    # Surface every side effect that landed at or after the revoking epoch so
    # the operator (or a compensating agent) can act on it. Do not silently drop.
    return tainted