Pavlo Ratushnyi 39dece60e4 the retention window is a config key now, and both tables say what it is
Retention was a constant on the policy record: 7 days for observations, 7 for
bans and alerts, read from nothing and shown nowhere (OPEN-19). Two keys now,
OpenWaf:Policy:ObservationRetentionDays and OpenWaf:Policy:BanRetentionDays,
1..365 whole days, and an out-of-range value aborts startup naming the key
rather than falling back to 7 — the same shape OPEN-13 chose for the refresh
TTL, because a silently widened window keeps rows longer than the deployment
asked for and nothing on any surface would say so. Split into two keys: the
two windows answer different questions and their sharing 7 days was
coincidence.

The window is printed where the rows it governs are printed: /admin-api/state
and /admin-api/policy answer observationRetentionDays and banRetentionDays,
the observation table appends "rows are pruned after Nd" and the alert table
"alerts are pruned after Nd".

Measured on this tree: build 0 warnings / 0 errors, unit 132/132, integration
181/181 in 20 s (8 new: 5 startup-refusal and bound cases, a 1-day window
pruning a 3-day-old observation, a 30-day window keeping a ban ten days past
expiry, both surfaces reporting 30 and 2, and the two defaults), smoke 28/0,
console 76 assertions 0 failed. The console gate needed two of its own
assertions rewritten, not relaxed: they compared the note text for equality
and the sentence grew.

Run against the real binary: ObservationRetentionDays=30 BanRetentionDays=2
reports 30 and 2 on both surfaces; ObservationRetentionDays=0 exits with
"OpenWaf:Policy:ObservationRetentionDays must be a whole number of days
between 1 and 365; got 0".
2026-10-04 15:37:27 +02:00

openwaf

An edge that sits in front of an application it knows nothing about, proxies to it, and bans a source because of what the application answered — a run of refusals from one address — while the operator's own block list stays exactly as it was.

Blocking is usually manual: a human notices abuse and adds an IP. That never fires at 3am. openwaf turns the block list from a record of past incidents into a live defence, without inventing a rule language nobody will maintain.

.NET 10, YARP reverse proxy, EF Core, one deployable.


The three pillars, and the one place they meet

There is exactly one middleware that may refuse a request (EdgeGuardMiddleware). Everything else observes. Precedence is a property of the design, not a side effect of registration order:

# Pillar Answer Lifetime
1 always-pass prefixes — /admin-api, /admin, /healthz, /readyz, /openapi pass the recovery hatch for an operator who blocked themselves
2 allowlist (address or CIDR, matched on the raw peer address) pass wins over everything, including a geo deny
3 operator block (source=operator) 301 to RedirectTo, else a honey-pot list never expires
4 engine ban (source=engine) 403 + Retry-After + a reason expires on its own
5 geo policy (deny list / allow list) 451 + a note that says the inference is probabilistic policy, not data

A second middleware, ResponseObservationMiddleware, sits inside the guard: it awaits the upstream, classifies the status the application actually returned, and feeds a streak counter. Being inside the guard is load-bearing — a refusal the edge generated itself must never feed the streak that produced the ban.

The streak

N consecutive refusals inside a window of M minutes ⇒ ban for BanDuration. Consecutive means what it says:

  • a 2xx/3xx resets the streak to zero;
  • a gap longer than M restarts it at one;
  • 4xx (default 400-499, inclusive of 400) counts toward a ban;
  • 5xx (default 500-599) never bans — it raises an alert instead, because a broken deploy would otherwise take the site down twice: once by being broken, once by banning its own honest visitors.

The ban takes effect on the request after the one that matured the streak, because the edge decides from the response it has already served.

The reset is done by the observer, not only by the counter: a 2xx/3xx calls StreakTracker.ResetIfTracked, which costs one dictionary lookup for a source the map has never seen and no MMDB read for anyone. Before that, the sentence above was true in the domain object and false on the wire — a visitor alternating a 404 with a normal page view accumulated refusals across every honest request and still matured a ban. A_clean_answer_between_refusals_ends_the_run… in the integration suite is the test for that sentence.

Alerts speak per escalation, not per request

Both alert kinds are edge-triggered: one row when the streak crosses N, then one more each time the count doubles. Twelve 502s at N=3 cost three rows (at 3, 6 and 12).

They used to be level-triggered, which meant one alert row per request for as long as the condition lasted — and neither condition ends on its own. A 5xx never bans, so the source is observed on every request; in Observe mode nothing bans at all, so the same is true of a refusal streak. At N=3 a source hammering a broken upstream for 10,000 requests cost 9,998 rows, 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. The safest mode was also the cheapest way to grow the operator's tables.

Silencing once was not the fix: an alert that fires once per source per process and never again hides an outage that got ten times worse while nobody was looking. So the count keeps escalating, and a gap longer than M or a clean answer ends the episode, which lets the next outage announce itself again. A_storm_of_server_errors_alerts_on_the_crossing_and_then_only_as_it_doubles (9 rows for 1,000 responses) and A_dry_run_announces_each_candidate_ban_twice_at_most_rather_than_once_per_request are the tests; both fail with the edge detection removed.

The toggle

Automatic banning is a mode, not a replacement:

mode observes records blocks
Off yes yes no
Observe yes yes, as candidate_ban alerts no
Enforce yes yes yes

Switching it off touches no rows. DELETE /admin-api/blocks?source=engine clears engine bans and cannot reach an operator's entries — provenance lives on the row, so "clear the automatic ones" is a filter, not a table operation.


Quickstart

# tests
dotnet test dotnet/OpenWaf.slnx

# end-to-end against a real upstream, with curl assertions
./scripts/smoke.sh

# the whole thing behind a proxy
OPENWAF_ADMIN_TOKEN=change-me docker compose up --build

# the assertions above, against the built image rather than the source tree:
# image HEALTHCHECK, streak ban over a socket, per-source isolation, operator
# block, allowlist precedence, country deny
OPENWAF_ADMIN_TOKEN=change-me ./scripts/compose-smoke.sh

Point one probe at it and watch the ban:

for i in 1 2 3 4; do curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8080/wp-admin; done
# 404 404 404 403

curl -s -H "X-Admin-Token: change-me" 'http://localhost:8080/admin-api/blocks?source=engine'

Configuration

Everything under OpenWaf:Policy (env: OpenWaf__Policy__…), overridable at runtime through PUT /admin-api/policy, which persists to policy_settings.

key default meaning
Mode Observe Off / Observe / Enforce
StreakThreshold 10 N
StreakWindow 00:05:00 M — the gap that still counts as one streak
BanDuration 01:00:00 how long a ban stays live
RefusalRange 400-499 statuses that count toward a ban
ServerErrorRange 500-599 statuses that raise an alert
Geo Off Off / DenyList / AllowList
TrustProxyHeaders false may X-Forwarded-For define the source?
MaxTrackedSources 10000 hard bound on the in-memory streak map
Ipv4KeyPrefixLength / Ipv6KeyPrefixLength 32 / 64 source-key granularity
EngineBlockStatus / OperatorBlockStatus 403 / 301 what a block answers
DefaultRedirectTargets iana example honey-pot targets for operator blocks

