Source code for cadrumo.adapters.persistence.profile.modelos_edit_receipts
"""Encrypted persistence adapter for Modelo edit mutation result receipts.:class:`ModeloEditReceiptRepository` persists one:class:`~application.modelo.edit_contract.ModeloEditMutationResultReceiptV1` per encryptedrow, keyed by its own content-addressed ``receipt_id``, through:class:`~adapters.persistence.storage.envelope.secure_bound_repository.SecureBoundRepository` at ``FINANCIAL``:class:`~core.classification.policies.SensitivityClass`. Each receipt is itsown row rather than one whole-catalogue singleton blob, so a lookup by``receipt_id`` is one atomic encrypted-SQL read -- the domain proof a guardedcompare-and-swap edit committed must be recoverable after a crash withoutdecrypting every receipt a bucket has ever produced.See Also: :class:`~application.modelo.edit_contract.ModeloEditMutationResultReceiptV1` The strict receipt payload this repository stores. :data:`~adapters.persistence.storage.secure_object_namespaces.MODELO_EDIT_RECEIPT_NAMESPACE` Central namespace, sensitivity, and schema-version contract for these secure objects. :class:`~adapters.persistence.storage.envelope.secure_bound_repository.SecureBoundRepository` Shared per-record Envelope-wrapped encrypted repository kernel this class binds to one payload family; exposes ``to_secure_object_write`` for the guarded co-commit the calculation-revision persistence writer composes this repository into."""from__future__importannotationsfromtypingimportoverridefrompydanticimportValidationErrorfrom....application.modelo.edit_contractimportModeloEditMutationResultReceiptV1from....application.modelo.edit_receipt_portsimportModeloEditReceiptPersistenceErrorfrom....core.secure_object_writeimportSecureObjectWritefrom..storage.envelope.secure_bound_repositoryimportSecureBoundRepositoryfrom..storage.errorsimportStorageErrorfrom..storage.secure_object_namespacesimportMODELO_EDIT_RECEIPT_NAMESPACE
[docs]classModeloEditReceiptRepository(SecureBoundRepository[ModeloEditMutationResultReceiptV1]):"""Store one bucket's Modelo edit mutation result receipts, one row each."""namespace=MODELO_EDIT_RECEIPT_NAMESPACE.namespacesensitivity=MODELO_EDIT_RECEIPT_NAMESPACE.sensitivityschema_version=MODELO_EDIT_RECEIPT_NAMESPACE.schema_versionpayload_type=ModeloEditMutationResultReceiptV1
[docs]@overridedefextract_identifier(self,payload:ModeloEditMutationResultReceiptV1)->str:"""Return the receipt's own content-addressed identity."""returnpayload.receipt_id
[docs]@overridedefto_secure_object_write(self,payload:ModeloEditMutationResultReceiptV1,*,expected_revision_id:str|None=None,)->SecureObjectWrite:"""Prepare the receipt write and translate storage-bound failures."""try:returnsuper().to_secure_object_write(payload,expected_revision_id=expected_revision_id)except(OSError,StorageError,TypeError,ValueError,ValidationError)asexc:raiseModeloEditReceiptPersistenceError("to_secure_object_write")fromexc