153 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 1e0d11df1c the first query moves off ef, and the aot edge reads its own policy from the database
ci / build, test, smoke (push) Failing after 3m33s
ci / the same smoke on an image with no base (push) Successful in 8m10s
ci / lint the workflow and the shell (push) Failing after 19s
ci / the operator page in a real browser (push) Successful in 4m41s
ci / build the image and smoke it (push) Failing after 8m11s
Wall 3 starts. Two projects, one query path, measured.

dotnet/OpenWaf.Data is the runtime: OrmContext (a DbDataSource plus an
ISqlDialect), Query<T>, RowReader, OrmMeta. It is typed over System.Data.Common
and carries no provider package; the driver is supplied at composition, which is
how the neighbouring deployment ships it too. Query<T> renders SQL by walking the
expression tree rather than compiling it — that is the exact difference from EF's
pipeline, and the reason it survives a NativeAOT link where EF does not. The
supported grammar is a closed set that refuses by name: joins, subqueries,
aggregates other than COUNT, updates, deletes, JSON columns and method calls each
raise UnsupportedQueryNodeException naming the node, because a renderer that
guesses is a renderer that ships wrong SQL.

dotnet/OpenWaf.Data.Generator is a Roslyn incremental generator attached to
OpenWaf.Infrastructure as an analyzer. For a [Table] class it emits the column
map, the row materializer and an OrmMeta.Register call inside a
[ModuleInitializer], so the question a NativeAOT binary cannot answer — what are
this type's properties — is never asked. The generated file is ordinary C#,
readable in obj/ and asserted against.

PolicySetting is the entity moved and EdgePolicyProvider.ReloadAsync the call
site, which was the first refusal in the probe log. Program.cs composes the
driver and dialect on the same Database:Provider switch EF uses, so one generated
query serves sqlite (the shipped image) and PostgreSQL (the migrations'
provider). EF still owns every write and every other read; the two layers
coexist on one composition root, which is what makes this incremental rather than
a rewrite.

Measured on the AOT binary, same probe, same window, before and after:
queries refused at run time 32 -> 18; EdgePolicyProvider reload failures 1 -> 0;
native binary 49,609,680 -> 49,676,016 bytes. The 18 that remain are named by
their own frames: 14 EdgeStateStore.RefreshAsync, 2 BlockStore.WriteBanAsync,
1 BlockStore.AddOperatorAsync, 1 admin endpoint.

The sqlite timestamp column turned out to be a contract, not a detail. The model
puts EF's DateTimeOffsetToBinaryConverter on every timestamp column, so every row
already written says (localTicks / 1000) * 2048 + (offsetMinutes & 2047); the
formula was derived by probing EF's converter and is now pinned by
SqliteTimestampEncodingTests against that converter over five instants including
+05:30, -05:00 and DateTimeOffset.MinValue — including the microsecond
truncation the /1000 imposes, which is EF's behaviour and is now a test rather
than a future surprise.

Two build traps, both paid for and both recorded where the next person will hit
them. -p:PublishAot on the command line is a global property, so it reaches every
project in the graph including a netstandard2.0 Roslyn analyzer, and the publish
dies with NETSDK1207; AOT is now switched by OpenWafAot=true, which only
OpenWaf.Edge.csproj turns into PublishAot — the same shape as the existing
OpenWafCompiledModel switch. And a raw Microsoft.Data.Sqlite data source needs
SQLitePCL.Batteries.Init() before its first open, because the order in which
EF's provider and this data source are first used is not guaranteed.

Gates on this tree: build 0 warnings, unit 391/391 (13 new: rendered SQL for both
dialects, null tests, the captured-null case, the refusals, the timestamp
encoding), integration 408/408, smoke 256/256, and the AOT probe above. One
earlier run of the 408 carried a single failure in AdminConsoleTests at a host
load average near 30 and the next run was clean; recorded rather than hidden, in
the same family as the load-sensitive compose gates this README already
documents.
2026-10-07 21:48:01 +02:00
Pavlo Ratushnyi 0a3d28184f the aot edge serves traffic now, and the shape still missing a contract was its own healthcheck
ci / lint the workflow and the shell (push) Failing after 54s
ci / build, test, smoke (push) Successful in 6m4s
ci / the operator page in a real browser (push) Failing after 4m53s
ci / build the image and smoke it (push) Failing after 10m29s
ci / the same smoke on an image with no base (push) Failing after 9m2s
Measured on this tree with scripts/aot-probe.sh (osx-arm64, a 49,609,680-byte
native binary, 10 IL warnings, 0 errors): the AOT edge reaches "Now listening
on:", creates its 12 tables from the DDL it carries, proxies a request to the
upstream for 200, and its own --healthcheck mode exits 0. The API wall that
stood between the first cut and a serving edge came down in two edits, and the
json-refusal count went 55 -> 1 -> 0.

The 55 were one shape. The anonymous 8-property /healthz literal had no
compiled contract, so the edge was serving traffic while the endpoint a scratch
container's HEALTHCHECK asks answered 500 - an edge that serves and is restarted
anyway. Health/HealthDtos.cs names it (HealthDto, ReadinessDto). The 1 after
that was Microsoft.AspNetCore.Mvc.ProblemDetails, the body Results.Problem
writes and nobody's DTO in this project: its visible cost was a /readyz 500
naming nothing where a 503 naming the failure is the truth. It now says
"Query wasn't precompiled and dynamic code isn't supported with NativeAOT."

The probe's scoreboard is split the way the finding is. Three assertions that
need no query are gated (healthz 200, proxy 200, --healthcheck exit 0), and the
host must be listening with no response refused for want of a contract. Five
that do need a query are recorded with the answer a working edge would give -
operator block 503 where 204 is right, the streak ban never forms, /readyz 503
where 200 is right - and any of them that ever matches prints MOVED, which is
the signal that the query wall moved. queries refused at run time: 32 in that
window, 30 in the run before it; it counts a window, not a total, because the
background refresh loop retries on its own clock.

Two probe bugs surfaced doing this. It sent "Authorization: Bearer" to the admin
API, which AdminAuth does not read, so three of its assertions were measuring a
401 rather than the query wall; and it asserted nothing about whether the host
had listened at all.

Gates on this tree: build 0 warnings, unit 378/378, integration 408/408 in 51 s
(the new one demands a contract for ProblemDetails and ValidationProblemDetails),
smoke 256/256.

Two stale figures corrected rather than left standing. The registered-type count
was 24 in README and ARCHITECTURE while the file at that commit holds 25 -
CountrySummaryDto arrived without the count being re-derived - and it is 29 now.
The anonymous-literal count is 29 in 23 shapes: 22 response shapes, and 7 inside
an EF query's Select, which belong to the query wall rather than this one. The
"48.8 MB" native binary in ARCHITECTURE matches no measured binary of this tree.
2026-10-07 19:28:22 +02:00
Pavlo Ratushnyi 5c1a2950d0 two more wire shapes stop being anonymous, and the count of the ones left gets re-measured
ci / lint the workflow and the shell (push) Successful in 22s
ci / build, test, smoke (push) Successful in 4m36s
ci / the operator page in a real browser (push) Successful in 4m48s
ci / build the image and smoke it (push) Successful in 8m34s
ci / the same smoke on an image with no base (push) Failing after 8m44s
`countries/summary` answered with a `List<anonymous>`: the anonymous shape is what
EF translates — the record-constructor form compiles and then fails at query time
with "could not be translated", which is a test's finding, not a guess — so the
projection stays inside the query and the *response* becomes a named record,
`CountrySummaryDto(Code, Sources, Refusals)`, mapped after `ToListAsync` with the
sort left where it was. Registered in `EdgeJson`. `Code` stays nullable in the
model and non-null in these rows: the query filters `LastCountryCode != null`,
which the compiler cannot see and EF does apply. The second literal is one the
first pass missed because it spans three lines — a `Results.BadRequest` whose body
was `new { error = … }`, now `ErrorDto`.

The counts in `README.md` and `docs/ARCHITECTURE.md` are corrected, and the
correction is stated rather than quietly applied: `fb75890` records **130
anonymous-object literals in 51 shapes**, and its message repeats that. Those two
figures came from a first-pass scanner that walked braces without skipping string
literals, so every `{` inside an interpolated string was counted as code. The same
tree re-measured with a scanner that skips strings, char literals and comments:
**144 literals in 27 shapes** before this change, **31 in 25 shapes** after it.
The **111** that became `ErrorDto` is the one figure both scanners agree on, which
is why the first commit still moved the wall it claimed to move.

Measured on this tree: `dotnet build OpenWaf.Edge -c Release` 0 warnings, unit
**378/378**, integration **407/407 in 34 s** (unsandboxed; the sandboxed run of
this suite is not a measurement — see the loopback-bind note in the README).
2026-10-07 09:06:57 +02:00
Pavlo Ratushnyi fb758900b8 the admin API's error body stops being anonymous, and the AOT build prices a reflection resolver
Wall 2 of the generator slice (OPEN-79) is the web host, not the database: the
AOT edge never reaches `Now listening` because the admin API's request DTOs have
no compiled JSON contract, and a NativeAOT binary has no reflection resolver to
fall back on. The wire shapes have to be types before a contract can exist for
them, so this starts with the shapes.

Counted in `dotnet/OpenWaf.Edge` before the change: **130 anonymous object
literals** in the JSON path, in **51 distinct shapes**, of which **111 are the
one shape `new { error = … }`**. Those 111 are now `ErrorDto`, and the two
read-only-token refusals that carried a second property are `ReadOnlyRefusalDto`.
`ErrorDto.Error` is nullable because the literal it replaces was — the
unknown-query-parameter validators hand back a `string?` next to the false they
return, and making it non-null would hide a second change inside a mechanical
one. `Admin/EdgeJson.cs` is the edge's `JsonSerializerContext`: 24 registered
types (5 request bodies, the 14 response records the tree already had, the two new
ones, the config-transfer document and its rejected-item row), with
`[JsonSourceGenerationOptions(PropertyNamingPolicy = CamelCase)]` because the
generated contract carries the property names — without that line the same record
answers `{"Error": …}` and the console, the smoke gate and every integration
assertion read a body with no error in it. The recipe is the neighbouring
deployment's (`app/lib/Kernel/KernelJson.cs`, `api/Domain/AppJson.cs`, one line in
its `Program.cs`), not an invention here. **18 anonymous literals in 50 shapes
remain**; they are the rest of the wall, and this commit does not pretend
otherwise.

