Expand description
§Audit Module
HIPAA §164.312(b) audit metadata for every persisted event.
Every event in the store carries an AuditMetadata value documenting who
caused the change, when it happened, from where, and why (causation).
The EventStore::append implementation rejects events whose audit fails
AuditMetadata::validate.
§Lifecycle
- An aggregate’s
handle()returnsVec<Event>withEvent::audit == AuditMetadata::pending(). Aggregates do not deal with audit data. - The
CommandBusbuilds oneAuditMetadatafrom the request-scopedCommandContext(withtimestamp_utc_us = now) and stamps it on every event before callingappend. - Every store implementation calls
audit.validate()?at the top of itsappendmethod as a defense-in-depth assertion.
§Why typed, not free-form JSON
Field names cannot drift; required fields cannot be silently null; an
auditor’s SELECT WHERE actor_id = ? query is reliable across every event
ever written.
§Reserved actor identifiers
"system"— internal jobs, seeders, migrations"anonymous"— unauthenticated requests (e.g. self-registration)"legacy-pre-hipaa"— backfill sentinel for events written before this module existed (see migrationadd_hipaa_audit)
Structs§
- Audit
Metadata - Audit fields stamped on every persisted event.
Enums§
- Audit
Error - Validation errors for
AuditMetadata.
Constants§
- ANONYMOUS_
ACTOR - Sentinel
actor_idfor unauthenticated requests. - LEGACY_
ACTOR - Sentinel
actor_idfor events written before HIPAA-1 landed. - SYSTEM_
ACTOR - Sentinel
actor_idfor system-internal commands (seeders, cron, migrations).