A PUT whose value is outside its range is a 400 that names the key and the range, not a 200 that quietly keeps the old value. Both halves of that matter, and both were measured on the shipped image (openwaf:ci) before the fix: {"streakThreshold":0}, {"maxTrackedSources":0}, {"banDurationMinutes":-1}, {"streakWindowMinutes":0} and {"refusalRange":"not-a-range"} each answered 200 with the untouched policy in the body and zero log lines, so the operator read a success that had not happened; {"engineBlockStatus":1000} was stored and obeyed, after which every banned request died as curl: (1) Unsupported HTTP/1 subversion in response — no HTTP response at all; and {"ipv4KeyPrefixLength":0} collapsed every IPv4 address into one source key (*), so a single 404 banned the whole address family — three never-seen addresses were refused on their first request.

field accepted why the floor is where it is
streakThreshold 1–1000 0 is not "never ban" — that is mode: Off
streakWindowMinutes 0.01–1440 past a day it is a record, not a streak
banDurationMinutes 0.01–10080 a ban that outlives its evidence row cannot be explained
maxTrackedSources 1–1000000 the bound exists to stop the process being grown at request rate
ipv4KeyPrefixLength 8–32 below /8 one key is most of the internet; at 0 it is all of it
ipv6KeyPrefixLength 32–128 an /32 is one provider's block; below that a key spans allocations
engineBlockStatus 400–599 a block must answer with a status that means blocked
operatorBlockStatus 301 or 400–599 301 is the redirect; any other 3xx is a redirect with no Location
refusalRange / serverErrorRange low-high inside 100–599 a range matching nothing is a pillar switched off by a typo
defaultRedirectTargets absolute http(s) URLs they are written into a Location header

Two more layers for a value that arrives without the API — a restored backup, a hand edit: a policy_settings row outside its range is ignored at load with a warning naming the key and the value, and DecisionEngine refuses to put a status the wire cannot carry (outside 100–999) on a response at all, answering 403 instead. The ranges live in one file, OpenWaf.Domain/Policy/PolicyBounds.cs.

Three keys are not policy and cannot be changed at runtime. One decides how long this process may keep enforcing a list that is already out of date; the other two decide how long the data behind the privacy promise sits in storage, and are startup-time because widening a retention window is a deployment decision, not something a request should be able to do:

key default meaning
OpenWaf:State:RefreshTtlSeconds 30 how stale the in-memory block list may get. On a single edge this is invisible; behind a load balancer it is the propagation delay — 23.7 s measured at ~36 req/s in research/2026-10-01-multi-instance/. Anything outside 1–300 aborts startup: the process exits non-zero and the log names the key. In Docker the container stays Up with nothing listening until the image HEALTHCHECK marks it unhealthy — that is what any startup failure in this image looks like, not a special case. /healthz reports the value an operator actually got, as snapshotTtlSeconds.
OpenWaf:Policy:ObservationRetentionDays 7 how long a source_observations row survives past its last request. 1–365 whole days; anything else aborts startup naming the key, exactly as RefreshTtlSeconds does rather than falling back to 7 — a silently widened window keeps rows longer than the deployment asked for and nothing would say so. Surfaced as observationRetentionDays on /admin-api/state and /admin-api/policy, and as rows are pruned after Nd on the console.
OpenWaf:Policy:BanRetentionDays 7 how long an expired engine ban and an alert stay readable after they stopped being live. Same 1–365 bound, same startup refusal, surfaced as banRetentionDays and alerts are pruned after Nd. Two keys rather than one because the two windows answer different questions, and their sharing 7 days was coincidence. Operator-written rows are never pruned by either window.

Database: Database:Provider = sqlite (default) or postgres, ConnectionStrings__OpenWaf. GeoIP: GEOIP_MAXMIND_DB_PATH.

The geo database ages on purpose, and a rebuild does not replace it

The image bakes a dbip-country-lite MMDB pinned by ARG DBIP_VERSION (currently 2026-10, moved by hand on 2026-10-01). /healthz reports geoBuiltAt, geoDatabase and geoStale (over 90 days), and /admin-api/geo reports the age in days.

The 90-day flag is an alarm, not the policy, and the gap is measurable: with the named volume holding dbip-country-lite-2026-09 while the Dockerfile pinned 2026-10, /healthz said geoBuiltAt: 2026-09-01T01:32:45+00:00 and geoStale: false, and every geo assertion in the smoke test still passed — the country deny list still refused 8.8.8.8 with 451. A month behind is a policy nobody chose, reported as healthy.

Three things close it:

  • scripts/geo-db-freshness.sh compares the pin with the newest release the vendor actually serves and answers with three codes, not two: 0 current, 1 the vendor has something newer (it prints the bump), 2 could not tell — no network, or a pin the vendor has never served, which would make the image build fail on a 404. "Could not check" is never printed as ok.
  • scripts/geo-db-bump.sh rewrites the ARG and prints the two commands that make the new database actually land. It refuses to write anything when the check could not run: a pin moved on the strength of a check that did not run is worse than a pin left alone.
  • .github/workflows/geo-freshness.yml runs the check on the 1st and the 8th, and deliberately does not open a pull request — a bot that cannot run the geo assertions bumping a data dependency is a worse default than a red job.

scripts/compose-smoke.sh asserts the pin against the running container (the loaded geo database is the pinned one). Its teeth were checked, not assumed: against the stale volume above it printed Dockerfile pins 2026-10, the container loaded 2026-09 plus the docker volume rm line, 27 passed, 1 failed, and after removing the volume 28 passed, 0 failed.

docker-compose.yml mounts a named volume at /app/geoip so a redeploy does not re-download 8 MB. Docker seeds a named volume from the image only the first time the volume is created, so an existing deployment keeps the old database after a rebuild. Measured on 2026-10-01: the same rebuilt image reported geoBuiltAt: 2026-09-01 against the existing volume and 2026-10-01 after docker volume rm openwaf_openwaf-geoip. That is the command to reach for when the pin moves.

Schema

Migrations are the schema of record for PostgreSQL, which is the provider a real deployment runs:

cd dotnet
dotnet ef migrations add <Name> --project OpenWaf.Infrastructure --startup-project OpenWaf.Infrastructure

A migration set is provider-shaped SQL, so it is not applied to the SQLite default — there the schema is created from the model at startup. OPENWAF_SCHEMA overrides the choice: migrate, ensurecreated, or none when an operator manages the schema themselves.

Admin API

Requires X-Admin-Token (or ?token=). No token configured means the admin API is closed, not open.

The header is the form to use. The query string is accepted anyway, because an operator at a keyboard types ?token= without thinking and the wrong answer to that is an operator who switches auth off. It is not silent: a request authenticated by the query string logs a warning naming the path — never the token. The reason is measured, not assumed. At the shipped log level (Microsoft.AspNetCore: Warning) the edge logs no URLs, and a container run with ?token= in the URL produced 0 lines containing the token; raise Microsoft.AspNetCore to Information — the ordinary next move while debugging something — and Kestrel logs the full URL, producing 2 such lines. The tests are A_token_in_the_query_string_is_served_but_named_in_the_log_without_the_secret and A_token_in_the_header_produces_no_such_warning_because_it_is_the_form_we_ask_for; delete the warning and exactly the first one fails.

