Source code for cadrumo.application.evidence.ports
"""Application-owned capabilities for evidence-bundle verification.The evidence service works with validated bundle models and a bucket-boundwork-unit existence check. Encrypted storage and catalogue adapters arecomposed outside the application package and implement these narrow contracts."""from__future__importannotationsfromcollections.abcimportIteratorfromdataclassesimportdataclassfromtypingimportProtocolfrom...core.errors.hierarchyimportCadrumoErrorfrom.modelsimportEvidenceBundle
[docs]classEvidenceBundlePersistenceError(CadrumoError):"""Translated failure from an evidence-bundle persistence capability."""def__init__(self,operation:str)->None:"""Carry only the application operation, never storage details."""self.operation=operationsuper().__init__(f"evidence bundle persistence operation failed: {operation}")
[docs]classEvidenceBundleRepositoryPort(Protocol):"""Bucket-bound persistence capability for evidence-bundle manifests."""
[docs]defload(self,identifier:str)->EvidenceBundle|None:"""Load one bundle by its complete storage identifier."""...
[docs]defsave(self,payload:EvidenceBundle)->None:"""Persist one validated bundle manifest."""...
[docs]defiter_records(self)->Iterator[EvidenceBundle]:"""Iterate persisted bundle manifests with integrity checks."""...
[docs]classEvidenceBundleWorkUnitPort(Protocol):"""Bucket-bound capability that answers whether a work unit exists."""
[docs]defexists(self,work_unit_id:str)->bool:"""Return whether ``work_unit_id`` is present in the work-unit catalogue."""...
[docs]@dataclass(frozen=True,slots=True)classEvidenceBundlePorts:"""Required authorities for one evidence-bundle service invocation."""repository:EvidenceBundleRepositoryPortwork_units:EvidenceBundleWorkUnitPort