namespace OpenWaf.Domain.Security;
///
/// Rolling per-source counters persisted for the operator's dashboard and for
/// post-hoc explanation of a ban. Aggregated, one row per source key — not an
/// append-only log — because the write-rate cap that keeps a scanner from
/// taxing the database only works if the row is upserted, not inserted.
///
public sealed class SourceObservation
{
public string SourceKey { get; init; } = string.Empty;
public DateTimeOffset FirstSeenAt { get; init; } = DateTimeOffset.UtcNow;
public DateTimeOffset LastSeenAt { get; set; } = DateTimeOffset.UtcNow;
/// Longest run of refusals ever seen for this source. The engine's
/// live streak counter is in memory; this is its durable shadow.
public int MaxConsecutiveRefusals { get; set; }
public int TotalRefusals { get; set; }
public int TotalServerErrorStreak { get; set; }
public int? LastStatusCode { get; set; }
public string? LastPath { get; set; }
public string? LastUserAgent { get; set; }
public string? LastCountryCode { get; set; }
public string? LastCity { get; set; }
public string? LastRegion { get; set; }
}