Most platforms treat audit as a feature. We treat it as the system of record.
The difference is enforcement. In our model, no mutation reaches the database without writing an audit_event row in the same transaction. There is no privileged path. There is no admin "undo" that skips the trail. There is no AI agent that mutates directly — agents produce recommendations that require human approval, and the approval is itself an audit event.
The shape
Every audit row carries seven invariants:
{
id: string // unique, monotonically ordered
clientId: string // tenant scope
actorType: 'human' | 'agent' | 'system' | 'provider'
actorId: string // who acted
action: string // 'ats_job.create', 'employee.terminate', etc.
resourceType: string // 'atsJob', 'employee', 'payrollRun'
resourceId: string
before: unknown | null // null on create
after: unknown // the resource state after the mutation
source: {
kind: 'api' | 'agent_action' | 'webhook' | 'admin' | 'cron'
endpoint?: string
idempotencyKey?: string
inResponseTo?: string // chain ID for multi-step ops
}
createdAt: ISO 8601
}
The source block is the critical part. Every audit event knows whether it was an operator clicking a button, an agent's recommendation that got approved, a provider webhook (Gusto, Check, Clerk), or a scheduled background job. The chain is forensic.
The invariants
- No mutation without an audit event. A failed write that didn't audit is a bug. Same transaction.
- Audit events are immutable. No update, no soft-delete. If state needs to be corrected, that's a new mutation with its own audit row.
- Tenancy on every row. No cross-tenant visibility. Clerk-injected
x-asure-client-idis read on every list query. - Idempotency-keyed. Same key + same body returns the previous result (HTTP 200). Same key + different body returns 409. Mutations are exactly-once.
What this makes possible
Replay. Given any resource, we can reconstruct its full history. /app/audit lets customers filter by resourceType + resourceId and see the chain.
Forensics on the bad day. When something goes wrong, the answer is in the audit log. Not "we'll investigate" — actually answerable.
Export. Customers can pull their full audit log as CSV or JSON on demand. The data is theirs.
Independent verification. Customers' security / audit teams can validate that the audit trail matches what they see in the UI. No vendor-only views.
See the audit trail explainer for a walk-through of a real chain, end-to-end, and /proof for the test catalogue that drives 19 paying flows through the audit chain on every commit.