aeat.domain.user_profile._values module

Strict Pydantic value records for centralized user profiles.

The portable-export bundle (UserProfilePortableExport) lives in the sibling _portable_export module so its heavy domain-type imports do not enter sys.modules at user-profile package init.

class UserProfileStatus(*values)[source]

Bases: StrEnum

Lifecycle status for a live profile root.

ACTIVE
TOMBSTONED
new_profile_id()[source]

Mint a fresh immutable profile identity.

A profile’s identity is a generated UUIDv4 in the canonical hyphenated 36-character form. It is created once at profile creation and never changes — the bucket directory, keystore directory, secure-object key, and active-profile pointer all key on it. The operator-chosen display name is a fully decoupled mutable label with no role in any key or path.

Return type:

str

new_profile_snapshot_id(profile_id, *, created_at=None)[source]

Create a deterministic-shape but unique snapshot id.

Return type:

str

Parameters:
class UserProfileFact(**data)[source]

Bases: BaseModel

One effective-dated user-profile fact.

Parameters:
  • path (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=3, max_length=192, pattern=^[a-z][a-z0-9_]*(?:\.(?:[0-9]+|[a-z][a-z0-9_]*))+$, ascii_only=None)])

  • value (UserProfileFactValue)

  • source (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=80, pattern=None, ascii_only=None)])

  • valid_from (date | None)

  • valid_to (date | None)

path: _FieldPath
value: UserProfileFactValue
source: _Source
valid_from: date | None
valid_to: date | None
class UserProfileRecord(**data)[source]

Bases: BaseModel

Live secure user-profile aggregate before persistence encoding.

Parameters:
  • schema_id (str)

  • schema_version (int)

  • profile_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=36, pattern=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$, ascii_only=None)])

  • display_name (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=160, pattern=None, ascii_only=None)])

  • status (UserProfileStatus)

  • facts (tuple[UserProfileFact, ...])

  • created_at (datetime)

  • updated_at (datetime)

  • removed_at (datetime | None)

schema_id: str
schema_version: int
profile_id: _ProfileId
display_name: _DisplayName
status: UserProfileStatus
facts: tuple[UserProfileFact, ...]
created_at: datetime
updated_at: datetime
removed_at: datetime | None
tombstone(*, removed_at=None)[source]

Return a tombstoned UserProfileRecord copy of the live profile root.

Return type:

UserProfileRecord

Parameters:

removed_at (datetime | None)

reactivate(*, reactivated_at=None)[source]

Return an active UserProfileRecord copy of a tombstoned profile root.

The symmetric inverse of tombstone(): clears removed_at and restores status to UserProfileStatus.ACTIVE so the lifecycle invariant (active profiles never carry removed_at) holds on the returned copy.

Return type:

UserProfileRecord

Parameters:

reactivated_at (datetime | None)

class UserProfileSnapshot(**data)[source]

Bases: BaseModel

Immutable filing/export profile snapshot.

Parameters:
  • snapshot_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=^[A-Za-z0-9][A-Za-z_0-9.:-]*$, ascii_only=None)])

  • profile_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=36, pattern=^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$, ascii_only=None)])

  • schema_id (str)

  • schema_version (int)

  • created_at (datetime)

  • facts (tuple[UserProfileFact, ...])

  • canonical_hash (str)

snapshot_id: _SnapshotId
profile_id: _ProfileId
schema_id: str
schema_version: int
created_at: datetime
facts: tuple[UserProfileFact, ...]
canonical_hash: str
classmethod from_profile(profile, *, snapshot_id=None, created_at=None)[source]

Create an immutable snapshot from a live profile record.

Parameters:
  • profile (UserProfileRecord) – The UserProfileRecord to snapshot.

  • snapshot_id (str | None) – Optional explicit snapshot identifier; when None a deterministic id is derived from the profile state.

  • created_at (datetime | None) – Optional UTC timestamp stamped on the snapshot; defaults to utc_now() when None.

Return type:

UserProfileSnapshot

Returns:

An immutable UserProfileSnapshot for the given profile.