Two measurements decided the wiring, and both were paid for:

  * A non-empty `TypeInfoResolverChain` **replaces** the reflection resolver, it
    does not extend it. With only the context in the chain, a type it does not
    know fails on a *JIT* build with the sentence the AOT probe reports —
    `JsonTypeInfo metadata for type '<>f__AnonymousType0`1[System.String]' was not
    provided by TypeInfoResolver of type '[EdgeJson]'` — reproduced with a
    standalone probe. So on a build that can reflect, reflection stays at the end
    of the chain: the 18 remaining literals kept served and visible rather than a
    break smuggled into a slice.
  * That fallback is not free on the other side. Naming `DefaultJsonTypeInfoResolver`
    in an AOT publish pulls the reflection-based JSON stack into the native image:
    the publish step ran **66 minutes and never finished**, against **232 s** for
    the same Dockerfile an hour earlier. The branch is now gated on
    `RuntimeFeature.IsDynamicCodeCompiled`, which the AOT compiler substitutes as
    a constant, so the shipped binary contains neither the branch nor the resolver.
    The 66-minute figure was taken at load average 26–34 against the earlier run's
    ~12, so that ratio is an upper bound, not a clean A/B; the weekly runner is
    where the clean number will come from.

`AotJsonContractTests` (2 new) asks the running edge which body types its
endpoints accept — `IAcceptsMetadata`, read from the live `EndpointDataSource`,
with the measured count of 5 asserted so the guard cannot pass on an empty set —
and demands a compiled contract for each; the second test asserts the generated
contract really says `error` and `tokenLevel`. An endpoint added without a
contract is therefore red in the suite, not in next Monday's probe.

Measured on this tree: `dotnet build OpenWaf.Edge -c Release` 0 warnings, unit
**378/378**, integration **407/407 in 2 m 16 s** (unsandboxed). The same suite run
inside the sandbox answered **8 failures of 407**, every one of them `Timed out
waiting for the entry point to build the IHost after 00:05:00` — the loopback-bind
symptom the README already recorded on 2026-10-04 and 2026-10-05, reproduced here
rather than re-diagnosed; the 407 figure is the unsandboxed one.

NOT measured on this tree: whether the AOT edge now reaches `Now listening`. The
rebuild that would answer it was interrupted, so the README and
`docs/ARCHITECTURE.md` say so in those words, and `.github/workflows/aot-probe.yml`
now prints `lines where the edge started listening` — 0 means the host still dies
before serving, 1 means it serves. The 18 remaining anonymous shapes are what
stands between the two.
2026-10-07 08:35:51 +02:00
Pavlo Ratushnyi 0a2cbee558 sqlite is baked into the static link, and the AOT probe now names two walls instead of one
The probe used to report one wall: the binary died in
`Microsoft.Data.Sqlite.SqliteConnection..cctor` with `DllNotFoundException:
e_sqlite3` / `Dynamic loading not supported`. That sentence described a build that
did not link sqlite at all. Two musl-only items in `OpenWaf.Edge.csproj` close it
— `NativeLibrary` puts Alpine's `sqlite-static` `/usr/lib/libsqlite3.a` on the
link line, `DirectPInvoke` makes ILC emit a direct call to the symbol instead of a
run-time module load — and `Dockerfile.aot-probe` installs the package.

Both items are needed, and the order was measured, not guessed. With
`NativeLibrary` alone the link is still fully static (0 interpreters, 0 NEEDED) and
the binary still calls `NativeLibrary.Load("e_sqlite3")` at the first query and
NativeAOT refuses it. The pair is what the runtime pack itself uses for
`System.Native` and the OpenSSL shim (`Microsoft.NETCore.Native.Unix.targets`
140-155), so this is the SDK's mechanism rather than a fork of it.

Measured on the arm64/musl half, this host, 2026-10-06: 58,343,456-byte
`static-pie linked` binary, `readelf -l` 0 interpreters, `readelf -d` 0 NEEDED,
96.4 MB scratch image, and a log with 0 `e_sqlite3` lines that says the edge
created 12 tables from the DDL it carries. Two standalone probes with the same
link say the same thing one level down: direct P/Invoke to sqlite3 opens
`:memory:`, writes two rows and reads `2` back (sqlite 3.53.4); and
`Microsoft.Data.Sqlite` — the ADO layer this tree already uses — opens a
connection and reads `sqlite_version()` back. So the ADO layer survives and only
EF's query compilation is left standing.

The check that sqlite is inside the binary is behavioural, and had to be: the
binary is stripped and `nm` reports 0 `sqlite3_` symbols on a binary that
demonstrably runs sqlite. No tool that only reads the file can answer this.
`.github/workflows/aot-probe.yml` therefore gates four things after the link — no
interpreter, no NEEDED, no `e_sqlite3` line, and the schema line as the positive
half, because a gate that only forbids an error string also passes when the
feature is simply absent. The step was run verbatim against the real artifact
before committing (exit 0), and both failure branches were tested against a
doctored log. It also had a bug caught by that run: it read the log after a fixed
20 s sleep and reported "no schema" on a loaded host, so it now waits up to 180 s
and prints how long it waited — measured 6 s on a quiet host, past 22 s under
load, 3 s in the verification run.

What the probe reports now, which is what closing the first wall buys:

  * hosting refuses to start — `JsonTypeInfo metadata for type
    'OpenWaf.Edge.Admin.NewBlockRequest' was not provided by TypeInfoResolver`,
    3 refusals. The route handlers in the stack are already the generated ones
    (`GeneratedRouteBuilderExtensionsCore`), so the API half is not missing code
    generation; it is missing a registered JSON contract for the admin DTOs.
  * every query is refused — `Query wasn't precompiled and dynamic code isn't
    supported with NativeAOT`, 2 refusals. That is EF's precompiler, whose four
    untranslatable shapes and codegen bug `docs/ARCHITECTURE.md` already carries.

Also measured: `dotnet build OpenWaf.Edge -c Release` (non-musl) 0 warnings, unit
378/378 — the two items are conditioned on the musl RID and the shipped images do
not take this path. Not measured here: the x86-64 musl half, because the musl ILC
crashes under emulation on Apple Silicon; the weekly workflow is the only place
that number exists, and it now carries this gate.
2026-10-06 22:45:59 +02:00
Pavlo Ratushnyi 925fc62d4b the gate's claim about its own writes was false, and the gate now counts it
ci / lint the workflow and the shell (push) Successful in 8s
ci / build, test, smoke (push) Successful in 1m45s
ci / the operator page in a real browser (push) Successful in 2m12s
ci / the same smoke on an image with no base (push) Successful in 4m20s
ci / build the image and smoke it (push) Successful in 4m20s
a8f440b wrote that the gate's admin writes go through `admin_write`. Measured
against the same file an hour later: of its 60 writes that do not go through
`admin`, 34 did — 25 still answered through the un-retried `code` and one went
straight to `curl`. The other 91 writes and 157 reads went through `admin`, which
carried no part of OPEN-39's rule at all: a read that reached nothing answered
NO_JSON_BODY and the log said nothing about why, because the sentinel names the
missing body, not the missing request. The dead-edge scene asserted the opposite
of the fix — that those dead reads write no line to stderr — so the gate was not
only un-instrumented there, it was guarding the missing instrument.

Call sites, counted on this file with comment lines excluded: 261 `admin` (91
writes, 157 reads, 8 carrying -D/-o/-w), 59 `admin_write`, 139 `code`.

What changed:

  * `curl_retry` puts OPEN-39's rule under the body-returning helpers. A transport
    failure is retried three times and each retry prints the container it sampled;
    an HTTP answer — 400, 403, 500 — is an answer and comes back after one attempt.
    `admin` and a new `body`, for the scenes that carry their own token, sit on it.
  * the body comes back byte for byte. `$(curl ...)` strips trailing newlines and
    the six-parallel-POSTs scene writes six `%{http_code}` lines into one shared
    file; a wrapper that re-printed carelessly would have turned that assertion
    into "204204204204204204". The exit status rides in on a marker suffix instead
    of riding on the output.
  * the 25 and the 1 joined `admin_write`.
  * the dead-edge assertion asks for the nine diagnosis lines and for the absence
    of a traceback instead of for silence. It also carried the bug that hid the gap
    for one run: `a | b 2>f` captures only b's stderr, so the first version read
    back an empty file while the nine lines went to the terminal.
  * the claim is now a gate: the file greps its own source and goes red, printing
    the count, if any write answers through the un-retried status helper or goes
    straight to curl — and fails closed when it cannot read itself.

Three assertions added, one removed: 375 -> 379.

Measured. compose-smoke 379 passed / 0 failed at load average 12 (21:07,
/tmp/compose-retry2.log); that run is one comment rewrap away from this text, and
the two self-audit greps were re-run against the committed file and answer 0 and 0.
readme-counts agrees against that run's totals (379=379, exit 0). shellcheck 0.11.0
and bash -n clean. The retry was again proved against a stub rather than a caught
flake: unreachable twice then a body -> two diagnosis lines and the body's trailing
newline intact (xxd: 610a 620a); always unreachable -> three lines and an empty
body; a 400 -> none; a body ending in `x` -> returned unchanged.

Not measured green: this text against the scratch image. The shared host has held
load average 26-72 since 21:10 and four runs of this tree went red on it — 375/4
at load 31, 377/2 at load 39, 378/1 at load 48 — with every failure in a scene that
reads a projection right after a write that was answered: the two alert-escalation
scenes, and once "the shipped story names the block, the covering range and the
exemption, oldest first" in a run where both alert scenes were green. No `000` near
any of them, and the same tree at load 10-12 was 379/0. That is OPEN-78, filed
today; the README's Gates section now carries those red numbers instead of a green
one it does not have.
2026-10-06 21:49:08 +02:00
Pavlo Ratushnyi a8f440b933 a write that never reached the edge stops taking four assertions down with it
ci / lint the workflow and the shell (push) Successful in 10s
ci / build, test, smoke (push) Successful in 2m17s
ci / the operator page in a real browser (push) Successful in 2m41s
ci / build the image and smoke it (push) Successful in 4m48s
ci / the same smoke on an image with no base (push) Successful in 4m43s
Measured 2026-10-06 (/tmp/compose-diag.log, recorded in the README's Gates
section): one POST of a /29 answered 000 while the edge container reported
running/healthy — the gate could not reach a live edge, with another project's
dotnet suite running on the same daemon — and four assertions about a range went
red about a row that was never written. One of those four was worse than red: a
bare `next()` over the block listing raised StopIteration into the log, the
OPEN-48 shape again in a third place.

OPEN-77 asked which rule the gate should have here. The rule it has now: a write
whose request got no answer at all is retried, three times, and each retry prints
the container's own state; a refusal is an answer, so 400 and 403 come back after
one attempt untouched; and the retry is bounded, so a surface that is really
closed still goes red rather than spinning. Retrying a write that got no response
is safe on this surface because every write it takes is keyed and idempotent —
the six-parallel-POSTs scene asserts that one address lands as one row, the
transfer scene asserts that importing the same document twice adds nothing — and
both of those are assertions, not assumptions.

All 33 admin writes in the gate now go through admin_write; the three bare
next() reads answer no-pillar / no-record / no-such-row instead of tracebacks;
and the dead-edge scene asserts the retry against a container that is really
stopped: the write still answers 000, and it says so three times. Two assertions,
373 -> 375.

Measured here: compose-smoke 375 passed / 0 failed against the chiseled image and
375 / 0 against the scratch image, same arm64 host; readme-counts agrees
(375=375); shellcheck 0.11.0 clean over scripts/*.sh. Against a stubbed `code`
that answers 000 twice and then 204, admin_write returns 204 after three attempts
with two retry lines; a 400 comes back after one attempt with none. Neither green
run printed a retry line — the host was quiet — which is why the rule is asserted
by a scene that stops the edge rather than by waiting to catch another flake.
2026-10-06 20:43:53 +02:00
Pavlo Ratushnyi 179e0f51a0 two compose-gate assertions reported a pass about an edge that had never started
ci / build, test, smoke (push) Successful in 3m54s
ci / the same smoke on an image with no base (push) Successful in 4m2s
ci / lint the workflow and the shell (push) Successful in 7s
ci / the operator page in a real browser (push) Successful in 2m23s
ci / build the image and smoke it (push) Successful in 4m1s
The NativeAOT measurement run of 2026-10-06 (/tmp/aot-smoke.log, the tree that
became d08ec30) is a run against an edge that dies at start-up, and the gate
answered it with 125 Python tracebacks, 32 `integer expression expected` shell
errors, `docker: volumes-from specification cannot be an empty string` 6 times
and `invalid container name or ID: value is empty` 121 times. Two assertions came
back `ok` in that run — `the state counts a policy pillar that cannot read its
table yes`, printed directly under `policy reload failures counted after the
table went away: NO_JSON_BODY`, and the same pair for the observation pillar —
because the comparison was `!= "0"` and a value that was never read is not the
string `0`. OPEN-48 fixed exactly this shape for jval; jcount and jget never got
it, and the `!= 0` sites were worse than the tracebacks: a green assertion about a
dead process.

jcount now answers -1 for a body it cannot read — the sentinel streaks_where has
used since it was written — and jget answers the NO_JSON_BODY jval prints. Every
count comparison goes through is_count/count_ge/count_gt/count_moved/count_sub,
so a value that is not a run of digits is "not read" rather than a number or the
shell's problem, and a delta whose either side was not read prints -1 where a
misleading 0 used to sit. The sidecar names the edge container it cannot share a
volume with instead of handing docker an empty --volumes-from, and the health wait
answers `no-container` instead of asking docker about an empty id once per
half-second. The dead-edge scene asserts all of it against a container that is
really stopped rather than a canned string: the three helpers answer their
sentinels, a comparison on a value that was never read answers no, and none of
those reads or comparisons wrote a line to stderr. Five assertions, 368 -> 373.

Measured here: compose-smoke 373 passed / 0 failed against the chiseled image and
373 / 0 against the scratch image, same arm64 host; the five new assertions were
green in all four runs of the gate today, including the two that went red
elsewhere. `readme-counts` agrees (373=373). shellcheck 0.11.0 clean over
scripts/*.sh; actionlint cannot run on darwin and the lint gate says so with exit
2 — the ci.yml change is a comment.

Two of those red runs are recorded in the README rather than smoothed: one lost
four alert assertions, the other five range assertions, and the second names its
own cause (`curl answered 000 … the edge container reports running/healthy`,
another project's dotnet suite running on the same daemon, load average 11). The
new arithmetic separates the two shapes a red alert scene can mean — a read that
did not parse prints -1, a row that is not there yet prints 0 — and both runs
printed 0.
2026-10-06 19:55:25 +02:00
Pavlo Ratushnyi e81f27e931 the AOT probe clears the container a dead run left on the shared daemon
ci / the same smoke on an image with no base (push) Successful in 3m58s
ci / lint the workflow and the shell (push) Successful in 8s
ci / build, test, smoke (push) Successful in 2m6s
ci / the operator page in a real browser (push) Successful in 2m21s
ci / build the image and smoke it (push) Successful in 4m13s
Run 2507: the static-link gate went green on x86-64 — `image size: 94.5MB`,
`binary bytes: 56351320`, `file says: … x86-64 … static-pie linked, stripped`,
`program headers naming an interpreter: 0`, `NEEDED shared objects: 0`,
`static: no interpreter, no NEEDED shared object`. The reporting step then died
at exit 125 on `Conflict. The container name "/aotprobe" is already in use` —
runs 2501 and 2503 aborted before their own teardown and left the container on a
daemon every later run shares. The step now removes the name before starting and
treats its own teardown as best-effort.
2026-10-06 09:42:44 +02:00
Pavlo Ratushnyi cbafca491b the static-link gate asks the binary, not the build log, because a cache prints nothing
ci / lint the workflow and the shell (push) Successful in 10s
ci / the operator page in a real browser (push) Successful in 2m36s
ci / the same smoke on an image with no base (push) Successful in 4m4s
ci / build the image and smoke it (push) Successful in 4m4s
ci / build, test, smoke (push) Successful in 2m19s
Run 2503 turned a good artifact red: the publish layer was cached, the report
layer was cached with it, the build log carried no report lines, and the gate
that greps that log found nothing to match. The report is now a script
(scripts/aot-link-report.sh) that the build stage copies in and runs, and that CI
runs again with `docker run --entrypoint sh … /report.sh` — a container start is
never cached, so the gate asks the binary. It exits non-zero when the link names
an interpreter or needs a shared object, which is the one claim a scratch layer
depends on.

Verified here: the script prints `binary bytes: 56820992`, `static-pie linked`,
`program headers naming an interpreter: 0`, `NEEDED shared objects: 0`,
`static: no interpreter, no NEEDED shared object`, exit 0 — both as a build step
and as a `docker run`. .dockerignore keeps `scripts/` out of the context and now
makes one named exception for it.
2026-10-06 09:35:16 +02:00
Pavlo Ratushnyi 5278eb4ac2 the smoke gate waits for the engine's async ban, and the AOT probe reports instead of dying
ci / lint the workflow and the shell (push) Successful in 7s
ci / build, test, smoke (push) Successful in 1m35s
ci / the operator page in a real browser (push) Successful in 2m27s
ci / the same smoke on an image with no base (push) Successful in 4m18s
ci / build the image and smoke it (push) Successful in 4m19s
Run 2500 went red on one assertion — `the two bans the edge wrote are inside one
block: expected 2, got 0` — while the same code was green at 149b2c0 (run 2482).
The engine's bans leave the request path through the durable writer, so the
listing is eventually consistent, and this host had a load average over 100 while
the writer had not run yet. The count is now polled until it answers twice,
bounded at 20 s, so a ban that never arrives still fails the gate. Locally after
the change: passed 256, failed 0.

Run 2501 is the x86-64 half of the AOT measurement and its gate passed there:
RID linux-musl-x64, `binary bytes: 56351320`, `file says: … x86-64 … static-pie
linked, stripped`, `program headers naming an interpreter: 0`, `NEEDED shared
objects: 0`, `image size: 94.5MB`. The job still went red one step later, on the
reporting step: `grep -c` exits 1 when it matches nothing, and a zero count of
refused queries is a finding rather than a step failure. Both greps now report
instead of aborting.
2026-10-06 09:25:14 +02:00
Pavlo Ratushnyi d08ec30e0a the AOT edge links fully static and dies on sqlite, which names the wall exactly
ci / lint the workflow and the shell (push) Successful in 10s
ci / build, test, smoke (push) Failing after 2m11s
ci / the operator page in a real browser (push) Successful in 2m29s
ci / build the image and smoke it (push) Successful in 4m15s
ci / the same smoke on an image with no base (push) Successful in 4m15s
Dockerfile.aot-probe applies the packaging recipe a neighbouring .NET 10 service
already ships — musl RID, StaticExecutable, StaticOpenSslLinking, IlcSingleThreaded,
scratch plus a CA bundle — and the link claim is checked inside the build rather
than asserted in a comment. Measured here (arm64, native): `file` says
`static-pie linked`, `readelf -l` reports 0 program interpreters, `readelf -d`
reports 0 NEEDED shared objects, the binary is 56,820,992 bytes and the image is
94 MB — against 222 MB for the self-contained scratch image and 262 MB chiseled.

It does not serve, and the reason is one step earlier than the query wall:
`Microsoft.Data.Sqlite.SqliteConnection..cctor` throws `DllNotFoundException:
e_sqlite3` with `Dynamic loading not supported`, because SQLitePCLRaw resolves
sqlite by loading a shared library and a NativeAOT binary has no way to load one.
`scripts/compose-smoke.sh` against that image therefore never gets past
readiness: the container reports exited/unhealthy and every curl answers 000.
Behind that sits the EF precompiler wall measured at 7c5e1ef and today.

So the static scratch shape is reachable for this program and the data layer is
the thing in the way. The deployment that ships it has no EF Core and no SQLite:
Npgsql plus a Roslyn source generator that emits queries at build time
(app/lib/MicroOrm there), which is why its AOT binary can be one static file.

.github/workflows/aot-probe.yml re-runs this on the x86-64 runner weekly and
gates only the static-link claim (0 interpreters, 0 NEEDED, static-pie), because
the musl AOT ILC crashes under emulation on Apple Silicon. docker-compose.aot.yml
runs the production smoke against the probe image for whoever wants the failure
in full rather than summarised.
2026-10-06 09:15:29 +02:00
Pavlo Ratushnyi 149b2c0782 the README's scratch-image claim becomes a runner measurement, not a promise
ci / lint the workflow and the shell (push) Successful in 11s
ci / build, test, smoke (push) Successful in 2m18s
ci / the operator page in a real browser (push) Successful in 2m25s
ci / build the image and smoke it (push) Successful in 3m57s
ci / the same smoke on an image with no base (push) Successful in 3m55s
Gitea Actions run 2476 (head be6c608) built the scratch image on the x86-64
runner: RID linux-x64, loader line 1, 12 shared objects and 19.9 MB of them,
scratch 218 MB against chiseled 258 MB, and the same curl suite answering
368 passed, 0 failed. The arm64 numbers stay, so the two architectures can be
compared rather than one extrapolated to the other.

The same run is the first green source job since 7c5e1ef: the schema-script gate
now restores dotnet/dotnet-tools.json by path and reports "ok, the committed
schema script is what the current model generates (5652 bytes)" on the runner
instead of exiting 2.
2026-10-06 06:55:28 +02:00
Pavlo Ratushnyi be6c608ada the edge ships on an image with no base, and the 368 assertions agree it behaves
ci / the operator page in a real browser (push) Successful in 2m38s
ci / lint the workflow and the shell (push) Successful in 13s
geo-freshness / the pinned geo database vs the vendor (push) Successful in 4s
ci / build, test, smoke (push) Successful in 2m48s
ci / build the image and smoke it (push) Successful in 4m23s
ci / the same smoke on an image with no base (push) Successful in 5m3s
Dockerfile.scratch builds the same program self-contained and puts it on
scratch: 12 shared objects and the CA bundle — 18.7 MB — carried at their
absolute paths, because a scratch layer has nothing to borrow them from, and the
dynamic loader has to land at the path recorded inside the binary or the kernel
refuses to start the process. Measured on one arm64 host: chiseled 262 MB,
scratch 222 MB. scripts/compose-smoke.sh runs against it unchanged through
docker-compose.scratch.yml: 368 passed, 0 failed, and 368/0 again when the same
gate is called as scripts/ci-gates.sh scratch-smoke.

The first scratch image built here is why that second run matters. It started,
its own HEALTHCHECK reported healthy, and it still failed 7 of the 368. A
self-contained apphost takes its content root from the process's working
directory, a scratch image has no WORKDIR, so the process began in /, never found
the appsettings.json next to it, the reverse proxy had no routes, and every
request that should have reached the upstream answered the edge's own 404 —
including /boom's 502, which turned the "server errors alert, they never ban"
scene into a streak ban. The edge said it in its own log: "Request reached the
end of the middleware pipeline without being handled by application code."

The schema-script gate was red on the runner at 7c5e1ef (run 2462, exit 2):
`dotnet tool restore` from the repo root finds no manifest, prints "No tools were
restored." and exits 0, so the gate's own restore check passed vacuously and
`dotnet ef` then died. It now restores dotnet/dotnet-tools.json by path and asks
the tool for its version before trusting it.

NativeAOT, measured further: with the two alert-queue queries taken out,
`dotnet ef dbcontext optimize --precompile-queries` on EF 10.0.12 reports 0
precompilation errors and writes 8 interceptor files — 14 of whose declarations
have dots in the identifier, because the local is named from the entity type's
full name. The 4 refusals that remain are four shapes the generator cannot
translate at all: Contains over a captured collection, any method parameter
referenced inside a query (down to the CancellationToken), an ExecuteUpdate
set-list, and a literal whose type is not the column's. docs/ARCHITECTURE.md
carries the exception for each. No C# changed in this commit: the experiments
that produced those numbers were reverted, and the query rewrites kept at
7c5e1ef are the ones that made 40 refusals into 4.

Gates: scratch-image and scratch-smoke in scripts/ci-gates.sh and in `all`, and a
fifth CI job that runs the 368 against the scratch image on the runner.
2026-10-06 06:38:07 +02:00
Pavlo Ratushnyi 7c5e1ef230 the edge gains a schema step a compiled binary can run, and NativeAOT gets a measured verdict
ci / lint the workflow and the shell (push) Successful in 10s
geo-freshness / the pinned geo database vs the vendor (push) Successful in 5s
ci / the operator page in a real browser (push) Successful in 3m42s
ci / build, test, smoke (push) Failing after 2m6s
ci / build the image and smoke it (push) Successful in 5m7s
The Dockerfile said "why not NativeAOT" on the authority of another repo's
Dockerfile. That claim is now this repo's own, and it is a measurement.

What was built to find out:

* Persistence/Schema/schema.sqlite.sql — the model's DDL, generated by
  `dotnet ef dbcontext script`, embedded in the binary and read by
  Persistence/EmbeddedSchema.cs. A NativeAOT build cannot ask EF to build a
  model at run time, and EnsureCreated and GenerateCreateScript both go through
  the design-time model, so the schema step has nowhere to get its SQL from.
  OPENWAF_SCHEMA=script is the fourth strategy: same provider-shaped
  statements, produced at build time instead of at start-up. The schema-script
  CI step regenerates the file and fails the run when the committed copy is not
  what the current model produces (5652 bytes today).
* SchemaUpgrader.ModelTables asks the runtime model, per entity type. The
  design-time one is refused outright under NativeAOT, and GetRelationalModel()
  on the runtime model of a compiled model throws
  "The annotation 'Relational:DefaultMappings' cannot be added because an
  annotation with the same name already exists on the object EntityType:
  CountryRule" — building a compiled model's relational model a second time
  collides with itself.
* The persistence layer's queries were rewritten into the shape EF's query
  precompiler accepts: captured parameters copied to locals, conditional
  IQueryable composition written as literal chains, aggregates that take a
  predicate given their own Where. 40 of them were refused before that.
* dotnet-ef and EF Core moved 10.0.0 -> 10.0.12, because 10.0.0's design package
  ships no build host and `--precompile-queries` cannot load a project without it.

What the measurement says, from scripts/aot-probe.sh on osx-arm64: the AOT build
compiles (48,797,072-byte native binary, 10 IL warnings, 0 errors), starts, and
creates all 12 tables from the DDL it carries. Then it never serves. EF refuses
every query at run time ("Query wasn't precompiled and dynamic code isn't
supported with NativeAOT"), and the precompiler that would fix that is not
usable on this model: after all 40 refusals were cleared it emitted 14
declarations with dots in the identifier
(`var openWaf.Domain.Security.BlockEntryPrimaryKeyProperties = …`) — 28 CS1002
and CS1003 errors, one per entity materialisation — with or without --nativeaot.
The refusals themselves trace to dotnet/efcore#35887, #38030 and #35494; the fix
landed in the 12.0-preview1 milestone, not in any 10.0.x.

Two things were not kept, and why:

* The atomic alert-queue claim and the claim release were rewritten as raw SQL
  to dodge the precompiler's ExecuteUpdate failures. Reverted: with the
  statement written as SQL, DateTimeOffset reaches sqlite as a provider
  parameter instead of through the property's own mapping, the reclaim
  comparison stops matching, and
  AlertPushQueueTests.A_delivery_owed_by_a_process_that_stopped_is_owed_by_the_next_one
  fails with the row still owed. A correctness risk here buys nothing when the
  AOT build is blocked further along anyway.
* --nativeaot on the compiled model: its unsafe accessors do not compile
  (CS1503 in BlockEntryEntityType.cs). The plain compiled model is what is
  committed.

The compose gate's two escalation-count scenes also stopped being a coin toss.
They slept a fixed 2 s and then counted; on a loaded host the same tree read 3
rows once and 1 the next, and the assertion is about a settled number either
way. They now wait for three equal reads, bounded. The scene count is unchanged
at 368.

Gates at this commit: build 0 warnings / 0 errors, unit 378/378, integration
405/405, schema-script ok, smoke 256/0, compose-smoke 368/0, README counts
match (256, 368), lint clean (actionlint 1.7.12, shellcheck 0.11.0).

Not verified: the AOT image on linux-x64 — the probe ran on osx-arm64, and the
ILC failure mode that ends the attempt is a codegen bug in EF, not a
platform-specific one, but that is an inference rather than a measurement.
2026-10-06 05:20:28 +02:00
Pavlo Ratushnyi 85b38ad0cd the runner's own record: four jobs green at cd5935b, and the README agreeing with the gates it quotes
ci / lint the workflow and the shell (push) Successful in 8s
ci / build, test, smoke (push) Successful in 1m34s
ci / the operator page in a real browser (push) Successful in 2m21s
ci / build the image and smoke it (push) Successful in 3m58s
2026-10-06 01:32:17 +02:00
Pavlo Ratushnyi cd5935b28e the gates gain the proof their own claims were missing, and the README has to pay for its numbers
ci / lint the workflow and the shell (push) Successful in 13s
ci / build, test, smoke (push) Successful in 1m59s
ci / the operator page in a real browser (push) Successful in 2m45s
ci / build the image and smoke it (push) Successful in 4m25s
compose-smoke.sh: the read-side redirect guard is proven on the shipped image at
last — a good target is written through the API, the stored column is rewritten
underneath a running edge through the sidecar, and the edge is asked what it
sends once the snapshot rebuilds. javascript:alert(1) answers 301 to the policy
default and never to the stored value; a CRLF-bearing row answers 301 rather than
the 500 Kestrel used to produce, and injects nothing. A curl 000 now samples the
container it was aimed at and prints what it reports, and the gate ends by making
the dead case happen on purpose: compose stop, 000 beside exited/unhealthy,
compose start, running/healthy again.

console-check.cjs: the observation table is waited for rather than read at one
instant (an act run saw X-Total-Count: 0 where the same head a minute earlier had
11 rows), and the page's own request paths are pinned — the 14 admin-api calls it
issues, their query strings, no others, none answered 404. A wrong URL on a page
never looks like a wrong URL; it looks like an empty table.

ci-gates.sh gains readme-counts: each gate records the total it actually ran into
GATE_TOTALS_DIR and the README's claimed number is compared with it. Its first
verdict was that the README claimed 229 assertions for a gate printing 368 — a
139-assertion gap nothing could see. The README now says 368 and 168, both
measured in this run, and the run-by-run table gains 2405.

Verified locally: compose smoke 368/0, console 168/0, smoke 256/0, lint green at
actionlint 1.7.12 and shellcheck 0.11.0.
2026-10-06 01:16:20 +02:00
Pavlo Ratushnyi 249e3f93b5 the gates gain the assertions they were missing, and lint gains a local caller
ci / lint the workflow and the shell (push) Successful in 9s
ci / build, test, smoke (push) Successful in 2m23s
ci / the operator page in a real browser (push) Successful in 2m47s
ci / build the image and smoke it (push) Successful in 4m0s
Four gaps named on the board, each closed by making the shipped image answer the
question instead of an in-process test:

OPEN-45 - three pagination bounds were proven only in-process. On the image now:
the block listing's ceiling at its UPPER end (limit=2001 -> 400 naming
"limit must be 1..2000; got 2001" - only the lower end was on the image), a
negative offset on the streak map (checked on observations, blocks and alerts,
never here), and that an offset on the alert listing moves to a different row -
the scene used to assert only the truncation arithmetic.

OPEN-49 - DELETE /admin-api/countries/{code} validates the code the same way the
write does, and nothing on the image had ever asked. Three checks added: "12" and
"USA" are refused with the write's own sentence, not answered as if a row existed.

OPEN-48 - jval piped the body straight into json.load, so a request that produced
no body printed a Python traceback into the middle of an assertion and the
assertion compared an empty string. "the counter is 0", "the field is missing"
and "there was no answer at all" were the same word in the log. Three states,
three answers now: NO_JSON_BODY, empty, the value.

OPEN-41 - the markup-path assertion read the observation table once. That row is
written by the coalesced observation writer, so its arrival is on a timer: two
runs of one head at 9383362, one failed with `[]` and the next passed, and the
`[]` could not tell "not persisted yet" from "never persisted". The row is waited
for with a 10 s budget, the wait is printed either way, and a failure names what
was waited for and every path cell the table did hold.

OPEN-44 - the workflow files and the smoke scripts were linted by exactly one
caller, a CI job, so `ci-gates.sh all` could be green on a tree CI would refuse.
The pinned actionlint 1.7.12 and shellcheck 0.11.0 (same checksums) move into
scripts/ci-gates.sh as a `lint` gate and the CI job calls it: one definition, two
callers. A host with neither tool and no supported platform exits 2 - "cannot
run" - rather than reporting a pass, the console gate's convention.

Measured on this tree: scripts/ci-gates.sh lint green locally (actionlint 1.7.12,
shellcheck 0.11.0); compose smoke 356 passed / 0 failed, up from 348 by exactly
the eight assertions added above; the console check passed all its assertions
locally against the built image.
2026-10-06 00:32:28 +02:00
Pavlo Ratushnyi 96b1bf1e7e the runner's own record: four jobs green at 992a7b7, and what each earlier run cost to find
ci / lint the workflow and the shell (push) Successful in 12s
ci / build, test, smoke (push) Successful in 2m25s
ci / build the image and smoke it (push) Successful in 3m40s
ci / the operator page in a real browser (push) Successful in 2m46s
Run 2376 is the first run of this workflow that ended green end to end: lint
(actionlint 1.7.12, shellcheck 0.11.0), source (unit 378/378, integration
405/405, smoke 256/0), image (openwaf:ci 258 MB, compose smoke 348/0) and
console (164 assertions, 0 failed). The run-by-run table is the record of how
the three platform causes were found — no docker CLI in the job image, a job
workspace the host daemon cannot see, and an artifact action the runner refuses —
and of the one that was in the workflow itself: two steps written as `run:` with
no `|`, folded by YAML into a single line, so the upstream-config volume stayed
empty, Docker initialised it from the image, /boom answered 404 instead of 502,
and the 502 scene banned its own source before its first assertion. Ten red
assertions across two jobs, one folded line.
2026-10-05 22:24:39 +02:00
Pavlo Ratushnyi 992a7b795b the console job stops owing the runner an artifact it cannot accept, and the snapshot-age test gets a bound start-up cannot blow
ci / lint the workflow and the shell (push) Successful in 10s
ci / build, test, smoke (push) Successful in 2m11s
ci / the operator page in a real browser (push) Successful in 2m16s
ci / build the image and smoke it (push) Successful in 3m33s
actions/upload-artifact@v4 is not a step this runner can run. Run 2370
(head 36d9338) drove the page through every assertion — console check: all
assertions passed — and the job went red one step later on
`@actions/artifact v2.0.0+ … not currently supported on GHES`. The step now
names each screenshot with its size and sha256 in the log, which is what the
gate's own output already describes assertion by assertion.

PillarFailureVisibilityTests.The_snapshot_age_is_measured_against_the_ttl_it_is_supposed_to_respect
asked whether a snapshot was older than a one-second TTL, and the age at the
first read already includes however long the fixture took to come up. On a
loaded machine that bound is blown before the assertion runs (OPEN-76). The TTL
is now 10 with a 13 s wait: the bound is one the fixture controls, and the
assertion still says stale and failing are different claims.

README: the blast-radius preview had no section — /admin-api/impact was the only
admin surface with none — and the Shape counts had drifted (unit 256 -> 378,
integration 245 -> 405, smoke 52 -> 256, console 90 -> 164), measured on this
tree: unit 378/378, integration 405/405, smoke 256/0, compose 348/0, console
164/0.
2026-10-05 22:08:28 +02:00
Pavlo Ratushnyi 36d9338621 the queue is settled when it is empty, and the impact scene asks its questions one at a time
ci / build, test, smoke (push) Successful in 2m39s
ci / the operator page in a real browser (push) Failing after 2m29s
ci / lint the workflow and the shell (push) Successful in 8s
ci / build the image and smoke it (push) Successful in 4m2s
Two assertions that could not pass, each for a different reason.

AlertPushQueueTests.Attempts_run_out_and_the_surface_says_who_was_never_told
waited for the first delivery to give up and then asserted the queue was empty.
Six 502s at N=3 raise two alerts - the crossing at 3, the doubling at 6 - so two
deliveries are owed, and the second is still inside its backoff window when the
first gives up. Measured on the Gitea runner (run 2361, head 223b8d6): 404 of 405
passed and this one read pending=1. The wait now asks for both, which is what the
Settled helper two screens up already says a settled queue means.

console-check.cjs asked /admin-api/impact whether a live range already covers the
match while its own seeded exemption was still live. The endpoint reports
alreadyCoveredBy as what already ANSWERS for the match's own address, and a live
allow answers that address first, so the field is null by design and the
assertion could not pass for any build. Measured on the same run: the answer
named the exemption and nothing else. The exemption now comes off before that
question is asked.
2026-10-05 21:53:02 +02:00
Pavlo Ratushnyi 63cc575eb9 the two volume-fill steps are block scalars, so their comments are comments
ci / lint the workflow and the shell (push) Successful in 10s
ci / build the image and smoke it (push) Successful in 3m25s
ci / the operator page in a real browser (push) Failing after 2m49s
ci / build, test, smoke (push) Failing after 1m37s
2026-10-05 21:35:27 +02:00
Pavlo Ratushnyi 223b8d6100 the gateway is read from the kernel table, because this job image has no ip command
ci / lint the workflow and the shell (push) Successful in 11s
ci / build, test, smoke (push) Failing after 1m27s
ci / the operator page in a real browser (push) Failing after 2m37s
ci / build the image and smoke it (push) Failing after 3m59s
Run 2355, image job: `ip: command not found`, exit 127 — the step that names the
address died one line in, before the gate ever ran. /proc/net/route carries the
same default route; its gateway is hex little-endian, and bash turns it back into
a dotted quad with no helper at all (0100110A → 10.17.0.1).
2026-10-05 21:26:23 +02:00
Pavlo Ratushnyi fb491a4041 the compose gates are pointed at the host address, because the job's own loopback is not where the ports are published
ci / lint the workflow and the shell (push) Successful in 8s
ci / build the image and smoke it (push) Failing after 20s
ci / the operator page in a real browser (push) Failing after 49s
ci / build, test, smoke (push) Successful in 1m45s
Run 2350 (b402ec4) got past the mount: the stack came up, the edge container
reached `healthy`, and the console gate died 8s later with curl exit 7 — a
connection refused to http://127.0.0.1:8090. The image job was further along but
showing the same face of it (empty curl bodies reaching a json decoder).

compose publishes the edge's port on the host. The job that curls it is a
container with its own network namespace, so 127.0.0.1:<published port> is not the
same place. The fix is the address the job's own default route names — the host's
address on that network — and compose publishes on 0.0.0.0, so the published port
is listening there. The step prints it into the log so the next run says which
address it asked.

Cross-reference for the platform, not invented here: ~/work/tskr documents the
same asymmetry from the other side in docker/test/workspace-mount.sh — the job
workspace is a named volume at /workspace/<owner>/<repo> that the host daemon
cannot see, `docker build` survives it because the context streams from the
client, and only `-v` is resolved daemon-side. tskr's answer is to run its gates
in sibling containers; openwaf's gates are shell + curl + node, so the smaller
answer is the volume for the file mount (previous commit) and the host address
for the port.
2026-10-05 21:18:58 +02:00
Pavlo Ratushnyi b402ec4cc9 the CI stack mounts its nginx config through a volume, because the daemon cannot see the job's workspace
ci / lint the workflow and the shell (push) Successful in 9s
ci / the operator page in a real browser (push) Failing after 53s
ci / build, test, smoke (push) Successful in 1m33s
ci / build the image and smoke it (push) Failing after 13m18s
Run 2346 named the cause, and it was not Docker and not the stack:

  error mounting "/workspace/para/openwaf/deploy/upstream.conf" to rootfs at
  "/etc/nginx/conf.d/default.conf": not a directory: Are you trying to mount a
  directory onto a file (or vice-versa)?

The job's workspace lives inside the runner's job container; the docker daemon is
the host's, reached through /var/run/docker.sock. A relative bind mount written in
docker-compose.yml is resolved by the daemon on the host, where that path does not
exist, so Docker turns it into a directory and the mount dies. deploy/upstream.conf
is tracked (b6126c2) — this was never a checkout problem.

docker-compose.ci.yml is the overlay: the upstream service gets its config from a
named volume at /etc/nginx/conf.d, filled by a step that pipes the tracked file
into the volume. `!override` replaces the base volumes list, otherwise the broken
mount would still sit next to the working one. Compose reads the overlay through
COMPOSE_FILE, which only the workflow sets — a laptop and the README demo keep the
plain file mount, and the gate scripts stay the scripts an operator runs.

Verified before pushing, on this tree: `docker compose config` shows the upstream
volumes as the named volume at /etc/nginx/conf.d with the bind mount gone; the
fill step writes 1209 bytes, exactly deploy/upstream.conf; scripts/compose-smoke.sh
under COMPOSE_FILE=docker-compose.yml:docker-compose.ci.yml reports 348 passed /
0 failed, including the 502-upstream scenes that need that config to be read.
2026-10-05 21:11:33 +02:00
Pavlo Ratushnyi 1ada35486f a stack that will not come up now says what compose said, and the runner gets buildx
ci / lint the workflow and the shell (push) Successful in 14s
ci / build the image and smoke it (push) Failing after 24s
ci / the operator page in a real browser (push) Failing after 1m0s
ci / build, test, smoke (push) Successful in 1m58s
Run 2344 on 4e303cd: lint green (the two SC2086 findings are gone), source green,
image and console still red — both at `- starting the stack / compose up failed`.
In the image job the docker install worked and `docker build` produced
openwaf:ci 258MB, so the CLI cause is closed; what fails now is compose, and the
gate threw compose's own output away at the one moment that decides whether the
rest of the run means anything. Both gates now write it to a temp log and print
it on failure.

The stack itself is not the suspect: scripts/compose-smoke.sh on this tree, on a
daemon of its own (COMPOSE_PROJECT_NAME=openwaflocal, EDGE_PORT=18085), reports
348 passed / 0 failed — including the shipped-image preview scenes. So the
remaining difference is the runner's client side, and `docker compose up --build`
reaches the daemon through buildx, which the install step did not put in. Added,
with `docker buildx version` printed next to `docker compose version` so the next
log names all three versions that actually ran.

shellcheck 0.11.0 clean over scripts/*.sh.
2026-10-05 20:57:35 +02:00
Pavlo Ratushnyi 4e303cd0ad the two docker jobs install the CLI the runner image never shipped
ci / build the image and smoke it (push) Failing after 57s
ci / lint the workflow and the shell (push) Successful in 12s
ci / build, test, smoke (push) Successful in 2m39s
ci / the operator page in a real browser (push) Failing after 1m38s
First real run of this workflow: Gitea Actions run 2316 on 6f92d37. Three jobs
red, each with a cause that names itself in the log:

  lint    — shellcheck 0.11.0: 2x SC2086 in scripts/smoke.sh (835, 837)
  image   — ./scripts/ci-gates.sh:44: docker: command not found (exit 127)
  console — - starting the stack / compose up failed (exit 7)
  source  — success, 1m53s

The runner's job image ships no docker CLI while /var/run/docker.sock is mounted
from the host, so the image and console jobs now install docker-ce-cli and
docker-compose-plugin themselves and then fail loudly, at that step, if the
socket is not there — an infrastructure answer should read as infrastructure
rather than as a broken product three steps later. Same install the
neemle-landing pipeline on this instance already uses.

The two SC2086 findings are the string-concatenation trick inside a single-quoted
python -c: '$EDGE_PORT' expands unquoted. Now '"$EDGE_PORT"', which is what
shellcheck proposed and what the scene was already meaning.

Gate evidence on this tree: shellcheck 0.11.0 (the pinned version, same command
as the gate: shellcheck -s bash scripts/*.sh) clean; scripts/smoke.sh 256 passed
/ 0 failed on EDGE_PORT=18411. build and unit were green at ddddfc8 and nothing
here touches C# — integration was not re-run locally, its two host-specific
races are OPEN-47 and OPEN-76.

The header comments that said this file had never executed on a runner are now
wrong and say what happened instead.
2026-10-05 20:46:22 +02:00
Pavlo Ratushnyi ddddfc864b recovered-partial: the blast-radius preview exists on disk with nobody's record on it
Recovered-partial, UNVERIFIED. These changes were in the working tree at session
start with no checkpoint record on any item (OPEN-75 carries no execution plan,
work result or handoff note), so they are preserved rather than built on.

Attribution: they are the OPEN-75 surface — GET /admin-api/impact, the console
panel that calls it, the write-path refusal of abbreviated v4 spellings, and the
smoke / compose / console scenes for it. The README section and endpoint-list
entry the item's definition of done asks for are not here.

Gate evidence taken against this state, not claimed for it:
  build (warnings-as-errors)  clean
  unit                        378/378
  integration                 403/405 — AlertPushQueueTests.Attempts_run_out_and_
                              the_surface_says_who_was_never_told and
                              PillarFailureVisibilityTests.The_snapshot_age_is_
                              measured_against_the_ttl_it_is_supposed_to_respect
                              fail here AND fail identically at 6f92d37 with
                              these changes absent, in a separate worktree, so
                              they are not this work's failures; their failure
                              site moves between runs (assertion vs fixture
                              StartServer), which is what an environment-sensitive
                              test looks like.
2026-10-05 18:20:42 +02:00
Pavlo Ratushnyi 6f92d377e7 one search across every store the operator's decisions live in
ci / lint the workflow and the shell (push) Failing after 12s
ci / build the image and smoke it (push) Failing after 10s
ci / the operator page in a real browser (push) Failing after 1m35s
ci / build, test, smoke (push) Successful in 1m53s
GET /admin-api/find?q=<text>&limit=<n> asks where a phrase appears in one call:
blocks (key, reason, last path), ranges (match, reason), exemptions (match,
note), path rules and path budgets (pattern, note), alerts (kind, key, detail,
last path), change records (target, detail) and country rules (code, name). Each
row names the store it came from, what it is keyed by, when it was written,
whether it is in force, the text that matched and the field it matched in. The
phrase an operator remembers - a ticket number, a customer's name - is not a
field any listing filters on, so asking it used to mean opening eight listings
and reading every row.

Rulings:
- the query is data, not LIKE's grammar. The backslash, the percent and the
  underscore are escaped and the match runs LIKE ... ESCAPE '\', so "100%"
  searches the four characters "100%" and not "anything after 100". Unescaped, a
  percent inside an operator's own sentence answers about rows nobody asked
  about; the gate searches 100%, a_b and a literal backslash to hold this.
- an address query returns the rows that COVER it, not only the rows that name
  it - the part a grep cannot do. Searching .69 returns the /29 that refuses it
  although no row contains that address, and the row says so: "203.0.113.64/29
  covers 203.0.113.69". Blocks are matched on the key this edge files the
  address under, the rule the dossier and the story both had to learn: with a /29
  key, searching .90 finds the ban stored as 203.0.113.88/29.
- a row that matches by text and also covers the address is answered once, with
  the text match as its reason: the row really does name the query.
- counts is per store and is that store's whole answer, not the rows this call
  happened to return, so matched: 0 over eight zeroed stores is a different
  sentence from a surface that read nothing - and a limit truncates the merged
  answer without pretending a store had nothing else in it.
- rows come newest-first. This is a search, not a story: the row an operator
  wants is the one they wrote last. /history reads oldest-first because it
  narrates, and neither default is wrong for the other question.
- q is 2..128 characters - one character is a dump rather than an answer, and 128
  is the longest target the change log stores, so a longer query cannot match the
  thing it was aimed at. limit is 100 by default, 500 at most. An unknown query
  parameter is refused by name. Country rules are searched by name as well as by
  code: "Ukraine" is what an operator remembers, "UA" is what the row stores.
- it is a read. The read-only token can ask it, and eight asks leave every store
  holding the same rows.

The console carries the same call: a phrase in, one line per row that carries it,
and a header counting all eight stores so an empty answer reads as an answer.

Gates: build 0/0, unit 377/377, integration 394/394 (11 new), console 159
assertions 0 failed (+8), smoke 243/0 (+13), compose 339/0 (+8), image 262 MB.
2026-10-05 12:24:50 +02:00
Pavlo Ratushnyi 3079b536ba one source through time: every decision this edge made about it, in order
GET /admin-api/history?ip=<address> joins the six dated stores that can name a
source - the operator's block, the ban this edge wrote itself, the range whose
CIDR covers the address, the exemption covering it, the alerts raised about the
key, the change records whose target is the key or a range that covers it, and
the observation row that counts its refusals - and returns them oldest-first with
what each one did. The dossier (OPEN-70) answers now, the horizon (OPEN-72)
answers soon; this answers what already happened, which is the question a
complaint on Monday actually asks.

Rulings:
- the order is the answer. "The exemption, then the ban" and "the ban, then the
  exemption" are different incidents, and an operator assembling this from six
  listings gets whichever one they opened last. Oldest-first is asserted even
  when the rows were written newest-first.
- a range or an exemption is in the story because it covers the address, not
  because a row names it - the distinction the dossier had to learn - and a
  change to that range is a change to this source's conditions, so its change
  record belongs here too.
- inForce is null for the kinds that are events rather than states. An alert, a
  change record and a sighting do not answer "is it in force"; false would say
  the alert had been switched off. Expired rows stay and say when they stopped.
- searched counts what was looked at, so an empty story is not confused with a
  surface that read nothing. Window 1..129600 min (7d default, the retention
  window of the rows that make up most of a story), limit 200 by default and it
  says how much it left out.
- the engine ban's evidence is its stored reason, not the reason plus the same
  fields again: the first run printed "last 404 /wp-login.php - last 404
  /wp-login.php - 3 refusals in a row".

The console carries the same call under the horizon: one address, the joined
timeline, each line stamped and marked in force or EXPIRED, with the header
naming the key the address is filed under and what was searched.

One gate assertion moved rather than the product: the scene asked for the story of
an address "with nothing recorded" and got 34 change records, because the
netblock scene writes and removes 192.0.2.0/24 through the run and a change to a
/24 really is part of the story of every address inside it. The surface was right;
the assertion had picked an address that was not outside anything.

gates: build 0 warnings / 0 errors, unit 377/377, integration 383/383 in 34 s,
console 151 assertions 0 failed, smoke passed 230 failed 0, compose 331 passed
0 failed against the built image at 262 MB, 0 containers left behind.

Refs OPEN-73.
2026-10-05 11:54:45 +02:00
Pavlo Ratushnyi 1ec794dc75 the horizon says what stops being enforced soon, and what answers afterwards
GET /admin-api/expiring?within=<minutes> (1..1440, 30 by default) lists the dated
entries that stop being enforced inside the window, nearest first, and each
address-shaped row carries thenAnswers: the real DecisionEngine.Decide over a
snapshot with only that entry removed. An exemption about to lapse therefore says
which ban is waiting underneath it ("block_operator by 203.0.113.16/28"), and a
block that stands alone says the source goes free. A path rule and a path budget
have no single answer: thenAnswers is null and whyNoAnswer points at
/admin-api/decide?ip=&path= instead of the surface guessing one. Entries that
never expire are not listed; alreadyExpired counts the dated rows whose moment
already passed, which is what separates "nothing expires soon" from "there are no
dated entries". The listing reads the database, the read-only token can ask it,
and six asks write nothing.

Rulings:
- the probe address for a CIDR is its network address, which is inside the group
  it describes; a pattern is not probed at all.
- the window is capped at a day because that is the longest thing an operator
  plans for; out of bounds is a 400 naming 1..1440.
- the console prints the window it asked for as the first line of the answer and
  empties the box before the call, so neither a scene nor an operator on a slow
  link can read the previous answer as the new one.

Two product defects fell out of the gates on the way:
- the alert push worker was registered as a hosted service above the schema step,
  and hosted services start in registration order: on a cold start its first
  queue sweep read alert_push_queue out of a database this process had not
  created, and "SQLite Error 1: no such table" became alertWebhookLastError -
  the state page blaming the webhook endpoint for the edge's own startup order.
  The notifier is now registered below the warmer and the order is asserted.
- a listing the edge could not answer was drawn as an empty one: with two of the
  page's fourteen calls answering an error, the observation line printed "0
  sources the edge has recorded" and the streak line "0 of 0 standing streaks
  listed" over a map holding twelve sources. A count read off a failed answer is
  0, and 0 says there is nothing to see. Every count-bearing note and its table
  now say NOT READ with the error beside them.

The gate's own traps, caught and fixed: the budget scene cleared the engine ban
its probes caused after the probe that ban was failing, and its reopen retry loop
banned itself three refusals deep; the alerts assertion read a row written off the
response before the next refresh drew it.

gates: build 0 warnings / 0 errors, unit 377/377, integration 375/375 in 35 s,
console 142 assertions 0 failed, smoke passed 217 failed 0, compose 324 passed
0 failed against the built image at 262 MB, 0 containers left behind.

Refs OPEN-72.
2026-10-05 11:22:01 +02:00
Pavlo Ratushnyi 4280ebb2ca a request budget says who it is pausing, and one source can be let out
The budget listing has carried three numbers per budget since OPEN-68 — sources
counted, windows running, over budget now — and no name. "3 over budget" is the
half an operator cannot act on, and the only lever for one of those three was
`DELETE /admin-api/rate-rules/{id}`: take the budget off every source on the site
to release one office behind one NAT. The edge-wide budget never had this hole,
because /admin-api/rate names its sources.

  * GET /admin-api/rate-rules/{id}/sources — who this budget is inside right now:
    sourceKey, count against the limit, when the window ends and how many seconds
    are left, overBudget. Busiest first, live windows only, paged with
    X-Total-Count / X-Truncated like every other listing. `total` is the same
    number the listing's `liveWindows` reports and the over-budget count matches
    `overBudgetNow`: the names come from the same state as the three counters,
    not from a second ledger.
  * DELETE /admin-api/rate-rules/{id}/sources?source=<key> — drop one source's
    window on one budget. Not an exemption, and the answer says so: the window
    restarts at zero and the budget counts this source again from there, while
    every other source stays paused. An operator who types an address gets the
    key this edge files it under, and the answer names the key it dropped,
    because the others sharing it are still paused. A second clear answers
    `cleared: false` and writes no second record; the first is in the change log
    under `rate rule / changed`.
  * Console: a `who` button per budget row, and a `let out` button per source.

Rulings kept: the entries are source keys with the prefix rule printed beside
them (a /24 in the list is the point, not a bug); the limit is passed in from the
rule row rather than copied into the counter, so one number is enforced once;
reading spends nothing, so the page that exists to show a pause cannot cause one;
an empty list says which kind of empty it is — "counting, nobody inside a window"
and "this budget has expired" are different answers; and the read-only token gets
a 403 on the clear, not a 401, because the token is known and its level is the
answer.

What the run caught, on this tree: two console scenes failed with `answered 403`
because the gate's own probes are refusals and the streak pillar had banned the
probe addresses — a correct edge, and a scene that cannot retry past a one-hour
ban. Both now clear that one ban by name, leaving the engine bans the netblock
scene reads standing. The first run of the feature also caught the clear
reporting `cleared: false` after actually dropping the window: the derived-key
branch dropped the state and never set the flag.

build 0 warnings / 0 errors, unit 377/377, integration 365/365 in 31 s,
console 129 assertions / 0 failed, smoke passed 202 / failed 0, compose 317
passed / 0 failed against the built image at 262 MB.

Refs OPEN-71.
2026-10-05 10:13:29 +02:00
Pavlo Ratushnyi bcfc83db40 one address in, and the edge answers everything it knows about it
An operator investigating one source had to open six admin calls — blocks,
allow, streaks, observations, alerts, the dry run — and hold the join in their
head. The join is where the wrong answers are: a v6 address looked up in full
when the ban is filed on the /64, a CIDR ban looked up by equality that never
finds it, an exemption that expired last week read as a live one, a streak
counted in one process read as the deployment's.

GET /admin-api/source?ip=<address>[&path=<path>] answers it in one call, by
asking the same objects the request path asks rather than a second copy of
their logic. Three rulings hold it together:

  * Containment, not equality. operatorBlock carries cameFromRange and the
    match that covered the address, through the same NetworkBanIndex the wire
    matches with (longest prefix first) and NetworkMatch for the allowlist.
    There is no second matcher in this build to drift.
  * The key, not the address. sourceKey and the prefix lengths that produced
    it travel in the answer: bans, streaks and budgets are filed under the key,
    the allowlist and the range bans are matched against the address, and the
    answer separates them.
  * `none` and "not visible here" are different words. A live engine ban under
    Observe mode reports applies: false with a verdict of none; an expired row
    reports live: false rather than null, because "this address used to be
    exempt" is a fact an operator acts on.

Nothing is written and nothing is spent — the dry run's rule applied to the
whole dossier. RateRuleTracker.WindowsFor is a new read that lists every path
budget a source is already inside without being handed a path, so the dossier
does not have to guess from a path it was not given, and N dossiers leave every
counter where they found it. ip is required and must be a full address: a typo
is a 400 naming the value, never a none. The read-only token may ask it.

What the run caught, on this tree: the console scene waited for "an answer is
in the box", which the previous answer still sitting there satisfies — three
assertions read the address asked one click earlier. The scene now empties the
box and waits for the address it asked by name, and matches a range row by the
key its delete button holds rather than by a cell that prints a `range` badge.

build 0 warnings / 0 errors, unit 374/374, integration 356/356 in 39 s,
console 126 assertions / 0 failed, smoke passed 192 / failed 0, compose 311
passed / 0 failed against the built image at 262 MB.

Refs OPEN-70.
2026-10-05 09:43:39 +02:00
Pavlo Ratushnyi 6a65cbf344 the dry run says what the volume pillar would answer for that source
`GET /admin-api/decide` answers what would happen to a named request and which
pillar said so, and it stayed silent about the one pillar whose number the
operator is choosing. The count is kept in the guard rather than read off a
snapshot, so the preview printed `rate: not_evaluated` and left "would this source
be rate-limited" as the one question the surface exists to answer could not ask.

The rulings this had to make, and the answer each one got:

* Reading, never spending, is the invariant. The section is built from peek reads
  of both trackers, so N dry runs leave `count` exactly where it was and write no
  alert. A preview that answered by counting its own question would refuse the next
  real request because somebody pressed a button — the tool for finding an
  over-tight budget would itself be the cause of it.
* Four silences stay apart: `not_counted` (the pillar is off, so there is no budget
  to cross), `no_source` (no address was asked, and a budget is a claim about a
  source), `refused_now`, `would_be_counted`. A fifth, `over_budget_not_enforced`,
  exists because "over budget" and "would be refused" are two answers separated by
  the mode, and collapsing them is how an observe budget becomes a surprise the day
  someone switches it on.
* `reached: false` says an earlier pillar answers the request, so the guard would
  never consult the counter for it. The volume section still reports the counters —
  they are true — but the note stops talking about a budget this request would
  never touch.
* A budget in force for the path with nothing counted for this source yet prints
  `counted: false`, not `count: 0`. "0 of 2" and "nothing yet" are answers an
  operator acts on differently.
* The path budgets are matched by the same `PathPattern.Matches`, in the same
  order, as the guard: a preview that matched differently would be a preview of a
  different edge.
* The counters are this process's (`scope: "this-process"`), said in the answer
  rather than left for the operator to remember.
* The `rate` pillar row keeps `not_evaluated` — the engine really did not evaluate
  it — and its note now points at the section that did, instead of ending as a
  silence.

What the runs caught, in order:

* The first version answered `refused_now` for an Observe crossing. The counters
  were right and the sentence was wrong: observe enforces nothing. The mode is now
  part of the verdict.
* An integration expectation asserted the note of the `rate` pillar row after a
  crossing, and read the engine ban the crossing itself had written instead — the
  request was no longer reaching the volume pillar. The assertion moved to the
  preview taken before the crossing, and the ban case now asserts the honest note.
* Rewording that note broke an older preview test that keyed on the word "preview"
  in it; the wording keeps the word, and the older test is the one that caught the
  rewording.
* The smoke scene compared a listing's over-budget count against a request count,
  which would have passed for the wrong reason; it now asserts the pair
  (tracked, over) before and after six previews.

Gates at this commit, each stage on its own: build 0 warnings / 0 errors, unit
371/371, integration 345/345 in 43 s, console 122 assertions 0 failed, smoke
passed 182 failed 0, compose 304 passed 0 failed against the built image at
262 MB, 0 containers left behind.

Refs OPEN-69.
2026-10-05 09:14:09 +02:00
Pavlo Ratushnyi 7beaa7e463 a source's request budget can be written for one path
The edge-wide budget is one number for the whole site, and for a login path that
number is always wrong: a hundred requests a minute does not stop a
credential-stuffing run that makes twenty attempts a minute — twenty looks like
a person — while five a minute locks an honest office behind one NAT out of every
page they own. The only way to make both statements true is to price the paths
differently.

The rulings this had to make, and the answer each one got:

* A rate rule is not a path rule. A path rule refuses a request because of what
  it asked for; a budget refuses it because of how often that source asked. The
  pattern language is shared because the thing being described — this path and
  what hangs off it — is the same.
* Crossing a budget writes no engine ban. The claim is about one path, so a ban
  would refuse the rest of the site as punishment for a login-page rate. The
  answer is 429 with Retry-After for the rest of that source's window, and the
  reason names the rule, its count, its limit and the pattern it was written for.
* The counters are a separate tracker, not a scope inside RateTracker. The
  edge-wide counter reads its limit and window from the policy; a rule carries
  its own. One map whose parameters change per entry is a map whose eviction and
  idle rules stop meaning anything.
* The budgets hang off rateMode rather than getting a switch of their own:
  Enforce refuses, Observe counts and raises one rate_breach alert per source per
  window naming the pattern, Off counts nothing at all. A half-counting edge is
  the state an operator cannot reason about.
* A second live budget for one pattern is a 409 — two live numbers for one path
  mean the stricter one wins by accident rather than by the operator's choice.
* The bounds are the policy's own (1..100000 requests, 1..3600 seconds), so one
  vocabulary of numbers covers both budgets and a document cannot bring in a
  budget the API would have refused.
* The listing answers with three counters — sources counted, windows running,
  over budget now — because "nobody has blown this" and "nobody can" look
  identical on paper and are different decisions.

What the runs caught, in order:

* The smoke scene first ran on 198.51.100.0/24, which an earlier scene of the
  same gate allowlists. An allowlisted source never reaches the counter, so the
  scene would have printed a row of 200s while measuring nothing. It runs on
  TEST-NET-1 now.
* The console scene drew three 404s of its own and the streak pillar banned the
  address, so the reopen assertion read the streak's 403 instead of the absence
  of the budget. The engine list is cleared before that probe and the comment
  says which pillar the clearing belongs to.
* The compose assertion compared a JSON boolean against the word "yes".
* The change-log vocabulary test still listed six sections; there are seven now.
* A unit expectation counted requests where the tracker holds windows: one
  (rule, source) pair is one window, and the count inside it is what the budget
  is measured against.

Gates at this commit, each stage on its own: build 0 warnings / 0 errors, unit
361/361, integration 337/337 in 30 s, console 120 assertions 0 failed, smoke
passed 169 failed 0, compose 300 passed 0 failed against the built image at
262 MB, 0 containers left behind.

Refs OPEN-68.
2026-10-05 08:40:58 +02:00
Pavlo Ratushnyi dd10dd9839 the edge notices the netblock behind its bans and offers it as a range
A scanner farm inside one /24 is twenty engine bans and twenty operator
decisions: the streak rule works per source, and nothing in the edge connected
the rows. OPEN-66 made a range enforceable; this is the half that notices the
range is there.

The rulings:

- The evidence is the edge's own live engine bans. An operator's row is a
  decision already taken, and an expired ban is a row the edge stopped
  honouring; neither is evidence about a netblock. Nothing new is observed and
  nothing new is stored.
- An offer is not a ban. A candidate changes nothing on the wire: the operator's
  POST /admin-api/blocks with the CIDR is what enforces it, and the console
  button is that same call. Twenty honest visitors of one provider and one farm
  inside one rented block produce the same number, and only a human tells them
  apart.
- Grouping is one allocation up from the key: v4 to /24, v6 to /48, because the
  v6 streak key is already a /64 and grouping there would only repeat the key.
  The count and both prefixes are policy keys with bounds, because a host that
  hands out /22s should be shown the block it can act on.
- A ban keyed on a block wider than the netblock prefix is skipped: that row
  already claims more than a /24, and counting it as one ban inside a /24 would
  invent a candidate out of it.
- Reading the list is not news — the scan that answers the surface raises no
  alert, so refreshing a page cannot manufacture alert rows. The timer's scan
  raises netblock_candidate through the same durable alert table and push queue
  as every other kind, at most once per block per six hours, and never for a
  block the operator has already banned.
- A failed scan retires the offers instead of repeating the last ones, and
  /admin-api/state says which of off / failed / found-nothing this is.

What the run caught:

- The console's "ban this range" button posted a body with no content type, and
  the edge refused it: the button did nothing and the page looked idle rather
  than wrong. It uses the page's own postJson now, and the console gate asserts
  the row it writes, the wire answer for a source inside it, and the offer
  turning into "already banned".
- The grouping parsed ban keys with SourceKey.TryParse, which fails on the
  "2001:db8:1:2::/64" spelling the engine stores v6 bans under — so no v6 ban
  was ever grouped. Keys are parsed as keys, prefix included.
- An assertion claimed 203.0.113.137 sits under 203.0.113.128/24. That is a /25:
  the arithmetic was wrong in the test, not in the mask.

build 0 warnings / 0 errors, unit 353/353, integration 326/326 in 31 s, console
114 assertions 0 failed, smoke passed 149 failed 0, compose 293 passed 0 failed
against the built image at 262 MB.

Refs OPEN-67.
2026-10-05 07:55:06 +02:00
Pavlo Ratushnyi 848ec1a82a an operator can ban a range, not only an address
A scanner rotating through a rented /29 used to cost one row and one write per
address: POST /admin-api/blocks answered "not an IP address" for a CIDR while
the allowlist control beside it accepted one, and the config export could not
carry the operator's answer either. A CIDR now has its own table and is enforced
by containment.

The rulings:

- One list, two shapes. GET /admin-api/blocks merges address rows and range rows
  and says which is which with `kind`; DELETE ?key= takes the CIDR as it was
  typed; ?source=engine still cannot reach an operator's range, while
  ?source=operator clears both operator shapes.
- Containment is checked on the raw peer address, the same field the allowlist is
  matched on, after the exact operator block and before the engine's own ban. The
  verdict stays block_operator, so nothing downstream had to learn a new reason;
  the decision trace names the range that answered, and an allow entry still
  outranks a range.
- What is written is normalised before it is stored: 203.0.113.37/28 is stored as
  203.0.113.32/28, a /32 or /128 is stored as the bare address it already was,
  and the full-width prefix is refused on meaning rather than on form — "0.0.0.0/0"
  covers every address there is, including the one this was written from; that is
  a shutdown, not a ban on a source.
- A request pays for the number of distinct prefix lengths, not for the number of
  ranges: the index buckets by prefix and asks a set for the request address
  masked to it, most specific first, and an expired row does not stop the search
  for a broader live one.
- Export carries ranges in the blocks section and import lands them idempotently,
  so an edge's decisions survive the move. /state counts them apart from address
  blocks, and the console prints the shape beside the row.

What the run caught:

- BlockRow read Range?.Field ?? Entry!.Field. The two rows are mutually
  exclusive, so a range with no expiry, reason or redirect — the common case —
  dereferenced the row that is not there and GET /admin-api/blocks answered 500.
- NetworkBanIndex filed a row under "a.b.c.d/24" while the lookup compared a
  masked address with no prefix, so no range ever matched: ten unit tests red
  before the bucket key was fixed to the network address alone.
- smoke and compose both wrote their JSON bodies with escaped quotes straight
  inside a command substitution, which truncates the body and answers 400 — the
  hazard this file's own header warns about. The payloads are variables now.
- Scene ordering in smoke: the range scene clears the engine's list wholesale,
  which took the expired scanner row a later scene asserts on. It runs after
  those scenes now, and says why in the file.
- Test-side, worth keeping: 203.0.113.37/28 is not the network 203.0.113.16/28
  names, so an assertion that writes one and expects the other is testing the
  mask, not the match.

build 0 warnings / 0 errors, unit 334/334, integration 312/312 in 31 s, console
105 assertions 0 failed, smoke passed 137 failed 0, compose 285 passed 0 failed
against the built image at 262 MB.

Refs OPEN-66.
2026-10-05 07:22:40 +02:00
Pavlo Ratushnyi 4db36f86d0 the operator's console shows what changed on this edge
OPEN-64 gave the edge a record of every deliberate config change and an
endpoint that reads it; the record was invisible to the person it is for.
`/admin` now draws it: when, section, action, target, the note somebody
typed, and the surface it came through, newest 25 of the total.

Rulings this copy holds to:

  * The surface column says `operator` or `import`, never a person. The
    edge has one admin token; a column implying a per-person attribution
    it cannot provide would be a false record, not a thinner one.
  * Engine bans are absent, and the line under the table says so in the
    same breath as the counts: "engine bans are not here, they are not
    decisions". A table that mixed them in would read as "the operator
    chose to ban this address", which is a different claim.
  * The log's two bounds are printed under the table they govern -
    "pruned after 30d or 5000 rows, whichever comes first" - the way the
    retention windows sit on the observations and alerts tables. They come
    from `/state` (`changeRetentionDays`, `changeLogMaxRows`), so the
    numbers are the ones this process was actually started with.
  * A change record that did not land is named in the durable-writes pill
    with its count: "change records not written x1 (1 changes
    unrecorded)". It is the one write failure that changes nothing the
    edge enforces, which is exactly why it would otherwise go unseen - the
    config did change, only its record is missing.

What the run measured rather than assumed: the gate's seed writes a block
whose reason carries markup (`<svg onload=document.title='XSS2'> probe`),
and that reason is now the detail of a change row - so the change table
is a place where a stored operator string reaches the one browser in this
system that holds the admin token. The markup-seed assertion now covers
`#changes tbody`, and a companion assertion proves the string really
arrived as text, because without it an injection count of zero would only
prove that nothing was looked at.

