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:
objectSchema-validated, secure-DB-backed user-profile lifecycle service.
- Parameters:
repository (UserProfileLifecycleRepository)
validator (ProfileValidationService)
events (BucketEventHistoryRepositoryProtocol | None)
- register(command)[source]¶
Register a new active profile aggregate.
Returns a
ProfileLifecycleResult.- Return type:
- Parameters:
command (RegisterProfileCommand)
- read(profile_id)[source]¶
Return the live
UserProfileRecordaggregate or raiseProfileNotFoundError.- Return type:
- Parameters:
profile_id (str)
- list_profiles()[source]¶
List every profile currently visible in the active bucket.
Returns a
ProfileListResultwith all non-tombstoned profiles.- Return type:
- edit_field(command)[source]¶
Upsert one effective-dated fact into a profile aggregate and return a
ProfileLifecycleResult.- Return type:
- Parameters:
command (EditProfileFieldCommand)
- remove(command)[source]¶
Tombstone the live root. Immutable filing snapshots are retained.
Returns a
ProfileLifecycleResultwith the tombstoned profile.- Return type:
- 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
ProfileLifecycleResultwith the reactivated profile.- Return type:
- 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. EmitsPROFILE_RENAMEDcarrying 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:
- Parameters:
command (RenameProfileCommand)
- duplicate(command)[source]¶
Copy an existing live profile under a new id and display name.
Returns a
ProfileLifecycleResultwith the newly created duplicate profile.- Return type:
- Parameters:
command (DuplicateProfileCommand)