namespace OpenWaf.Domain.Engine; /// The one answer the edge gives a request. There is exactly one /// place in the pipeline that may produce a non-Pass value. public enum EdgeVerdict { Pass = 0, /// Passed because the operator allowlisted the address. Wins over /// every other pillar, including a geo deny. PassAllowlisted = 1, /// Passed because the path is an always-pass prefix (admin API, /// health probes) — the recovery hatch for a self-blocked operator. PassBypassed = 2, BlockOperator = 3, BlockEngine = 4, GeoReject = 5, /// Refused by an operator-written request rule. Fires in Observe /// mode too: the mode switches off what the edge decides by itself, not /// what a human wrote down. BlockRule = 6, /// Passed. An observe-action request rule matched, and the guard /// records it — the verdict exists so "nothing matched" and "a rule matched /// and was told to watch" are different answers. PassRuleObserved = 7, /// Refused for asking too often (OPEN-56). Produced by the guard /// rather than by the ordered decision, because it is the only pillar that /// reads live state; it is still one answer from the one place that may /// refuse a request, and it deserves a name in the log for that. BlockRate = 8 } /// The verdict in the spelling every surface uses — the log, the metrics /// label, and the decision preview (OPEN-59). One mapping, because the same word /// has to mean the same thing in an alert rule and in a grepped line, and /// ToString() on the enum answers "blockrule", which is neither. public static class EdgeVerdictLabel { public static string For(EdgeVerdict verdict) => verdict switch { EdgeVerdict.Pass => "pass", EdgeVerdict.PassAllowlisted => "pass_allowlisted", EdgeVerdict.PassBypassed => "pass_bypassed", EdgeVerdict.PassRuleObserved => "pass_rule_observed", EdgeVerdict.BlockOperator => "block_operator", EdgeVerdict.BlockEngine => "block_engine", EdgeVerdict.BlockRule => "block_rule", EdgeVerdict.GeoReject => "geo_reject", EdgeVerdict.BlockRate => "block_rate", _ => "unknown" }; }