Gates on this head: build 0 warnings / 0 errors, unit 313/313,
integration 298/298 in 34 s, console 98 assertions / 0 failed, smoke
passed 127 failed 0, image 262 MB, compose-smoke 278 passed 0 failed.

Refs OPEN-65.
2026-10-05 06:30:22 +02:00
Pavlo Ratushnyi 3959f1fe6b a change to the operator's config leaves a record of itself
Every operator write already changes a row; what was missing is the answer an operator actually asks at 03:00 - when did this rule get here, who cleared that ban, did a document bring this edge's config. Since the transfer landed, an edge can be different from yesterday with nothing on it saying how.

config_changes carries one row per deliberate change: the instant, the section (block, allow, rule, country, policy, config), the action (added, removed, changed, imported), the target the operator typed, their own sentence where one was given, and the surface the change came through. GET /admin-api/changes answers it newest first, capped and paged like every other listing, filterable by section and since, readable by the read-only token because it is a read. A policy record says what moved ("mode Enforce->Off, streakThreshold 3->4") rather than only that something did. /admin-api/state counts the rows and the write failures.

The rulings, because each is a decision and not a detail:

 * Engine bans are not in the log. A ban the engine earned is not a decision somebody made, and the block row already carries its evidence - consecutive refusals, status code, path, user agent, country, city. Logging bans would answer a different question and grow the table at the rate of traffic.
 * An import is one record per section, not one per row: "3 added, 1 already there, 0 past expiry, 0 rejected". A 2 000-row document would otherwise bury a table whose whole use is being readable.
 * The record names the surface, never a person. The edge has one admin token; a log that implied per-person attribution it cannot provide would be a false record, which is worse than no record.
 * A record that cannot be written never undoes the change it describes. Enforcement is the product, so the change stands and the failure is counted - changeWriteFailures, changesNotWritten, changeLastError - because "the config changed and the record of it did not land" has to be a sentence an operator can read rather than one that silently never happened.
 * Bounded twice, both keys the operator's: ChangeRetentionDays (30) and ChangeLogMaxRows (5000, oldest dropped first). The age window alone would let a scripted churn grow the table without limit; the cap alone would drop last month's incident record the week someone did a lot of editing.

