namespace OpenWaf.Domain.Engine;
/// The decision plus everything the response writer and the log need
/// to explain it. An engine block always carries its reason and expiry: a ban
/// nobody can explain is a ban nobody can defend.
public sealed record EdgeDecision(
EdgeVerdict Verdict,
int StatusCode = 0,
string? Location = null,
string? Reason = null,
string? SourceKey = null,
DateTimeOffset? ExpiresAt = null,
/// The pattern that matched, for a rule verdict. The rule id is in
/// Reason; the pattern is what an operator reads in the log and the alert,
/// because an id means nothing without the page in front of them.
string? RulePattern = null,
/// The range that covered this address, for an operator block that
/// came from a range rather than from the address itself (OPEN-66). The
/// verdict is the same claim — the operator's list refused this source — and
/// this is what makes the row that refused it findable.
string? Range = null)
{
public bool IsBlocked => Verdict is EdgeVerdict.BlockOperator or EdgeVerdict.BlockEngine
or EdgeVerdict.GeoReject or EdgeVerdict.BlockRule;
public static readonly EdgeDecision Pass = new(EdgeVerdict.Pass);
}