GET    /admin-api/blocks?source=operator|engine&live=true
POST   /admin-api/blocks            {"ip","reason","redirectTo"}
DELETE /admin-api/blocks?source=engine[&key=…]
GET    /admin-api/allow?live[=false]&limit&offset   POST {"match","note","expiresInMinutes"}   DELETE /admin-api/allow/{id}
GET    /admin-api/policy            PUT  {"mode":"Enforce","streakThreshold":8,…}
GET    /admin-api/observations      per-source streaks, durable — the maximum ever seen
GET    /admin-api/streaks           the streak standing right now, in this process, with the threshold
GET    /admin-api/alerts            server_error_streak | candidate_ban
GET    /admin-api/countries         PUT /admin-api/countries/{code}?allowed=false
GET    /admin-api/countries/summary sources and refusals per country, from the aggregates
GET    /admin-api/geo               which database is loaded and how old it is
GET    /admin-api/state             snapshot age, tracked sources, counts

?source= on /admin-api/blocks is a provenance filter, and it used to accept anything: an unrecognised value meant operator. With two operator blocks and three engine bans live, GET ?source=enigne returned the operator list and hid the engine bans, and DELETE ?source=enigne answered {"deleted":1} and left operator=0 engine=3 — a typo in the parameter that exists precisely so that "clear the automatic bans" can never erase a human's list erased the human's list. source is now operator|engine|all or a 400 naming what was sent; a missing source is still "all", and the delete guard for a missing source is unchanged. Two more of the same family: expiresInMinutes must be 1–5,256,000 when present (0 and −5 used to mean "never expires", silently, on the one control that outranks every ban — leaving it out is now the only way to say never), and reason/note are bounded at 512 characters, the budget the attacker-written path field already gets, after a 1 MB note and a 1 MB reason were both accepted and made the listings return ~1 MB each.

Every capped listing now says how much it cut, and a limit nobody meant is refused instead of reinterpreted. ?limit= used to be clamped: with 1,103 sources recorded, GET /admin-api/observations?limit=100000 answered 200 with 1000 rows, no total and no flag, so 103 recorded sources were unreachable and the answer read like the whole window; ?limit=0 and ?limit=-1 each answered 200 with one row. The block listing already carried X-Total-Count and X-Truncated, with a comment saying that is what stops a page reading like a complete answer; the two listings the console reads most carried neither. They do now, all three take an offset that reaches the rest, and a limit outside its range is refused by name — limit must be 1..1000; got 0. All of it is now measured on the shipped image rather than only in-process: the compose gate seeds five sources one second apart, reads them back one row at a time, and requires the five pages to be five different sources and exactly the first five rows of the whole listing, with the same total on every page. /admin-api/streaks had the opposite fault: it measured truncation against the size of the streak map, and the map keeps a source whose streak a clean answer ended while the listing leaves those out on purpose — with two standing streaks and one reset source, ?limit=1000 returned 2 rows and answered X-Truncated: true although nothing had been cut. It measures against standing streaks now and reports standingStreaks beside trackedSources. On the page, the same run prints "newest 25 of 42 recorded sources" and "Newest 25 of 274 alerts": the data volume survives compose down, which is precisely where a table that looks like a window stops being honest.

A query parameter the endpoint has never heard of is now refused rather than dropped. Measured on the shipped image with 16 recorded sources: GET /admin-api/observations?source=203.0.113.11 answered 200 with all 16 rows across 16 different addresses and X-Total-Count: 16, and ?src=203.0.113.11 answered the same. The filter was not applied and not refused — it was absent, because the framework binds the parameters a handler declares and discards the rest without a trace. An operator investigating one address was handed fifteen other addresses and a total that matched those fifteen, which is the same shape as the bug found one level up, where an unknown ?source= value meant "operator". Every list endpoint behaved this way. They now answer 400 naming the parameter and listing what that endpoint accepts, and /observations and /alerts gained the filter the shape of the question implied: ?source=<key>, exact match, with X-Total-Count counting the filtered set rather than the table, so the truncation flag cannot claim a cut that never happened. An empty ?source= is refused rather than read as "every source"; a source with no rows answers [] with a total of 0. /admin-api/streaks learned the same filter in the same shape: exact match, standingStreaks counting the filtered set while trackedSources stays the size of the map, and sourceFilter echoed in the body — null when unfiltered, so a reader never has to guess whether an absent key means "unfiltered" or "this build forgot to say". The operator page asks the question now: a box under "Sources the edge is watching", and every source key the page prints is a button that asks it, narrowing the observation and streak tables together and printing the filtered total under each. A key with nothing recorded is answered in words — no recorded observations for <key> — rather than with an empty box that looks like a loading failure. ?token= stays accepted, because the admin auth layer reads it out of the query string and that transport is deliberate — and the guard's first run broke three tests that were right to send it, which is the worse failure mode for a guard of this kind: refusing a request that works.

That guard covered the read side only, and the image that carried it then answered the same request two ways depending on the verb. Measured on that image: POST /admin-api/blocks?zzz=1 answered 204 and wrote the ban, PUT /admin-api/policy?zzz=1 answered 200 and changed the policy, PUT /admin-api/countries/DE?allowed=true&zzz=1 answered 204, DELETE /admin-api/blocks?key=…&zzz=1 answered 200 {"deleted":1} — while GET /admin-api/blocks?zzz=1 answered 400 naming the parameter. The silent half was the half that changes state: a misspelled scoping parameter on a write acts with a wider scope than the caller meant, and answers as if the scope had applied. Every endpoint under /admin-api refuses an unknown parameter now — the writes, plus /state, /geo and /policy, which take none — and the refusal runs before any state change, so a rejected write cannot half-happen. One measurement changed the design rather than the coverage: GET /admin-api/countries?limit=2 still answered 200 with every row after the GET guard landed, because that listing has no paging to honour and the guard had assumed limit/offset were legal everywhere — the same bug one level down, in the guard itself. Each endpoint now declares its own parameter surface and the base set is only token, so the list a refusal prints is true for the endpoint that printed it.

