Audit Trail Design
Purpose
Design audit logging systems that provide accountability, traceability, and compliance evidence. Produce event catalogs, log schemas, and retention policies that satisfy regulatory requirements and support forensic investigation.
Scope Constraints
Reads system architecture, regulatory requirements, and data classification outputs for audit design. Does not implement logging infrastructure or access production log stores.
Inputs
- System architecture and services to be audited
- Regulatory requirements (from compliance review if available)
- Data classification (which data elements are Confidential/Restricted)
- User roles and access control model
- Existing logging infrastructure and constraints
Input Sanitization
No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.
Procedure
Progress Checklist
Step 1: Identify Auditable Events
Catalog every event that must be recorded for compliance, security, or operational accountability:
- Authentication events: Login success/failure, logout, session creation/expiry, MFA challenges, password changes
- Authorization events: Permission grants/revocations, role changes, access denied events
- Data access events: Read access to Restricted/Confidential data, bulk exports, API queries returning PII
- Data mutation events: Create/update/delete of sensitive records, schema migrations, bulk operations
- Consent events: Consent granted/modified/withdrawn, privacy preference changes
- Administrative events: Configuration changes, feature flag toggles, deployment events, user account management
- Compliance events: Data subject requests (access, erasure, portability), breach detection, regulatory submissions
Step 2: Define Log Schema
Design a consistent schema that answers who/what/when/where/why for every event:
- who: Actor identity (user ID, service account, API key ID). Never log credentials or tokens.
- what: Event type (enum), action performed, resource affected (type + ID), before/after state for mutations
- when: Timestamp in UTC (ISO 8601), with millisecond precision. Clock synchronization requirements.
- where: Service name, instance ID, request ID (correlation), source IP (masked per policy), geographic region
- why: Business context — the operation that triggered the event, request path, feature context
- outcome: Success/failure, error code if applicable, affected record count
Step 3: Specify Retention Policies
Define retention based on regulatory and business requirements:
- Regulatory minimums: HIPAA (6 years), SOC2 (1 year), PCI-DSS (1 year), financial regulations (5-7 years)
- Tiered retention: Hot storage (fast query, 90 days) -> Warm storage (indexed, 1 year) -> Cold storage (archived, regulatory maximum)
- Deletion policy: Audit logs of deleted user data must be retained for compliance even after user data deletion
- Cost modeling: Estimate storage costs per tier and growth rate
Step 4: Design Immutability Requirements
Ensure audit records cannot be tampered with after creation:
- Write-once storage: Append-only log stores, WORM storage for compliance
- Integrity verification: Hash chaining or Merkle trees to detect tampering or gaps
- Separation of duties: Audit log administrators cannot modify log contents
- Tamper evidence: If a record is modified or deleted, the system must detect and alert
Step 5: Plan Access Controls for Audit Data
Define who can access audit records and under what circumstances:
- Read access: Security team (full), compliance officers (filtered), engineering (operational only, no PII)
- Export controls: Bulk export requires approval, exports are themselves audited
- PII in audit logs: Mask or encrypt PII fields; provide decryption only for authorized investigations
- Cross-team access: Support/customer success may need filtered views — define scope limits
Step 6: Define Compliance Reporting
Specify the reports and dashboards that audit data must support:
- Regulatory reports: Data subject access requests, breach timeline reconstruction, consent audit trail
- Operational dashboards: Failed authentication trends, unusual access patterns, bulk export monitoring
- Periodic evidence: SOC2 control evidence, HIPAA access review reports, PCI-DSS log review evidence
- Alerting: Real-time alerts for high-severity events (mass data export, privilege escalation, repeated auth failures)
Compaction resilience: If context was lost during a long session, re-read the Inputs section to reconstruct what system is being analyzed, check the Progress Checklist for completed steps, then resume from the earliest incomplete step.
Output Format
Event Catalog
| Event Category |
Event Type |
Trigger |
Data Captured |
Retention Tier |
| Authentication |
login_success |
User login |
user_id, timestamp, IP, method |
Hot 90d → Cold 1y |
| Authentication |
login_failure |
Failed login |
attempted_user, timestamp, IP, reason |
Hot 90d → Cold 1y |
| Data Access |
pii_read |
PII field accessed |
user_id, accessor_id, field, purpose |
Hot 90d → Cold 7y |
| Consent |
consent_granted |
User gives consent |
user_id, purpose, scope, version, timestamp |
Hot 90d → Cold 7y |
| ... |
... |
... |
... |
... |
Log Schema
{
"event_id": "uuid-v4",
"event_type": "enum(event_catalog)",
"timestamp": "2024-01-15T10:30:00.000Z",
"actor": {
"type": "user|service|system",
"id": "user_123",
"ip": "192.168.x.x",
"session_id": "sess_abc"
},
"resource": {
"type": "user|record|config",
"id": "res_456",
"field": "email"
},
"action": "read|create|update|delete|grant|revoke",
"outcome": "success|failure",
"context": {
"service": "user-service",
"request_id": "req_789",
"region": "us-east-1"
},
"metadata": {}
}
Retention Policy
| Tier |
Storage Type |
Duration |
Query SLA |
Cost Model |
| Hot |
Primary database / search index |
90 days |
< 1s |
$$$ |
| Warm |
Indexed archive |
1 year |
< 30s |
$$ |
| Cold |
Object storage (compressed) |
Regulatory max (up to 7y) |
Minutes |
$ |
Access Control Matrix
| Role |
Read Events |
Search PII Fields |
Export |
Admin |
| Security Team |
All |
Yes |
With approval |
No |
| Compliance Officer |
All |
Yes (masked) |
With approval |
No |
| Engineering |
Operational only |
No |
No |
No |
| Audit Log Admin |
Metadata only |
No |
No |
Yes (config, not content) |
Handoff
- Hand off regulatory compliance gaps discovered during audit design to compliance-review for full gap analysis.
- Hand off data sensitivity questions to data-classification if audit events contain unclassified data elements.
Quality Checks
Evolution Notes
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: audit-trail-design3description: Use when designing audit logging systems for accountability and compliance evidence. Covers event catalogs, log schemas, retention policies, immutability requirements, and compliance reporting. Do not use for regulatory gap analysis (use compliance-review) or data sensitivity classification (use data-classification).4---56# Audit Trail Design78## Purpose9Design audit logging systems that provide accountability, traceability, and compliance evidence. Produce event catalogs, log schemas, and retention policies that satisfy regulatory requirements and support forensic investigation.1011## Scope Constraints12Reads system architecture, regulatory requirements, and data classification outputs for audit design. Does not implement logging infrastructure or access production log stores.1314## Inputs15- System architecture and services to be audited16- Regulatory requirements (from compliance review if available)17- Data classification (which data elements are Confidential/Restricted)18- User roles and access control model19- Existing logging infrastructure and constraints2021## Input Sanitization2223No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.2425## Procedure2627### Progress Checklist28- [ ] Step 1: Identify auditable events29- [ ] Step 2: Define log schema30- [ ] Step 3: Specify retention policies31- [ ] Step 4: Design immutability requirements32- [ ] Step 5: Plan access controls for audit data33- [ ] Step 6: Define compliance reporting3435### Step 1: Identify Auditable Events36Catalog every event that must be recorded for compliance, security, or operational accountability:3738- **Authentication events**: Login success/failure, logout, session creation/expiry, MFA challenges, password changes39- **Authorization events**: Permission grants/revocations, role changes, access denied events40- **Data access events**: Read access to Restricted/Confidential data, bulk exports, API queries returning PII41- **Data mutation events**: Create/update/delete of sensitive records, schema migrations, bulk operations42- **Consent events**: Consent granted/modified/withdrawn, privacy preference changes43- **Administrative events**: Configuration changes, feature flag toggles, deployment events, user account management44- **Compliance events**: Data subject requests (access, erasure, portability), breach detection, regulatory submissions4546### Step 2: Define Log Schema47Design a consistent schema that answers who/what/when/where/why for every event:4849- **who**: Actor identity (user ID, service account, API key ID). Never log credentials or tokens.50- **what**: Event type (enum), action performed, resource affected (type + ID), before/after state for mutations51- **when**: Timestamp in UTC (ISO 8601), with millisecond precision. Clock synchronization requirements.52- **where**: Service name, instance ID, request ID (correlation), source IP (masked per policy), geographic region53- **why**: Business context — the operation that triggered the event, request path, feature context54- **outcome**: Success/failure, error code if applicable, affected record count5556### Step 3: Specify Retention Policies57Define retention based on regulatory and business requirements:5859- **Regulatory minimums**: HIPAA (6 years), SOC2 (1 year), PCI-DSS (1 year), financial regulations (5-7 years)60- **Tiered retention**: Hot storage (fast query, 90 days) -> Warm storage (indexed, 1 year) -> Cold storage (archived, regulatory maximum)61- **Deletion policy**: Audit logs of deleted user data must be retained for compliance even after user data deletion62- **Cost modeling**: Estimate storage costs per tier and growth rate6364### Step 4: Design Immutability Requirements65Ensure audit records cannot be tampered with after creation:6667- **Write-once storage**: Append-only log stores, WORM storage for compliance68- **Integrity verification**: Hash chaining or Merkle trees to detect tampering or gaps69- **Separation of duties**: Audit log administrators cannot modify log contents70- **Tamper evidence**: If a record is modified or deleted, the system must detect and alert7172### Step 5: Plan Access Controls for Audit Data73Define who can access audit records and under what circumstances:7475- **Read access**: Security team (full), compliance officers (filtered), engineering (operational only, no PII)76- **Export controls**: Bulk export requires approval, exports are themselves audited77- **PII in audit logs**: Mask or encrypt PII fields; provide decryption only for authorized investigations78- **Cross-team access**: Support/customer success may need filtered views — define scope limits7980### Step 6: Define Compliance Reporting81Specify the reports and dashboards that audit data must support:8283- **Regulatory reports**: Data subject access requests, breach timeline reconstruction, consent audit trail84- **Operational dashboards**: Failed authentication trends, unusual access patterns, bulk export monitoring85- **Periodic evidence**: SOC2 control evidence, HIPAA access review reports, PCI-DSS log review evidence86- **Alerting**: Real-time alerts for high-severity events (mass data export, privilege escalation, repeated auth failures)8788> **Compaction resilience**: If context was lost during a long session, re-read the Inputs section to reconstruct what system is being analyzed, check the Progress Checklist for completed steps, then resume from the earliest incomplete step.8990## Output Format9192### Event Catalog93| Event Category | Event Type | Trigger | Data Captured | Retention Tier |94|---|---|---|---|---|95| Authentication | login_success | User login | user_id, timestamp, IP, method | Hot 90d → Cold 1y |96| Authentication | login_failure | Failed login | attempted_user, timestamp, IP, reason | Hot 90d → Cold 1y |97| Data Access | pii_read | PII field accessed | user_id, accessor_id, field, purpose | Hot 90d → Cold 7y |98| Consent | consent_granted | User gives consent | user_id, purpose, scope, version, timestamp | Hot 90d → Cold 7y |99| ... | ... | ... | ... | ... |100101### Log Schema102```json103{104 "event_id": "uuid-v4",105 "event_type": "enum(event_catalog)",106 "timestamp": "2024-01-15T10:30:00.000Z",107 "actor": {108 "type": "user|service|system",109 "id": "user_123",110 "ip": "192.168.x.x",111 "session_id": "sess_abc"112 },113 "resource": {114 "type": "user|record|config",115 "id": "res_456",116 "field": "email"117 },118 "action": "read|create|update|delete|grant|revoke",119 "outcome": "success|failure",120 "context": {121 "service": "user-service",122 "request_id": "req_789",123 "region": "us-east-1"124 },125 "metadata": {}126}127```128129### Retention Policy130| Tier | Storage Type | Duration | Query SLA | Cost Model |131|---|---|---|---|---|132| Hot | Primary database / search index | 90 days | < 1s | $$$ |133| Warm | Indexed archive | 1 year | < 30s | $$ |134| Cold | Object storage (compressed) | Regulatory max (up to 7y) | Minutes | $ |135136### Access Control Matrix137| Role | Read Events | Search PII Fields | Export | Admin |138|---|---|---|---|---|139| Security Team | All | Yes | With approval | No |140| Compliance Officer | All | Yes (masked) | With approval | No |141| Engineering | Operational only | No | No | No |142| Audit Log Admin | Metadata only | No | No | Yes (config, not content) |143144## Handoff145146- Hand off regulatory compliance gaps discovered during audit design to compliance-review for full gap analysis.147- Hand off data sensitivity questions to data-classification if audit events contain unclassified data elements.148149## Quality Checks150- [ ] Every auditable event category is represented in the event catalog151- [ ] Log schema captures who/what/when/where/why for every event type152- [ ] Retention policies reference specific regulatory requirements with durations153- [ ] Immutability controls prevent tampering and detect gaps in the audit trail154- [ ] PII within audit logs is masked or encrypted with controlled decryption155- [ ] Access control matrix defines least-privilege access for every role156- [ ] Compliance reporting covers all required regulatory evidence outputs157- [ ] Alerting is defined for high-severity events requiring real-time response158159## Evolution Notes160<!-- Observations appended after each use -->161162---163> Converted and distributed by [TomeVault](https://tomevault.io/claim/dtsong) — claim your Tome and manage your conversions.164<!-- tomevault:4.0:skill_md:2026-04-13 -->