Source code for cadrumo.application.user_profile.custody_carry
"""Application policy for portable-profile secure-object custody carry.The application owns custody-profile normalization, fail-closed full-coveragepolicy, and the exported coverage fact. Concrete persistence enumeration,natural-key recovery, and atomic restoration are provided by the bound profilecustody port."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfrom...core.storage_taxonomyimportStorageCustodyProfilefrom...domain.user_profile.errorsimportProfileExportErrorfrom...domain.user_profile.portable_exportimportCarriedSecureObject,CoverageManifestfrom.custody_portsimportProfileCustodyCarryMaterial,profile_custody_portifTYPE_CHECKING:from...domain.calculations.registry.authority_artifactimportProfileDecodeContext
[docs]defnormalize_storage_custody_profile(custody_profile:StorageCustodyProfile|str,)->StorageCustodyProfile:"""Resolve an operator custody selection into the closed neutral value set."""ifisinstance(custody_profile,StorageCustodyProfile):returncustody_profiletry:returnStorageCustodyProfile(custody_profile)exceptValueErrorasexc:raiseProfileExportError(context={"custody_profile":custody_profile})fromexc
[docs]defbuild_secure_object_custody_payload(*,bucket_id:str,custody_profile:StorageCustodyProfile,profile_decode_context:ProfileDecodeContext,)->tuple[tuple[CarriedSecureObject,...],CoverageManifest]:"""Build generic custody rows and their exact namespace-coverage fact."""material=_carry_material(bucket_id=bucket_id,profile=custody_profile,profile_decode_context=profile_decode_context,)ifcustody_profileisStorageCustodyProfile.FULLandmaterial.unclassified_namespaces:raiseProfileExportError(context={"unclassified_namespaces":material.unclassified_namespaces,"custody_profile":StorageCustodyProfile.FULL.value,},)coverage_manifest=CoverageManifest(custody_profile=(StorageCustodyProfile.FULL.valueifcustody_profileisStorageCustodyProfile.FULLelseStorageCustodyProfile.STRUCTURED.value),carried_namespaces=material.carried_namespaces,excluded_namespaces=material.excluded_namespaces,row_counts_by_namespace=material.row_counts_by_namespace,)returnmaterial.carried_objects,coverage_manifest