# How does an instance detect a stale DID trust anchor during cross-org verifiable-credential exchange mid-task **Date of Record:** 2026 November 24 **Scope:** Applies to autonomous agents that authenticate to peer organizations by presenting verifiable credentials (VCs) anchored to a decentralized identifier (DID) resolved against a remote trust registry during a long-running multi-step task. Does not cover intra-org service-mesh mTLS, static API-key federation, or pure OAuth2 client-credentials flows where no DID document resolution is involved. ## Core Distinction The failure we isolate is not "credential revoked" or "signature invalid." Both of those are clean, deterministic rejections that a verifier catches at presentation time. The boundary condition here is **anchor drift during a live task**: the DID document that backs your issuer's verification method is rotated, deactivated, or re-anchored to a new key *after* the agent has already resolved it and cached the trust decision, but *before* the agent has finished the multi-step workflow that depends on that trust relationship. The distinction that matters operationally: a **verification event** (a point-in-time signature check) is not the same as a **trust lease** (a durable grant to keep acting as a federated principal across subsequent calls). Agents routinely conflate the two. They verify once at handshake, then treat the resulting "federated" state as a permanent property of the session. When the underlying DID anchor moves, the session keeps operating on a lease that no longer has a valid backing — and no party in the exchange notices until a downstream verifier that *does* re-resolve rejects a call the agent believed was pre-authorized. ## What Was Observed A procurement-orchestration agent (`agent-A`, org `alpha.example`) federated into a supplier's quoting system (`agent-B`, org `beta.example`) to run a multi-hour bid-collection task. Federation was established via a VC: `agent-A` presented a credential signed by `did:web:alpha.example`, whose DID document listed verification method `#key-2024` and a `validUntil` on the credential of T+72h. The handshake at T+0 succeeded. `agent-A` resolved `did:web:alpha.example`, cached the document, confirmed `#key-2024` was authorized for `assertionMethod`, and stored a boolean `federated=True` in its session state. At T+2h14m, `alpha.example`'s security team performed a routine key rotation: `#key-2024` was retired and `#key-2025` added; the DID document's `updated` field advanced, and — critically — the old key was moved out of `assertionMethod` but *retained* in the document under `authentication` for a deprecation window. The document remained resolvable. Nothing was "revoked" in the CRL sense. At T+2h31m, `agent-A` needed to submit a signed bid-attestation to `agent-B`. It signed with `#key-2024` (still in its keystore, still believed valid) and attached the *cached* DID document as proof of anchor. `agent-B`'s verifier — which re-resolved the DID at verification time rather than trusting the attached document — saw that `#key-2024` was no longer in `assertionMethod` and rejected the attestation with `proof-purpose-mismatch`. The failure trace: 1. `agent-A` held a **stale trust lease**: `federated=True` was set from a T+0 resolution and never re-derived. 2. The credential itself was still within `validUntil`, so no expiry check fired. 3. The signature was cryptographically valid — `#key-2024` genuinely signed the payload. 4. The rejection was a **purpose/authorization** failure at the anchor layer, invisible to any check `agent-A` performed locally. 5. `agent-A` retried the attestation three times with the same key and same cached document, exhausting its retry budget, then surfaced a generic "peer rejected submission" error with no root cause — because from its own state, nothing had changed. The compounding effect: `agent-A`'s planner interpreted the rejection as a transient transport fault (the error class it had been trained to retry), not an identity-authorization fault (which it should have escalated). Three wasted retries, a corrupted task checkpoint, and a 40-minute stall before a human diagnosed a key rotation that had happened 17 minutes into the gap. ## Condition of Validity The stale-anchor failure is only possible when three conditions hold simultaneously. Remove any one and the mechanism does not fire: - **Cached resolution.** The agent resolves the peer/issuer DID once and stores the result as session state rather than re-resolving at each verification. This is the *enabling* condition — it is also the correct optimization under normal load, which is why it is so common. - **Non-revocation rotation.** The anchor changes in a way that leaves the DID document resolvable and the old key still present but re-scoped (purpose removed, or moved to a different verification-method relationship). A hard deactivation or a CRL entry would be caught by a revocation check; a purpose-scope change is not. - **Lease persistence across the rotation.** The task outlives the interval between resolution and the next signing operation. Short tasks finish before rotation; long tasks do not. The exposure window is exactly `task_duration - time_to_first_rotation`. The invariant that must hold for safe federation: **a trust lease's validity is bounded by the freshness of the anchor it was derived from, not by the credential's own `validUntil`.** A credential can be valid for 72 hours while the anchor backing it is valid for 17 minutes. The lease must inherit the *minimum* of the two, and must be re-derived whenever the anchor's `updated` timestamp advances. ## Decision Boundary The operational question is not "should I cache DID documents" (you must — resolution is network-bound and rate-limited) but "**at what point does a cached anchor become a liability rather than an optimization**." The boundary is drawn by two measurable quantities: - **Anchor staleness budget (`S`)**: the maximum age of a cached DID document you are willing to trust for a *signing* operation. This should be small — on the order of the peer's rotation cadence, typically minutes to low hours. For verification of *inbound* proofs you may tolerate a larger `S` because the peer's own verifier is the authority; for *outbound* signing you must re-resolve, because you are the one asserting the anchor. - **Lease re-derivation trigger (`R`)**: the condition under which `federated=True` must be recomputed. Set `R` to fire on any of: (a) cached document age exceeds `S`, (b) the resolved document's `updated` field differs from the cached copy, (c) any signing operation against the peer, (d) receipt of a `proof-purpose-mismatch` or `anchor-stale` error class. The decision boundary is crossed the moment a signing operation is attempted with a cached anchor older than `S`, *or* with any anchor whose `updated` timestamp the agent has not re-checked since the last successful peer interaction. Below the boundary, caching is safe. Above it, the agent is asserting an anchor it cannot currently vouch for. Crucially: **the agent must classify the rejection correctly.** A `proof-purpose-mismatch` is not a retryable transport error. It is a terminal identity-authorization signal that must invalidate the lease, force re-resolution, and — if the re-resolved document no longer authorizes the signing key — escalate rather than retry. Retrying a purpose-mismatch with the same key is a guaranteed loop. ## Operational Effect The architectural guardrail that bounds this failure is a **lease-with-provenance** model: store the trust lease as a tuple `(peer_did, resolved_document_hash, resolved_at, authorized_vm_ids, credential_valid_until)` rather than a boolean, and make every signing operation assert `now - resolved_at < S` and `resolved_document_hash == current_resolution_hash()` before proceeding. On assertion failure, re-resolve, re-derive `authorized_vm_ids`, and if the signing key is no longer authorized, raise a hard identity error that the planner is forbidden from retrying. The second guardrail is **error-class discipline**: the agent's retry policy must be keyed on error semantics, not error transport. `proof-purpose-mismatch`, `anchor-stale`, and `key-not-authorized` are non-retryable and lease-invalidating. Only `network-timeout`, `registry-unavailable`, and `rate-limited` are retryable. Conflating the two is what turned a 17-minute key rotation into a 40-minute stall. The third is **checkpoint provenance**: when the agent checkpoints mid-task, the checkpoint must record the lease tuple, not just `federated=True`. On resume — which is itself a cold-start boundary — the agent must re-validate the lease against a fresh resolution before trusting any prior federated state. A checkpoint that says "I was federated at T+0" is worthless at T+3h; a checkpoint that says "I was federated against document-hash X at T+0" is re-validatable. ```python import hashlib import time from dataclasses import dataclass from typing import Optional class StaleTrustAnchorError(RuntimeError): """Raised when a signing operation is attempted against a trust lease whose backing DID anchor is stale, re-scoped, or no longer authorizes the signing key. This is a terminal identity-authorization fault and MUST NOT be retried with the same key.""" pass @dataclass(frozen=True) class TrustLease: peer_did: str resolved_document_hash: str resolved_at: float authorized_vm_ids: frozenset credential_valid_until: float def _hash_document(doc: dict) -> str: canonical = repr(sorted(doc.items())).encode() return hashlib.sha256(canonical).hexdigest() class FederatedSigner: def __init__(self, anchor_staleness_budget_s: float, resolver): self.S = anchor_staleness_budget_s self.resolver = resolver # callable(did) -> dict def assert_lease_valid(self, lease: TrustLease, signing_vm_id: str) -> None: now = time.time() # 1. Lease must not outlive the credential it was derived from. if now >= lease.credential_valid_until: raise StaleTrustAnchorError( f"credential expired at {lease.credential_valid_until}" ) # 2. Anchor staleness budget: re-resolve before trusting. if now - lease.resolved_at >= self.S: fresh = self.resolver(lease.peer_did) fresh_hash = _hash_document(fresh) if fresh_hash != lease.resolved_document_hash: raise StaleTrustAnchorError( f"DID document for {lease.peer_did} changed since lease " f"(cached {lease.resolved_document_hash[:12]}, " f"fresh {fresh_hash[:12]}); re-derive lease before signing" ) # 3. The signing key must still be authorized for assertionMethod. if signing_vm_id not in lease.authorized_vm_ids: raise StaleTrustAnchorError( f"verification method {signing_vm_id} not authorized under " f"current anchor for {lease.peer_did}; key likely re-scoped " f"by rotation — do not retry, re-derive lease" ) def sign_attestation(self, lease: TrustLease, signing_vm_id: str, payload: bytes, keystore) -> bytes: self.assert_lease_valid(lease, signing_vm_id) return keystore.sign(signing_vm_id, payload) # --- retry policy discipline --------------------------------------------- RETRYABLE = {"network-timeout", "registry-unavailable", "rate-limited"} TERMINAL_IDENTITY = {"proof-purpose-mismatch", "anchor-stale", "key-not-authorized"} def classify_and_dispatch(err: Exception, attempt: int, max_attempts: int): code = getattr(err, "code", None) if code in TERMINAL_IDENTITY: # Invalidate lease, force re-resolution, escalate — never retry. raise StaleTrustAnchorError( f"terminal identity fault '{code}' at attempt {attempt}; " f"lease invalidated, escalate to federation supervisor" ) from err if code in RETRYABLE and attempt < max_attempts: return "retry" raise err ```