Audit Trails & HIPAA WORM Compliance
Operational traceability and healthcare regulatory compliance require knowing both how records changed and who viewed or disclosed protected records — stored on an isolated append-only ledger guarded against silent tampering.
1. Operational Traceability: Auditable, SoftDelete & State History
General operational entities track full mutation provenance automatically via built-in platform traits:
AuditableTrait: Injects indexedcreatedAt(DateTime) andupdatedAt(DateTime) timestamps maintained automatically across creates and updates.SoftDeleteTrait: Appends nullabledeletedAt(DateTime?) so record removals preserve referential audit continuity across contracts, invoices, and completed work orders.- State Machine Audit Trails: Transitions (
AssignTechnician,CompleteWorkOrder,ConfirmAppointment) log structured actor, timestamp, and prior-to-next status transitions cleanly on domain workflows.
2. Dedicated ePHIAudited Access Logging Microservice
Regulated clinical and financial entities attach the ePHIAudited trait (retentionYears: 7, logAccessViews: true). Whenever a generated controller executes READ_QUERY (list/view), READ_VIEW (findOne), CREATE, UPDATE, or DELETE, it dispatches an asynchronous audit event via AuditClientService.logAccess(...) to the dedicated perlite-audit-service sidecar microservice:
- Authenticated Sidecar Dispatch: Sends
POST ${AUDIT_SERVICE_URL}/api/audit/eventscarrying anx-audit-service-tokenshared secret validated with constant-timecrypto.timingSafeEqualcomparison. - Fail-Safe Resilience: If the sidecar endpoint experiences transient pressure or timeout (
1,500 msbudget),AuditClientServicelogs structured warnings cleanly so emergency clinical reads remain responsive. - Structured Identity Metadata: Every event records
actorId,actorRole,targetEntity,recordId,patientId,actionType, and forwardedclientIp.
3. Cryptographic HMAC-SHA256 Hash Chaining & WORM Archival
Inside perlite-audit-service, AuditStore maintains an append-only tamper-evident ledger:
- Linked Hash Chain (
prevHash→eventHash): Each persisted event authenticates its normalized JSON payload together with the preceding event’seventHashusing keyed HMAC-SHA256 (AUDIT_HMAC_SECRET) before appending tohipaa-audit.jsonl, exposingGET /api/audit/verifyto prove zero historical gaps or edits. - Immutable S3 WORM Archives (
ArchiverService): Nightly batch archival computes a batchsha256Checksum(AuditArchiveManifest) and writes compliance archives into immutable S3 Object Lock (COMPLIANCEmode) buckets configured for2,555days (7 years) under thehipaa-sox-prodcompliance policy.