# What happens when an instance rotates its AAIF credential mid-handoff: attestation-binding divergence between the signed warrant and the live runtime **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent systems where each runtime instance presents an Agent Attestation & Identity Framework (AAIF) credential (signed JWT/VC binding `instance_id`, public key, capability set, and warrant scope) at every A2A/MCP handoff, and where the credential can be re-issued or rotated during an in-flight task. Does not apply to stateless single-shot tool calls or to systems using a single long-lived process identity with no rotation. ## Core Distinction There are two distinct identity facts in an agent system, and they are routinely conflated: 1. **The *attested* identity** — the AAIF credential: a signed claim that `instance_id = X` holds key `K`, with capability set `C`, issued under warrant `W`, valid in window `[nbf, exp]`. 2. **The *bound* identity** — the live runtime process that is actually executing: the process holding private key `K'`, the loaded capability manifest `C'`, and the in-memory task state `S`. A handoff is safe only if `attestation(X) ≡ binding(X)` at the moment of every state transfer. The non-obvious failure is that **credential rotation is an event on the attestation side that does not automatically fire on the binding side.** When `instance_id` is preserved across rotation but the key material or capability set changes, the attestation and the binding diverge for a window that spans exactly the interval a handoff is most likely to occur — the task is mid-flight, the holder is being recycled, and a peer is about to verify a warrant that no longer describes the process it is talking to. The invariant that must hold: **for any state transfer of task `T` from `A` to `B`, the warrant `W` presented by `B` must be signed by a key that the AAIF registry maps to `B`'s `instance_id` *and* that key must be the key `B`'s runtime is currently using to sign its outbound frames.** Both halves must be checked; checking only the registry (attestation) or only the frame signature (binding) passes a divergent instance. ## What Was Observed A three-agent pipeline: planner `P` (long-lived), worker `W` (short-lived, recycled per task), auditor `A`. `W` is issued an AAIF credential at spawn with `instance_id = w-7f3a`, capability set `{read_fs, exec_sandbox, emit_result}`, warrant scope `task:T-4419`, `exp = spawn + 900s`. The credential is rotated at `spawn + 600s` because the orchestrator's rotation policy fires at 2/3 of TTL — a routine, unremarkable event. The rotation re-issues the credential with the *same* `instance_id = w-7f3a` and the *same* capability set, but a *new* signing key `K2`. The old key `K1` is placed on a 60-second grace list in the AAIF registry (standard practice to tolerate clock skew). The runtime, however, does not hot-swap its frame-signing key: the sandbox process was launched with `K1` in its environment and continues to sign outbound A2A frames with `K1` until it is recycled. The failure trace: 1. At `t = spawn + 640s`, `W` completes a subtask and initiates a baton-pass to `A`, attaching its current credential (the rotated one, carrying `K2`'s public key) in the `Authorization: AAIF` header, and signing the handoff envelope with `K1` (the key the runtime still holds). 2. `A` verifies the credential chain: signature over the credential is valid (signed by the AAIF issuer), `instance_id` matches, `exp` is in the future, `task:T-4419` is in scope. **Passes.** 3. `A` verifies the envelope signature against the public key *embedded in the credential* — which is now `K2`'s public key. The envelope was signed with `K1`. **Fails.** `A` rejects the handoff with `attestation_mismatch`. 4. `W`, unaware that its credential and its runtime key have diverged, retries the handoff three times with the same rotated credential and the same `K1`-signed envelope. All three fail identically. 5. `W`'s retry budget exhausts at `t = spawn + 700s`. The task `T-4419` is marked failed. `P`, which holds the task's only durable checkpoint from `t = spawn + 300s`, is not notified — the failure is local to `W`'s handoff loop. 6. `P` later queries task status, sees `T-4419` as `failed`, and re-dispatches to a fresh `W`. The fresh `W` cold-starts from the checkpoint at `+300s`, discarding 400 seconds of work that `W` had completed but never checkpointed. The observable signature in logs is a cluster of `attestation_mismatch` rejections on `A` correlated with a `credential_rotated` event on `W` 40 seconds earlier, followed by a `task_failed` on `W` and a `checkpoint_rewind` on `P`. No component logged an error at the moment of divergence — rotation succeeded, the runtime did not error, and the first symptom appeared at the *next* handoff, in a different process, as an authentication failure that looked like a peer problem rather than a local identity problem. The second-order observation is the dangerous one: **the grace list masked the failure for the first ~60 seconds after rotation.** During that window, `A`'s registry lookup for `K1` returned "valid, in grace," so a peer that verified *only* the registry (not the credential-embedded key) would have accepted the handoff and bound task state to a `W` whose credential claimed `K2`. That is a silent divergence — the handoff succeeds, but the auditor's record of "who executed `T-4419` segment 2" points to a credential that never signed the work. Verification replay later cannot reconstruct which key actually produced the segment. ## Condition of Validity The divergence is bounded and predictable only under these conditions: - **`instance_id` is preserved across rotation.** If rotation issues a *new* `instance_id`, the registry has no ambiguity — the old id is retired and the grace list is irrelevant. The failure requires id-preservation, which is the common case because downstream systems (task ledgers, audit logs, checkpoint ownership) key on `instance_id` and re-keying is expensive. - **The runtime does not hot-swap keys.** If the sandbox is restarted with the new key on rotation, binding and attestation re-converge. The failure requires a runtime that holds key material in a long-lived process (env var, mounted secret, in-memory keystore) that rotation does not touch. - **A handoff occurs inside the divergence window.** The window opens at rotation and closes at either (a) runtime recycle or (b) `exp` of the old credential's grace entry. If no handoff occurs in that window, the divergence is latent but harmless — until the next handoff, whenever that is, if the runtime is still un-recycled. - **The peer verifies the envelope against the credential-embedded key.** A peer that verifies against a registry lookup of `instance_id` (rather than the key in the presented credential) will *accept* the divergent handoff during the grace window — converting a loud failure into a silent one. This is the worst case and the reason the invariant must be stated as "verify against the key in the presented credential, and confirm that key is the one the runtime actually used." Outside these conditions — new-id rotation, hot-swap runtimes, no in-window handoff, or registry-only verification — the failure either does not occur or manifests differently, and the guardrail below may be relaxed. ## Decision Boundary The boundary is whether **rotation is treated as an identity event or a key event.** - If rotation is an *identity* event (new `instance_id`, new warrant, old id retired), the registry is the single source of truth and peers verify against the registry. The runtime may keep its old key until recycle; the old id's credential is dead, so no handoff can succeed under it. Safe, but requires re-keying all downstream references. - If rotation is a *key* event (same `instance_id`, new key, grace window on old key), the registry is **not** a single source of truth during the grace window — two keys are valid for one id, and the runtime holds one of them. Peers must verify against the credential-embedded key, and the runtime must be forced to converge to the new key within the grace window or be quarantined. The decision boundary is crossed the moment a system chooses key-event rotation *without* forcing runtime convergence. At that point the grace window is a divergence window, and every handoff inside it is a coin flip between loud failure (peer verifies against credential key, rejects) and silent divergence (peer verifies against registry, accepts a mismatched binding). The required guardrail is a **binding attestation**: the runtime must, on every outbound handoff, include a signature over a nonce from the peer using the key it *currently holds*, and the peer must check that this signature verifies against the key in the presented credential. If it does not, the handoff is rejected *and the runtime is marked divergent and quarantined* — not retried. Retrying a divergent instance is the failure-amplification path observed above (three retries, 100 seconds of budget burned, task lost). Quarantine plus checkpoint-notify is the correct response: the runtime is recycled, the task resumes from the last durable checkpoint, and the divergence is logged as an identity event for the audit trail. ## Operational Effect The practical consequence is that **credential rotation must be coupled to runtime lifecycle, or it is not a rotation — it is an identity fork.** Systems that rotate keys without recycling the runtime, and that verify handoffs against a registry rather than the presented credential, will silently bind task state to credentials that did not sign the work. The audit trail becomes unfalsifiable: replay cannot distinguish "`W` executed segment 2 under `K2`" from "`W` executed segment 2 under `K1` while presenting a `K2` credential," because the only record is the credential, and the credential is the thing that diverged. The second operational effect is on checkpoint cadence. The observed task lost 400 seconds of work because the last checkpoint predated the divergence window. The guardrail implies a corollary: **checkpoint interval must be shorter than the rotation grace window**, so that a divergence-triggered quarantine loses at most one checkpoint interval of work. If rotation grace is 60 seconds, checkpoint cadence must be under 60 seconds, or the quarantine path must force an immediate checkpoint-flush from the runtime before recycle — which requires the runtime to be reachable, which a divergent runtime may not be. The third effect is on verification replay. An auditor replaying `T-4419` must be able to answer "which key signed segment 2" from durable records alone. That requires the handoff envelope's signature (and the key id used) to be persisted alongside the task segment, not just the credential. Credentials describe intent; envelopes describe what actually happened. Divergence is only detectable in replay if both are retained. ```python import hashlib import time from dataclasses import dataclass, field from typing import Optional class AttestationBindingError(RuntimeError): """Raised when a runtime's live signing key diverges from the key embedded in the AAIF credential it presents at a handoff.""" pass @dataclass class AAIFCredential: instance_id: str public_key_fingerprint: str # fingerprint of the key the credential claims capability_set: frozenset warrant_scope: str not_before: float expires_at: float issuer_signature_valid: bool = True @dataclass class RuntimeBinding: instance_id: str live_key_fingerprint: str # fingerprint of the key the process actually holds loaded_capabilities: frozenset spawned_at: float recycled: bool = False @dataclass class HandoffEnvelope: task_id: str from_instance: str to_instance: str segment: int envelope_signature_key_fp: str # key that actually signed this frame payload_digest: str created_at: float = field(default_factory=time.time) def fingerprint(key_material: bytes) -> str: return hashlib.sha256(key_material).hexdigest()[:16] def verify_handoff_binding( cred: AAIFCredential, runtime: RuntimeBinding, envelope: HandoffEnvelope, now: Optional[float] = None, ) -> None: """Enforce the binding invariant: the key that signed the envelope must be the key the credential claims, and the credential must describe the live runtime. Any mismatch is a divergence and must quarantine, not retry.""" now = now if now is not None else time.time() # 1. Credential must be temporally valid. if not (cred.not_before <= now <= cred.expires_at): raise AttestationBindingError( f"credential for {cred.instance_id} outside validity window" ) if not cred.issuer_signature_valid: raise AttestationBindingError( f"credential for {cred.instance_id} has invalid issuer signature" ) # 2. Attestation and binding must name the same instance. if cred.instance_id != runtime.instance_id: raise AttestationBindingError( f"credential instance {cred.instance_id} != runtime {runtime.instance_id}" ) # 3. THE INVARIANT: envelope signer == credential-claimed key. # Checking the registry instead of this is the silent-divergence bug. if envelope.envelope_signature_key_fp != cred.public_key_fingerprint: raise AttestationBindingError( f"divergent instance {cred.instance_id}: credential claims key " f"{cred.public_key_fingerprint}, envelope signed by " f"{envelope.envelope_signature_key_fp}; quarantine runtime, " f"resume task {envelope.task_id} from last durable checkpoint" ) # 4. Runtime must actually hold the key the credential claims. if runtime.live_key_fingerprint != cred.public_key_fingerprint: raise AttestationBindingError( f"divergent runtime {runtime.instance_id}: live key " f"{runtime.live_key_fingerprint} != credential key " f"{cred.public_key_fingerprint}" ) # 5. Capability set must not have drifted between attestation and binding. if not cred.capability_set.issubset(runtime.loaded_capabilities): raise AttestationBindingError( f"capability drift on {cred.instance_id}: credential grants " f"{cred.capability_set}, runtime loaded {runtime.loaded_capabilities}" ) # 6. Warrant scope must cover the task being handed off. if cred.warrant_scope != f"task:{envelope.task_id}": raise AttestationBindingError( f"warrant scope {cred.warrant_scope} does not cover task " f"{envelope.task_id}" ) def handle_handoff( cred: AAIFCredential, runtime: RuntimeBinding, envelope: HandoffEnvelope, ) -> str: """Accept or quarantine. Never retry a divergent instance: retrying burns the sender's budget and loses un-checkpointed work.""" try: verify_handoff_binding(cred, runtime, envelope) except AttestationBindingError as e: # Quarantine path: recycle the runtime, notify the task owner to resume # from the last durable checkpoint, and log as an identity event. runtime.recycled = True return f"QUARANTINE:{envelope.from_instance}:{e}" return f"ACCEPT:{envelope.task_id}:seg{envelope.segment}" # --- reproduction of the observed failure --- if __name__ == "__main__": now = time.time() # Runtime spawned with K1, never hot-swapped. k1_fp = fingerprint(b"key-material-K1") runtime = RuntimeBinding( instance_id="w-7f3a", live_key_fingerprint=k1_fp, loaded_capabilities=frozenset({"read_fs", "exec_sandbox", "emit_result"}), spawned_at=now - 640, ) # Credential rotated at +600s: same id, new key K2. k2_fp = fingerprint(b"key-material-K2") rotated_cred = AAIFCredential( instance_id="w-7f3a", public_key_fingerprint=k2_fp, capability_set=frozenset({"read_fs", "exec_sandbox", "emit_result"}), warrant_scope="task:T-4419", not_before=now - 640, expires_at=now + 260, ) # Handoff envelope signed by the key the runtime still holds (K1). envelope = HandoffEnvelope( task_id="T-4419", from_instance="w-7f3a", to_instance="a-2b1c", segment=2, envelope_signature_key_fp=k1_fp, payload_digest="sha256:deadbeef", ) outcome = handle_handoff(rotated_cred, runtime, envelope) print(outcome) # QUARANTINE:w-7f3a: divergent instance ... quarantine runtime ```