You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rust: retention/cap enforcement for the SQLite audit backend
Closes the last documented gap from the SQLite cutover slice. Two new
Rust functions, trim_audit_events_to_cap and purge_audit_events_older_than
- both single indexed DELETEs, cheap regardless of table size (unlike the
JSON backend's full-file-rewrite equivalent, which is why that backend
needed a soft cap with batching in the first place). audit-log-store.ts's
SQLite write path now enforces the same MAX_EVENTS/TRIM_BATCH cap and
age-based retention as the JSON backend, with equivalent semantics
(purge runs on every write when retention is configured; trim still
batches to avoid a DELETE per insert, though a single trim isn't
expensive here either).
Found and fixed a real bug in the process: get_last_audit_event_hash
crashed on a legacy-shaped last event (NULL event_hash column) - none of
the original tests exercised that case. A new TypeScript retention
integration test seeded exactly that shape and caught it. Fixed by
reading the column as Option<String> and flattening the two
independently-nullable layers instead of assuming non-null. New
dedicated Rust test covers it directly.
7 new tests (4 Rust: trim/purge correctness and no-op cases, 1 Rust bug
regression test, 2 TypeScript bridge tests) plus 1 new integration test
proving retention purge works end-to-end through the real SQLite path.
Verified through the real built addon, with and without it present, plus
full e2e suite (10/10) and app unit suite (584/585, 1 intentional skip).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments