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.
This commit is contained in:
Pavlo Ratushnyi
2026-10-07 19:28:22 +02:00
parent 5c1a2950d0
commit 0a3d28184f
8 changed files with 250 additions and 73 deletions
+3
View File
@@ -133,6 +133,9 @@ jobs:
# 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
+66 -25
View File
@@ -404,19 +404,24 @@ answer this question. A standalone probe says the same thing one level down:
(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:
It named **two** walls rather than one, which is what closing the sqlite one
bought; as of 2026-10-07 **the first of those two is down on this tree**:
- the web host refuses to start at all — `Hosting failed to start` /
- ~~the web host refuses to start at all~~ — closed. The AOT edge now reaches
`Now listening on:`, answers `/healthz` with 200, proxies a request to the
upstream for 200, and its own `--healthcheck` mode exits 0. The refusal was
`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).
provided by TypeInfoResolver`; the route handlers in that stack were already
the generated ones (`GeneratedRouteBuilderExtensionsCore`), so the API half was
never missing code generation, only a registered contract for the shapes that
cross the wire. See the next section.
- every query is still refused — `Query wasn't precompiled and dynamic code isn't
supported with NativeAOT`, **32 refusals in the 2026-10-07 probe window**
(30 in the run before it — it counts a window, not a total, because the
background refresh loop retries on its own clock) —
which is EF's precompiler (the NativeAOT entry in `docs/ARCHITECTURE.md`
carries its four untranslatable query shapes and its codegen bug). This is the
one wall left, and it is the generator slice.
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
@@ -436,9 +441,13 @@ not braces in the code): **144 anonymous-object literals**, in **27 distinct
shapes**, of which **111 are the one shape `new { error = … }`**. A source
generator cannot describe an anonymous type at all, so those 111 became one
named record — `ErrorDto` — and `Admin/EdgeJson.cs` is now the edge's
`JsonSerializerContext`: 24 registered types (the 5 request bodies, the 14
`JsonSerializerContext`: **29 registered types** (the 5 request bodies, the
response records the tree already had, `ErrorDto`, `ReadOnlyRefusalDto`, the
config-transfer document and its rejected-item row), with
config-transfer document and its rejected-item row, `HealthDto`, `ReadinessDto`,
`ProblemDetails`, `ValidationProblemDetails`). The previous sentence in this
section said 24, and 24 was already stale when it was written: the file at that
commit holds 25 — `CountrySummaryDto` arrived without the count being
re-derived. With
`[JsonSourceGenerationOptions(PropertyNamingPolicy = CamelCase)]` because the
generated contract carries the property names — without that line the same record
answers `{"Error": …}` and every consumer of this API reads a body with no error
@@ -454,7 +463,9 @@ learn:
fails on a *JIT* build with the same sentence the AOT probe reports
(`JsonTypeInfo metadata for type '<>f__AnonymousType0` `` `1[System.String]' was
not provided by TypeInfoResolver of type '[EdgeJson]'` `, from a standalone
probe). Thirty-one anonymous literals are still standing, so on a build that
probe). Twenty-nine anonymous literals are still standing (2026-10-07: 22 of
them response shapes, 7 inside an EF query's `Select`, which is the query
wall's problem rather than this one), so on a build that
can reflect, reflection stays at the end of the chain: the debt kept served and
visible rather than a break smuggled into a slice.
* **That fallback is not free on the other side.** Naming
@@ -468,23 +479,53 @@ learn:
not a clean A/B — the weekly runner is where the clean number will come from.
What is measured on this tree: `dotnet build OpenWaf.Edge -c Release` **0
warnings**, unit **378/378**, and integration **407/407 in 2 m 16 s** — the two
new ones are `AotJsonContractTests`, which asks the running edge which body types
warnings**, unit **378/378**, and integration **408/408 in 51 s** — three of them
`AotJsonContractTests`, which asks the running edge which body types
its endpoints accept (`IAcceptsMetadata`, read from the live endpoint table, so an
endpoint added without a contract is red here rather than in next Monday's probe)
and asserts the generated contract really says `error` and not `Error`. The
407th number also carries a caveat worth keeping: the same suite run **inside the
sandbox** answered **8 failures of 407**, every one of them
and asserts the generated contract really says `error` and not `Error`, and that
the `ProblemDetails` body every handler falls back to has a contract too. The
408th number also carries a caveat worth keeping: the same suite — 407 tests at
the time — run **inside the sandbox** answered **8 failures of those 407**, every
one of them
`Timed out waiting for the entry point to build the IHost after 00:05:00` — the
loopback-bind symptom this README already recorded on 2026-10-04 and 2026-10-05,
reproduced here rather than re-diagnosed.
What is **not** measured on this tree: whether the AOT edge now reaches
`Now listening`. The rebuild that would answer it was interrupted, and the answer
is the reason the probe now prints `lines where the edge started listening` —
a 0 means the host still dies before serving, a 1 means it serves. The remaining
**31 anonymous literals, in 25 distinct shapes**, are what stands between the
two, and they are the next cut.
What the AOT edge then **does**, measured on this tree on 2026-10-07 with
`scripts/aot-probe.sh` (osx-arm64, a **49,609,680-byte** native binary, 10 IL
warnings, 0 errors):
```
lines where the edge started listening: 1
json metadata refusals: 0 (was 55, then 1)
queries refused at run time: 32
```
The 55 were **one shape**: the anonymous 8-property `/healthz` literal — the
endpoint a scratch container's `HEALTHCHECK` asks, so the edge was serving
traffic while its own liveness probe declared it dead. `Health/HealthDtos.cs`
names it (`HealthDto`, `ReadinessDto`). The 1 that followed was
`Microsoft.AspNetCore.Mvc.ProblemDetails`, the body `Results.Problem` writes and
nobody's DTO in this project; its visible cost was a `/readyz` **500 that named
nothing** where a **503 naming the failure** is the truth.
The probe's scoreboard is now split the way the finding is: three assertions that
need no query are **gated** (`/healthz` 200, proxy 200, `--healthcheck` exit 0),
five that do are **recorded** with the answer a working edge would give — an
operator block answers 503 where 204 is right, the streak ban never forms,
`/readyz` says 503 — and any of them that ever matches prints `MOVED`, which is
the signal that the query wall moved. The 503 is worth reading, because it is the
one the JIT edge gives: `{"status":503,"detail":"Query wasn't precompiled and
dynamic code isn't supported with NativeAOT."}`. Before `ProblemDetails` had a
contract that body did not exist and the status was 500. Two probe bugs came out of doing this: it
sent `Authorization: Bearer` to the admin API, which `AdminAuth` does not read
(three assertions were measuring a 401 rather than the query wall), and it
checked nothing about whether the host had listened at all.
The remaining **29 anonymous literals in 23 shapes** are the rest of the API
wall: **22 response shapes** and **7 that live inside an EF query's `Select`**
and belong to the query wall instead.
The first version of this section carried **130 literals in 51 shapes**, and
`fb75890` repeats those figures in its message. They came from a first-pass
+37 -16
View File
@@ -40,11 +40,17 @@ classifies the status, and is the only thing that can create an engine ban.
denied country gets whichever guard runs first.
* **Two block tables**: makes "clear engine bans" a table operation and invites
a future merge that loses data.
* **NativeAOT**: relitigated here on 2026-10-06 and measured, not inherited. The
build compiles (48.8 MB native arm64 binary, 10 IL warnings, 0 errors) and the
edge starts and creates its own schema from the DDL the binary carries — but it
never serves: EF refuses to compile a LINQ query at run time in a NativeAOT
binary, and the only alternative, `dotnet ef dbcontext optimize
* **NativeAOT**: relitigated here on 2026-10-06 and measured, not inherited, and
re-measured on 2026-10-07. The build compiles — a **49,609,680-byte** native
arm64 binary, 10 IL warnings, 0 errors; the "48.8 MB" this entry used to carry
is a rounded figure no measured binary of this tree matches — and the edge
starts, creates its own schema from the DDL the binary carries **and serves**:
`Now listening on:`, `/healthz` 200, a proxied request 200, its own
`--healthcheck` mode exit 0. What it still cannot do is run a query. EF refuses
to compile a LINQ query at run time in a NativeAOT binary — **32 refusals in
the 2026-10-07 probe window**, 30 in the run before it: a window count, not a
total, because the background refresh loop retries on its own clock — and the
only alternative, `dotnet ef dbcontext optimize
--precompile-queries`, first refused 40 of this tree's queries (parameter-symbol
roots and captures, dotnet/efcore#35887 / #38030 / #35494, fixed only in the
12.0-preview1 line). Four refusals remain, and they are not a style to rewrite
@@ -111,12 +117,24 @@ classifies the status, and is the only thing that can create an engine ban.
schema line, because a gate that only forbids an error string also passes when
the feature is simply absent.
What remains is **two** walls, not one. The edge 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`
— and the reason it never listens is upstream of the database: the admin API's
request DTOs had no compiled JSON contract, so the host throws before Kestrel
opens a port.
What were **two** walls on 2026-10-06 is **one**. The API wall came down on
2026-10-07: the edge reaches `Now listening on:` and serves, and
`scripts/aot-probe.sh` now gates exactly that — a `Now listening on:` line must
be in the log and no response may be refused for want of a compiled contract.
The **55** refusals standing between the first cut and a serving edge were
**one shape**: the anonymous 8-property `/healthz` literal, which is the
endpoint a scratch container's `HEALTHCHECK` asks — an edge serving traffic
while its own liveness probe called it dead. The **1** after that was
`Microsoft.AspNetCore.Mvc.ProblemDetails`, the body `Results.Problem` writes
and nobody's DTO here, whose cost was a `/readyz` 500 naming nothing where a
503 naming the failure is the truth. The query wall is what is left: 30
refusals in that window, and five query-backed assertions the probe now
**records** rather than checks — an operator block answers 503 where 204 is
right, the streak ban never forms, `/readyz` says 503 where 200 is right — each
printing `MOVED` the day EF compiles a query again. The `/readyz` 503 carries
the sentence now (`"detail":"Query wasn't precompiled and dynamic code isn't
supported with NativeAOT."`); with no contract for that body it was a 500
saying nothing.
**The API half, first cut (2026-10-07).** A source generator cannot describe an
anonymous type, and the edge's wire shapes were largely anonymous: **144
@@ -125,11 +143,14 @@ classifies the status, and is the only thing that can create an engine ban.
the first pass reported 130 in 51 because it counted braces inside interpolated
strings as code). Those 111 are now one named record
(`ErrorDto`), and `Admin/EdgeJson.cs` is the edge's `JsonSerializerContext` —
24 registered types, `[JsonSourceGenerationOptions(PropertyNamingPolicy =
CamelCase)]` because the generated contract carries the property names and the
whole API reads `error`, not `Error` — registered at the head of the resolver
chain in `Program.cs`. **31 anonymous literals in 25 shapes remain**, and
they are the rest of this wall. Two facts about the wiring are load-bearing and were
**29 registered types** — 25 at the commit this entry first described, and the
"24" it and the README carried was stale the day it was written — with
`[JsonSourceGenerationOptions(PropertyNamingPolicy = CamelCase)]` because the
generated contract carries the property names and the whole API reads `error`,
not `Error`, registered at the head of the resolver chain in `Program.cs`.
**29 anonymous literals in 23 shapes remain**: **22 response
shapes**, and **7 inside an EF query's `Select`**, which are the query wall's
problem rather than this one. Two facts about the wiring are load-bearing and were
measured, not assumed: a non-empty `TypeInfoResolverChain` **replaces** the
reflection resolver rather than extending it (so an unregistered type breaks on
a JIT build too, with the same sentence the AOT probe reports), and naming
+19 -1
View File
@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Json.Serialization;
using OpenWaf.Edge.Health;
namespace OpenWaf.Edge.Admin;
@@ -6,7 +8,7 @@ namespace OpenWaf.Edge.Admin;
/// The edge's source-generated JSON contract — the half of the NativeAOT slice
/// that is not the database.
///
/// Measured on 2026-10-06, the AOT edge does not start at all: the host dies with
/// Measured on 2026-10-06, the AOT edge did not start at all: the host died with
/// <c>JsonTypeInfo metadata for type 'OpenWaf.Edge.Admin.NewBlockRequest' was not
/// provided by TypeInfoResolver</c> (3 refusals in the probe window), while the
/// route handlers in that same stack are already the generated ones
@@ -16,6 +18,14 @@ namespace OpenWaf.Edge.Admin;
/// the fallback it would need is exactly the thing the runtime refuses
/// (<c>Dynamic code isn't supported with NativeAOT</c>).
///
/// What registering it bought, measured on 2026-10-07 with the same probe: the
/// edge now reaches <c>Now listening on:</c>, creates its 12 tables from the DDL
/// it carries and proxies a request to the upstream for 200. The one shape still
/// refused at run time was <c>/healthz</c> — 55 refusals, all of them the same
/// anonymous 8-property literal, now <see cref="HealthDto"/>. That is the shape
/// the container's own HEALTHCHECK asks, so the edge was serving traffic while
/// declaring itself dead.
///
/// The recipe is taken, not invented: this is how the neighbouring .NET 10
/// NativeAOT deployment does it (<c>app/lib/Kernel/KernelJson.cs</c> and
/// <c>api/Domain/AppJson.cs</c> in <c>~/work/tskr</c> — one context per assembly,
@@ -48,6 +58,14 @@ namespace OpenWaf.Edge.Admin;
[JsonSerializable(typeof(RateSourceDto))]
[JsonSerializable(typeof(ObservationDto))]
[JsonSerializable(typeof(StreakDto))]
// The body Results.Problem writes — the error path of /readyz and of every
// handler that catches. Measured 2026-10-07: once /healthz got its contract this
// was the ONLY remaining refusal in the probe window (1 of them), and it turned a
// 503 that names the failure into a 500 that names nothing.
[JsonSerializable(typeof(ProblemDetails))]
[JsonSerializable(typeof(ValidationProblemDetails))]
[JsonSerializable(typeof(HealthDto))]
[JsonSerializable(typeof(ReadinessDto))]
[JsonSerializable(typeof(CountrySummaryDto))]
[JsonSerializable(typeof(HistoryEvent))]
[JsonSerializable(typeof(HorizonRow))]
+35
View File
@@ -0,0 +1,35 @@
namespace OpenWaf.Edge.Health;
/// <summary>
/// What <c>/healthz</c> says. A named record rather than an anonymous literal for
/// one measured reason: this was the last response shape on the edge that had no
/// compiled JSON contract, and it is the shape the container's own HEALTHCHECK
/// asks. Measured 2026-10-07 on the NativeAOT binary — the host started, listened
/// and proxied traffic, and then answered 500 on every single <c>/healthz</c>
/// with <c>JsonTypeInfo metadata for type '&lt;&gt;f__AnonymousType52`8[…]' was not
/// provided by TypeInfoResolver</c>: 55 refusals in one probe window, all of them
/// this one shape. So the AOT edge was alive and its liveness probe was the thing
/// that could not read it — which in a scratch container means an edge that serves
/// traffic and is restarted anyway.
///
/// The property names are the wire contract the console, the smoke gate and the
/// readiness assertions already read; <c>EdgeJson</c>'s camelCase policy turns
/// these into exactly the JSON the anonymous literal produced, so this changes no
/// byte on any build.
/// </summary>
internal sealed record HealthDto(
string Status,
string Mode,
double SnapshotAgeSeconds,
double SnapshotTtlSeconds,
bool GeoLoaded,
string? GeoDatabase,
DateTimeOffset? GeoBuiltAt,
bool GeoStale);
/// <summary>What <c>/readyz</c> says when it has nothing to complain about. Named
/// for the same reason as <see cref="HealthDto"/>: a shape with no compiled
/// contract is a shape a NativeAOT build cannot serialise, and this one sits on
/// the endpoint an orchestrator uses to decide whether the edge stays in
/// rotation.</summary>
internal sealed record ReadinessDto(string Status);
+15 -15
View File
@@ -29,8 +29,10 @@ var builder = WebApplication.CreateBuilder(args);
// over a missing JsonTypeInfo for an admin request DTO (measured 2026-10-06,
// 3 refusals, first type NewBlockRequest). On a non-AOT build the chain still
// ends at the reflection resolver, so an unregistered type behaves exactly as it
// did before — which is why the 19 anonymous response literals still standing are
// a debt this records rather than a break it causes.
// did before — which is why the 22 anonymous response literals still standing
// (measured 2026-10-07, plus 7 more that live inside an EF query's Select and are
// the query wall's problem rather than this one) are a debt this records rather
// than a break it causes.
builder.Services.ConfigureHttpJsonOptions(o =>
{
o.SerializerOptions.TypeInfoResolverChain.Insert(0, OpenWaf.Edge.Admin.EdgeJson.Default);
@@ -41,7 +43,7 @@ builder.Services.ConfigureHttpJsonOptions(o =>
// know fails on a JIT build with the same sentence the AOT probe reports —
// `JsonTypeInfo metadata for type '<>f__AnonymousType0`1[System.String]' was
// not provided by TypeInfoResolver of type '[EdgeJson]'` (standalone probe,
// 2026-10-06). Eighteen anonymous response literals are still in this
// 2026-10-06). Twenty-two anonymous response literals are still in this
// project (the rest of the JSON wall, OPEN-79), so on a build that can
// reflect, reflection stays at the end of the chain: the debt kept served and
// visible rather than a break introduced in the middle of a slice.
@@ -204,17 +206,15 @@ var app = builder.Build();
app.UseMiddleware<EdgeGuardMiddleware>();
app.UseMiddleware<ResponseObservationMiddleware>();
app.MapGet("/healthz", (IGeoIpLookup geo, EdgeStateStore state) => Results.Ok(new
{
status = "ok",
mode = state.Current.Policy.Mode.ToString(),
snapshotAgeSeconds = Math.Round((DateTimeOffset.UtcNow - state.Current.GeneratedAt).TotalSeconds, 1),
snapshotTtlSeconds = Math.Round(state.RefreshTtl.TotalSeconds, 1),
geoLoaded = geo.IsLoaded,
geoDatabase = geo.Info?.DatabaseType,
geoBuiltAt = geo.Info?.BuildDate,
geoStale = geo.Info is not null && geo.Info.IsStale(TimeSpan.FromDays(90))
}));
app.MapGet("/healthz", (IGeoIpLookup geo, EdgeStateStore state) => Results.Ok(new HealthDto(
Status: "ok",
Mode: state.Current.Policy.Mode.ToString(),
SnapshotAgeSeconds: Math.Round((DateTimeOffset.UtcNow - state.Current.GeneratedAt).TotalSeconds, 1),
SnapshotTtlSeconds: Math.Round(state.RefreshTtl.TotalSeconds, 1),
GeoLoaded: geo.IsLoaded,
GeoDatabase: geo.Info?.DatabaseType,
GeoBuiltAt: geo.Info?.BuildDate,
GeoStale: geo.Info is not null && geo.Info.IsStale(TimeSpan.FromDays(90)))));
app.MapGet("/readyz", async (OpenWafDbContext db, EdgeStateStore state, EdgePolicyProvider policy, DurabilityHealth durability, CancellationToken ct) =>
{
@@ -299,7 +299,7 @@ app.MapGet("/readyz", async (OpenWafDbContext db, EdgeStateStore state, EdgePoli
// tells the operator about what it enforced. Pulling every edge out of
// rotation because a 30-minute cleanup loop is failing would trade a
// data-retention defect for an outage.
return Results.Ok(new { status = "ready" });
return Results.Ok(new ReadinessDto("ready"));
}
catch (Exception ex)
{
@@ -56,6 +56,21 @@ public sealed class AotJsonContractTests
+ "will not start on them: " + string.Join(", ", missing));
}
[Fact]
public void The_problem_body_every_handler_falls_back_to_has_a_contract()
{
// Results.Problem is the error path of /readyz and of any handler that
// catches. It writes ProblemDetails, which is nobody's DTO in this
// project, so nothing else in the build asks for a contract for it — and
// a NativeAOT binary has no resolver to discover one. Measured
// 2026-10-07, after the /healthz shape came down: this was the single
// remaining JsonTypeInfo refusal in the probe window, and its visible
// effect was that a /readyz 503 explaining the failure became a 500
// explaining nothing.
Assert.NotNull(EdgeJson.Default.GetTypeInfo(typeof(Microsoft.AspNetCore.Mvc.ProblemDetails)));
Assert.NotNull(EdgeJson.Default.GetTypeInfo(typeof(Microsoft.AspNetCore.Mvc.ValidationProblemDetails)));
}
[Fact]
public void The_generated_contract_uses_the_wire_names_the_operator_reads()
{
+60 -16
View File
@@ -117,27 +117,71 @@ printf '\n=== the schema step ===\n'
tables=$(python3 -c "import sqlite3;print(len([r for r in sqlite3.connect('$DB').execute(\"select name from sqlite_master where type='table' and name != 'sqlite_sequence'\")]))" 2>/dev/null || echo 0)
check 'tables the shipped DDL created' 12 "$tables"
printf '\n=== the curl assertions ===\n'
# Two halves, and the split is the finding, not a convenience. Measured 2026-10-07
# on this tree (osx-arm64, the same binary): the AOT edge reaches "Now listening
# on:", creates its 12 tables from the DDL it carries and proxies a request to the
# upstream for 200 — everything below in the first half passes. Every assertion in
# the second half fails, and fails with the SAME sentence 130 times in the log:
# "Query wasn't precompiled and dynamic code isn't supported with NativeAOT". They
# are recorded rather than checked because a check that fails for a reason this
# project already knows, and has a ticket for, stops being a signal; and they are
# recorded rather than deleted because the day EF compiles a query again, one of
# these answers changes and says so.
printf '\n=== the half that needs no query (gated) ===\n'
check 'healthz answers' 200 "$(code "http://127.0.0.1:$EDGE_PORT/healthz")"
check 'a request reaches the upstream' 200 "$(code "http://127.0.0.1:$EDGE_PORT/body.txt")"
check 'an operator block is accepted' 204 "$(code -X POST -H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"ip":"198.51.100.7","reason":"aot probe","redirectTo":"https://honeypot.example.org/"}' \
"http://127.0.0.1:$EDGE_PORT/admin-api/blocks")"
check 'the blocked source is redirected' 301 "$(code -H 'X-Forwarded-For: 198.51.100.7' \
"http://127.0.0.1:$EDGE_PORT/body.txt")"
ban=""
for _ in 1 2 3 4; do ban="$ban $(code -H 'X-Forwarded-For: 203.0.113.66' "http://127.0.0.1:$EDGE_PORT/probe")"; done
check 'four probes draw the streak ban' " 403 403 403 403" "$ban"
check 'the state surface answers' 200 "$(code -H "Authorization: Bearer $TOKEN" \
"http://127.0.0.1:$EDGE_PORT/admin-api/state")"
HEALTHCHECK_PORT="$EDGE_PORT" "$BIN" --healthcheck >/dev/null 2>&1
check 'the healthcheck mode answers 0' 0 "$?"
printf '\npassed %s, failed %s\n' "$pass" "$fail"
printf '\n=== what the edge said about its own queries ===\n'
grep -c "Query wasn't precompiled and dynamic code isn't supported with NativeAOT" "$LOG" \
| sed 's/^/ queries refused at run time: /'
# The header the edge actually reads. The probe used to send "Authorization:
# Bearer", which the admin surface does not look at, so three of these assertions
# were measuring a 401 rather than the query wall. Measured 2026-10-07: AdminAuth
# reads X-Admin-Token (or ?token=, which it names out loud).
printf '\n=== the half behind the query wall (recorded, not gated) ===\n'
recorded=0; drifted=0
record() {
if [ "$2" = "$3" ]; then
drifted=$((drifted+1)); printf ' MOVED %-50s %s — the query wall moved here, promote it back to a check\n' "$1" "$3"
else
recorded=$((recorded+1)); printf ' %-56s got %s, a working edge answers %s\n' "$1" "$3" "$2"
fi
}
record 'an operator block is accepted' 204 "$(code -X POST -H "X-Admin-Token: $TOKEN" \
-H 'Content-Type: application/json' \
-d '{"ip":"198.51.100.7","reason":"aot probe","redirectTo":"https://honeypot.example.org/"}' \
"http://127.0.0.1:$EDGE_PORT/admin-api/blocks")"
record 'the blocked source is redirected' 301 "$(code -H 'X-Admin-Token: $TOKEN' -H 'X-Forwarded-For: 198.51.100.7' \
"http://127.0.0.1:$EDGE_PORT/body.txt")"
ban=""
for _ in 1 2 3 4; do ban="$ban $(code -H 'X-Forwarded-For: 203.0.113.66' "http://127.0.0.1:$EDGE_PORT/probe")"; done
record 'four probes draw the streak ban' " 403 403 403 403" "$ban"
record 'the state surface answers' 200 "$(code -H "X-Admin-Token: $TOKEN" \
"http://127.0.0.1:$EDGE_PORT/admin-api/state")"
record 'readiness answers' 200 "$(code "http://127.0.0.1:$EDGE_PORT/readyz")"
# The body, not just the code. Before ProblemDetails had a contract this endpoint
# answered 500 and said nothing; the point of registering it is that the 503
# names the failure an operator would otherwise have to find in the log.
printf ' what /readyz says about itself: %s\n' \
"$(curl -s -m 5 "http://127.0.0.1:$EDGE_PORT/readyz" | tr -d '\n\r' | head -c 220)"
printf '\npassed %s, failed %s; recorded behind the wall %s, moved %s\n' \
"$pass" "$fail" "$recorded" "$drifted"
printf '\n=== the two walls, counted from the edge log ===\n'
listening=$(grep -c 'Now listening on:' "$LOG")
json_refusals=$(grep -c 'JsonTypeInfo metadata for type' "$LOG")
queries=$(grep -c "Query wasn't precompiled and dynamic code isn't supported with NativeAOT" "$LOG")
printf ' lines where the edge started listening: %s\n' "$listening"
printf ' json metadata refusals: %s\n' "$json_refusals"
{ [ "$json_refusals" -gt 0 ] && grep -m1 -o "JsonTypeInfo metadata for type '[^']*'" "$LOG" | sed 's/^/ first type without a contract: /'; }
printf ' queries refused at run time: %s\n' "$queries"
grep -c "Application startup exception" "$LOG" | sed 's/^/ startup exceptions: /'
printf ' full log: %s\n' "$LOG"
# The API half is a claim now, so it is gated: the host must be listening, and no
# response may be refused for want of a compiled contract. Before 2026-10-06 the
# first number was 0 (the host threw before Kestrel opened a port); on 2026-10-07
# the second was 55, all of them one anonymous /healthz literal.
[ "$listening" -ge 1 ] || { printf 'the edge never listened: the API half regressed\n' >&2; exit 1; }
[ "$json_refusals" -eq 0 ] || { printf 'a response shape still has no compiled JSON contract\n' >&2; exit 1; }
[ "$fail" -eq 0 ] || exit 1