The exemption listing was the last one left uncapped, and it had a second fault worth more than the ceiling. GET /admin-api/allow answered with every row ever written and no statement of whether any of them still meant anything. Measured on the shipped image — one entry written for one minute against an operator block on the same address: POST /admin-api/allow {"match":"192.168.65.1", "expiresInMinutes":1} at 03:58:16; that address answered 502 (through to the upstream, the exemption outranking the block) at 03:58:20 and 301 (blocked again) at 03:59:38; and at 03:59:39 GET /admin-api/allow still printed the row with no liveness field while /admin-api/state still answered "allowEntries":1. The engine was right and the surface was a minute behind it, in the one table whose whole purpose is "who is exempt right now". With 1,101 rows the same endpoint answered 130,386 bytes with no X-Total-Count and no X-Truncated, and ignored every paging parameter — ?limit=10, ?offset=1000, ?limit=0 and ?limit=100000 each returned all 1,101. It takes live (default true; live=false means "do not filter", the same shape /blocks uses), limit 1–2,000 and offset now, refuses a limit nobody meant by name, carries X-Total-Count and X-Truncated computed from the same predicate as the rows, and puts live on every row — computed from AllowEntry.IsLive, the rule the engine itself applies, which is what keeps the listing and the wire from drifting apart again. /admin-api/state answers allowEntries as the number of exemptions in force, with allowEntriesExpired beside it. The dead rows are not pruned, on purpose: retention ages out observations, engine bans and alerts, and an operator's own writes are not the machine's to delete — which is precisely why they have to be visible instead of quietly absent from the only table that shows them.

A country rule is matched against the two-letter code the geo database returns, so the code has to be two letters. PUT /admin-api/countries/{code} used to check only the length, and on the shipped image PUT /countries/12?allowed=false and PUT /countries/U.?allowed=false both answered 204: GET /countries then listed 12: denied and U.: denied while a source from the busiest country still got through with a 404 — the operator's table claimed two countries were denied and the edge enforced nothing (denying US for real turns that same probe into 451, which is the difference the table was hiding). The code is now refused by name — code must be a two-letter ISO country code; got "12" — and DELETE /admin-api/countries/{code} takes a rule out of the table and out of the snapshot, answering no country rule for "ZZ" when there is nothing to remove. That second half matters because a rule used to be permanent: the console gate's own comment read "a country rule cannot be deleted, only overwritten", and the residue outlived compose down in the data volume.

That was proven in-process first, which is the wrong layer: the shipped image had four country assertions in it, every one of them about a rule that had already been written correctly. It now has nineteen, seeded from the country this run's geo database actually resolves for the probe IP, and the scene refuses to run against leftovers (it counts the junk rows before it starts and requires zero). The teeth were measured, not assumed, and measured on both halves: putting the validation back to a length check answers 179 passed, 6 failed on the image (/tmp/c25_mutA_compose.log) against 5 failed in-process, and moving the DELETE route off /countries/{code} answers 179 passed, 6 failed (/tmp/c25_mutB_compose.log) against 2 failed in-process. Two of the six in the first case are rows the image would have kept forever (and none of the four wrote a row reads 3, and the closing the junk that used to be eternal is still not in the table reads 3), which is the sentence the whole ticket is about. That gap — 2 in-process versus 6 on the image for the delete half — is the reason the image-level scene exists.

A write that could not happen does not get to answer like one that did. Measured on two images of one stand — the tree before the fix (b46f5c20) and after (08bebf43) — with the block and policy tables dropped out from under a running edge that held 3 blocks and 1 policy row:

the operator's command before now
DELETE /admin-api/blocks?source=operator 200 {"deleted":0} 503 {"error":"…NOTHING was deleted"}
DELETE /admin-api/blocks?key=203.0.113.201 200 {"deleted":0} 503 the same
POST /admin-api/blocks 400 {"error":"database error"} 503 {"error":"…the block is NOT in effect"}
PUT /admin-api/policy {"mode":"Enforce"} 200, body mode:"Observe" 503 {"error":"…the change is NOT in effect"}
GET /readyz 200 {"status":"ready"} 503
GET /healthz 200 200 — unchanged on purpose: it is the recovery hatch, and it does not touch the database

{"deleted":0} is a fact about the list, so it may only be said when the delete ran; a 400 is a fact about the request, so it may not be used for a storage failure; and readiness has to prove the table the commands touch is readable — CanConnectAsync only proves the file opens. The same stand with a healthy storage and six concurrent POSTs for one address answered 204 204 400 400 400 400 before and 204 six times now: the unique index on (source key, provenance) made the loser of a race the API itself started look like a caller who sent a bad request, which is what a double-click on "block" in the console is. The write retries against the winner's row.

That was measured on two images of one stand; the gate had never asked the same question of the ship shape. It now does — 22 assertions of it, triggered with SQLite BEFORE INSERT/UPDATE/DELETE triggers rather than a dropped table. A dropped table breaks the listing too, and a listing that answers 500 is honest about being broken; the lie this scene is after is the 2xx that still looks complete, so the trigger has to leave reads working. It also has to cover DELETE: measured on the first run of this scene, an INSERT/UPDATE pair left the delete path untouched, so the two blocks really were deleted, the answer really was 200, and the scene was asserting a failure that had not been produced (195 passed, 6 failed, /tmp/c26_compose1.log).

The teeth, measured on this tree rather than quoted from the ticket:

what was put back in-process on the shipped image
a failed DELETE answering {"deleted":0} again 2 of 7 fail 204 passed, 3 failed (/tmp/c26_mutM1_compose.log)
/readyz trusting CanConnectAsync again 1 of 7 fails 208 passed, 1 failed (/tmp/c26_mutM2b_compose.log)
the console swallowing an empty 5xx again — 72 ok, 3 failed (/tmp/c26_mutM3_console2.log)

The second row is the one worth keeping. The scene already asserted readiness stops saying ready when the block table is not there → 503, and it still answered 207 passed, 0 failed with /readyz put back to CanConnectAsync (/tmp/c26_mutM2_compose.log): renaming the table breaks the snapshot build as well, so the snapshot guard refused for its own reason under the same 503. A status code two different guards can produce proves nothing about either of them. The scene now reads the body — the block-table read answers with the storage error alone, the pillar answers with "the guard's snapshot has not refreshed" — and only then does that assertion have teeth.

The console half is the sentence the page says when the edge says nothing. An empty 5xx used to make r.json() throw, the caller's catch claim that note() had already explained, and the status line go quiet exactly when the edge had the worst news to report. Five assertions cover it now, one of them recording every sentence the status line wears during the click — because the regression writes ok: deleted ? block(s) and loses it under refreshed before a single after-the-fact read could see it.

A pillar that stopped reading its table kept answering as though nothing had changed, and nothing on the surface said otherwise. Measured on the shipped image: PUT /policy {"streakThreshold":2,"trustProxyHeaders":true} answered 200, and four 404s followed by a 403 from 203.0.113.79 proved a threshold of 2 was live. DROP TABLE policy_settings at 04:44:43; 35 s later GET /policy still answered streakThreshold: 2, /state still answered snapshotAgeSeconds: 0, /healthz and /readyz were both 200, and the log carried one line. A docker restart brought the table's truth back (streakThreshold: 10, trustProxyHeaders: false) and four 404s plus a fifth wrote no ban: the rule the operator believed was in force had silently been off for that whole window, and the only place that was visible was a log line nobody was reading. Each pillar now counts its own failures — policyReloadFailures / policyLastReadAt and snapshotRefreshFailures / snapshotLastRefreshError — /state reports them plus snapshotStale, /policy carries X-Policy-Reload-Failures and X-Policy-Last-Read, and /readyz answers 503 naming the pillar and the age of the snapshot while any counter is non-zero. /healthz deliberately stays a liveness answer — the process is up and can serve what it holds — and readiness is the one that stops claiming the policy on the wire is the policy in the database.

