cadrumo.application.user_profile.bundle module

Portable profile-bundle serialisation and payload validation.

This module composes UserProfilePortableExport payloads at the application boundary. A v3 bundle contains the profile record plus the four bucket-local history categories that must move with it: work units, ledger transactions, calculation revisions, and filing records. The v3 shape additionally carries the generic secure-object custody schema and coverage manifest, default-empty until the transport-aware phases populate them. The ledger category is loaded as a TransactionCatalogue through its application-owned repository port.

Bundles carry typed domain-model payloads, not encrypted blobs, key material, or raw secure-storage rows. Export reads domain records from their owning repositories.

The serializer stamps the current bundle version on every exported payload.

BUNDLE_SCHEMA_VERSION: Final[int]

Current bundle write version. Every export stamps this.

serialize_profile_bundle(*, bucket_id, custody_profile=StorageCustodyProfile.STRUCTURED, profile_decode_context)[source]

Build a v3 UserProfilePortableExport.

Reads the profile record and all four financial-history categories from bucket_id’s encrypted repositories and assembles them into one portable payload. The caller is responsible for ensuring a live bucket session is active for bucket_id.

Parameters:
  • bucket_id (str) – Profile bucket whose domain repositories are exported.

  • custody_profile (StorageCustodyProfile | str) – Secure-object custody scope to apply, as a StorageCustodyProfile or one of its string values.

  • profile_decode_context (ProfileDecodeContext) – Decode context supplied by the enclosing pinned authority operation for the encrypted profile rows.

Return type:

UserProfilePortableExport

The bundle carries only decrypted pydantic domain-model payloads (no encrypted envelopes or key material). The recipient re-encrypts each object under its own bucket data-encryption key through the standard repository save paths on import.