aeat.application.user_profile._lifecycle module

Canonical lifecycle service for the schema-driven user-profile backend.

This service is the single sanctioned write path for live user-profile values. It routes every register / edit / remove / duplicate / list / read operation through the secure-DB repository and the schema-aware validation service. CLI thin adapters and downstream consumers call this surface; no caller should construct UserProfileRecord aggregates or touch the secure repository directly. Every mutating operation emits a typed bucket event to BucketEventHistoryRepository.

class ProfileLifecycleService(*, repository, validator, events=None)[source]

Bases: object

Schema-validated, secure-DB-backed user-profile lifecycle service.

Parameters:
register(command)[source]

Register a new active profile aggregate.

Returns a ProfileLifecycleResult.

Return type:

ProfileLifecycleResult

Parameters:

command (RegisterProfileCommand)

read(profile_id)[source]

Return the live UserProfileRecord aggregate or raise ProfileNotFoundError.

Return type:

UserProfileRecord

Parameters:

profile_id (str)

list_profiles()[source]

List every profile currently visible in the active bucket.

Returns a ProfileListResult with all non-tombstoned profiles.

Return type:

ProfileListResult

edit_field(command)[source]

Upsert one effective-dated fact into a profile aggregate and return a ProfileLifecycleResult.

Return type:

ProfileLifecycleResult

Parameters:

command (EditProfileFieldCommand)

remove(command)[source]

Tombstone the live root. Immutable filing snapshots are retained.

Returns a ProfileLifecycleResult with the tombstoned profile.

Return type:

ProfileLifecycleResult

Parameters:

command (RemoveProfileCommand)

reactivate(command)[source]

Restore a tombstoned root to active status; symmetric inverse of remove().

Refuses if the target is not currently tombstoned, so a reactivate can never silently no-op against an already-active profile.

Returns a ProfileLifecycleResult with the reactivated profile.

Return type:

ProfileLifecycleResult

Parameters:

command (ReactivateProfileCommand)

rename(command)[source]

Update a live profile’s display label and return a ProfileLifecycleResult.

Profile identity is an immutable UUID, so a rename touches only the operator-visible display_name: the record is loaded, its label updated, and re-saved under the same secure-object key. There is no re-key, no directory move, and no rollback machinery. Refuses if the profile is tombstoned. Emits PROFILE_RENAMED carrying the prior label so the audit trail records the relabel.

The orchestration layer updates the parallel copy of the label held in the plaintext bucket manifest; the service contract is record-only.

Return type:

ProfileLifecycleResult

Parameters:

command (RenameProfileCommand)

duplicate(command)[source]

Copy an existing live profile under a new id and display name.

Returns a ProfileLifecycleResult with the newly created duplicate profile.

Return type:

ProfileLifecycleResult

Parameters:

command (DuplicateProfileCommand)