The engine's own ban write is the durable write on the enforcement path, and it was described worst of all. Measured on the shipped image with writes to block_entries aborted by triggers while reads kept working: five refusals from one source at a threshold of 3 answered 404 five times, no ban reached storage or /state, /readyz answered 200, and the log said "BlockStore: concurrent ban on 203.0.113.12; keeping the winner" four times over an inner SQLite Error 19: 'gate: ban write blocked'. Enforcement reads the snapshot, and the snapshot is built from storage — so a ban that cannot be written is a ban that exists nowhere: not on this edge, not on any other edge sharing the database, not after a restart. Nothing was in force, and the only sentence the log offered said the opposite: that another process had won a race and its ban stood. The store now asks storage which case it is, by re-reading the row. A live engine ban for that source means somebody won the unique-index race and nothing is wrong; no row — or a re-read that cannot run either — means the write never happened, and that is counted (banWriteFailures, bansNotWritten, banLastWriteError) and gates /readyz. The ban then lands on the next refusal from that source, which is what clears readiness: on a write, not on a timer.

That last clause used to have a cost nobody had measured. With the write path broken and then REPAIRED — triggers dropped, zero triggers left, storage healthy — and no further request from the banned source, GET /readyz answered 503 at t+30, t+60, t+90 and t+120 s, with banWriteFailures and bansNotWritten unmoved. The ban pillar clears only on a successful ban write, and the only thing that produced one was the source crossing the threshold again. So the signal an orchestrator uses to keep an edge in rotation was coupled to attack traffic: the quieter the site, the longer a repaired edge sat out of service, enforcing everything except one ban nobody had written. A ban the engine decided and could not write is now kept and re-attempted by a hosted loop on the same 15 s cadence the observation writer uses. The sentence still runs from the moment the ban was decided, so a retry that lands late cannot quietly lengthen it, and a pending ban whose sentence expired first is counted (bansNeverEnforced) and logged as never enforced rather than rewritten as a fresh, longer one. /admin-api/state answers bansPendingRetry and bansNeverEnforced, because without the first a healed storage failure is indistinguishable from a quiet site. The readiness gate was not loosened to get this: the enforcement-path boundary above still holds, what changed is that the failure repairs itself.

Which failures gate is now a stated boundary rather than a habit. The enforcement path gates — the policy read, the snapshot read, the ban write. The reporting pillars — observations, alerts, retention — are counted and shown and do not gate. The first version of this code gated on all of them, and one measurement moved it: with that gate in place a single lost alert left alertWriteFailures at 3 and /readyz at 503; the triggers were then removed and the stand left idle for 120 s, and it answered 503 the whole time with the write path healthy. An alert pillar writes only when an alert happens to be raised, so "not yet proven healthy" had become "unready forever", and an orchestrator would have pulled a working edge out of rotation over a reporting side-channel. Counters clear on evidence — a successful write of that same pillar — never on a clock.

The write side had the same silence, and a failed write is worse than a failed read: the row never existed, and no later request brings it back. Measured on the shipped image with SQLite triggers aborting every INSERT and UPDATE on source_observations and edge_alerts while reads kept working — a trigger rather than a dropped table, because a missing table breaks the listing too and a broken listing is honest about being broken, while a trigger leaves the listing answering 200. Three new sources refused and a six-request 5xx storm later: GET /admin-api/observations answered 200 with the same X-Total-Count it had before the break, GET /admin-api/alerts still showed the one row it had, /healthz and /readyz were both 200, /state had no write-side field at all, and the log carried "ObservationWriter: flush failed, 4 entries dropped." plus two "AlertWriter: could not persist…". Each writer now counts its own failures — observationWriteFailures / observationsLost / observationLastWriteError, alertWriteFailures / alertsLost, and retentionPruneFailures for the prune that ages aggregates out — and /readyz answers 503 naming the pillar and how many rows were lost. A counter clears only on a successful write of its own pillar: measured on the same stand, the observation pillar healed on its next flush while readiness stayed red until an alert was actually written again, which is the difference between a counter and a gauge. retentionPruneFailures is reported and deliberately not a readiness failure — a prune that cannot run keeps aggregates past the age they promise to age out at, which the operator has to be told about, but it does not change what this edge enforces, and pulling every edge out of rotation over a cleanup loop would trade a retention defect for an outage. The error quoted is the innermost one, not the wrapper: "An error occurred while saving the entity changes" is not something an operator can act on, and "gate: durable write blocked" is.

The console had its own copy: every destructive row button wrote its green note whatever came back — a refused delete read as deleted ? block(s) — and load(), which runs after every action and on a 5 s interval, replaced the error line with refreshed inside a second. An empty 5xx body threw inside apiRaw and was swallowed by the caller's catch. A row action now asks whether the answer carried an error before it says it worked, and the refresh that follows a failed action holds the note instead of erasing it.

A 404 has to explain itself, because the page has nothing else to work from. On the shipped image the same API answered two missing rows differently:

request before now
DELETE /admin-api/countries/ZZ 404 {"error":"no country rule for \"ZZ\""} unchanged
DELETE /admin-api/allow/999999 404, Content-Length: 0 404 {"error":"no allow entry with id 999999"}

The silent half is what the console filled in itself: apiRaw read every 404 as "admin api disabled — set OpenWaf__Admin__Token" and threw, so removing a row another tab had already removed sent the operator to configure a token that is already configured — and since the throw landed in a catch that says nothing, the status line ended up reading refreshed in the success colour. A 404 is now an answer like any other: its body is shown, and whether the admin surface is off at all is decided by the core read (/admin-api/state), which shows the edge's own sentence rather than a guess made from a status code. The same pass found the most destructive button on the page — "clear the automatic bans" — firing its DELETE and reading nothing back, so cleared 7, cleared 0 and a refused write looked identical after the reload; it now reports the count the edge gave, and the note for the action just taken survives the refresh that action itself triggered.

redirectTo on a block is the one field that ends up in a response header, and the shipped image used to accept any string in it — POST /admin-api/blocks answered 204 for all of these, and the next request from that source paid:

target written what the blocked request answered
https://example.com/ok 301 Location: https://example.com/ok
http://bad target 301 Location: http://bad target — unparseable
http://x.invalid/ + CRLF + X-Injected: 1 500 Internal Server Error, Content-Length: 0
javascript:alert(1) 301 Location: javascript:alert(1)
not-a-url 301 Location: not-a-url

The CRLF row is the one that makes this a defect rather than a wart: Kestrel refuses to write the header, so the operator's own block — accepted with 204 — turned that visitor's request into a server error. No header was injected, which is the only part of the old behaviour that was safe. redirectTo is now an absolute http(s) URL or a 400, and the decision point ignores a target it cannot send and answers the block's own default instead, for a row that arrived by a restored backup or a hand edit.

Console

