Source code for cadrumo.application.diagnostics_ports
"""Application-owned capabilities for secure-object diagnostics.Diagnostic reports need a small read/mutation surface over secure objects andone way to classify the expected cold-start session failure. The applicationowns these contracts; the storage adapter translates its records and errorsbefore binding them at an executable composition root."""from__future__importannotationsfromdataclassesimportdataclassfromtypingimportProtocolfrompydanticimportBaseModel,Field,NonNegativeIntfrom..core.modelsimportSTRICT_FROZEN_CONFIG
[docs]classDiagnosticSecureObjectNamespace(BaseModel):"""Application DTO for one secure-object namespace integrity result."""model_config=STRICT_FROZEN_CONFIGnamespace:str=Field(min_length=1)readable:NonNegativeIntunreadable:NonNegativeInt
[docs]classDiagnosticSecureObjectRepository(Protocol):"""Read and quarantine capabilities required by diagnostic reports."""
[docs]deflist_namespaces(self)->tuple[str,...]:"""Return the populated secure-object namespaces."""...
[docs]defprobe_namespace_integrity(self,namespace:str)->DiagnosticSecureObjectNamespace:"""Return translated decryptability counts for ``namespace``."""...
[docs]defquarantine_unreadable_rows(self)->tuple[DiagnosticSecureObjectNamespace,...]:"""Move unreadable rows and return translated namespace counts."""...
[docs]classDiagnosticSessionFailureClassifier(Protocol):"""Classify storage failures without exposing adapter exception types."""def__call__(self,error:BaseException)->bool:"""Return whether ``error`` represents a missing active session."""...
[docs]@dataclass(frozen=True,slots=True)classDiagnosticsPorts:"""Required secure-object capabilities for one diagnostics invocation."""secure_object_repository:DiagnosticSecureObjectRepositorysession_failure_classifier:DiagnosticSessionFailureClassifier