Source code for cadrumo.application.user_profile.aggregate
"""Non-authoritative projection of one committed profile capsule.Custody material is deliberately absent. A profile view is visible only afterthe storage owner has validated its immutable commit marker; the label is therepository's presentation mapping, never a manifest or a key-selection hint."""from__future__importannotationsfromdatetimeimportdatetimefromtypingimportAnnotated,LiteralfrompydanticimportBaseModel,ConfigDict,Field,NonNegativeInt,field_validatorfrom...core.errors.hierarchyimportpydantic_validation_boundaryfrom...core.identity.digestimportContentDigest,PrefixedContentDigestfrom...core.identity.profileimportProfileIdfrom...core.identity.profile_labelimportProfileLabelfrom...core.profile_publicationimportProfilePublicationKindValuefrom...core.time.utcimportvalidate_utc_awarefrom...domain.user_profile.valuesimportProfileSetupState
[docs]classLockedProfileFactSummary(BaseModel):"""The only fact/status projection available without an unlocked session."""model_config=ConfigDict(strict=True,frozen=True,extra="forbid",hide_input_in_errors=True)availability:Literal["UNAVAILABLE_LOCKED"]="UNAVAILABLE_LOCKED"setup_state:Literal["UNAVAILABLE_LOCKED"]="UNAVAILABLE_LOCKED"fact_count:Literal[0]=0
[docs]classUnlockedProfileFactSummary(BaseModel):"""Session-authenticated current-record summary and provenance."""model_config=ConfigDict(strict=True,frozen=True,extra="forbid",hide_input_in_errors=True)availability:Literal["AVAILABLE_UNLOCKED"]="AVAILABLE_UNLOCKED"setup_state:ProfileSetupStatefact_count:NonNegativeIntrecord_revision:int=Field(ge=1)content_digest:ContentDigest
typeProfileFactSummary=Annotated[LockedProfileFactSummary|UnlockedProfileFactSummary,Field(discriminator="availability"),]typeProfileRestoreAuthority=Literal["password"]"""Which door proved the key a restore republishes a capsule under.Declared beside ``publication_kind`` because it is the same class of axis andanswers the question that one leaves open: a view already says a capsule waspublished by a restore, but not what authorised it. ``password`` means theprofile's own credential unwrapped its own envelope. A recovery code neverrestores a capsule: it proves the enrolled wrapper of a COMMITTED capsule so alost passphrase can be replaced in place, which is a different door."""
[docs]classCommittedProfileView(BaseModel):"""A safe read model, assembled from a committed capsule and label owner."""model_config=ConfigDict(strict=True,frozen=True,extra="forbid",hide_input_in_errors=True)profile_id:ProfileIdlabel:ProfileLabelcommitted_at:datetimepublication_kind:ProfilePublicationKindValuepassword_generation:int=Field(ge=1)custody_present:Literal[True]=Truelabel_revision:int=Field(ge=1)label_content_digest:PrefixedContentDigestlabel_self_digest:PrefixedContentDigestlabel_source_witness:PrefixedContentDigestfact_summary:ProfileFactSummary=Field(default_factory=LockedProfileFactSummary)@field_validator("committed_at")@classmethod@pydantic_validation_boundarydef_validate_committed_at(cls,value:datetime)->datetime:returnvalidate_utc_aware(value)