GET /admin serves a single page over those endpoints — mode and snapshot age, live bans with their reasons, the streak standing in this process right now (current count against the threshold, not the historical maximum), the sources being watched, and the countries seen — counted per ISO code, with a bar per country sized against the busiest one. That bar is the honest limit of the word "map" here: the admin API exposes counts per country code, not coordinates, and the runtime image is distroless with no external assets, so there is no world outline and no tile server. A geographic map would be a decoration this page could not load at the moment it is wanted. It also writes, with the two controls an incident actually reaches for: block one address with a reason, and allowlist an address or CIDR with a note and an optional expiry (the "my customer is locked out" control — an allow entry outranks every ban). Each ban row has a delete that removes that row, each allow row a remove, and each country row a rule toggle plus — only when a rule actually exists — a "remove rule" button. An allow entry whose expiry has passed stays in the table and says "EXPIRED, the edge no longer honours it", and the pill above it counts live exemptions and expired rows apart — the row is not the answer. DELETE /admin-api/countries/{code} takes the rule out of the table and out of the snapshot; flipping it to allowed=true does not, it leaves a row behind that only means "not denied". The summary line states which geo database this edge is enforcing on, when it was built and how old it is (marked past the 90-day runtime alarm), and the snapshot age against the TTL it is measured against — because on a single edge the TTL is invisible, and behind a load balancer it is the delay a ban has. That pill turns warn, rather than staying quiet, when the snapshot is older than the TTL or either pillar's failure counter is non-zero, and it names which: snapshot 412.7s / ttl 30s · older than the ttl · snapshot refresh failing ×14 · policy not re-read from storage ×14. A second pill carries the write side and is present in the clean case too — durable writes ok, or durable writes bans not written ×2 (2 not enforced) · observations not persisted ×3 (4 rows lost) · alerts not persisted ×2 (2 lost) · retention not running ×1 — because a pill that only appears when something is wrong makes "no alerts" and "alerts are not being written" look identical from the operator's chair, and because the ban case has to read differently: those two bans are not merely unrecorded, they are not in force anywhere. It shows the alerts the edge raises — server_error_streak (your upstream is failing, and the edge will not ban the visitor who saw it) and candidate_ban (the rule would have banned, but the mode is Observe). That table is the whole point of the alerting pillar: an alert nobody reads is a log line. It decides nothing: every control on it is one call to the API above. It is on the always-pass list, so an operator who is themselves blocked can still reach the page that clears it, and it is never observed, so fumbling it cannot build a streak. The token is typed into the page and sent as a header; it is never in a URL, because a token in a query string ends up in proxy logs and browser history. No external assets — a page that needs a CDN fails at the moment it is wanted.

Gates

scripts/ci-gates.sh is the single definition of every gate; the CI workflow calls the same script one gate per step, so a local green run and a CI green run cannot mean different things.

scripts/ci-gates.sh all            # restore, build, unit, integration, smoke, image, compose-smoke
scripts/ci-gates.sh unit           # or any one gate on its own
scripts/ci-gates.sh console        # the page, in a real Chromium (not part of `all`)

OPENWAF_ADMIN_TOKEN defaults inside ci-gates.sh to a throwaway for the stack the gate starts itself and tears down on exit; the standalone scripts still refuse to invent one, because run by hand they can be pointed at a real deployment.

The compose gate does not only read the stack: it breaks a pillar on purpose. Through a python:3.12-slim sidecar sharing the edge container's volume it runs DROP TABLE policy_settings, then drives proxy requests in a loop — the snapshot is refreshed by traffic, not by a timer, so a stack nobody is asking anything never notices — until the failure counter appears, and asserts that /state counts it, that /readyz has stopped saying ready, that /policy carries its own provenance headers, that the other pillar still reports healthy, and that CREATE TABLE IF NOT EXISTS returns the counters to 0 and readiness to 200. Six assertions, and all six were red before the fix.

The compose gate breaks the write path on purpose too, with the same care about how it breaks: SQLite triggers (BEFORE INSERT/BEFORE UPDATE on source_observations and edge_alerts, RAISE(ABORT, …)) installed through the sidecar, so the reads stay honest and only the writes fail. It then asserts that /state counts both pillars and says how many rows were lost, that the observation listing's X-Total-Count is unchanged across the break — the lie, asserted directly — that the failure it names is the storage error rather than EF's wrapper, that the three sources the scene says it lost were really three distinct sources in the live streak map and not one docker bridge address wearing a header nobody trusted, and that recovery is per pillar: the observation counter clears on the next flush, while an alert pillar that has had nothing to write since the break stays reported and stays unproven. Eleven assertions. The recovery half was red against the first version of the fix, which reset readiness as soon as any pillar healed. The readiness half was rewritten a cycle later: this scene used to assert /readyz 503 for a reporting-path failure, and the measurement described above moved that boundary — a reporting failure is counted and shown, and only an enforcement-path failure makes the edge unready.

The same gate breaks the enforcement-path write too, and asserts the discriminator rather than the log's mood: with block_entries writes aborted, a scanner at a threshold of 3 answers 404 404 404 404 404, no engine ban for it reaches storage, /readyz is 503 quoting the storage error, the number of log lines calling a ban write a race is measured before and after the scene and must not move (0/0), the honest line is present — counted, 3 lines, and polled, because the line reaches the daemon's log store a moment after the /state counter it belongs to and a grep run immediately after the burst answers 0 — and after the triggers go the ban lands on a later refusal with readiness returning on that write. Eleven assertions, and the split matters: the ones that describe the fix — the counters, the 503, the quoted reason, the log-line delta, the honest line — were red before it, while the three that describe the consequence (404 404 404 404 404, the scanner really is one source the edge is tracking, nothing in storage) were already green. That is the whole point of the finding: the consequence was always observable and nothing on any surface pointed at it.

The console gate starts the stack, seeds a source sitting at 2 of a threshold of 3 and an operator block with a reason, four 502s from an address chosen for this run (/boom, see the alerting note above), drives /admin in a real Chromium, and asserts 70 things. The read side: it authenticated, listed the streak as current-over-threshold rather than as a historical maximum, listed the operator block with its reason, listed observations and countries with bars that have real pixel widths, said how many recorded sources the observation table is only a page of, and counted the streak note against standing streaks rather than against the size of the map, listed the alert this run's seeding wrote (by source and count, not just "a row exists"), said in words that a server error is never a reason to ban, kept the token out of the markup, and threw no javascript. The write side, checked on the wire and not just in the table: an address reaches the upstream (404), the page writes a ban for it, the same address is then refused (301 with the policy's redirect Location — the probe uses redirect: 'manual', because following it walks out to the public internet and comes back 200, which is how this assertion first read as a failure while the edge was refusing the client the whole time), the per-row delete removes that one ban and the address reaches the upstream again, an allow entry appears with an expiry and can be removed, an allow entry whose minute passed a minute ago is still listed and marked EXPIRED while a live one is not (the seed writes it with a one-minute TTL ahead of waits the gate already pays, so the expired state arrives for free), and a country rule is written from no rule at all, toggled both ways and then removed (— → allowed → denied → —). The gate used to assume a US rule was already there, so on a fresh volume — where the first click allows instead of denying — it failed; a gate that only passes on residue from the previous run is not a gate. The quiet failure mode is asserted too: typing not-an-ip into the block form has to come back as the API's own error (not an IP address: not-an-ip) with no new row, because an operator who believes they blocked an address and did not is worse than an operator with no console at all. The escaping invariant is asserted too: the seed asks for a path carrying a percent-encoded <img … onerror=…> and writes an operator block whose reason carries <svg onload=…>, and the page must show both as text, create no img/svg/script/iframe/object/embed inside any table body, and keep its own title — the path in an observation row is whatever an anonymous visitor asked for, and the only browser in this system holding the admin token is the one rendering it. Reducing esc() to the identity function makes this gate go red with 6 failures and the page title becomes "XSS", which is the price of the invariant. Then the pass repeats at 375 px in dark mode, where the document must not scroll sideways and the status line must clear WCAG AA (measured 11.85:1). It needs playwright-core (PLAYWRIGHT_CORE=/path/to/it) and exits 2 when that is missing — a gate that reports success having asserted nothing is worse than no gate. Its negative control (a wrong token) exits 1. SCREENSHOT=console-evidence.png writes the desktop and phone screenshots the CI job publishes as artifacts.

