Source code for cadrumo.adapters.persistence.profile.modelo_reconciliation
"""Encrypted persistence for modelo reconciliation records and audit events.Core types::class:`~cadrumo.core.classification.policies.SensitivityClass`."""from__future__importannotationsfromcollections.abcimportIteratorfromtypingimportClassVar,overridefrompydanticimportBaseModelfrom....application.modelo.reconciliation_recordsimport(ModeloReconciliationPersistencePort,ModeloReconciliationRecord,)from....core.classification.policiesimportSensitivityClassfrom....domain.buckets.eventimportBucketEventfrom....domain.buckets.event_repositoryimportappend_bucket_eventfrom..storage.envelope.secure_bound_repositoryimportSecureBoundRepositoryfrom..storage.path_safetyimportsafe_repository_idfrom..storage.secure_object_namespacesimportMODELO_RECONCILIATION_RECORDS_NAMESPACEfrom.bucketsimportBucketEventHistoryRepository
[docs]defmodelo_reconciliation_record_key(*,work_unit_id:str,bucket_event_id:str)->str:"""Return the storage key for one reconciliation of one work unit. The event id keeps repeated reconciliations distinct and joins the encrypted detail row to the audit event co-written with it. """safe_repository_id(work_unit_id,context="work_unit_id")safe_repository_id(bucket_event_id,context="bucket_event_id")returnf"modelo-reconciliation:{work_unit_id}:{bucket_event_id}"
[docs]classModeloReconciliationRecordRepository(SecureBoundRepository[ModeloReconciliationRecord]):"""Repository over encrypted SQL-backed reconciliation records."""namespace:ClassVar[str]=MODELO_RECONCILIATION_RECORDS_NAMESPACE.namespacesensitivity:ClassVar[SensitivityClass]=MODELO_RECONCILIATION_RECORDS_NAMESPACE.sensitivityschema_version:ClassVar[int]=MODELO_RECONCILIATION_RECORDS_NAMESPACE.schema_versionpayload_type:ClassVar[type[BaseModel]]=ModeloReconciliationRecord
[docs]classModeloReconciliationPersistence(ModeloReconciliationPersistencePort):"""Concrete atomic persistence for reconciliation detail and audit event."""