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).
This commit is contained in:
Pavlo Ratushnyi
2026-10-07 09:06:57 +02:00
parent fb758900b8
commit 5c1a2950d0
5 changed files with 39 additions and 13 deletions
+12 -4
View File
@@ -431,7 +431,8 @@ The host-start refusal is not a missing switch. A NativeAOT binary has no
reflection-based JSON resolver to fall back on, and the fallback it would need is
the thing the runtime refuses. So the wire shapes have to be **types** before a
contract can be compiled for them. Counted in `dotnet/OpenWaf.Edge` on
2026-10-06: **130 anonymous object literals** in the JSON path, in **51 distinct
2026-10-07 with a string-aware scanner (braces inside interpolated strings are
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
@@ -453,8 +454,8 @@ 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). Eighteen anonymous literals are still standing, so on a build that can
reflect, reflection stays at the end of the chain: the debt kept served and
probe). Thirty-one anonymous literals are still standing, 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
`DefaultJsonTypeInfoResolver` in an AOT publish pulls the reflection-based JSON
@@ -482,9 +483,16 @@ 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
**18 anonymous literals, in 50 distinct shapes**, are what stands between the
**31 anonymous literals, in 25 distinct shapes**, are what stands between the
two, and they are the next cut.
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
scanner that walked braces without skipping string literals, so every `{` inside
a `$"…{x}…"` was counted as code. The numbers above are the same tree re-measured
with a scanner that skips strings, char literals and comments; the 111 that became
`ErrorDto` is the one figure both scanners agree on.
## Schema
Migrations are the schema of record for PostgreSQL, which is the provider a
+7 -5
View File
@@ -119,15 +119,17 @@ classifies the status, and is the only thing that can create an engine ban.
opens a port.
**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: **130
anonymous object literals** in `OpenWaf.Edge`, **51 distinct shapes**, **111 of
them the single shape `new { error = … }`**. Those 111 are now one named record
anonymous type, and the edge's wire shapes were largely anonymous: **144
anonymous-object literals** in `OpenWaf.Edge`, **27 distinct shapes**, **111 of
them the single shape `new { error = … }`** (string-aware count, 2026-10-07;
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`. **18 anonymous literals in 50 shapes remain**, and they
are the rest of this wall. Two facts about the wiring are load-bearing and were
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
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
+6
View File
@@ -170,6 +170,12 @@ internal sealed record ObservationDto(
string? LastCountryCode,
string? LastCity);
/// <summary>One country in the countries summary: how many sources the edge saw
/// there and how many refusals they account for. Named because the response needs
/// a compiled JSON contract; the anonymous shape EF translates stays inside the
/// query (see the countries/summary endpoint).</summary>
internal sealed record CountrySummaryDto(string Code, int Sources, int Refusals);
/// <summary>The edge's one error body: <c>{"error": "…"}</c>.
///
/// It used to be written 111 times as the anonymous literal <c>new { error = … }</c>.
+13 -4
View File
@@ -817,7 +817,17 @@ internal static partial class AdminEndpoints
.GroupBy(o => o.LastCountryCode)
.Select(g => new { Code = g.Key, Sources = g.Count(), Refusals = g.Sum(o => o.TotalRefusals) })
.ToListAsync(ct);
return Results.Ok(rows.OrderByDescending(r => r.Sources));
// The anonymous shape has to survive the query and stop at the query:
// it is what EF translates, and the record-constructor form fails at
// query time with "could not be translated" (measured by a test). The
// wire shape is a named type, so the response has a compiled contract
// and the sort stays where it was — after translation.
// `Code` is nullable in the model and non-null in these rows: the
// query filters `LastCountryCode != null`, which the compiler cannot
// see and EF does apply.
return Results.Ok(rows
.Select(r => new CountrySummaryDto(r.Code!, r.Sources, r.Refusals))
.OrderByDescending(r => r.Sources));
});
group.MapGet("/geo", (IGeoIpLookup geo, HttpContext ctx) =>
@@ -1774,9 +1784,8 @@ note = t.Note
if (!TryKnownQuery(ctx, out var unknown, "match", "path", "limit"))
return Results.BadRequest(new ErrorDto(unknown));
if (string.IsNullOrWhiteSpace(match))
return Results.BadRequest(new {
error = "match is required: an address or a CIDR, the same value the write takes"
});
return Results.BadRequest(new ErrorDto(
"match is required: an address or a CIDR, the same value the write takes"));
// Normalised by the write path's own code, so the preview answers
// about the row the write would create and refuses a match the write
// would refuse, in the write's words. 198.51.100.37/24 and
+1
View File
@@ -48,6 +48,7 @@ namespace OpenWaf.Edge.Admin;
[JsonSerializable(typeof(RateSourceDto))]
[JsonSerializable(typeof(ObservationDto))]
[JsonSerializable(typeof(StreakDto))]
[JsonSerializable(typeof(CountrySummaryDto))]
[JsonSerializable(typeof(HistoryEvent))]
[JsonSerializable(typeof(HorizonRow))]
[JsonSerializable(typeof(HorizonAfter))]