The same gates on the runner's operating system

Every green number above was produced on darwin; the workflow runs on ubuntu-latest. scripts/ci-linux-rehearsal.sh runs the gates in containers. The source gates (restore, build, unit, integration, smoke) run against a copy of the tree — no .git, no host build output, because Linux binaries landing in a macOS working tree make the next --no-build try to exec an ELF file — inside mcr.microsoft.com/dotnet/sdk:10.0. The compose gate runs in docker:cli against the host daemon, so the image build and the stack are Linux.

Rehearsed 2026-10-02, most recently at dc88f36, each stage run on its own.

On the head of this file the host suite has been re-run and the container stages have not, so the two sets of numbers are labelled separately rather than merged into one green line. macOS host, this tree, re-measured 2026-10-04 with the retention window as configuration: build 0 warnings / 0 errors, unit 132/132, integration 181/181 in 20 s, console 76 assertions, 0 failed, smoke passed 28, failed 0. Carried from the 2026-10-02 run and not re-measured since: compose 209 passed, 0 failed, image 261 MB, 0 containers left behind, enforcement lag 33 ms (/tmp/c26_build.log, /tmp/c26_unit.log, /tmp/c26_int4.log, /tmp/c26_smoke.log, /tmp/c26_compose5.log, /tmp/c26_console4.log). The integration count says how it was scheduled, because that changed the answer once: the suite as xUnit runs it — parallel test collections — answered 157 passed, 16 failed, every one of them Timed out waiting for the entry point to build the IHost after 00:05:00 (/tmp/c26_int3.log), and with xunit.parallelizeTestCollections=false the same tree answered 173/173 in 23 s (/tmp/c26_int4.log). Re-measured 2026-10-04, the default parallel scheduling answered 181/181 in 20 s, and the same tree run inside a filesystem-and-network sandbox failed every fixture with exactly that timeout — a test host that cannot bind a loopback socket hangs in this shape. Scheduling is one variable in that symptom; whether the test host can open a socket at all is another, and it is the one that decided the run today. Earlier in the same cycle two overlapping runs of the suite produced the older OPEN-47 symptom on PillarFailureVisibilityTests.The_snapshot_age_is_measured_against_the_ttl_it_is_supposed_to_respect — a real Assert.False, not a timeout — while that test passed on its own. The suite is not the only measurement in this project whose value depends on what else was running. The Linux rehearsal and the act run below still describe dc88f36 — compose 185, console 70 — because neither stage has been run since the two scenes in this cycle were added, and quoting them for this tree would be a number the tree does not produce. The same suite on the macOS host at dc88f36 gave unit 132/132, integration 173/173, smoke passed 28, failed 0, compose 185 passed, 0 failed, console 70 assertions, 0 failed, image 261 MB, 0 containers left behind. Source gates: Ubuntu 24.04.5, SDK 10.0.401 resolving dotnet/global.json (pinned 10.0.100, rollForward: latestFeature — which is also the answer to whether setup-dotnet with 10.0.x satisfies the pin), unit 132/132, integration 173/173, smoke 28/28, first try, nothing to fix. The first rehearsal of this pipeline timed a cold container and a cold NuGet cache at 1:02.81; the runs after it were not re-timed, so that is the only wall clock measured here, and the source job's 25-minute timeout is not close either way. Compose gate on Linux: 185 passed, 0 failed (27 before the geo-pin and alerting assertions, 41 before the alert-edge ones, 47 before the pillar-health ones, 53 before the write-health ones, 63 before the ban-write ones, 72 before the scenes were made non-vacuous, 74 before the query surface was refused rather than dropped, 81 before the retry loop, 86 before the write-endpoint guard, 94 before the streak map learned the source filter, 100 before the policy bounds were driven from the image, 107 before the redirect target an edge cannot send was refused by the image, 113 before the provenance a caller mistyped and the bounds an entry has were refused by the image, 132 before the image said which part of a listing it is and how far it reached, 165 before the image refused a country code that is not a code, 184 before the ban scene stopped reading the pillar at one instant, and 185 before an operator command that could not run was asked of the shipped image), enforcement lag 0 ms, 12 ms and 36 ms in three runs, 12 ms at a77ab53, 13 ms at 6e6461a, 11 ms at c97c7a1, 12 ms at 7e081da, 12 ms at 7b57c56, 14 ms at 1bcc086, 12 ms at 336c2f7, 13 ms at dcf8a73, 11 ms at ac672d9, 17 ms at 17b764e, 12 ms at cfe47d1, 30 ms at b75888f, 56 ms at 24e329d, 29 ms at d871d57, 18 ms at 5c44b7c, 15 ms at 9383362, 44 ms at 0f17d32, 20 ms at dc88f36. One Linux run at d871d57 answered 112 passed, 1 failed — the geo-restore assertion got 000, which the gate prints for a request that blew its 10 s budget, for a container that had exited and for any other curl error, all as the same three characters — and the run after it was 113/0; the Linux runs at 5c44b7c, 9383362, 0f17d32 and dc88f36 were 113/0, 132/0, 165/0 and 185/0, so it has not reproduced in the six runs since. Filed as OPEN-39 rather than smoothed over: a gate that fails once for an unexplained reason makes the next real regression indistinguishable from it. The same class showed up again in the same cycle: in one run the ban-write scene read banWriteFailures as 0 while that same scene logged "the ban was not persisted" three times and answered /readyz 503 with the storage error quoted. Filed as OPEN-42. The read side of that is fixed: the scene now polls the pillar for up to 20 s and prints the trajectory (failures/notWritten: 0/0 1/1 ...) and the reason string it quoted, so "the counter is 0" and "the field is not in the answer" are no longer the same word in the log, and the wait itself is an assertion (the ban pillar reached its failure state within the wait budget). Breaking it on purpose — threshold 3 → 99, so no ban is ever attempted — answers 178/7 with that assertion first (/tmp/c25_mutD_banteeth.log). What OPEN-42 still owns is the product half: the pillar is only updated on the request path, so a quiet edge reports a stale failure count for as long as it stays quiet. Console gate on Linux: 70 assertions, 0 failed — described below, 0 containers left behind. scripts/geo-db-freshness.sh was run in mcr.microsoft.com/dotnet/sdk:10.0 too: current pin answers 0, and a forced PIN=2026-05 answers 1 with the bump command, so the gate that decides whether the geo database is current behaves the same on the runner's OS.