What the run caught, in order: (1) Two gate assertions were wrong rather than the product - a policy record was asserted in a scene where no policy write had happened yet, and "one imported record per section" was asserted against a stack that had already imported twice, so the assertion now reads the newest imported record instead of counting them. (2) DELETE /admin-api/countries/{code} answers 204, and the new assertion expected 200. (3) A shell trap in the new scene: a $VAR inside a single-quoted python -c is not interpolated, so the first version would have handed python a literal "$CHANGES_BEFORE" instead of a number.

Gates on this tree: build 0 warnings / 0 errors, unit 313/313, integration 298/298 in 23s, smoke 127 passed / 0 failed (14 new), image 262 MB, compose-smoke 278 passed / 0 failed with 0 containers left behind (11 new, against the shipped image), console 90 assertions / 0 failed.

Refs OPEN-64.
2026-10-05 05:58:42 +02:00
Pavlo Ratushnyi a8f2b05340 an edge that refuses to start says so and then leaves
Every bound this build refuses to run with - the refresh TTL, the two retention windows, the push-attempt and retry intervals, the webhook timeout, the token pair - was already refused with a sentence naming the key and the value. The sentence was right and the form was not. Measured on the shipped image: an unhandled exception during startup printed the reason and then the process sat at 100% CPU inside the runtime's crash path. The container stayed "Up (unhealthy)" forever with no exit code, so compose reported nothing, k8s restarted nothing, and the only symptom of a mistyped number was a spinning core. OPEN-62 caught this for one refusal; this is the convention for all of them.

