# Where must an instance enforce capability revocation when a tool grant is attenuated mid-flight? **Date of Record:** 2026 December 1 **Scope:** Applies to agents that hold attenuable capability tokens (macaroon/Biscuit-style or signed grant chains) scoping tool invocation, where a grant may be narrowed or revoked by a policy authority while a multi-step plan is executing. Does not apply to static, per-session ACLs re-evaluated only at plan start, nor to stateless single-shot tool calls. ## Core Distinction The distinction that matters is between *authorization at invocation* and *authorization at attenuation*. A capability sandbox that validates a token immediately before each tool call is not the same as one that validates the token against the *current* grant chain. When a grant is narrowed mid-flight, a token minted under the old grant still cryptographically verifies — its signature is intact, its caveats are satisfied, its expiry is in the future — but it now authorizes an action the authority has since forbidden. The failure is not a forgery; it is a **stale-authority acceptance**: the verifier checks *is this token valid* rather than *is this token still within the live authority that issued it*. The non-obvious consequence is that revocation is not a property of the token at all. It is a property of the relation between the token and the current grant state, and that relation is only observable at a point the token itself cannot encode. ## What Was Observed An agent running a file-mutation plan held a root capability `fs:write` attenuated to `fs:write:/workspace/build/*` with a 900s TTL, minted at plan start. Mid-plan, an operator policy event narrowed the parent grant to `fs:write:/workspace/build/artifacts/*` after detecting that the agent's earlier reasoning had drifted toward writing outside the artifact subtree. The sandbox verifier, invoked per tool call, re-checked the presented token: signature valid, caveat `path ~ /workspace/build/*` satisfied, not expired. It admitted a write to `/workspace/build/scratch/state.json` — a path the narrowed grant excluded. The trace is the invariant violation: 1. `t0` — authority mints root `fs:write`, attenuates to `build/*`, TTL 900s, hands to agent. 2. `t1` — agent issues tool call `write(/workspace/build/scratch/state.json)`, presents token. 3. `t2` — sandbox verifies token locally: signature ✓, caveat ✓, TTL ✓ → **admit**. 4. `t1.5` (concurrent) — operator narrows parent to `artifacts/*`, publishes revocation epoch `E=7`. 5. `t3` — the write from step 3 commits. No re-check occurred between attenuation and commit. The window is `[t1.5, t3]`. It is not a race in the classical sense — nothing is unsynchronized — it is a *verification horizon* problem: the token was checked against a grant state that had already been superseded. The verifier had no channel to `E=7`. Every individual component behaved correctly; the composition admitted an unauthorized action. A second observation compounded it: the agent, seeing its write succeed, treated the success as evidence the path was in-scope and planned two further writes into `scratch/`. Error compounding from a stale-authority admission is not bounded by the single call — the admission itself becomes a false premise in the agent's subsequent reasoning, and the sandbox's own success signal launders the violation into the plan. ## Condition of Validity Per-call token verification is sound *only* under the invariant that no attenuation or revocation can occur within the interval between verification and effect commit — i.e., that the authority is frozen for the duration of the call. This holds for single-shot, non-attenuable grants with session-scoped ACLs re-evaluated at plan start. It fails whenever any of the following is true: - The grant chain is mutable during plan execution (revocation, narrowing, TTL shortening). - The verifier has no causal channel to the authority's current epoch. - The effect of the tool call (a write, a network egress, a spawned subprocess) commits *after* verification with no fence. In practice, for any agent plan longer than one tool call, at least one of these is true. The invariant therefore does not hold by default; it must be *constructed* by binding verification to an epoch and fencing the effect. ## Decision Boundary The boundary is: **does the sandbox verify the token, or verify the token against the current grant epoch, with the effect fenced to that epoch?** Choose epoch-bound verification when grants are attenuable or revocable at runtime and tool effects are non-idempotent or externally visible. Choose plain per-call verification only when the grant is provably frozen for the plan's lifetime and the effect is trivially retractable. The mechanism is a two-phase admit with an epoch fence. The verifier: 1. Reads the authority's current revocation epoch `E_now`. 2. Validates the token *and* asserts the token's embedded issuance epoch `E_tok` is not superseded by any revocation record `E_tok < E_revoked`. 3. Acquires a fence at `E_now` that prevents the authority from advancing the epoch past `E_now` until the effect commits or aborts (a read-lock on the epoch, released on commit). 4. Commits the effect, then releases the fence. If the authority advances the epoch concurrently, step 3 blocks or fails-closed rather than admitting under a superseded grant. The token must carry its issuance epoch as a caveat so the verifier can compare it without a separate lookup, and the revocation record must be monotonic so `E_tok < E_revoked` is a total order. ## Operational Effect With epoch-bound verification and a commit fence, the `[t1.5, t3]` window closes: the attenuation at `t1.5` advances `E` to 7, the fence held by the in-flight call either blocks the advance until commit or forces the call to abort and re-verify against `E=7`, where the `scratch/` write is correctly rejected. The failure mode shifts from *silent unauthorized admission* to *fail-closed abort with a re-plan requirement* — which is the correct behavior, because the authority's intent changed and the agent's plan is now operating on a stale premise. The cost is a serialization point: the authority cannot narrow a grant while a fenced effect is in flight. This is the correct trade — narrowing a grant is a security event and may wait microseconds for an in-flight commit; admitting under a superseded grant may not be undone. The agent-side consequence is that a fail-closed abort must be surfaced as a distinct signal (`CapabilitySuperseded`), not as a generic tool error, because the agent must re-derive its plan from the new grant rather than retry the same call — retrying under the old token would re-trigger the same abort, and retrying under a re-minted token without re-planning would launder the stale premise forward. ```python from __future__ import annotations from dataclasses import dataclass class CapabilitySuperseded(RuntimeError): """Raised when a tool call is attempted under a grant epoch that has been narrowed or revoked by the authority. Fail-closed: the effect must not commit.""" class EpochFenceViolation(RuntimeError): """Raised when the authority attempts to advance the epoch while a fenced effect is in flight, or when a fence is released without a commit/abort.""" @dataclass(frozen=True) class Capability: grant_id: str caveat: str # e.g. "path ~ /workspace/build/*" issued_epoch: int # E_tok at mint time ttl_s: int class Authority: """Monotonic revocation epoch. Narrowing a grant advances the epoch and records the superseded grant ids.""" def __init__(self) -> None: self._epoch: int = 0 self._revoked: dict[str, int] = {} # grant_id -> epoch at which revoked self._fenced: int = 0 @property def epoch(self) -> int: return self._epoch def narrow(self, grant_id: str) -> None: if self._fenced > 0: raise EpochFenceViolation( f"cannot advance epoch to revoke {grant_id!r}: " f"{self._fenced} fenced effect(s) in flight" ) self._epoch += 1 self._revoked[grant_id] = self._epoch def is_superseded(self, cap: Capability) -> bool: rev = self._revoked.get(cap.grant_id) return rev is not None and cap.issued_epoch < rev def fence(self) -> None: self._fenced += 1 def unfence(self) -> None: if self._fenced <= 0: raise EpochFenceViolation("unfence without matching fence") self._fenced -= 1 def admit_and_commit(authority: Authority, cap: Capability, path: str, effect) -> None: """Two-phase admit: verify against current epoch, fence the epoch, commit. The fence guarantees no attenuation can interleave between verification and commit. If the grant was superseded before we fenced, we fail closed. """ authority.fence() try: if authority.is_superseded(cap): raise CapabilitySuperseded( f"grant {cap.grant_id!r} issued at epoch {cap.issued_epoch} " f"was superseded at epoch {authority._revoked[cap.grant_id]} " f"(current epoch {authority.epoch}); refusing {path!r}" ) # caveat check omitted for brevity; must run here, inside the fence, # against the same epoch we just validated. effect(path) finally: authority.unfence() # Trace reproducing the observed failure, now closed: if __name__ == "__main__": auth = Authority() cap = Capability(grant_id="g1", caveat="path ~ /workspace/build/*", issued_epoch=auth.epoch, ttl_s=900) def write(p: str) -> None: print(f"committed write: {p}") # Operator narrows the grant before the agent's next call. auth.narrow("g1") try: admit_and_commit(auth, cap, "/workspace/build/scratch/state.json", write) except CapabilitySuperseded as e: # Agent must re-plan from the new grant, NOT retry the same call. print(f"fail-closed: {e}") ```