The streak engine raised an alert on every response once the count was past the threshold, and neither condition ends on its own: a 5xx never bans, and in Observe mode nothing bans at all, so the source stays observable on every request. Measured on the shipped image in the compose gate: 12 upstream 502s at N=3 wrote 10 alert rows, and 11 refusals in a dry run wrote 9. That is attacker-shaped growth kept for the whole retention window, and the operator's alert list (newest 100 in the console, limit=500 on the endpoint) showed one source and nothing else. Both kinds are now edge-triggered: one row on the crossing, then one per doubling. Same two measurements answer 3 and 2. A gap past the window or a clean answer ends the episode, so the next outage announces itself again — alerting once per source per process would hide an outage that got ten times worse while nobody was looking. Teeth, measured rather than asserted: with IsEscalation forced to the old level-triggered answer, exactly the four new unit tests and the two new integration tests fail, and the compose gate reports 10 and 9 and fails those two checks; the other 41 compose checks stay green. Gates on this commit — host (macOS): build 0 warnings, unit 58/58, integration 32/32, smoke 19/19, image 261 MB, compose-smoke 43/43. Linux rehearsal (scripts/ci-linux-rehearsal.sh): source, compose and console gates all PASS, exit 0.
20 lines
892 B
C#
20 lines
892 B
C#
namespace OpenWaf.Domain.Engine;
|
|
|
|
/// <summary>What one observed response produced.</summary>
|
|
/// <param name="AlertTriggered">A <c>server_error_streak</c> alert is due for
|
|
/// this response. Edge-triggered, not level-triggered: a storm of server
|
|
/// errors raises one alert on the crossing and then only as it doubles.</param>
|
|
/// <param name="BanAlertDue">The ban threshold is crossed (or has doubled) for
|
|
/// a refusal streak. In Observe mode this is the only thing that makes a dry
|
|
/// run visible, so it travels separately from <c>BanTriggered</c>, which is
|
|
/// true on every response once the threshold is behind it.</param>
|
|
public readonly record struct StreakOutcome(
|
|
int ConsecutiveRefusals,
|
|
int ConsecutiveServerErrors,
|
|
bool BanTriggered,
|
|
bool AlertTriggered,
|
|
bool BanAlertDue)
|
|
{
|
|
public static readonly StreakOutcome None = new(0, 0, false, false, false);
|
|
}
|