Source code for cadrumo.application.auth.diagnostics_ports
"""Application-owned persistence contract for encrypted auth diagnostics.The auth diagnostic use case only needs decrypted payload bytes. This narrowport keeps secure-object namespaces, repository construction, and storagefailures in the persistence adapter while giving application callers a stablecapability contract."""from__future__importannotationsfromdatetimeimportdatetimefromtypingimportProtocol,runtime_checkablefrompydanticimportBaseModelfrom...core.errors.hierarchyimportCadrumoErrorfrom...core.modelsimportSTRICT_FROZEN_CONFIG
[docs]classAuthDiagnosticPersistenceRecord(BaseModel):"""One decrypted auth-diagnostic payload supplied by persistence."""model_config=STRICT_FROZEN_CONFIGpayload:bytes
[docs]classAuthDiagnosticPersistenceError(CadrumoError):"""A persistence operation for auth diagnostics failed at the adapter boundary."""def__init__(self,operation:str)->None:"""Carry only the capability operation, leaving storage details behind."""self.operation=operationsuper().__init__(f"auth diagnostic persistence operation failed: {operation}")
[docs]@runtime_checkableclassAuthDiagnosticPersistencePort(Protocol):"""Read and update encrypted auth-diagnostic payloads for the active profile."""
[docs]deflist_records(self)->tuple[AuthDiagnosticPersistenceRecord,...]:"""Return every readable diagnostic payload for the active profile."""...
[docs]defload_record(self,diagnostic_id:str)->AuthDiagnosticPersistenceRecord|None:"""Return one diagnostic payload, or ``None`` when it is absent."""...
[docs]defsave_record(self,diagnostic_id:str,payload:bytes,*,written_at:datetime)->None:"""Persist one diagnostic payload for the active profile."""...