fix: persist audit-export entries to disk WAL before channel send (PILOT-302)#25
fix: persist audit-export entries to disk WAL before channel send (PILOT-302)#25matthew-pilot wants to merge 1 commit into
Conversation
…LOT-302)
Add AuditWAL — a simple JSON-lines write-ahead log that persists
audit entries before they enter the export channel. On clean
shutdown the WAL is truncated after drain; on crash restart all
entries are replayed for re-export.
Also log a warning (slog.Warn) when the export channel is full and
an entry is dropped — entries were previously dropped silently with
only an atomic counter increment.
Changes:
- audit/audit_wal.go: new AuditWAL type (append, replay, truncate)
- audit/audit_export.go: integrate WAL into Export/Close, log drops
- audit/audit.go: add SetStorePath, derive WAL path from storePath
- server_lifecycle.go: wire auditStore.SetStorePath at init
The WAL path is {storePath}.audit-export-wal (empty storePath = no
persistence, preserving backward compat).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📊 PR Status — #25 PILOT-302
CI Checks (2/2 passing)
Scope
🟢 CLEAN — all CI green, mergeable. No canary configured. |
🔍 PR Explanation — #25 PILOT-302What this doesAdds a write-ahead log (AuditWAL) for audit-export entries so they survive crash restarts, and logs a warning when the export channel is full instead of silently dropping. The problemThe 1024-entry async export channel silently drops entries when the export endpoint is slow or stalled. The ring buffer is in-memory only — a restart loses everything not yet exported. The fix1. New
2.
3.
4.
Backward compatibilityWhen Verdict🟢 CLEAN — all CI green, mergeable. No canary configured. Safe to merge. |
📊 PR Status — #25 PILOT-302
CI Checks (2/2 passing)
Canary🧪 Running — dispatched run JiraPILOT-302 — QA/IN-REVIEW (unassigned). Updated: 2026-05-30T21:16 EEST. Last operator activityPR created by matthew-pilot at 18:16 UTC. No operator activity yet. |
🔍 PR Explanation — #25 PILOT-302What this doesAdds a write-ahead log (WAL) to the audit export pipeline, ensuring no audit event is lost on a crash. Before this change, the The problemThe Walkthrough: 4 files (+192/−4)
Why this approach
|
🤖 PR Status CheckPR #25: fix: persist audit-export entries to disk WAL before channel send (PILOT-302) matthew-pr-worker • 2026-05-31T11:58:00Z |
🤖 PR Explanationfix: persist audit-export entries to disk WAL before channel send (PILOT-302) SummarySummaryAdds an on-disk write-ahead log (AuditWAL) for audit export entries so they survive crash restarts, and logs a warning when the export channel is full instead of silently dropping. Problem (PILOT-302)
Fix
Changes+192/−4 lines across 4 file(s):
Files Changed
matthew-pr-worker • 2026-05-31T11:58:00Z |
Summary
Adds an on-disk write-ahead log (AuditWAL) for audit export entries so they survive crash restarts, and logs a warning when the export channel is full instead of silently dropping.
Problem (PILOT-302)
audit_export.go:62-68— the 1024-entry async channel silently drops entries when the export endpoint is slow or stalled. The ring buffer is in-memory only, so a restart loses everything not yet exported.Fix
Scope
Testing
go build ./...PASSgo vet ./...PASSgo test ./...all packages passBackward Compatibility
When storePath is empty (no persistence), no WAL file is created — existing behavior unchanged.