diff --git a/.github/workflows/aot-probe.yml b/.github/workflows/aot-probe.yml
index 2072ba9..1c31ac3 100644
--- a/.github/workflows/aot-probe.yml
+++ b/.github/workflows/aot-probe.yml
@@ -5,18 +5,25 @@
# the musl AOT ILC crashes under emulation on Apple Silicon, so a local build
# can only ever produce the arm64 half of the story.
#
-# What it gates, and only this: that the AOT link is FULLY STATIC — no PT_INTERP,
-# no NEEDED shared object — because that is the claim `Dockerfile.aot-probe`
-# makes and the claim a scratch image depends on. A build that links against a
-# shared libc would still produce a bootable-looking image and a silently
-# different artifact.
+# What it gates:
#
-# What it reports without gating: that the binary then refuses to start, because
-# SQLitePCLRaw resolves libe_sqlite3 by dynamic loading and NativeAOT says
-# "Dynamic loading not supported". Behind that wall sits the next one — EF's
-# precompile-queries generator (docs/ARCHITECTURE.md, NativeAOT entry). Both are
-# recorded here rather than argued, and both are why the shipped images are the
-# chiseled and the self-contained-scratch ones.
+# 1. that the AOT link is FULLY STATIC — no PT_INTERP, no NEEDED shared object
+# — because that is the claim `Dockerfile.aot-probe` makes and the claim a
+# scratch image depends on. A build that links against a shared libc would
+# still produce a bootable-looking image and a silently different artifact.
+# 2. since 2026-10-06, that sqlite is INSIDE the binary rather than loaded by
+# it. `OpenWaf.Edge.csproj` links libsqlite3.a and asks ILC for a direct
+# call to the symbol (`NativeLibrary` + `DirectPInvoke`), and the proof is
+# behavioural: the log must carry the schema this binary creates for itself
+# and must NOT carry an `e_sqlite3` line. Behavioural because the binary is
+# stripped — `nm` cannot answer this question at all, and a stripped binary
+# with a missing symbol and a stripped binary with it inside look identical
+# to any tool that only reads the file.
+#
+# What it reports without gating: that the edge then refuses every query —
+# "Query wasn't precompiled and dynamic code isn't supported with NativeAOT" —
+# which is EF's precompile-queries generator, the next wall and the one the
+# generator slice is about (docs/ARCHITECTURE.md, NativeAOT entry).
name: aot-probe
on:
@@ -85,14 +92,61 @@ jobs:
-e OPENWAF_ADMIN_TOKEN=ci-only-throwaway \
-e ReverseProxy__Clusters__upstream__Destinations__upstream1__Address=http://127.0.0.1:1/ \
"$IMAGE" >/dev/null
- sleep 20
+ # A bounded wait, not a fixed sleep. Measured on 2026-10-06 against the
+ # same image: on a quiet host the edge reached its schema step in about
+ # 6 seconds; on a loaded one it had not got there after 22. A gate that
+ # reads the log too early reports a missing schema line as if the sqlite
+ # link had regressed, so it waits for the edge to say something — the
+ # schema, or a startup failure — and prints how long it waited.
+ waited=0
+ while [ "$waited" -lt 180 ]; do
+ docker logs aotprobe > aotprobe.log 2>&1
+ if grep -qE 'created 12 table\\(s\\)|Hosting failed to start|DllNotFoundException|Dynamic loading not supported' aotprobe.log; then
+ break
+ fi
+ sleep 3; waited=$((waited + 3))
+ done
+ printf 'waited %s s for the edge to reach its schema step\n' "$waited"
docker inspect --format 'container state: {{.State.Status}} health: {{if .State.Health}}{{.State.Health.Status}}{{else}}no healthcheck{{end}}' aotprobe
# `|| true` on both greps: grep exits 1 when it matches nothing, and a
# zero count is a finding, not a step failure. Measured on run 2501,
# where the reporting step died on exactly that while the static-link
# gate above it had already passed (56,351,320-byte static-pie x86-64
# binary, 0 interpreters, 0 NEEDED, 94.5 MB image).
- docker logs aotprobe 2>&1 | { grep -m1 -E 'Hosting failed to start|DllNotFoundException|Dynamic loading not supported' || echo 'no startup failure line found — that would be news worth reading'; }
- docker logs aotprobe 2>&1 | { grep -c "Query wasn't precompiled and dynamic code isn't supported with NativeAOT" || true; } \
- | sed 's/^/queries refused at run time: /'
+ { grep -m1 -E 'Hosting failed to start|DllNotFoundException|Dynamic loading not supported' aotprobe.log \
+ || echo 'no startup failure line found — that would be news worth reading'; }
+
+ # Reported, not gated: the SECOND wall, found on 2026-10-06 once the
+ # sqlite one came down. The web host itself refuses to start because the
+ # admin API's request DTOs have no JSON source-generation metadata —
+ # `JsonTypeInfo metadata for type 'OpenWaf.Edge.Admin.NewBlockRequest'
+ # was not provided by TypeInfoResolver`. The route handlers are already
+ # the generated ones (`GeneratedRouteBuilderExtensionsCore` is in the
+ # stack), so this is the API half of the same slice: register the
+ # contract, do not reflect over it at run time.
+ printf 'json metadata refusals at startup: %s\n' "$(grep -c 'JsonTypeInfo metadata for type' aotprobe.log || true)"
+ { grep -m1 -o "JsonTypeInfo metadata for type '[^']*'" aotprobe.log || true; } | sed 's/^/first type without a contract: /'
+ grep -c "Query wasn't precompiled and dynamic code isn't supported with NativeAOT" aotprobe.log \
+ | sed 's/^/queries refused at run time: /' || true
+
+ # Gate 2: sqlite inside the binary, not loaded by it. Measured on the
+ # arm64 half of this same recipe on 2026-10-06: 58,343,456-byte
+ # static-pie binary, 0 interpreters, 0 NEEDED, 96.4 MB image, and a log
+ # with 0 `e_sqlite3` lines that says it created 12 tables from the DDL
+ # the binary carries. Before the link those two numbers were the other
+ # way round: the run died in `SqliteConnection..cctor` with
+ # `DllNotFoundException: e_sqlite3`.
+ printf 'e_sqlite3 lines in the log: %s\n' "$(grep -c e_sqlite3 aotprobe.log || true)"
+ printf 'schema lines from the carried DDL: %s\n' "$(grep -c 'created 12 table(s)' aotprobe.log || true)"
+ if grep -q 'e_sqlite3' aotprobe.log; then
+ echo 'NOT static sqlite: the binary is reaching for a shared library again — the DirectPInvoke/NativeLibrary link regressed'
+ docker rm -f aotprobe >/dev/null 2>&1 || true
+ exit 1
+ fi
+ if ! grep -q 'created 12 table(s)' aotprobe.log; then
+ echo 'the binary never created its schema: sqlite is not working inside it'
+ docker rm -f aotprobe >/dev/null 2>&1 || true
+ exit 1
+ fi
+ echo 'sqlite is inside the binary: no dynamic load, schema created from the DDL it carries'
docker rm -f aotprobe >/dev/null 2>&1 || true
diff --git a/Dockerfile.aot-probe b/Dockerfile.aot-probe
index 09b3f1b..2fc3235 100644
--- a/Dockerfile.aot-probe
+++ b/Dockerfile.aot-probe
@@ -5,12 +5,16 @@
# and Dockerfile.scratch (self-contained on no base) are what ship.
#
# What this proves: the AOT build of this program links FULLY STATIC against musl
-# — no libc, no interpreter — so a scratch layer holding one binary is reachable
-# for openwaf too. What it does not prove: that the binary serves traffic. EF
-# refuses to compile a LINQ query at run time in a NativeAOT binary and EF
-# 10.0.12's precompile-queries generator cannot produce code for this model;
-# docs/ARCHITECTURE.md (NativeAOT entry) carries the four refusal shapes and the
-# codegen bug, and scripts/aot-probe.sh reproduces the runtime half.
+# — no libc, no interpreter — AND carries sqlite inside itself rather than
+# loading one: sqlite-static on the link line plus DirectPInvoke in
+# OpenWaf.Edge.csproj, so ILC emits a direct call to the symbol and nothing ever
+# asks NativeLibrary.Load. Measured 2026-10-06: 0 e_sqlite3 lines in the log and
+# the edge creating 12 tables from the DDL it carries. What it does not prove:
+# that the binary serves traffic. EF refuses to compile a LINQ query at run time
+# in a NativeAOT binary and EF 10.0.12's precompile-queries generator cannot
+# produce code for this model; docs/ARCHITECTURE.md (NativeAOT entry) carries the
+# four refusal shapes and the codegen bug, and scripts/aot-probe.sh reproduces
+# the runtime half.
#
# The recipe is not invented here. ~/work/tskr ships a .NET 10 NativeAOT API FROM
# scratch as one static musl binary (app/api/Dockerfile, app/api/leasevibe.csproj)
@@ -33,7 +37,8 @@ FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-alpine AS restore
WORKDIR /src
# The AOT link needs a real toolchain plus the STATIC system libs: libz.a,
# libssl.a, libcrypto.a. cmake is pulled in by the StaticOpenSslLinking step.
-RUN apk add --no-cache clang build-base cmake zlib-dev zlib-static openssl-dev openssl-libs-static
+RUN apk add --no-cache clang build-base cmake zlib-dev zlib-static openssl-dev openssl-libs-static \
+ sqlite-dev sqlite-static
COPY dotnet/global.json dotnet/Directory.Build.props dotnet/NuGet.Config dotnet/OpenWaf.slnx ./
COPY dotnet/OpenWaf.Domain/OpenWaf.Domain.csproj OpenWaf.Domain/
COPY dotnet/OpenWaf.Infrastructure/OpenWaf.Infrastructure.csproj OpenWaf.Infrastructure/
diff --git a/README.md b/README.md
index adbcc2f..19d2ad0 100644
--- a/README.md
+++ b/README.md
@@ -379,19 +379,51 @@ And the fully static shape, measured the same day rather than argued:
`Dockerfile.aot-probe` publishes this edge NativeAOT against musl and puts the
result on scratch. The link really is static — `file` calls the binary
`static-pie linked`, `readelf -l` finds **0** program interpreters, `readelf -d`
-finds **0** `NEEDED` shared objects — one **56,820,992-byte** file in a **94 MB**
-image, against 222 MB self-contained and 262 MB chiseled. It does not serve. It
-dies in `Microsoft.Data.Sqlite.SqliteConnection..cctor` with
-`DllNotFoundException: e_sqlite3` and `Dynamic loading not supported`:
-SQLitePCLRaw resolves sqlite by loading a shared library, and a NativeAOT binary
-has no way to load one. Behind that wall sits EF's query precompiler (the
-NativeAOT entry in `docs/ARCHITECTURE.md`). So the packaging is reachable and the
-data layer is the wall — which is the choice a neighbouring deployment of the same
-runtime made: no EF Core and no SQLite, Npgsql plus a Roslyn source generator that
-emits the queries at build time, one static binary in production.
-`.github/workflows/aot-probe.yml` re-measures this on the x86-64 runner weekly,
-because the musl AOT compiler crashes under emulation on Apple Silicon and a
-laptop can only ever produce the arm64 half.
+finds **0** `NEEDED` shared objects — one **58,343,456-byte** file in a
+**96.4 MB** image (arm64/musl, measured 2026-10-06), against 222 MB
+self-contained and 262 MB chiseled.
+
+**The sqlite wall is closed, and the sentence this paragraph used to carry was
+wrong for this tree.** It said the binary dies in
+`Microsoft.Data.Sqlite.SqliteConnection..cctor` with `DllNotFoundException:
+e_sqlite3`. That was true of a build that *did not link sqlite*. Two items in
+`OpenWaf.Edge.csproj`, musl-only, close it: `NativeLibrary` puts
+`/usr/lib/libsqlite3.a` (Alpine `sqlite-static`) on the link line and
+`DirectPInvoke` makes ILC emit a **direct call to the symbol** instead of a
+run-time module load. With only the first, the binary still calls
+`NativeLibrary.Load("e_sqlite3")` at the first query and NativeAOT answers
+`Dynamic loading not supported` — which is what the probe was reporting. These
+are the same two items the runtime pack uses for `System.Native` and the OpenSSL
+shim (`Microsoft.NETCore.Native.Unix.targets`), not an invention here. Measured
+after the change: the log carries **0** `e_sqlite3` lines and says the edge
+**created 12 tables** from the DDL the binary carries. The proof is behavioural
+because the binary is stripped — `nm` reports **0** `sqlite3_` symbols on a
+binary that demonstrably runs sqlite, so no tool that only reads the file can
+answer this question. A standalone probe says the same thing one level down:
+`Microsoft.Data.Sqlite` opens a connection and reads `sqlite_version()` back
+(3.53.4) from a fully static AOT binary — so the ADO layer survives and only
+EF's *query compilation* is the wall.
+
+It still does not serve, and the probe now names **two** walls rather than one,
+which is what closing the first one buys:
+
+- the web host refuses to start at all — `Hosting failed to start` /
+ `JsonTypeInfo metadata for type 'OpenWaf.Edge.Admin.NewBlockRequest' was not
+ provided by TypeInfoResolver`. 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.
+- and every query is refused — `Query wasn't precompiled and dynamic code isn't
+ supported with NativeAOT`, 2 refusals in the probe window — which is EF's
+ precompiler (the NativeAOT entry in `docs/ARCHITECTURE.md` carries its four
+ untranslatable query shapes and its codegen bug).
+
+The shape that ships past both walls, in a neighbouring deployment of the same
+runtime, has no EF Core at all: Npgsql plus Roslyn source generators that emit
+the queries — and the endpoints, and the OpenAPI document — at build time, one
+static binary in production. `.github/workflows/aot-probe.yml` re-measures this
+on the x86-64 runner weekly, because the musl AOT compiler crashes under
+emulation on Apple Silicon and a laptop can only ever produce the arm64 half.
## Schema
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 0afc6f8..e60e37e 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -83,17 +83,44 @@ classifies the status, and is the only thing that can create an engine ban.
`StaticExecutable=true`, `StaticOpenSslLinking=true`, `IlcSingleThreaded=true`)
and the result is one fully static binary — `file`: `static-pie linked`,
`readelf -l`: **0** program interpreters, `readelf -d`: **0** `NEEDED` shared
- objects, **56,820,992 bytes**, a **94 MB** scratch image against 222 MB
- self-contained and 262 MB chiseled. It dies one step before the query wall:
- `Microsoft.Data.Sqlite.SqliteConnection..cctor` → `DllNotFoundException:
- e_sqlite3`, `Dynamic loading not supported`, because SQLitePCLRaw resolves
- sqlite by loading a shared library and a NativeAOT binary cannot load one.
- The deployment that does ship this way has neither EF Core nor SQLite: Npgsql
- (managed) plus a Roslyn source generator that turns `Where(...)` into generated
- code at build time. Re-measured on x86-64 weekly by
- `.github/workflows/aot-probe.yml`, which gates only the static-link claim —
- the musl AOT ILC crashes under emulation on Apple Silicon, so the x86 number
- cannot come from a laptop.
+ objects — a **96.4 MB** scratch image against 222 MB self-contained and 262 MB
+ chiseled.
+
+ **Ruling, 2026-10-06: every native dependency is baked into the link, and the
+ link is checked after it runs.** The sentence this entry used to carry — that
+ the binary dies in `SqliteConnection..cctor` with `DllNotFoundException:
+ e_sqlite3` — described a build that did not link sqlite. Two musl-only items in
+ `OpenWaf.Edge.csproj` close that wall: `NativeLibrary` puts
+ `/usr/lib/libsqlite3.a` (Alpine `sqlite-static`) on the link line, and
+ `DirectPInvoke` makes ILC emit a **direct call to the symbol** instead of a
+ run-time module load. Only the first is not enough: the binary then still calls
+ `NativeLibrary.Load("e_sqlite3")` at the first query and NativeAOT answers
+ `Dynamic loading not supported`. The pair is what the runtime pack itself uses
+ for `System.Native` and the OpenSSL shim (`Microsoft.NETCore.Native.Unix.targets`
+ 140–155), so it is the SDK's mechanism, not a fork of it. Measured on the arm64
+ half: **58,343,456-byte** static-pie binary, 0 interpreters, 0 NEEDED, and a log
+ with **0** `e_sqlite3` lines that says the edge **created 12 tables** from the
+ DDL it carries. A standalone probe with the same link shows `Microsoft.Data.Sqlite`
+ opening a connection and reading `sqlite_version()` (3.53.4) back — so the ADO
+ layer survives and **only EF's query compilation is left**.
+ The check that sqlite is inside the binary is **behavioural**, and has to be:
+ the binary is stripped, and `nm` reports **0** `sqlite3_` symbols on a binary
+ that demonstrably runs sqlite. `nm` cannot answer this question; only the run
+ can. `.github/workflows/aot-probe.yml` now gates three things after the link —
+ no interpreter, no `NEEDED`, no `e_sqlite3` line — plus the positive half, the
+ schema line, because a gate that only forbids an error string also passes when
+ the feature is simply absent.
+
+ What remains is the query wall and nothing else: the edge starts, creates its
+ schema, refuses every query (`Query wasn't precompiled and dynamic code isn't
+ supported with NativeAOT`, 2 refusals in a 25-second window) and never reaches
+ `Now listening`. The shape that ships past it, in a neighbouring deployment of
+ the same runtime, has no EF Core at all: a Roslyn source generator emits the
+ queries — and the endpoints, and the OpenAPI document — at build time over
+ `System.Data.Common`, with the concrete driver supplied at composition. That is
+ the slice this entry now points at, and the reason it is the *correct* step
+ rather than the cheap one: it removes the only remaining wall instead of
+ routing around it.
* **Keying the ban on ip+UA** (as the analytics `SessionHash` does): a bot that
varies its UA multiplies into many sources and never reaches the threshold.
* **Banning on 5xx because the original wording said `> 400`**: turns an outage
diff --git a/dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj b/dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj
index 253f878..aa9d58b 100644
--- a/dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj
+++ b/dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj
@@ -24,4 +24,22 @@
+
+
+
+
+
+