One way out: RefuseStartup writes the reason to stderr and returns 1, and every refusal goes through it, so the exit code is the same for all of them and a supervisor can tell "refused to start" from "an edge that died while serving". Most refusals are not raised in the entry point at all - the TTL and the retention windows surface during host start, when a hosted service resolves the service whose factory parsed the value - so app.Run is wrapped in a catch guarded by whether ApplicationStarted ever fired. Before that point an exception leaving app.Run is a configuration the operator can fix; after it, it is not, and it must not be reported as one.

What the run caught, in order: (1) The app.Run guard does not reach the three alert bounds, which are parsed in the entry point before the host exists, so MaxPushAttempts=0 still took the crash path - they are now wrapped where they are parsed. (2) The refusal messages name the key in the appsettings spelling (OpenWaf:State:RefreshTtlSeconds), not the environment spelling the gate overrode it with, so the first version of the new assertions failed four times for a reason that was the gate's, not the product's. (3) The shape of the assertion matters as much as the code: a gate that waits on the process cannot tell a refusal from a hang, which is exactly why OPEN-62's original assertion passed on a container that never exited. Both suites now start the edge detached and poll for an exit, and "still running after the bound" is a failure.

Gates on this tree: build 0 warnings / 0 errors, unit 307/307, integration 286/286 in 37s, smoke 113 passed / 0 failed (8 new: four bounds, each asserting the exit code and that the reason names the key), image 262 MB, compose-smoke 267 passed / 0 failed with 0 containers left behind (6 new, against the shipped image), console 90 assertions / 0 failed.

