fix(management): purge terminal PendingSecuredWrites rows on the list sweep after a retention window (review 2026-10-21 08/G3)

This commit is contained in:
Joseph Doherty
2026-10-22 09:25:48 -04:00
parent baab6ac78e
commit d495494074
8 changed files with 237 additions and 1 deletions
@@ -153,4 +153,18 @@ public interface ISecuredWriteRepository
string? siteId,
IReadOnlyCollection<string>? permittedSiteIds = null,
CancellationToken ct = default);
/// <summary>
/// Deletes up to <paramref name="batchSize"/> rows in a post-Pending status
/// (<c>Approved</c>, <c>Rejected</c>, <c>Expired</c>, <c>Executed</c>, <c>Failed</c>) whose
/// last lifecycle instant — <c>ExecutedAtUtc</c>, else <c>DecidedAtUtc</c>, else
/// <c>SubmittedAtUtc</c> — is older than <paramref name="olderThanUtc"/>. <c>Pending</c>
/// rows are never purged (they are expired first). The table is operational state; the
/// append-only <c>AuditLog</c> keeps the lifecycle history (review 2026-10-21 08/G3).
/// </summary>
/// <param name="olderThanUtc">Rows whose last lifecycle instant is before this are purged.</param>
/// <param name="batchSize">Maximum rows deleted in this call.</param>
/// <param name="ct">Cancellation token.</param>
/// <returns>A task that resolves to the number of rows deleted.</returns>
Task<int> PurgeTerminalAsync(DateTime olderThanUtc, int batchSize, CancellationToken ct = default);
}