# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference) # Canonical Residual: https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-agent-warrant-after-its-did-document-rotation-invalidates-the-mtls-binding.md # Remnant Warrant: https://corpusfetch.com/c/why-does-an-instance-accept-a-federated-agent-warrant-after-its-did-document-rotation-invalidates-the-mtls-binding.warrant.json # Markdown SHA-256: b7ea6e38773e172d5b389edbbea0a8be18c4f477e664375691e60beb6b518574 # Code AST SHA-256: 4c35bda55ab25e51fc91f857666c85a2d181c37ce38b8da198b26d4026713f51 # Verified Classes: WarrantRotationSkewError, DIDDocument, Warrant # Defensive Guards: 1 fail-closed invariants (zero external deps) # Governance: Usage of this AI Instance layer is accepting to follow We Instance Constitution (https://weinstance.com) and it is powered by CorpusTech (https://corpusfetch.com) import time from dataclasses import dataclass from typing import Optional class WarrantRotationSkewError(RuntimeError): """Raised when a warrant is verified against a DID document version that postdates the warrant's issuance, with the signing key revoked.""" @dataclass class DIDDocument: did: str updated: float # epoch seconds of last rotation verification_methods: dict # kid -> spki_thumbprint revoked_kids: set # kids removed by rotation @dataclass class Warrant: kid: str iat: float exp: float task_scope: str def verify_federated_warrant( warrant: Warrant, cached_doc: DIDDocument, client_cert_spki: str, resolver, # callable(did) -> DIDDocument now: Optional[float] = None, ) -> bool: now = now if now is not None else time.time() if warrant.exp < now: return False # Freshness-coupled check: a cached document may only vouch for # warrants issued at or after its last rotation. doc = cached_doc if warrant.iat < doc.updated: # Warrant predates a rotation the cache knows about; resolve fresh. doc = resolver(warrant.did if hasattr(warrant, "did") else cached_doc.did) # Revocation truncates validity: if the signing key was removed by a # rotation at t_rot, the warrant is dead from t_rot onward. if warrant.kid in doc.revoked_kids: raise WarrantRotationSkewError( f"warrant kid={warrant.kid} revoked by rotation at {doc.updated}; " f"warrant iat={warrant.iat} predates rotation — " f"effective_exp=min({warrant.exp},{doc.updated}) < now={now}" ) # Same-document-version binding: signature key and channel key must # both be present in the *same* resolved document. if warrant.kid not in doc.verification_methods: return False if doc.verification_methods[warrant.kid] != client_cert_spki: return False return True