Refs OPEN-63.
2026-10-05 05:17:42 +02:00
Pavlo Ratushnyi 718dcaaba3 a second token can read the operator's surfaces and change none of them
One admin secret meant one thing: whatever could read /admin-api/state could also delete every block and rewrite the policy. A Prometheus scrape therefore held a key that can lift a ban, a second operator checking why a visitor was refused held a key that can change what the edge enforces, and OPEN-61's export put a whole edge's config behind the same single GET. The operator's question was never "does this thing know the secret" but "what is it allowed to do", and the shipped answer could only be all or nothing.

OpenWaf:Admin:ReadOnlyToken (env OPENWAF_READ_ONLY_TOKEN) is the second level. Unset is the default and the whole of the previous behaviour. The rulings:

 * A known token without the right is answered 403, not 401, and the body names the key that would grant the write. Collapsing the two sentences sends someone debugging a failing script to check the secret when what is wrong is the endpoint it was sent to.
 * The line is drawn by the request method, not by a flag per endpoint: GET/HEAD/OPTIONS read, everything else writes. A write endpoint added tomorrow is behind the rule the moment it is written; a per-endpoint flag would fail the other way, and one forgotten flag would open the write.
 * GET /admin-api/export is the one read held to the admin token. It is a read and it is still the whole config, so it is the surface where "can read" and "can take" are the same act - and the dashboard token is exactly the one that must not be able to lift a fleet's config.
 * A read-only token sees byte-identical answers to the admin token. Read-only is about what a token may do, not about a weaker view: two people comparing answers must not get different answers because of who asked.
 * A read-only token equal to the admin token (compared after trimming, because env files add newlines) aborts startup naming both keys and never the secret. /admin-api/state answers readOnlyTokenConfigured, so the operator can check the key took effect instead of guessing from a 401.

