IRetentionStore
AgentPrism.Abstractions.dllThe data plane that counts, batch-deletes, and reads-for-archive over the actual retention data.
public interface IRetentionStoreRemarks
Section titled “Remarks”The target name parameter always comes from the RetentionTargets allowlist; implementations must throw ArgumentException for an unknown target.
Which column counts as “age” and which extra condition (for example, only completed jobs) applies is fixed for EACH target and stays embedded inside the implementation; the caller knows only the target name and the cutoff date.
Tenant scoping is mandatory. A retention
policy is defined per tenant; if tenantId is not given, the
operation touches every tenant’s rows. Only the installation-wide
('*') policy should pass null.
The default (in-memory) setup registers NullRetentionStore, which
always returns empty/zero: retention is meaningful only when a SQL
provider is enabled.
Methods
Section titled “Methods”CountOlderThanAsync(string, string?, DateTimeOffset, CancellationToken)
Section titled “ CountOlderThanAsync(string, string?, DateTimeOffset, CancellationToken)”Returns the number of rows in the target currently older than the cutoff date.
ValueTask<long> CountOlderThanAsync(string target, string? tenantId, DateTimeOffset cutoff, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”target string
The target name.
tenantId string?
Only this tenant’s rows; if null, runs installation-wide
(the '*' policy).
cutoff DateTimeOffset
The cutoff date (UTC). Rows older than this match.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The number of matching rows.
DeleteBatchAsync(string, string?, DateTimeOffset, int, CancellationToken)
Section titled “ DeleteBatchAsync(string, string?, DateTimeOffset, int, CancellationToken)”Deletes a batch of rows older than the cutoff date. This is not a
single bulk DELETE; it runs batch by batch, depending on the provider.
ValueTask<int> DeleteBatchAsync(string target, string? tenantId, DateTimeOffset cutoff, int batchSize, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”target string
The target name.
tenantId string?
Only this tenant’s rows; if null, runs installation-wide
(the '*' policy).
cutoff DateTimeOffset
The cutoff date (UTC).
batchSize int
The maximum number of rows to delete.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The number of rows deleted. Zero means no matching rows remain.
FindRowLimitCutoffAsync(string, string?, long, CancellationToken)
Section titled “ FindRowLimitCutoffAsync(string, string?, long, CancellationToken)”Counting from newest, returns the ordering column’s value at row
maxRows
as the cutoff date.
ValueTask<DateTimeOffset?> FindRowLimitCutoffAsync(string target, string? tenantId, long maxRows, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”target string
The target name.
tenantId string?
Only this tenant’s rows; if null, runs installation-wide (the
'*' policy).
maxRows long
The maximum number of rows to keep (at least 1).
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The cutoff date; null if the target holds FEWER than
maxRows
rows (the volume limit is not exceeded).
Remarks
Section titled “Remarks”The returned value can be passed directly into this interface’s other three
methods (the @cutoff parameter): volume-based trimming uses the SAME
batch mechanism as age-based deletion.
ReadForArchiveAsync(string, string?, DateTimeOffset, int, CancellationToken)
Section titled “ ReadForArchiveAsync(string, string?, DateTimeOffset, int, CancellationToken)”Reads a batch of rows older than the cutoff date (does not delete).
ValueTask<IReadOnlyList<ArchiveRow>> ReadForArchiveAsync(string target, string? tenantId, DateTimeOffset cutoff, int batchSize, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”target string
The target name.
tenantId string?
Only this tenant’s rows; if null, runs installation-wide
(the '*' policy).
cutoff DateTimeOffset
The cutoff date (UTC).
batchSize int
The maximum number of rows to read.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<ArchiveRow>>
The rows read; an empty list once no matching rows remain.