aeat.adapters.persistence.profile.buckets module

Encrypted SQL repository for the bucket-event-history catalogue.

BucketEventHistoryRepository persists BucketEventHistoryCatalogue through SecureObjectRepository, which handles encrypted BLOB storage and key management for the active profile bucket. Each stored record is wrapped in an Envelope at FINANCIAL SensitivityClass.

This concrete repository is the persistence adapter behind the read-side BucketEventHistoryRepositoryProtocol. It lives in the persistence adapter (not in buckets) because its secure-object coupling is SQL/crypto-bound; the domain package owns only the typed BucketEventHistoryCatalogue model, its narrow port, and the BucketEventHistoryPersistenceError boundary error. The namespace/version constants are redeclared here as the persisted-envelope contract; the strings are preserved to avoid orphaning persisted envelopes.

See also

buckets

Public bucket-event facade that owns the catalogue, event taxonomy, and repository protocol.

BucketEventHistoryCatalogue

Domain payload encrypted by this repository.

BucketEventHistoryRepositoryProtocol

Domain port this concrete persistence adapter implements.

BUCKET_EVENT_HISTORY_NAMESPACE

Central namespace, sensitivity, schema-version, and singleton-key contract for these secure objects.

secure_object_repository_for_active_bucket()

Runtime storage factory used when no secure-object repository is injected.

bucket_maintenance

Application lifecycle surface that records bucket-maintenance events through this repository.

class BucketEventHistoryRepository(*, objects=None)[source]

Bases: object

Repository over encrypted SQL-backed event-history catalogue storage.

BUCKET_EVENT_HISTORY_NAMESPACE is the central profile-local namespace, schema-version, sensitivity, and singleton-key contract for the encrypted BucketEventHistoryCatalogue. The catalogue preserves the append-only BucketEvent history, is wrapped in Envelope, and is persisted through SecureObjectRepository. The same envelope can be emitted as a SecureObjectWrite when sibling catalogue updates need one transaction. This class exposes the concrete load/save implementation behind BucketEventHistoryRepositoryProtocol.

Parameters:

objects (SecureObjectRepository | None)

property secure_object_repository: SecureObjectRepository

Return the secure-object backend used by this catalogue.

Returns:

The SecureObjectRepository backing this repository.

exists()[source]

Return whether a bucket-event-history catalogue has been persisted.

Return type:

bool

load()[source]

Return the persisted catalogue or an empty catalogue if absent.

Return type:

BucketEventHistoryCatalogue

Returns:

The deserialised BucketEventHistoryCatalogue, or a fresh empty instance when no database object is present.

Raises:

BucketEventHistoryPersistenceError – If secure-object classification, envelope version, or payload validation fails.

save(catalogue)[source]

Persist catalogue atomically through the secure-object repository.

Parameters:

catalogue (BucketEventHistoryCatalogue) – The BucketEventHistoryCatalogue to persist.

Return type:

None

to_secure_object_write(catalogue)[source]

Return the secure-object upsert for catalogue without committing it.

The returned SecureObjectWrite carries the same Envelope and SensitivityClass classification that save() would persist directly.

Return type:

SecureObjectWrite

Parameters:

catalogue (BucketEventHistoryCatalogue)