Chapter 17 · Security, Privacy, Governance, and Auditability

Audit Trails, Provenance, and Immutable History

Build trustworthy audit trails and provenance records that answer who changed what, when, why, and from which source without confusing audit history with mutable business state.

Beginner70–100 minutesAuditability + provenanceLast reviewed: August 2026

Learning outcomes

An audit trail should answer who changed what, when, from where, and why. Provenance goes further by recording where data originated and how it was transformed. These are governance features, but they also support debugging, incident response, reconciliation, and trust.

01

Distinguish business history from audit history.

02

Design append-oriented audit records.

03

Capture actor, source, correlation, and before/after context appropriately.

04

Model provenance for imports and derived data.

Business history versus audit history

Business history:

Audit history:

model · example
user 912 changed status from scheduled to closedvia API request abc123at 2026-08-10T12:00Z

They overlap but serve different purposes.

Audit-event shape

model · example
AuditEvent(  audit_event_id,  occurred_at,  actor_type,  actor_id,  action_code,  entity_type,  entity_id,  request_id,  source_system,  reason_code,  metadata_json)

Actor identity

An actor may be:

  • human user;
  • service account;
  • scheduled job;
  • migration;
  • external integration.

“system” is often too vague.

Correlation IDs

One request may update many rows. A stable request/correlation ID lets investigators reconstruct the full operation across services and audit events.

Before/after values

Options:

  • store full before/after snapshots;
  • store changed fields only;
  • store business event semantics;
  • store hashes plus source history.

Full snapshots are easy to understand but may duplicate sensitive data heavily.

Audit minimization

An audit log should not become an uncontrolled second copy of every sensitive field.

Immutable or append-oriented

Audit records should generally not be silently updated. Corrections can be represented by additional events rather than rewriting history.

Tamper evidence

High-assurance systems may use:

  • restricted append-only storage;
  • separate audit database;
  • cryptographic hashes/chains;
  • WORM/object retention controls;
  • external log shipping.

Database triggers versus application audit

Triggers capture changes regardless of application path but may lack rich business context. Application events know intent but can be bypassed by direct SQL. Critical systems may combine layers.

Migration audit

Schema/data migrations should identify:

model · example
migration versionoperator/pipelinedeployment IDrows affectedstarted/completed time

Provenance for imported data

model · example
DataImport(  import_id,  source_name,  source_file_hash,  received_at,  imported_by,  schema_version)

Imported rows can reference import_id.

Field-level provenance

For critical derived fields, record:

model · example
source systemsource record IDtransformation versioncalculated_at

This helps explain why a derived result has its current value.

Lineage versus provenance

Provenance often focuses on origin and transformation of a specific data item. Lineage often describes the broader flow:

Lesson 5 develops lineage further.

Who viewed data?

Some domains require access auditing, not only change auditing. Reading highly sensitive records may need an access log with actor, purpose, and time.

Reason codes

For administrative overrides:

model · example
reason_code = 'customer_correction'ticket_id = 'SUP-1842'

can make privileged changes accountable.

Audit retention

Audit records may need longer retention than operational rows, but privacy laws/policies may still require deletion or minimization. “Audit” does not automatically mean “keep everything forever.”

WorkshopHub audit examples

ActionAudit fields
Close WorkOrderactor, old/new status, request, time
Change Asset ownerold/new customer, effective date, actor
Override inventoryquantity delta, reason, ticket, actor
Import Part catalogsource file/hash, import ID, pipeline version

Practice: audit the override

Manual inventory correction

A supervisor changes inventory from 8 to 12 after a physical count. What should be captured?

Review answer

Capture the affected Part/location, previous and new quantity or delta, supervisor identity, timestamp, reason code, related count/ticket/reference, request/correlation ID, and source application. Avoid storing unrelated sensitive data in the audit record.

Summary and next lesson

Auditability and provenance make changes explainable and attributable. The final lesson expands governance to the entire lifecycle: retention, deletion, lineage, and data quality.

References

  • NIST audit/logging guidance.
  • OWASP Logging Cheat Sheet.
  • Database and platform documentation for audit extensions/logging features.

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only assets compatible with the Ethereum/ERC-20 network. Do not send TRC-20/TRON assets.