namespace StellaOps.Policy.Engine.EffectiveDecisionMap;
///
/// Interface for effective decision map storage.
/// Maintains policy decisions per asset/snapshot for Graph overlays.
///
public interface IEffectiveDecisionMap
{
///
/// Sets an effective decision entry.
///
Task SetAsync(
string tenantId,
string snapshotId,
EffectiveDecisionEntry entry,
CancellationToken cancellationToken = default);
///
/// Sets multiple effective decision entries.
///
Task SetBatchAsync(
string tenantId,
string snapshotId,
IEnumerable entries,
CancellationToken cancellationToken = default);
///
/// Gets an effective decision entry.
///
Task GetAsync(
string tenantId,
string snapshotId,
string assetId,
CancellationToken cancellationToken = default);
///
/// Gets multiple effective decision entries.
///
Task GetBatchAsync(
string tenantId,
string snapshotId,
IReadOnlyList assetIds,
CancellationToken cancellationToken = default);
///
/// Gets all effective decisions for a snapshot.
///
Task> GetAllForSnapshotAsync(
string tenantId,
string snapshotId,
EffectiveDecisionFilter? filter = null,
CancellationToken cancellationToken = default);
///
/// Gets a summary of effective decisions for a snapshot.
///
Task GetSummaryAsync(
string tenantId,
string snapshotId,
CancellationToken cancellationToken = default);
///
/// Invalidates a specific entry.
///
Task InvalidateAsync(
string tenantId,
string snapshotId,
string assetId,
CancellationToken cancellationToken = default);
///
/// Invalidates all entries for a snapshot.
///
Task InvalidateSnapshotAsync(
string tenantId,
string snapshotId,
CancellationToken cancellationToken = default);
///
/// Invalidates all entries for a tenant.
///
Task InvalidateTenantAsync(
string tenantId,
CancellationToken cancellationToken = default);
///
/// Gets the current map version for a snapshot.
///
Task GetVersionAsync(
string tenantId,
string snapshotId,
CancellationToken cancellationToken = default);
///
/// Increments and returns the new map version for a snapshot.
///
Task IncrementVersionAsync(
string tenantId,
string snapshotId,
CancellationToken cancellationToken = default);
///
/// Gets statistics about the effective decision map.
///
Task GetStatsAsync(
string? tenantId = null,
CancellationToken cancellationToken = default);
}
///
/// Statistics about the effective decision map.
///
public sealed record EffectiveDecisionMapStats
{
///
/// Total entries across all tenants/snapshots.
///
public long TotalEntries { get; init; }
///
/// Total snapshots tracked.
///
public long TotalSnapshots { get; init; }
///
/// Memory used in bytes (if available).
///
public long? MemoryUsedBytes { get; init; }
///
/// Entries expiring in the next hour.
///
public long ExpiringWithinHour { get; init; }
///
/// Last eviction timestamp.
///
public DateTimeOffset? LastEvictionAt { get; init; }
///
/// Count of entries evicted in last eviction run.
///
public long LastEvictionCount { get; init; }
}