perf(audit): indexed, chunked retention sweep that runs off the startup path (SEC-014, #256)

This commit is contained in:
Joseph Doherty
2026-12-03 09:46:43 -05:00
parent 7ec4c20239
commit 9756ab843e
5 changed files with 128 additions and 16 deletions
+1 -1
View File
@@ -403,7 +403,7 @@ it is about to do; a deployment that needs crash-durable admin audit should ship
rather than rely on this table.
`MxGateway:Security:AuditRetentionDays` (default 90, minimum 1) bounds the table: the drain sweeps
at startup and hourly, deleting older rows. Retention cannot be configured off. The sweep compares
hourly, deleting older rows in 5,000-row chunks (the first sweep runs from the background loop right after host startup, not inside it; an expression index on `datetime(occurred_at_utc)`, created by the first sweep, keeps the delete from scanning the table). Retention cannot be configured off. The sweep compares
through SQLite's `datetime()` rather than on the stored ISO-8601 text. Text comparison is correct
only while every row is UTC-normalized — which the canonical model guarantees for rows written
through the store, but not for rows that entered the table any other way — and on a mixed-format