Source code for cadrumo.application.modelo.m036_lifecycle_ports
"""Application-owned capabilities for the Modelo 036 declaration lifecycle.The M036 application service owns declaration validation, sequencing, and eventderivation. This module is the inward contract for the persistence andbucket-event capabilities it requires; executable composition supplies thebucket-scoped implementation and the outward adapter translates storagefailures before they cross this boundary."""from__future__importannotationsfromdataclassesimportdataclassfromtypingimportTYPE_CHECKING,Protocolfrom...core.errors.hierarchyimportCadrumoErrorfrom...core.secure_object_writeimportSecureObjectWritefrom...domain.buckets.protocolsimportBucketEventHistoryRepositoryProtocolifTYPE_CHECKING:from.m036_lifecycleimportM036DeclarationResult
[docs]classM036DeclarationPersistenceError(CadrumoError):"""Translated failure from a declaration persistence capability."""def__init__(self,operation:str)->None:"""Carry only the application operation, never storage details."""self.operation=operationsuper().__init__(f"m036 declaration persistence operation failed: {operation}")
[docs]classM036DeclarationRepositoryPort(Protocol):"""Required encrypted-record operations for one Modelo 036 bucket."""
[docs]defexists(self,declaration_id:str)->bool:"""Return whether the addressed declaration exists."""...
[docs]defload(self,declaration_id:str)->M036DeclarationResult:"""Load one declaration by its full content-addressed identifier."""...
[docs]deflist_snapshots(self)->tuple[M036DeclarationResult,...]:"""List every declaration stored for the bound bucket."""...
[docs]defresolve(self,declaration_id:str)->M036DeclarationResult:"""Resolve one full identifier or an unambiguous identifier prefix."""...
[docs]defsave(self,declaration:M036DeclarationResult)->None:"""Persist one declaration record."""...
[docs]defsave_with_secure_object_writes(self,declaration:M036DeclarationResult,extra_writes:tuple[SecureObjectWrite,...],)->None:"""Persist a declaration atomically with its related event-history writes."""...
[docs]@dataclass(frozen=True,slots=True)classM036LifecyclePorts:"""Required authorities for one bucket-scoped M036 lifecycle call."""declaration_repository:M036DeclarationRepositoryPortbucket_event_repository:BucketEventHistoryRepositoryProtocol
[docs]classM036LifecyclePortsFactory(Protocol):"""Construct the complete M036 lifecycle capability bundle."""def__call__(self,*,bucket_id:str)->M036LifecyclePorts:"""Return all authorities required for the requested bucket."""...