Source code for cadrumo.application.ledger.evidence_ports
"""Application-owned capabilities for purchase-invoice evidence.The evidence service coordinates a bucket catalogue, secure attachment custody,and bucket-event history. The concrete encrypted repositories and attachmentmanifest service are composed by an executable root and translated into thesenarrow application contracts before they reach the service."""from__future__importannotationsfromcollections.abcimportSequencefromdataclassesimportdataclassfromdatetimeimportdatetimefrompathlibimportPathfromtypingimportTYPE_CHECKING,Protocolfrom...core.identity.digestimportContentDigestfrom...domain.buckets.protocolsimportBucketEventHistoryRepositoryProtocolifTYPE_CHECKING:from.evidenceimportPurchaseInvoiceEvidence
[docs]defload(self,*,bucket_id:str)->tuple[PurchaseInvoiceEvidence,...]:"""Return the evidence records persisted for ``bucket_id``."""...
[docs]defsave(self,*,bucket_id:str,records:Sequence[PurchaseInvoiceEvidence])->None:"""Persist the complete evidence record set for ``bucket_id``."""...
[docs]@dataclass(frozen=True,slots=True)classEvidenceAttachmentIngestRequest:"""Application facts needed to place one evidence file in secure custody."""bucket_id:strsource_path:Pathmedia_kind:strmime_type:strcaptured_at:datetimeactor:str
[docs]classEvidenceAttachmentIngestorProtocol(Protocol):"""Capability that stores evidence bytes and returns their content address."""
[docs]defingest(self,request:EvidenceAttachmentIngestRequest)->ContentDigest:"""Store the admitted file and return its content-addressed identifier."""...
[docs]@dataclass(frozen=True,slots=True)classLedgerEvidencePorts:"""Required authorities for one purchase-invoice evidence invocation."""evidence_repository:PurchaseInvoiceEvidenceRepositoryProtocolattachment_ingestor:EvidenceAttachmentIngestorProtocolbucket_event_repository:BucketEventHistoryRepositoryProtocol
[docs]classLedgerEvidencePortsFactory(Protocol):"""Construct the complete evidence bundle for one profile bucket."""def__call__(self,*,bucket_id:str)->LedgerEvidencePorts:"""Return all evidence capabilities bound to ``bucket_id``."""...