Source code for cadrumo.application.filing.history_repository
"""Application repository facade for local filing-history records.The repository persists lightweight :class:`ModeloHistory` payloads keyed bymodelo. Encrypted storage, envelope validation, and persistence failures areowned by the required outer capability in :mod:`history_ports`.Core types::class:`~cadrumo.core.classification.policies.SensitivityClass`."""from__future__importannotationsfromcollections.abcimportIteratorfrompathlibimportPathfromtypingimportClassVarfrom...core.classification.policiesimportSensitivityClassfrom.history_modelsimportModeloHistoryfrom.history_portsimport(FILING_HISTORY_NAMESPACE,FILING_HISTORY_SCHEMA_VERSION,FILING_HISTORY_SENSITIVITY,FilingHistoryPorts,)
[docs]classModeloHistoryRepository:"""Bucket-bound application facade over the filing-history capability."""namespace:ClassVar[str]=FILING_HISTORY_NAMESPACEsensitivity:ClassVar[SensitivityClass]=FILING_HISTORY_SENSITIVITYschema_version:ClassVar[int]=FILING_HISTORY_SCHEMA_VERSIONpayload_type:ClassVar[type[ModeloHistory]]=ModeloHistorydef__init__(self,*,ports:FilingHistoryPorts)->None:"""Bind one complete, already-composed filing-history capability."""ifnotports.bucket_id.strip():raiseValueError("filing-history bucket_id must not be blank")self._ports=ports@propertydefbucket_id(self)->str:"""Return the bucket identity carried by the required port bundle."""returnself._ports.bucket_id@propertydefstore_dir(self)->Path:"""Return the logical secure-store marker for this repository."""returnself._ports.repository.store_dir
[docs]defenvelope_path_for(self,identifier:str)->Path:"""Return the logical marker for ``identifier``."""returnself._ports.repository.envelope_path_for(identifier)
[docs]deflock_target_for(self,identifier:str)->Path:"""Return the logical lock marker for ``identifier``."""returnself._ports.repository.lock_target_for(identifier)
[docs]defextract_identifier(self,payload:ModeloHistory)->str:"""Return the natural modelo identifier carried by ``payload``."""returnstr(payload.modelo)
[docs]@classmethoddefpayload_model(cls)->type[ModeloHistory]:"""Return the payload type for outer custody-key inspection."""returncls.payload_type
[docs]defload(self,identifier:str)->ModeloHistory|None:"""Load one history through the composed application capability."""returnself._ports.repository.load(identifier)
[docs]defsave(self,payload:ModeloHistory)->None:"""Persist one history through the composed application capability."""self._ports.repository.save(payload)
[docs]defdelete(self,identifier:str)->bool:"""Delete one history through the composed application capability."""returnself._ports.repository.delete(identifier)
[docs]defiter_records(self)->Iterator[ModeloHistory]:"""Iterate all histories through the composed application capability."""returnself._ports.repository.iter_records()
[docs]deflist_modelos(self)->tuple[str,...]:"""Return every modelo persisted in this repository, sorted."""returntuple(sorted(str(history.modelo)forhistoryinself.iter_records()))