Files
Pavlo Ratushnyi 0a3d28184f
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
the aot edge serves traffic now, and the shape still missing a contract was its own healthcheck
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

164 lines
9.5 KiB
YAML

# 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:
#
# 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:
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; }
# Two builds, one cache. The image build produces the artifact; the
# `--target build` build produces the stage that HOLDS the binary, and a
# `docker run` of the report script against it always executes — which is
# what the gate needs, since a cached build layer prints nothing (run 2503
# failed on exactly that).
- name: Build the AOT image and ask the binary whether it is static
run: |
set -eu
docker build -f Dockerfile.aot-probe -t "$IMAGE" --progress=plain . 2>&1 \
| tail -20
printf 'image size: %s\n' "$(docker image ls --format '{{.Size}}' "$IMAGE")"
docker build -f Dockerfile.aot-probe --target build -t openwaf-aot-build:ci . 2>&1 \
| tail -5
docker run --rm --entrypoint sh openwaf-aot-build:ci /report.sh
# 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
# A run that died before its own teardown leaves the container behind on
# a shared daemon, and the next run then dies on the name rather than
# reporting anything (run 2507, exit 125: Conflict. The container name
# "/aotprobe" is already in use). Clear it first; there is nothing of
# this probe's worth keeping in it.
docker rm -f aotprobe >/dev/null 2>&1 || true
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
# 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).
{ 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: /'
# Did the host get as far as listening? Until 2026-10-06 the answer was
# no for a reason that had nothing to do with the database: the admin
# API's request DTOs had no compiled JSON contract, so the host threw
# before Kestrel opened a port. `OpenWaf.Edge/Admin/EdgeJson.cs` registers
# those contracts and Program.cs puts the context at the head of the
# resolver chain, so this line is the half-scoreboard of the API slice:
# a 0 here means the host still dies before serving, a 1 means it serves.
# Measured 1 on the arm64 half of this recipe's own tree on 2026-10-07
# (`scripts/aot-probe.sh`, which now gates that line and the refusal
# count below); this runner is where the x86-64 half gets said.
printf 'lines where the edge started listening: %s\n' "$(grep -c 'Now listening on:' aotprobe.log || true)"
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