feat(audit): archive retention and superseded stale-archive cleanup (ScadaBridge#109)
Owner decisions recorded: the archive destination stays a directory/UNC (no object-storage client; share + permissions named at enablement), parquet-tools-only reading (no re-import), unsigned like the chain (#107). AuditLog:Archive:RetentionDays (default 0 = never delete; else must exceed AuditLog:RetentionDays, counted from the archived month's end) and DeleteSupersededStaleArchives (default true) run after every purge tick. A retried purge's stale Archived archive is deleted only when a later, verifying, Purged archive of the same partition provably holds every row: same prior anchor and the stale chain-end hash at its chain-end sequence (row or tombstone), every unchained row present by EventId; otherwise it is reported KeptStale. A sole copy left at Archived is never touched. Deletion removes only the archive name's own three files in its folder, manifest first, never a manifest-supplied path. `audit archive cleanup [--dry-run]` = CleanupAuditArchives (Administrator). AuditLogArchiveCleanupTests (MSSQL) cover retried purge, kept stale copy, sole copy, retention and the path guard; each safety rule mutation-checked. Follow-ups filed: #113, #114, #115. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -319,6 +319,7 @@ scadabridge audit verify-chain --month <YYYY-MM>
|
||||
scadabridge audit verify-heads --path <file-or-directory>
|
||||
scadabridge audit archive list
|
||||
scadabridge audit archive verify --name <archive>
|
||||
scadabridge audit archive cleanup [--dry-run]
|
||||
```
|
||||
|
||||
- `audit query` — filtered query against the central `AuditLog` table, matching the
|
||||
@@ -370,6 +371,12 @@ scadabridge audit archive verify --name <archive>
|
||||
archived hash chain and compares its end with the purge anchor; exit `0` verified,
|
||||
`3` not verified, `1` error, `2` authorization failure. Same gate as `verify-chain`.
|
||||
See Component-AuditLog.md, Retention & Purge.
|
||||
- `audit archive cleanup [--dry-run]` (ScadaBridge#109) — sends `CleanupAuditArchives`:
|
||||
deletes superseded stale archives (a retried purge's, once a later purged archive provably
|
||||
holds all their rows) and archives past `AuditLog:Archive:RetentionDays` (0 = never), the
|
||||
same pass the purge actor runs after every tick; `--dry-run` only reports. Prints each
|
||||
`DeletedSuperseded` / `DeletedExpired` / `KeptStale` with its reason; exit `0`. Administrator
|
||||
only (it deletes files).
|
||||
|
||||
### Health Commands
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user