1 Commits
Author SHA1 Message Date
Pavlo Ratushnyi b6126c2fd2 Two rules that had only ever been proven inside a test process
`Server errors alert, they never ban` and `Observe mode records the decision and
blocks nothing` are the two claims that protect honest traffic from this WAF: a
bad deploy must not lock out the site's own visitors, and a dry run must be
judgeable before it is allowed to act. Both were proven in-process, against
`FakeUpstream`, in `EdgeBlockingTests`. Neither had ever been proven against the
image users actually run. And `GET /admin-api/alerts` appeared in **zero** gate
scripts — the operator-visible half of the alerting pillar had no gate at all,
which is how the console gate found its first bug: everything below the surface
looks fine while nothing reads it.

`deploy/upstream.conf` is nginx's own default plus one path that answers 502,
mounted read-only into the compose upstream. `scripts/compose-smoke.sh` grew two
sections, 28 → **35 assertions**:

    - server errors alert, and never ban
      a 502 reaches the client through the edge / four 502s did not ban the source
      that saw them / no engine ban written / a server_error_streak alert exists
    - Observe mode records the decision and blocks nothing
      five refusals still reach the upstream / no ban written / the dry run is
      visible as a candidate_ban alert

Numbers: host **35 passed, 0 failed**; the same script in the Linux rehearsal
(`docker:cli` against the host daemon) **35 passed, 0 failed**.

Two lessons about counting, both written into the script:

- The data volume survives `compose down`, so an absolute alert count asserts
  history rather than this run. Alerts are counted as a delta now.
- The alert is written *after* the response is, so a count read the instant the
  last request returns undercounts. The first version of the measurement line
  printed 1 where the settled number is 2. A number that is wrong by a race is
  worse than no number, so the count is taken after a pause.

The measurement itself is the finding: **4 requests past N=3 wrote 2 alert rows**
— one row per response past the threshold, not one per source. A real 5xx storm
therefore writes at request rate. Retention ages alerts out (`BanRetention`), so
they do not accumulate forever, but the write rate is a number an operator should
know before their upstream falls over.

Honest about the fixture: the 502 is nginx returning it directly, not an
application failing behind nginx. The edge's classifier sees a status code on a
socket, which is exactly what the rule is about; the fixture does not simulate a
crashed process, and nothing should read it as if it did.
2026-10-01 16:24:02 +02:00