Getting the compose stage green surfaced two things about the harness rather than the product, both now written into the script. The gate asserts over JSON with python3: a bare container failed 23 of 27 assertions for nothing else. And the stack the host daemon publishes lives in the host's network namespace, so without EDGE=http://host.docker.internal:8080 every HTTP assertion returns curl code 000 while the image's own HEALTHCHECK says healthy — a green stack with red assertions, the most confusing failure this gate can produce.

The console gate needs a real Chromium, so it runs in mcr.microsoft.com/playwright:v1.63.0-noble: scripts/console-smoke.sh with SEED_ONLY=1 starts and seeds the stack from docker:cli, the browser image drives scripts/console-check.cjs against EDGE=http://host.docker.internal:8080, and the stack is torn down afterwards. That image ships the browsers but not the npm package, so the script installs playwright-core into /tmp and points PLAYWRIGHT_CORE at it, mounting the repository read-only so the install never lands in the working tree. Rehearsed the same day on Linux 7.0.12-linuxkit aarch64, node v24.20.0, chromium-1243: 70 assertions, 0 failed, including the round-trip the page alone cannot fake — a ban drawn on the page answers 301 on the next request from that address. The driver also refuses to report success when the markup seed never reached it: unsetting SEED_MARKUP_PATH and SEED_MARKUP_BLOCK used to drop four assertions to 65 ok / 0 failed and still print "all assertions passed"; the same run now exits 1 naming both empty values, and the Linux rehearsal refuses the stage outright. The gate is still a sampler, though: at ff70c64 a host run answered 68 ok, 2 failed — the click-a-source-key assertion read the observation table after the filter had applied and found nothing recorded for that key — and the run after it was 70/0 on the same tree. Recorded on OPEN-41 rather than smoothed into the re-run: same root, an assertion that reads a table once while the row it wants arrives on a coalesced write. All three scenes in one cold run: 2:14.33 (measured at that earlier commit; the stage has not been re-timed since).

Running that stage with the console job's own environment (COMPOSE_PROJECT_NAME=openwafci-console, EDGE_PORT=8090) turned up a bug in the stage itself: its cleanup container passed no project name, so it tore down the stack named after the repository directory — nothing — and left the CI-named one running, holding its port, behind a summary line that said PASS. 53 assertions green, 2 containers still up. Passing the name through is 7e081da; the stage re-run after it leaves 0 containers.

Honest status of the workflow itself: it has never executed on a GitHub-hosted runner, because the repository has no remote. It has been executed start to finish by a local Actions-compatible runner — nektos/act 0.2.89 on catthehacker/ubuntu:act-latest, most recently at dc88f36 — 5 jobs succeeded, 0 failed: lint (both pinned tools download, verify their checksums and find nothing), source (unit 132/132, integration 173/173, smoke 28/28), image (openwaf:ci 261 MB, compose smoke 185 passed / 0 failed), console (70 assertions / 0 failed with playwright@1.63.0 and chromium-1243, screenshot artifact published, 685,222-byte zip) and the freshness job (pin 2026-10 = newest 2026-10). The two act runs before that one failed, and both failures were real: lint refused three SC2086 findings in the new compose scene, which a local shellcheck -S warning had passed over in silence — the workflow pins 0.11.0 and runs with no severity filter, and no local gate runs lint at all (filed as OPEN-44); and in the run after the fix, image died on a TLS handshake timeout to auth.docker.io while console read an empty observation listing (X-Total-Count: 0) in a run where the same table had 11 rows a minute earlier (filed as OPEN-43). That is a stronger claim than "the steps were run by hand", and a weaker one than "CI is green": it proves the YAML executes and the pinned tools resolve, not that GitHub's image agrees. The gap is not hypothetical — running the file that way is what turned lint red, because ubuntu-latest ships shellcheck 0.9.0-1 while developers run 0.11.0, and the two disagree about one line of scripts/geo-db-bump.sh (SC2015). Both halves are fixed: the script is an explicit if, and the version is pinned with a checksum in the workflow.

What this deliberately costs

Stated, because a defence that hides its failure modes is not a defence.

  • One shared IPv4 egress is one source. An office behind one address can accumulate a ban. Mitigations: the streak is consecutive (one honest click resets it), the allowlist outranks every pillar, and the ban explains itself so an operator can undo it in one call.
  • IPv6 is grouped to /64. A subscriber holds a whole /64, so a bot rotating addresses inside one allocation is one source; a per-address v6 rule is unenforceable. A wider prefix over-blocks, which is worse.
  • Geo is a probabilistic claim about an address, not a fact about a person. The 451 body says so. The database is pinned by a build argument and ages with the image, so /healthz reports its build date and geoStale.
  • Streak state is per process, and that is measured, not assumed. Round-robin over two edges multiplies the effective threshold by the instance count: four refusals from one address, two per edge, at a threshold of 3, produced no ban at all. A block issued by one edge is enforced by the other after up to OpenWaf:State:RefreshTtlSeconds (23.7 s measured at ~36 req/s). The block list is already shared through the database; the streak map is not. Numbers, method and caveats: research/2026-10-01-multi-instance/RESULTS.md.
  • Aggregates, not a request log. source_observations keeps counters and the last-seen evidence per source, and ages out after OpenWaf:Policy:ObservationRetentionDays (default 7, 1–365). Raw IPs are not logged.

Shape

dotnet/
  OpenWaf.Domain/          pure decision core: source key, streak, ordered decision
  OpenWaf.Infrastructure/  EF Core (sqlite/postgres), snapshot store, writers, MMDB geo
  OpenWaf.Edge/            the deployable: guard, observer, admin API, healthcheck mode
  OpenWaf.Tests.Unit/      132 tests over the decision logic and the durability counters
  OpenWaf.Tests.Integration/  173 tests driving the real pipeline against a fake upstream
scripts/smoke.sh           28 assertions against a running edge + a real upstream
scripts/compose-smoke.sh     209 assertions against the built image (compose + nginx)
scripts/console-check.cjs    75 assertions against the page, in a real Chromium
scripts/geo-db-freshness.sh  the pinned geo database vs the vendor (0/1/2)
.github/workflows/ci.yml   runs the gates on every push
.github/workflows/geo-freshness.yml  the same check on a schedule
docs/ARCHITECTURE.md       the design authority and its rulings

Two protections are inherited from the reference deployment rather than rediscovered, and both are load-bearing: at most one durable write per source per 30 s, and a hard LRU bound on the in-memory map, so a scanner farm cannot grow the process or tax the database.

S
Description
No description provided
Readme
3.2 MiB
Languages
C# 76.3%
Shell 16.5%
JavaScript 6%
Python 0.9%
Dockerfile 0.3%