feat: the trust release — observability, shutdown teardown, routing correctness and the docs split #41

Merged
chrnx merged 46 commits from feature/trust-release into develop 2026-08-17 23:17:14 +00:00
3 changed files with 23 additions and 15 deletions
Showing only changes of commit 5fafe97bc5 - Show all commits

No files matched your search

@@ -149,7 +149,9 @@ Two things follow. `Date.now()` loses on both axes — slower *and* coarser —
At 0.25% per step the overhead sits **below the 0.3% run-to-run CV of the project's own benchmark**, so it is not measurable in the harness that would have to justify a flag. Making it opt-in would buy two code paths and a configuration surface in exchange for something nobody can observe. Always on.
> **Correction, after implementation.** This decision survived; its reasoning did not. Measured over a real socket the cost is **−3.9% on JSON hello and −2.1% on a three-step pipeline** — the shallower route loses *more*, which is the opposite of a per-step model. Per-step work is skipped entirely when nothing subscribes; what is left is a fixed per-request cost. "Always on" is still right, and for a better reason: there is nothing per-step left to make optional. See Task 7 in the implementation plan.
> **Correction, after implementation.** This decision survived; its reasoning did not. The measured cost is **+7.0% of the framework's own per-request work** (~0.29 µs, ~2% over a real socket), and it is *fixed per request* rather than per step — per-step work is skipped entirely when nothing subscribes. "Always on" is still right, and for a better reason: there is nothing per-step left to make optional.
>
> Three earlier figures for this were published before that one and all three were wrong, each from a comparison with more than one variable moving. See Task 7 in the implementation plan for what went wrong and why interleaving is not optional here.
### D8 — Request logging is a `Bus` subscriber, wrapped so a failing logger cannot go silent
+10 -6
View File
@@ -116,14 +116,18 @@ Tasks 1–3 are the correction; 4–6 are what consumes it. Do not start 4 befor
**Files:**
- Modify: `BENCHMARKS.md`
D7 predicted ~0.25% **per step**, invisible against the harness's own 0.3% CV. Measured over a real socket, on the box `BENCHMARKS.md` was produced on, same server config both sides:
D7 predicted ~0.25% **per step**, invisible against the harness's own 0.3% CV.
| Scenario | Before | After | |
|---|---:|---:|---:|
| JSON hello | 78,118 req/s | 75,075 req/s | −3.9% |
| Pipeline (3 steps) | 70,671 req/s | 69,164 req/s | −2.1% |
**Measured: +7.0% of the framework's own per-request work** — 4.074 µs → 4.361 µs, medians of five interleaved rounds, ranges not overlapping. About 0.29 µs, or ~2% of a request over a real socket.
**The route with fewer steps loses more**, which falsifies the model rather than only the number. The per-step cost is real but is skipped entirely when nothing subscribes (`Bus.hasListeners`); what remains is a **fixed per-request** cost — generating the request id, reading two headers, and the guard checks. A shallow route amortises that over less work, so it shows up larger.
The prediction was wrong in **shape**, not only magnitude. Per-step work is skipped entirely when nothing subscribes (`Bus.hasListeners`), so a deep pipeline pays no more than a shallow one; what remains is a **fixed per-request** cost — generating the request id, reading two headers, and the guard checks. "Always on" survives, for a better reason than it was made with: there is nothing per-step left to make optional.
**Three earlier numbers for this were published and all three were wrong**, which is the more useful lesson: −3.9%, then 0.8%, then −6.8%. Each came from a comparison with more than one variable moving.
- The first two were sequential rather than interleaved. The same code measured at the start and end of one session differed by **12%** as the machine warmed, so run order was indistinguishable from effect — one of them even reported the wrong sign.
- The third compared `7bd11bf` against `HEAD`, which differ by observability **and** three performance fixes pulling the other way. It reported their net as if it were one of them.
The number above compares `7bd11bf` against `523e318`, the last commit before those fixes, alternating round by round.
Two regressions were found and fixed by measuring rather than reasoning, both larger than anything the design anticipated:
@@ -131,13 +131,15 @@ instrumentation — the graph already knows every node.
## What it costs
Measured, not asserted, on the box that produced [BENCHMARKS.md](https://github.com/Expressive-Tea/green-tea/blob/main/BENCHMARKS.md):
**About 0.29 µs per request** — roughly **7% of the framework's own work**, or **~2% of a request
measured over a real socket**, where the transport dominates.
| Scenario | Before | After | |
|---|---:|---:|---:|
| JSON hello | 78,118 req/s | 75,075 req/s | −3.9% |
| Pipeline (3 steps) | 70,671 req/s | 69,164 req/s | −2.1% |
The cost is **per request, not per step**. Per-step timing and payload construction are skipped
entirely when nothing is subscribed, so a deep pipeline pays no more than a shallow one. What
remains is fixed: generating the request id, reading two headers, and the checks that decide
whether anyone is listening.
The cost is **per request, not per step** — which is why the route with *fewer* steps loses more.
Most of it is generating the request id; per-step timing and payload construction are skipped
entirely when nothing is subscribed.
Absolute throughput numbers are deliberately not quoted here. The figure above comes from an
interleaved A/B — alternating both versions round by round — because the same code measured at the
start and end of one session on the same machine differed by 12% as it warmed up. Any before/after
that does not interleave is measuring the clock as much as the code.