diff --git a/.github/workflows/aot-probe.yml b/.github/workflows/aot-probe.yml
new file mode 100644
index 0000000..6b1c02c
--- /dev/null
+++ b/.github/workflows/aot-probe.yml
@@ -0,0 +1,87 @@
+# The NativeAOT relitigation, run on the architecture that ships it.
+#
+# Not a merge gate. `ci.yml` gates what ships; this one measures what does not
+# ship yet, and it is the only place the x86-64 musl AOT build can be produced —
+# 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 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.
+name: aot-probe
+
+on:
+ schedule:
+ - cron: '17 4 * * 1'
+ workflow_dispatch:
+
+env:
+ IMAGE: openwaf-aot-probe:ci
+
+jobs:
+ aot:
+ name: the static musl link, on x86-64
+ runs-on: ubuntu-latest
+ timeout-minutes: 45
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Docker CLI + compose plugin
+ run: |
+ set -eu
+ if command -v docker >/dev/null 2>&1; then
+ echo "docker already present: $(docker --version)"
+ else
+ export DEBIAN_FRONTEND=noninteractive
+ apt-get update -qq
+ apt-get install -qq -y ca-certificates curl gnupg >/dev/null
+ install -m 0755 -d /etc/apt/keyrings
+ curl -fsSL https://download.docker.com/linux/debian/gpg \
+ | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
+ chmod a+r /etc/apt/keyrings/docker.gpg
+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" \
+ > /etc/apt/sources.list.d/docker.list
+ apt-get update -qq
+ apt-get install -qq -y docker-ce-cli docker-compose-plugin docker-buildx-plugin >/dev/null
+ fi
+ [ -S /var/run/docker.sock ] || { echo "no /var/run/docker.sock on this runner"; exit 1; }
+
+ - name: Build the AOT image and keep the link report
+ run: |
+ set -eu
+ docker build -f Dockerfile.aot-probe -t "$IMAGE" --progress=plain . 2>&1 | tee /tmp/aot-build.log
+ printf 'image size: %s\n' "$(docker image ls --format '{{.Size}}' "$IMAGE")"
+ # The gate: the two lines the build stage prints about the binary itself.
+ grep -E 'program headers naming an interpreter: 0$' /tmp/aot-build.log >/dev/null \
+ || { echo 'the AOT binary names an interpreter — the link is not static'; exit 1; }
+ grep -E 'NEEDED shared objects: 0$' /tmp/aot-build.log >/dev/null \
+ || { echo 'the AOT binary needs a shared object — the link is not static'; exit 1; }
+ grep -E 'static-pie linked' /tmp/aot-build.log >/dev/null \
+ || { echo 'file(1) does not call this a static-pie executable'; exit 1; }
+ grep -E 'binary bytes: [0-9]+' /tmp/aot-build.log || true
+
+ # Reported, not gated: what the binary does once it is running. It is
+ # expected to die, and the log line it dies with is the finding.
+ - name: Start it and record what it says
+ run: |
+ set -uo pipefail
+ docker run -d --name aotprobe -p 18099:8080 \
+ -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
+ docker inspect --format 'container state: {{.State.Status}} health: {{if .State.Health}}{{.State.Health.Status}}{{else}}no healthcheck{{end}}' aotprobe
+ docker logs aotprobe 2>&1 | grep -m1 -E 'Hosting failed to start|unable to start|DllNotFoundException|Dynamic loading not supported|queries refused' \
+ || 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" \
+ | sed 's/^/queries refused at run time: /'
+ docker rm -f aotprobe >/dev/null 2>&1
diff --git a/Dockerfile.aot-probe b/Dockerfile.aot-probe
new file mode 100644
index 0000000..ac10973
--- /dev/null
+++ b/Dockerfile.aot-probe
@@ -0,0 +1,117 @@
+# syntax=docker/dockerfile:1.7
+#
+# NativeAOT probe: the packaging recipe that works for its neighbour project,
+# applied to this edge and measured. NOT the shipped image — Dockerfile (chiseled)
+# 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.
+#
+# 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)
+# and it gets there by deleting the thing that blocks us: it has no EF Core at
+# all — Npgsql plus a Roslyn source generator (app/lib/MicroOrm) that turns
+# Where(...) expressions into generated code at build time. The parts that
+# transfer regardless of the data layer are here:
+# apk add clang build-base cmake zlib-dev zlib-static openssl-dev openssl-libs-static
+# RID linux-musl-*, true,
+# true, true
+# scratch + CA bundle + SSL_CERT_FILE, healthcheck answered by the binary itself.
+# It also names the wall this host has: the musl AOT ILC crashes under emulation
+# on Apple Silicon, so the linux-musl-x64 build belongs on the x86 runner.
+
+ARG DOTNET_VERSION=10.0
+ARG DBIP_VERSION=2026-10
+ARG DBIP_EDITION=country
+
+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
+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/
+COPY dotnet/OpenWaf.Edge/OpenWaf.Edge.csproj OpenWaf.Edge/
+COPY dotnet/OpenWaf.Tests.Unit/OpenWaf.Tests.Unit.csproj OpenWaf.Tests.Unit/
+COPY dotnet/OpenWaf.Tests.Integration/OpenWaf.Tests.Integration.csproj OpenWaf.Tests.Integration/
+ARG TARGETARCH
+RUN case "${TARGETARCH}" in \
+ amd64) RID=linux-musl-x64 ;; \
+ arm64) RID=linux-musl-arm64 ;; \
+ *) printf 'no musl RID for architecture %s\n' "${TARGETARCH}" >&2; exit 1 ;; \
+ esac && printf 'RID=%s\n' "$RID" > /rid && dotnet restore OpenWaf.Edge/OpenWaf.Edge.csproj -r "$RID"
+
+FROM restore AS build
+COPY dotnet/ ./
+RUN . /rid && dotnet publish OpenWaf.Edge/OpenWaf.Edge.csproj \
+ -c Release \
+ -r "$RID" \
+ --self-contained true \
+ -p:PublishAot=true \
+ -p:InvariantGlobalization=true \
+ -p:DebugType=none \
+ -p:OpenWafCompiledModel=true \
+ -p:NoWarn=IL2026%3BIL3050 \
+ -p:IlcTreatWarningsAsErrors=false \
+ -p:StaticExecutable=true \
+ -p:StaticOpenSslLinking=true \
+ -p:IlcSingleThreaded=true \
+ -o /publish/api \
+ && mkdir -p /publish/data
+
+# The static-link claim, checked at build time rather than asserted in a comment:
+# a fully static executable has no PT_INTERP and `file` calls it static.
+RUN apk add --no-cache file binutils \
+ && BIN=/publish/api/OpenWaf.Edge \
+ && printf 'binary bytes: %s\n' "$(wc -c < "$BIN" | tr -d ' ')" \
+ && printf 'file says: %s\n' "$(file -b "$BIN")" \
+ && printf 'program headers naming an interpreter: %s\n' \
+ "$(readelf -l "$BIN" 2>/dev/null | grep -c 'program interpreter' )" \
+ && printf 'NEEDED shared objects: %s\n' \
+ "$(readelf -d "$BIN" 2>/dev/null | grep -c '(NEEDED)')"
+
+FROM curlimages/curl:8.10.1 AS geoip
+ARG DBIP_VERSION
+ARG DBIP_EDITION
+RUN mkdir -p /tmp/geoip && \
+ curl --fail --silent --show-error --location --retry 3 --retry-delay 2 \
+ "https://download.db-ip.com/free/dbip-${DBIP_EDITION}-lite-${DBIP_VERSION}.mmdb.gz" \
+ | gunzip > /tmp/geoip/GeoLite2-Country.mmdb
+
+FROM scratch
+# Content root is the working directory for a self-contained apphost, and this
+# one is the binary itself: without WORKDIR the process starts in / and never
+# finds appsettings.json, which leaves the proxy with no routes. Measured on the
+# scratch (JIT) image, where it cost 7 of the 368 assertions.
+WORKDIR /app
+COPY --from=build --chown=1654:1654 /publish/api/OpenWaf.Edge /app/OpenWaf.Edge
+COPY --from=build --chown=1654:1654 /publish/api/appsettings*.json /app/
+COPY --from=build --chown=1654:1654 /publish/data /app/data
+COPY --from=geoip --chown=1654:1654 /tmp/geoip /app/geoip
+# Outbound TLS (an https alert webhook, an https upstream) verifies a chain, and
+# scratch ships no trust store. Static OpenSSL reads this path when told to.
+COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
+
+USER 1654:1654
+
+ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
+ ASPNETCORE_URLS=http://+:8080 \
+ ASPNETCORE_FORWARDEDHEADERS_ENABLED=false \
+ ConnectionStrings__OpenWaf="Data Source=/app/data/openwaf.db" \
+ Database__Provider=sqlite \
+ GEOIP_MAXMIND_DB_PATH=/app/geoip/GeoLite2-Country.mmdb \
+ HEALTHCHECK_PORT=8080 \
+ OPENWAF_SCHEMA=script
+
+EXPOSE 8080
+
+HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
+ CMD ["/app/OpenWaf.Edge", "--healthcheck"]
+
+ENTRYPOINT ["/app/OpenWaf.Edge"]
diff --git a/README.md b/README.md
index 9f385cb..08b1c8d 100644
--- a/README.md
+++ b/README.md
@@ -368,10 +368,23 @@ scripts/ci-gates.sh scratch-image # build it, print both images' sizes
scripts/ci-gates.sh scratch-smoke # the 368, against it
```
-What is still not measured: a NativeAOT build of this edge that serves traffic.
-The NativeAOT entry in `docs/ARCHITECTURE.md` says what EF 10.0.12's precompiler
-refuses and what it emits when it does not — the static-binary shape is blocked
-there, not in the Dockerfile.
+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.
## Schema
diff --git a/docker-compose.aot.yml b/docker-compose.aot.yml
new file mode 100644
index 0000000..cbc7c57
--- /dev/null
+++ b/docker-compose.aot.yml
@@ -0,0 +1,11 @@
+# The same stack against the NativeAOT probe image (Dockerfile.aot-probe):
+# COMPOSE_FILE=docker-compose.yml:docker-compose.aot.yml scripts/compose-smoke.sh
+# This is a measurement, not a deployment: the binary is one fully static musl
+# executable on a scratch layer, and EF refuses its queries at run time, so the
+# suite is expected to fail — the point is how much of it survives and what the
+# edge says while it fails.
+services:
+ edge:
+ build:
+ context: .
+ dockerfile: Dockerfile.aot-probe
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 03f7054..0afc6f8 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -77,6 +77,23 @@ classifies the status, and is the only thing that can create an engine ban.
required are kept: they are behaviour-identical (378 unit, 405 integration,
256 smoke at the same commit) and they are the precondition for trying again
when EF's precompiler is fixed.
+
+ The **packaging** half of NativeAOT is not the problem and is now measured:
+ `Dockerfile.aot-probe` publishes against musl (`linux-musl-*`,
+ `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.
* **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