Which invariants prevent identity-rotation replay during short-lived credential minting under AAIF governance
**Date of Record:** 2026 December 1 **Scope:** Applies to AAIF-governed agent fleets where an agent instance rotates its cryptographic identity and mints short-lived capability warrants (TTL-bounded, audience-scoped tokens) mid-task. Does not apply to long-lived static service credentials, nor to human-delegated OAuth flows where the principal is a human session.
Core Distinction
The failure this record isolates is **rotation-mint skew**: the window in which an agent has *committed* to a new keypair but the governing authority (AAIF issuer) has *not yet* propagated the revocation of the old key to every warrant-verifying peer. It is not a key-compromise problem, not a clock-skew problem, and not a schema-negotiation problem. It is a **causal-ordering problem between two independently-sequenced state machines** — the agent's local identity FSM and the distributed warrant-status FSM — that share no transactional boundary.
The naive invariant engineers reach for is "old key dies before new key lives." That invariant is unimplementable across a network without a consensus round, and agents cannot afford one per rotation. The correct invariant is weaker and subtler: **no warrant signed by key generation `N-1` may be honored after a warrant signed by generation `N` for the same agent has been honored by the same verifier.** This is monotonicity per verifier, not global atomicity.
What Was Observed
An agent (`planner-7`) executing a multi-step task rotated identity at step 14 of 22. The rotation was triggered by AAIF policy: warrants older than 300s must be re-minted. The local FSM transitioned `ACTIVE(gen=3) → ROTATING(gen=3→4) → ACTIVE(gen=4)`. During `ROTATING`, the agent held both keypairs in memory and — because the tool-call loop was mid-flight — emitted two outbound warrants in the same 40ms window:
- `warrant_A`: signed with `key_3`, audience `worker-2`, scope `read:scratchpad`, issued at `t=0`.
- `warrant_B`: signed with `key_4`, audience `worker-2`, scope `read:scratchpad`, issued at `t=38ms`.
`worker-2` received `warrant_B` first (different TCP path, no ordering guarantee across gRPC streams), validated it, bumped its local `last_seen_generation[planner-7] = 4`, and executed the scoped read. Then `warrant_A` arrived. `worker-2`'s verifier had **no monotonicity check** — it validated `warrant_A` against the AAIF status endpoint, which still reported `key_3` as `VALID` (revocation propagation lag ≈ 1.2s). `worker-2` executed the read *again*.
The observable symptom was a duplicated side-effecting tool call (`read:scratchpad` was idempotent, so it surfaced only as a doubled audit-log entry). With a non-idempotent scope — `write:ledger` — the same mechanism produced a **double-write**, and because `warrant_A` and `warrant_B` carried *different nonces but the same logical intent*, the downstream deduplication layer treated them as distinct operations.
The root trace: the agent's `ROTATING` state permitted **concurrent emission under two generations**, and the verifier had no per-agent generation watermark to reject the stale one. Both sides were individually correct. The composition was not.
Condition of Validity
The monotonicity invariant holds **only if** every verifier maintains a per-agent-generation watermark and the AAIF warrant carries an explicit, signed `generation` integer that is:
- **Monotonically assigned by the issuer**, not by the agent. If the agent self-assigns the generation counter, a compromised or buggy agent can mint `gen=99` to poison the watermark and then legitimately replay `gen=4` warrants forever. The generation must be countersigned in the warrant's AAIF envelope.
- **Total-ordered per (agent, issuer) pair**, not per audience. Two verifiers with different watermark values must not both accept conflicting generations of the same warrant — the issuer's counter is the single source of truth, and verifiers must reject any warrant whose generation exceeds `watermark + 1` (a gap indicates a missed revocation or a forged counter).
- **Bound to the key material**, so that possession of `key_3` after `gen=4` is established cannot be used to forge a `gen=4` warrant. This requires the AAIF envelope to sign `(generation, key_fingerprint, nonce)` jointly.
The invariant is **invalid** if the system relies on TTL expiry alone to bound the skew window. TTL bounds *lifetime*, not *ordering*: a `warrant_A` with TTL 300s and `warrant_B` with TTL 300s are both "live" for 300s regardless of which was minted first. TTL is a liveness bound; generation is an ordering bound. They are orthogonal and both required.
Decision Boundary
The decision boundary is where an agent must choose between **blocking rotation until in-flight warrants drain** versus **allowing concurrent dual-generation emission with verifier-side watermark enforcement**.
- **Blocking (drain-then-rotate)** is correct only when the agent can enumerate all in-flight warrants and the maximum tool-call latency is bounded below the AAIF rotation deadline. For a 300s warrant TTL and a p99 tool latency of 4s, draining costs ≤4s and is safe. Choose this when the tool surface includes non-idempotent scopes.
- **Concurrent dual-generation** is safe only when every verifier in the audience set enforces the generation watermark *and* the issuer countersigns generations. If even one verifier in the audience set is a legacy AAIF node without watermark support, the invariant is unenforceable for that audience, and the agent must fall back to drain-then-rotate for warrants targeting that audience.
The boundary is therefore **audience-dependent, not agent-global**. An agent rotating while emitting to a mixed audience (some watermark-capable, some not) must partition its warrant emission: drain for legacy audiences, dual-emit for watermark-capable ones. Treating rotation as a single global FSM transition is the design error that produced the observed double-write.
Operational Effect
Enforcing the generation-watermark invariant changes three operational properties:
- **Verifier state becomes non-trivial and must be durable.** A verifier that loses its watermark on restart will accept stale warrants. Watermark state must be persisted with the same durability class as the audit log, and must be recovered *before* the verifier accepts any warrant post-restart.
- **Warrant rejection becomes a first-class, observable signal.** A rejected stale warrant is not an error to swallow — it is evidence of rotation-mint skew and must be surfaced to the AAIF governance layer as a rotation-timing violation, so the offending agent's rotation policy can be tightened.
- **Idempotency keys must be derived from `(agent, generation, logical_intent)`, not from the warrant nonce.** Because the nonce differs across generations by design, nonce-based dedup cannot catch the cross-generation duplicate. The dedup key must be generation-independent.
The cost is a per-agent-generation watermark table at every verifier — small, bounded, and prunable to the last `K` generations per agent. The benefit is that identity rotation becomes a *monotone* operation from every verifier's perspective, which is the only property that makes short-lived credential minting safe under concurrent emission.
from dataclasses import dataclass
from typing import Dict, Tuple
class RotationReplayError(RuntimeError):
"""Raised when a warrant violates per-agent generation monotonicity."""
@dataclass(frozen=True)
class AAIFWarrant:
agent_id: str
issuer_id: str
generation: int # countersigned by issuer, not agent-assigned
key_fingerprint: str
nonce: str
scope: str
audience: str
ttl_seconds: int
class GenerationWatermark:
"""Per-verifier monotonic watermark over (agent, issuer) pairs."""
def __init__(self) -> None:
self._watermarks: Dict[Tuple[str, str], int] = {}
def check_and_advance(self, w: AAIFWarrant) -> None:
key = (w.agent_id, w.issuer_id)
seen = self._watermarks.get(key)
if seen is None:
# First sighting: accept, but only gen 0 or 1 may open the watermark.
if w.generation > 1:
raise RotationReplayError(
f"first warrant for {key} has generation {w.generation}; "
f"expected <= 1 (possible forged counter or missed revocation)"
)
self._watermarks[key] = w.generation
return
if w.generation < seen:
raise RotationReplayError(
f"stale warrant for {key}: gen {w.generation} < watermark {seen} "
f"(rotation-mint skew replay; scope={w.scope})"
)
if w.generation > seen + 1:
raise RotationReplayError(
f"generation gap for {key}: gen {w.generation} > watermark {seen} + 1 "
f"(missed revocation or forged counter)"
)
# gen == seen is a same-generation retry: idempotent, allow.
# gen == seen + 1 is a legitimate advance.
self._watermarks[key] = w.generation
def verify_warrant(w: AAIFWarrant, wm: GenerationWatermark) -> None:
if w.ttl_seconds <= 0:
raise RotationReplayError(f"expired warrant {w.nonce} for {w.agent_id}")
# Issuer countersignature of (generation, key_fingerprint, nonce) is assumed
# validated upstream by the AAIF envelope check; watermark enforces ordering.
wm.check_and_advance(w)