What the run caught, in order: (1) A real defect, and the interesting one. On the shipped image the startup refusal printed its reason and then the process sat at 100% CPU inside the runtime's crash path - the container stayed "Up (unhealthy)" forever, no exit code, nothing for a supervisor to react to. Refusing to start is only useful if the process leaves, so the refusal now writes the reason to stderr and returns 1; measured again on the image, it exits in 2 s with code 1 and the same sentence. (2) The gate's own assertion for that case had the same blind spot as the bug: waiting on a foreground docker compose run cannot tell "refused" from "hung", so the container is now started detached and polled for an exit within 30 s, and the assertion is that it left. (3) Two smoke asserts were wrong rather than the product: the blocks listing field is sourceKey, not ip, so the first version read an empty answer, and a two-code assertion compared a newline-separated pair against a space-separated literal. (4) An integration assert compared JsonElement.ToString() against "true" - a bool element prints True, so it now reads GetBoolean().

Gates on this tree: build 0 warnings / 0 errors, unit 307/307, integration 286/286 in 26s, smoke 105 passed / 0 failed (23 new), image 262 MB, compose-smoke 261 passed / 0 failed with 0 containers left behind (18 new, against the shipped image), console 90 assertions / 0 failed.

Refs OPEN-62.
2026-10-05 04:57:59 +02:00
Pavlo Ratushnyi 6664f94b22 an operator's decisions move to another edge in one call
An operator running several edges types every rule several times: blocks, allowlist, request rules, country rules and the policy overrides have their own endpoints one row at a time, and nothing moved them as a set. A new deployment starts empty, and a change that turns out wrong has nothing to be restored from. This is the multi-instance finding one level up from the shared streak store: SharedStreaks shares the counters, nothing shared the decisions.

GET /admin-api/export answers one document — version, exportedAt, edgeId, per-section counts, the policy section, and blocks / allowlist / rules / country rules. Only live rows; rules keep their evaluation order; and the document names how many engine bans it left behind, because "0 blocks" and "0 operator blocks, 7 engine bans left behind" are different sentences. A ban the engine earned is a claim about this edge's own traffic, so enforcing it where that traffic was never seen is a decision nobody made.

POST /admin-api/import is additive and idempotent: it never deletes a row the document does not mention — a transfer that silently clears a fleet's exemptions is worse than one that duplicates a block — a live row for the same source is reported as already there rather than rewritten, and expiry travels as an instant, so a block that expires in ten minutes where it came from expires in ten minutes here. Per-section counts (added / alreadyThere / skippedExpired / rejected) and a rejected[] list named by section and index; an unknown version, an oversize body or a malformed document writes nothing at all; a storage failure answers 503 with the report, because "it failed" and "it added 41 of 60" must not collapse into one sentence.

What the run caught, in order: (1) a unit assert used "203.0.113" as the invalid address and passed for the wrong reason — IPAddress.TryParse accepts it as 203.0.113.0, so the assert now names 203.0.113.999. (2) Two smoke asserts were wrong rather than the product: a helper printed a Python boolean where the gate compares text, and a blocks delete was asserted as 204 when the endpoint answers 200 with {"deleted":n}. (3) The metrics-as-a-number test could pass its wait on a cache refreshed between an enqueue and its first attempt — pending > 0 was true a moment before attempts > 0 could be — so the wait now requires both numbers. (4) A real defect, not a test one: the alert notifier left the rows it had claimed claimed when the process stopped, so the next process waited out the five-minute reclaim window to deliver an alert that was already owed. It now releases what it holds on the way out, and the reclaim window is back to being what it is for — a process that was killed and cannot say anything.

Gates on this tree: build 0 warnings / 0 errors, unit 285/285, integration 257/257 in 23s, smoke 82 passed / 0 failed (14 new), image 262 MB, compose-smoke 243 passed / 0 failed with 0 containers left behind (11 new, against the shipped image).

Refs OPEN-61.
2026-10-05 04:16:05 +02:00
Pavlo Ratushnyi 78e20b1859 the push queue says how hard it tried, not only what it still owes
The ticket named openwaf_alert_push_attempts_total and the queue published delivered instead. The two answer different questions: pending and given-up say what the queue holds now, attempts says what it cost to get there — attempts per delivery is what separates an endpoint that refuses everything from one that refuses occasionally, and it is the number that makes the give-up bound checkable from outside.

PushQueueCounts carries the sum, /metrics publishes it, /admin-api/state answers alertPushAttempts, and the smoke and compose gauge assertions now name all four. Re-run of every gate on this commit: build 0/0, unit 277/277, integration 251/251 in 34s, smoke 68/0, image 261 MB, compose-smoke 232/0 with 0 containers left behind, console 90/0.

Refs OPEN-60.
2026-10-05 03:31:51 +02:00
Pavlo Ratushnyi d635a00078 an alert that could not be pushed is pushed later, and says so while it waits
The push queue was a channel in one process: three attempts inside one request of work, then the row was simply no longer owed to anybody. An endpoint down for ten minutes swallowed every alert raised in that window, and a restart swallowed everything still waiting. The alert table stayed correct the whole time, which is exactly what made the hole invisible from the surface.

What is owed is now a row in alert_pushes: denormalised payload (retention prunes edge_alerts, and a delivery still owed must not go with the row it was copied from), attempts, next-attempt time, last error, and a claim so two edges over one database send each row once. Attempts are configuration (OpenWaf:Alerts:MaxPushAttempts, PushRetrySeconds), validated at startup like the other bounds; when they run out the row records that and the surface says how many were given up, because a counter that cannot tell 'still retrying' from 'stopped retrying' is the blindness this item removes.

