DBRaven
OwnershipHigh operational impact

Audit Trails Require Architectural Commitment, Not Afterthought

Adding a comprehensive audit trail to a system that was not designed for auditability requires rewriting the write path of every operation that must be audited: and the cost scales with how much business logic has accumulated since launch.

A payment processing system built without audit logging records that something happened, but not the state before, the state after, who authorized it, or why. Retrofitting this requires instrumenting every code path that touches financial state: triggers (brittle), application-level dual-write (error-prone), or CDC (operationally complex). If the write model had been append-only events from inception, the event log would be the audit trail. The compliance cost is set at schema design time, not at compliance audit time.

Why It Matters

The retroactive audit problem surfaces at the worst possible moment: during a compliance audit, a security incident investigation, or a regulatory inquiry. The engineering team discovers that the system records current state but not history. Account balances are stored as single values, not as a ledger of transactions. User permissions are stored as current flags, not as a log of grants and revocations. The database knows what is true now. It does not know how it got there, who made it true, or when the last state transition occurred. This is not a query problem that can be solved with a clever SELECT. It is a write model problem that requires fundamental architectural change.

Event sourcing provides native auditability by making it the default. When the write model is an append-only log of domain events: payment_initiated, payment_authorized, payment_settled, payment_reversed: the event log is the audit trail. Current state is derived by replaying the event log, not stored directly. This design makes auditability free. It also makes temporal queries free: "what was this account's state on March 15th?" is a projection over the event log filtered by timestamp. The tradeoff is read model complexity and eventual consistency between the event log and derived read models.

Compliance requirements are not uniform in what they demand from audit trails. SOC 2 requires evidence that access to sensitive data is logged and reviewed. HIPAA requires audit logs of all PHI access with user, timestamp, and action. PCI DSS requires tamper-evident logs that cannot be modified or deleted. GDPR requires the ability to demonstrate that data processing was lawful and that consent was recorded. Each of these requires different audit capabilities, and the cost of adding them to a mature CRUD system is typically measured in engineer-months, not sprint points. The engineer who decides that audit logging is a "later" concern is scheduling a future compliance remediation project for their successors.

Failure Modes

  • ·Audit gap: system records current state but not state transitions, making forensic reconstruction impossible
  • ·Tamper vulnerability: audit logs stored in the same mutable database as operational data are alterable
  • ·Trigger brittleness: database triggers for audit capture silently fail or are dropped during schema migrations
  • ·Dual-write audit gap: application-level audit writes fail silently, leaving operations in the operational log but not the audit log
  • ·Compliance audit failure: required audit fields (user, timestamp, before-state, after-state) not captured at write time
  • ·Retention gap: audit logs deleted or overwritten before the compliance-required retention period expires

Amplification Risks

  • A missing audit write on a high-volume operation creates a large compliance gap that grows with every operation until detected
  • Trigger-based audit capture silently dropped during a schema migration creates a gap that may not be detected until a compliance audit
  • Tampered audit logs in a mutable store can retroactively conceal security incidents

Temporal Behavior

  • Audit trail completeness degrades over time in CRUD systems as schema migrations drop triggers or miss new write paths
  • Event sourcing audit trails are naturally complete over time: every write is an event, there are no gaps
  • Compliance retention requirements create temporal horizons: audit data before the horizon can be deleted; within it, must be preserved

Boundary Implications

  • The audit boundary must be defined at system inception: which operations are auditable, which are not
  • The tamper resistance boundary requires physical or cryptographic separation between the audit store and the operational system
  • Ownership of the audit trail must be explicitly assigned: shared ownership produces the same governance drift as shared database ownership

Topology

  • ·Systems designed with event sourcing have audit capability built into the event store node: no separate audit topology is required
  • ·CRUD systems require a separate audit capture mechanism in the topology: triggers, CDC, or application-level dual-write
  • ·The audit store must be topologically isolated from the operational database to prevent tamper by operational access

Scaling

  • ·CDC-based audit capture scales with write volume: high-write systems generate proportionally high audit event volumes
  • ·Immutable audit log storage costs grow monotonically: retention policy and storage tiering must be designed for compliance-required durations
  • ·Event sourcing read model rebuilds at scale require processing the full event log: this must be provisioned for

Resilience

  • ·Event sourcing provides audit trail resilience by design: the event log can be replayed to reconstruct state after any failure
  • ·Immutable audit stores (S3 Object Lock, write-only credentials) prevent accidental deletion during incident response
  • ·Audit trail completeness is a resilience property: it enables forensic reconstruction after security incidents

Governance Implications

  • ·Auditability requirements must be determined before schema design: the write model depends on this decision
  • ·Audit log tamper resistance must be verified at least annually: a compromised audit log is a compliance failure
  • ·Retention policies must meet the most stringent applicable regulatory requirement, not the most convenient storage target
  • ·Audit log access must itself be audited: who read the audit log is as important as what the audit log contains

Evolution Implications

  • ·Adding auditability to a mature CRUD system requires a write path refactoring project, not a feature addition
  • ·Migrating from CRUD to event sourcing for auditability requires a migration strategy for historical data that was not stored as events
  • ·New write paths added after audit architecture is established must be explicitly reviewed for audit coverage before deployment

Mitigation Patterns

  • Decide at schema inception whether the system requires auditable history: if yes, use append-only event log or event sourcing
  • Store audit logs in a tamper-resistant store: S3 Object Lock, dedicated audit database with write-only application credentials
  • Use CDC (Change Data Capture) from WAL for audit capture in CRUD systems: more reliable than triggers
  • Define audit schema explicitly: user, timestamp, operation, before-state, after-state, request_id: not just a text log
  • Test audit trail completeness before compliance audits: not during them

Cross-References

shared ownership creates governance driftreplayability accumulates burdenrecovery paths matter more than happy pathsaudit gapevent sourcing replayevent sourcingoutbox patternaudit design