fix(audit): purge/archive also cover partition 1 (rows before the first boundary) (AUD-6, WP4 task 4.11)

This commit is contained in:
Joseph Doherty
2026-12-03 10:26:08 -05:00
parent 2a41122a39
commit e719e9027e
4 changed files with 81 additions and 1 deletions
+9
View File
@@ -730,6 +730,15 @@ MS SQL for direct-write events). Unredacted secrets never persist.
and emits an `AuditLogPurgedEvent` (partition range, rowcount, duration) per
switched partition. A partition-maintenance step rolls forward each month,
creating the next month's partition ahead of time.
- **Partition 1 is purged and archived too (AUD-6, 2026-12).** Rows stamped before
the first boundary (a site whose clock was reset, a back-dated row) land in
partition 1, which has no lower boundary, so the per-boundary enumeration never
offered it and those rows outlived retention and the cold archive indefinitely.
`GetPartitionBoundariesOlderThanAsync` now also returns partition 1 — once its
newest row is older than the window — as the **month start of its newest row**, a
value inside partition 1: the switch-out and the archive resolve the partition
with `$partition.pf_AuditLog_Month(value)`, so they handle it like any month, and
the archive is labelled (and its `RetentionDays` counted) by the age of that data.
- **Purge failure is a health metric, not just a log line:** every purge step that
throws — a partition switch-out, a per-channel override DELETE, or the pre-purge
boundary enumeration — publishes an `AuditLogPurgeFailedEvent` (month boundary,