audit_logs table in Neon PostgreSQL. No row may ever be updated or deleted.
Design Principles
- Append-only —
INSERTis the only permitted operation. NoUPDATE, noDELETE, ever. - Immutable snapshots — previous and new state are captured as JSON blobs at the moment of the event, not as foreign keys to records that may later change
- No PII in notes — the
notesfield is for metadata (e.g., job IDs) only. Personal data is captured viapreviousState/newStatesnapshots, not free-text - Tenant-scoped — every entry is linked to at least one of
brokerId,employerId,schemeId, ormemberId
Schema
Actor Types
Example Events
| action | entityType | Typical trigger |
|---|---|---|
MemberStatusChanged | Member | FSM transition (e.g., PendingEnrolment → Active) |
ContributionFileUploaded | ContributionBatch | Broker uploads CSV |
ChangeProposalApproved | ChangeProposal | Broker approves AI suggestion |
ChangeProposalRejected | ChangeProposal | Broker rejects AI suggestion |
SchemeCreated | Scheme | New scheme provisioned |
PolicyDocumentUploaded | Document | Governance document stored |
Querying the Audit Log
The audit log is accessible viaGET /api/audit-log with query parameters:
entity_type— filter by entity type (e.g.,Member,Scheme)entity_id— filter by specific entityaction— filter by action nameactor_id— filter by who performed the action
Tamper-Evidence
The append-only guarantee is enforced at:- Application layer — no service method calls
UPDATEorDELETEonaudit_logs - Database layer — Row-Level Security (RLS) policy on the
audit_logstable permitsINSERTfor authenticated roles but explicitly deniesUPDATEandDELETE
Future enhancement: cryptographic chaining of audit log entries (similar to a blockchain/hash chain) to make retroactive tampering mathematically detectable. This is on the roadmap for higher assurance deployments.
IORP II Relevance
Article 25 of IORP II requires IORPs to have adequate internal control systems. The audit log provides:- A complete record of trustee actions for regulatory inspection
- Evidence of the four-eyes principle (AI proposals require human approval)
- Traceability from each compliance outcome back to the actor who triggered it