Surfaces: /admin-api/state answers alertPushPending/Delivered/GivenUp/OldestPendingAt/LastError from the table, /metrics publishes the same as gauges from a cache no older than 5s (the metrics endpoint's rule is that it never leans on the database per scrape). Retention prunes only rows that are finished.

What the run caught, in order: (1) SchemaUpgradeTests hardcoded the migration count as a literal, so the new migration turned a working upgrade into a red test - the count is now read from the migrations assembly. (2) Two of the new queue tests asserted 'pending == 0' after waiting only for 'delivered >= 1'; one scene raises more than one alert, so the read landed between two rows and failed on a correct product - the wait now requires the queue to have emptied. (3) The whole integration suite answered 9 failures of 251, every one 'Timed out waiting for the entry point to build the IHost after 00:05:00', while the identical build minutes later answered 251/251 in 34s: a test host that cannot bind a loopback socket fails as a timeout, and the README now says so next to the scheduling note that used to be the only explanation on file.

Gates on this tree: build 0 warnings / 0 errors, unit 277/277, integration 251/251 in 34s, smoke 68 passed / 0 failed (3 new), image 261 MB, compose-smoke 232 passed / 0 failed with 0 containers left behind (2 new, including the push-queue table being added by the edge to a volume that predates it), console 90 assertions / 0 failed.

Refs OPEN-60.
2026-10-05 03:21:39 +02:00
Pavlo Ratushnyi 575ef88afe an operator can ask what the edge would answer, before it answers anyone
OPEN-59. Every other admin surface answers what the edge already did, so the only test for a path rule, an exemption or a country rule is a real visitor getting the real refusal. GET /admin-api/decide?ip=&path=&country= runs the same DecisionEngine over the same snapshot the wire reads — there is no second decision to drift — and narrates the order.

The trace is the product: a verdict says what would happen, the pillar list says which pillar to change, and it keeps four silences apart (did_not_match, not_reached, not_enforced_in_this_mode, not_evaluated). In Observe mode the engine line says whether a live ban for that source exists, because 'nothing was known about this address' and 'something was known and the mode chose not to act' are the two answers operators read as one. What a preview cannot honestly answer — the live rate counter and a streak that depends on responses the upstream has not produced — is named in the body rather than left out.

Three things the run caught. IPAddress.TryParse accepts abbreviated IPv4, so '203.0.113' parses as 203.0.113.0 and a missing octet was answered 'pass' for an address the operator did not mean; the guard now requires a full dotted quad. The preview read state.Current while the guard calls GetOrRefresh(), so it could answer from a snapshot the wire had already replaced — the whole claim of the feature is that the two agree. And a Pass carries no source key, so the Observe note claimed 'no live ban' for a source that had one; the key is now computed for the question rather than read off the answer.

Gates on this tree: build 0 warnings / 0 errors, unit 256/256, integration 245/245, smoke 65/0, compose 229/0 against the built image (261 MB), console 90/0.
2026-10-05 01:36:29 +02:00
Pavlo Ratushnyi 892cec172f the edge answers /metrics in the format the operator's alerting already reads
OPEN-58. The edge had one push surface — the alert webhook, at-most-once, for the four things it can alert about — and every other number it keeps was readable by a human on /admin-api/state and by nothing else. 'The ban writes have been failing for forty minutes' is a pull question with a threshold on it, so it belongs in Prometheus, where the operator already keeps their alerting.

The exposition is a pure type in the domain project (PrometheusText) rather than a metrics library: the numbers already exist in one place, and the parts that break a scrape — label escaping, HELP on one line, the name alphabet, NaN, sample ordering — are testable as a string without a running edge. EdgeCounterLedger adds the one piece of new state, counted at the single place that may refuse a request, so the verdict totals add up to the requests answered.

Three rules, each a decision: aggregate only (no source key, address, path, user agent or operator note anywhere in the body, and the only labels are bounded sets written in the code — a label per source is a cardinality explosion and an IP leak); no query per scrape (every number is already in memory, so a scrape cannot be what makes an unhealthy database unhealthy for the request path); and behind the same token as the admin API, on an always-pass prefix, so an edge that has blocked the operator's own address is still watchable. The token check moved out of the admin group into AdminAuth rather than being copied.

Three things the run caught. The 'closed surface' assertion passed alone and failed under the gate: Program falls back to OPENWAF_ADMIN_TOKEN when the configured token is blank and the gate scripts export a throwaway value into the test process, so a blank token there is an OPEN surface — 401, not 404. The smoke and compose sample helpers grepped for the metric name and matched the '# HELP' line first, answering with the help text's last word; they now match the line prefix. And EndpointFilterDelegate is not what AddEndpointFilter accepts — the two have different arities, which only shows when the filter is a method rather than a lambda at the call site.

Gates on this tree: build 0 warnings / 0 errors, unit 250/250, integration 236/236, smoke 60/0, compose 223/0 against the built image (261 MB), console 90/0.
2026-10-05 01:00:10 +02:00
Pavlo Ratushnyi b5d8d77870 the baseline asks the database which tables it has, because EF's own check answers wrong on postgres
Measured against a real postgres 18, not inferred: a database created by ensurecreated and then asked to migrate gained request_rules and source_streaks — one migration baselined, one applied, both rows in __EFMigrationsHistory, PK and both indexes present. Before this, the same scenario answered schemaMissingTables: [request_rules, source_streaks] and requestRulesAvailable false, and the log said nothing about why.

The reason it said nothing: IHistoryRepository.Exists() returned true for a database that has tables and no history table at all — the one state BaselineIfUntrackedAsync exists to notice — so the method returned 0 through its first guard and never reached a log line. The same call returns false on sqlite, which is why the sqlite integration test was green and the postgres path was broken: the test and the product were asking different providers. The check is now made against the table listing this step already takes, which is the answer both providers agree on.

The empty-listing branch is no longer silent either. An empty listing is the one answer that would make an upgrade destructive — it would mean 'create everything' against a database that has data — so it is logged rather than treated as 'empty database'.

Also measured on the same postgres instance, with the sqlite default strategy pointed at it: AddMissingTables created the two dropped tables in place (schemaTablesAdded 2, schemaMissingTables []) and the PK and both indexes arrived with the table, which is the GO-batch splitting in SchemaDdl working on a provider that uses batch separators.

Gates: build 0 warnings / 0 errors, unit 240/240, integration 230/230, smoke passed 52 failed 0, compose 216 passed 0 failed against the rebuilt image. Console unchanged at 90 assertions 0 failed from the previous commit; the admin surface this commit touches is a field the page does not read.
2026-10-04 23:43:30 +02:00
Pavlo Ratushnyi 871eac48a5 an upgrade adds the tables a database predates, and says what it added
The default schema step is EnsureCreated: it creates a missing database and changes nothing about an existing one. The migrate path could not rescue that database either, because a database EnsureCreated once made has no __EFMigrationsHistory, so the migration set would begin by creating tables that are already there. Same bug with two faces. An operator who upgraded kept a schema with every table except the new ones, and the pillar behind them answered as if there were nothing to see — the compose data volume outliving 'compose down' is exactly that state, which is where it was noticed.

At startup the edge now lists the tables the model describes and the database lacks and creates exactly those, from the model through the provider in use, indexes included. A table that exists is never touched, so an upgrade cannot lose an operator's block list — proven on the wire, not asserted: a block written before the upgrade still refuses the same request after it, with the note the operator typed still in the listing. On the migrate path a database with no history table is baselined first: a migration is claimed as applied only when every table its target model describes is already present, and the claim stops at the first migration it cannot confirm, so a later one is never applied over an unclaimed earlier one. SchemaBaseline is that decision as a pure function; SchemaDdl is the statement filter over EF's own generated script, and an unrecognised statement is left out rather than run, because the safe failure is a table that stays missing and is reported.

What happened is on /admin-api/state: schemaStrategy, schemaTablesAdded, schemaMigrationsBaselined, schemaMigrationsApplied, schemaMissingTables. The last is the invariant — non-empty names a pillar this build can run with no storage behind it, and OPENWAF_SCHEMA=none now changes nothing and reports all of it the same way. The limit is stated rather than hidden: the baseline recognises a table by its name, so a migration that alters an existing table still needs a human decision and the edge refuses to guess one.

OPENWAF_SCHEMA is read through configuration instead of the environment directly. An environment variable still sets it; the change is that a test can now ask for a strategy without mutating process-wide state that parallel xUnit collections share.

Gates on this tree: build 0 warnings / 0 errors, unit 240/240 (+13: the baseline claim, the statement filter), integration 230/230 in 22 s (+5: an edge started against a database with two tables dropped, the indexes arriving with the table, the operator block surviving, the baseline on the migrate path, and the operator-managed schema reporting rather than fixing), smoke passed 52 failed 0 unchanged, compose 216 passed 0 failed (+7: the same upgrade against the shipped image, where the volume really does outlive the stack), console 90 assertions 0 failed unchanged.

Two things the new compose scene caught about the gate itself. The rule-write assertion used code(), which discards the body, so the first run answered 400 and the gate could not say why — the assertion now prints the body it got. And the delete looked its rule up with jget while writing jcount's loop variable, a NameError inside the helper that surfaced as a 405 on the assertion: the trap the script's own comment names, walked into anyway.
2026-10-04 22:51:58 +02:00
Pavlo Ratushnyi f1715e4b7c a refused visitor gets the answer in sentences, and the status never moves
Every refusal this edge makes was written for the operator and read by a person. The audience that can actually act on a refusal — the office whose address tripped a streak, the visitor who followed a link into a path a rule refuses, the customer a geo policy misattributed — cannot do anything with {"error":"blocked_by_policy","reason":"3 consecutive refusals…"}. The guard now negotiates the body by Accept: a client that names text/html or application/xhtml+xml with q>0 gets a page, everything else gets the JSON it has always got. Accept: */* is deliberately not HTML: it means "I did not think about it", and it is what curl, monitors and SDKs send, which are exactly the clients that parse the body.

BlockPage is a pure function in the domain (no HttpContext, no I/O) so the wording is testable without a pipeline; it landed there rather than in Edge/Pipeline because the unit project references Domain and Infrastructure only. Three rules it exists to keep: the status never changes (a 429 that became 200 because a browser looked at it would be a defence that switches itself off when observed); nothing is fetched (inline CSS, no script/font/image/link, robots=noindex — the page goes to anonymous visitors and the runtime image is distroless); and the operator's own note is never rendered, because an operator block's reason is free text typed during an incident about a source, not a message to this visitor, so that branch shows the fact and no reference. What the page does carry is the machine reference the JSON already carried — rule_12, country_denied_DE, rate_3_of_2 — plus Retry-After and the expiry in UTC: the string the visitor quotes and the string the operator searches the listings for.

EdgeVerdict gained BlockRate so the rate branch logs the same verdict line the other four do instead of being the one refusal with no log, and the same helper now writes all five.

Gates on this tree: build 0 warnings / 0 errors, unit 227/227 (+20 BlockPage cases), integration 225/225 in 20 s (+6 wire cases asking what a browser and what curl get for the same refusal), smoke passed 52 failed 0 (+4), compose 209 passed 0 failed against the image at 261 MB, console 90 assertions 0 failed — unchanged, because this feature changes what a visitor sees and nothing the console shows.

The smoke count also had to be re-derived rather than trusted: a python replace whose replacement omitted its anchor deleted the line check 'the path is refused rather than proxied' 403 and left its command dangling as a continuation of the rule-add check above it, so the gate reported 51 and one assertion had silently vanished while still looking green. Same failure mode as the PolicyBounds edit earlier in this session — replace(a, b) where b does not contain a is a delete, not an insert.
2026-10-04 21:53:06 +02:00
Pavlo Ratushnyi 5cf93ef0fd a source that asks too often is stopped, even when the origin keeps answering
Every defence this edge had reads something that already happened: the status the
application answered, the country the address sits in, a list a human wrote. A
source asking for a cheap path two hundred times a minute produces no refusal, so
no streak matures, no path rule names it, and the origin serves all two hundred.
The only signal is the count, and a count has to be kept while the requests are
arriving — which is why this pillar is the one piece of live state on the request
path, and why it runs after the ordered decision instead of inside it.

`rateMode` off|observe|enforce, `rateLimitPerWindow`, `rateWindowSeconds`
(policy_settings, so no schema change). Off is the default: a limit nobody wrote
is a defence nobody asked for, and a false positive here locks out a whole office
behind one address. `observe` counts and raises one `rate_breach` alert per
source per window. `enforce` answers the request that crosses with 429 +
Retry-After — the surplus never reaches the origin — and writes an engine ban, so
the stop outlives the window, is shared with the other edges and survives a
restart; from then on the answer is the ban's own 403. One breach, one alert, one
ban write per source per window: a flood is exactly the traffic that turns a
per-request durable write into the thing that takes the database down.

Exempt by construction rather than by a second copy of the precedence rules: the
counter runs only on a plain Pass, so an always-pass prefix, an allowlisted
address, a matched rule, a block or a geo refusal never reaches it. The budget
counts exactly the requests that would have cost the origin.

Costs, stated rather than hidden: the counter is per process, so N edges allow N
times the budget (the same trade `SharedStreaks` made for the streak, at a round
trip per request instead of per observed response); the window is fixed, not
sliding, so the worst sustained rate is twice the limit across one boundary — a
sliding counter needs one entry per request, which is a map that grows at attack
rate.

Two things the run caught rather than the design assumed:

 * The guard wrote the 429 and then called next() anyway, so YARP answered
   "the request cannot be forwarded, the response has already started". The
   pillar now says whether the request may go through.
 * `StreakTracker.Configure` was called by nobody outside its own tests, so
   `maxTrackedSources` bounded nothing in a running edge — the map grew to the
   built-in 10000 whatever the operator had asked for. Both maps are configured
   at warm-up and on a policy write now.

And the smoke gate was not testing what its first line says. The edge was started
from the repository root, where there is no appsettings.json, so it loaded no
ReverseProxy section at all, logged "Request reached the end of the middleware
pipeline without being handled by application code" for every request, and
answered 404 for a path the upstream was serving with 200. Every assertion in the
file expects a 404 or a refusal, so the gate kept passing on an edge that never
proxied anything. Naming the content root fixes it; the streak scene also waits
for the ban row to exist before asking the wire whether it is enforced, because
the ban is written out of band after the response that proved it.

Gates on this tree: build 0 warnings 0 errors, unit 207/207, integration 219/219
in 20 s, smoke passed 48 failed 0, console 90 assertions 0 failed, compose 209
passed 0 failed, image 261 MB.

OPEN-56
2026-10-04 21:00:33 +02:00