a test proving that misses after the index is built recompile nothing.
Result: D4 passes at ed19f16, which is rebased on develop72f591d and so includes #131. The 10-route late param hit passes by 0.1 point: its CI lower bound is +4.9% against the +5% limit.
History
First run (b128139): D4 failed at 10 routes: late param +52.5%, method miss +31.8%, path miss +101.9%. This branch's attribution run traced the regression to a2b71e2. That commit reset the walk stacks' length in a finally on every lookup. #131 fixed it, and it is merged.
A/A bias: the same run's A/A (oracle vs a byte-identical copy) showed a steady bias of up to +8.3% against the second-listed router. The bias came from bench/lookup.ts, which alternated only the import order between processes; warm-up and the shared lookup call site always saw the first-listed router first. ed19f16 reverses the whole order per process. With that change, the 8 × 21 A/A for that cell went from +8.3% to −0.1%. The owner approved this method change on 2026-10-12.
Formal run: repeated at ed19f16, 16 × 21 = 336 paired rounds per cell, on jarvis. It used the baseline's image (sha256:5647be70…) and cpuset 6,7,14,15. Load was about 1.
bench/results/router-b128139/ is kept and marked superseded, as the record of both findings.
1. No miss-time recompilation
test/router-miss-compilation.test.ts builds and warms the index, then repeats 404 path misses, 405 method misses and automatic OPTIONS 50 times through:
It asserts that compilePattern calls and index builds stay at 0 during the repeats, while status (404/405/204) and Allow stay correct. A first test checks that the counters do see a build (1 index build, 1 compilePattern call per route), so the zeros are not vacuous.
Seam (minimal src/ change):compilePattern is called inside router.ts, and vi.spyOn on the module export cannot see an intra-module call. So router.ts gets two internal counters, incremented at the top of compilePattern and on an index cache miss in routeIndex. They are exposed as @internal routerSeamCounts(), following the existing walkStackSize test seam. src/http/router.ts is not a package entry. The counters are off the lookup hot path. In the attribution run in bench/results/router-b128139/, b128139 (with counters) matches cb123e3 (without them).
Proof that the test fails when the behaviour breaks (both mutations made locally, then reverted):
Mutation
Result
Index cache disabled (routeIndex rebuilds on every call)
Linear-style recompile in allowedMethods (for (r of routes) compilePattern(r.pattern))
3/3 fail. 20,000 / 15,000 / 450 compiles
2. Formal D4 run (bench/results/router-ed19f16/)
routes
workload
radix / oracle
95% CI
D4 rule
verdict
10
static hit
−57.7%
−58.8% … −55.9%
lower ≤ +5%
pass
10
late param hit
+5.6%
+4.9% … +6.6%
lower ≤ +5%
pass (0.1 pt)
10
method miss
−6.1%
−6.9% … −5.2%
lower ≤ +5%
pass
10
path miss
−2.5%
−3.2% … −2.0%
lower ≤ +5%
pass
100
static hit
−55.4%
−55.8% … −55.2%
lower ≤ +5%
pass
100
late param hit
−57.9%
−58.1% … −57.7%
lower ≤ +5%
pass
100
method miss
−70.6%
−70.7% … −70.6%
lower ≤ +5%
pass
100
path miss
−80.1%
−80.2% … −80.1%
lower ≤ +5%
pass
500
static hit
−54.2%
−54.7% … −53.8%
lower ≤ +5%
pass
500
late param hit
−87.3%
−87.4% … −87.3%
upper ≤ −20%
pass
500
method miss
−93.8%
−93.8% … −93.8%
upper ≤ −20%
pass
500
path miss
−96.1%
−96.1% … −96.1%
upper ≤ −20%
pass
A/A noise band (same settings)
routes
static hit
late param hit
method miss
path miss
10
+7.9% (+5.2 … +14.1)
−0.6% (−6.4 … +5.4)
−0.7% (−1.9 … +0.9)
−0.6% (−1.1 … −0.0)
100
−2.4% (−3.0 … −2.0)
−0.4% (−1.5 … +1.3)
+0.2% (−0.5 … +0.6)
+0.0% (−0.3 … +0.5)
500
−2.1% (−2.7 … −0.9)
−0.0% (−0.4 … +0.3)
+0.5% (+0.0 … +1.0)
+0.1% (−0.1 … +0.7)
The 10-route static hit is still noisy. It is the cheapest cell, at about 80 ns. The radix router is −58% on it, so the noise does not affect the verdict.
Gates (at ed19f16)
gate
result
lint
0 errors
format
clean
build, typecheck, typecheck:bench
clean
npm test
822 pass
npm run parity:mutants
21/21 killed
Deno
36 passed
Bun
26 pass
edge
PASS
complexity
ok
npm audit --audit-level=moderate
0
Deviations
16 × 21 rounds instead of the minimum 8 × 21, so each cell has 336 paired rounds.
bench/lookup.ts changed the order method. The owner approved it, and the reason is above.
Containers ran with --user 1000:1000 -e HOME=/tmp. Otherwise the run matches the baseline.
End-to-end req/s A/B was not run (optional per the card).
CARD-10 (FPRD-001b, #109) adds two things:
- formal D4 lookup evidence for the radix index;
- a test proving that misses after the index is built recompile nothing.
**Result: D4 passes** at `ed19f16`, which is rebased on `develop` `72f591d` and so includes #131. The 10-route late param hit passes by 0.1 point: its CI lower bound is +4.9% against the +5% limit.
## History
1. **First run (`b128139`):** D4 failed at 10 routes: late param +52.5%, method miss +31.8%, path miss +101.9%. This branch's attribution run traced the regression to `a2b71e2`. That commit reset the walk stacks' `length` in a `finally` on every lookup. #131 fixed it, and it is merged.
2. **A/A bias:** the same run's A/A (oracle vs a byte-identical copy) showed a steady bias of up to +8.3% against the second-listed router. The bias came from `bench/lookup.ts`, which alternated only the import order between processes; warm-up and the shared `lookup` call site always saw the first-listed router first. `ed19f16` reverses the whole order per process. With that change, the 8 × 21 A/A for that cell went from +8.3% to −0.1%. The owner approved this method change on 2026-10-12.
3. **Formal run:** repeated at `ed19f16`, 16 × 21 = 336 paired rounds per cell, on jarvis. It used the baseline's image (`sha256:5647be70…`) and cpuset 6,7,14,15. Load was about 1.
`bench/results/router-b128139/` is kept and marked superseded, as the record of both findings.
## 1. No miss-time recompilation
`test/router-miss-compilation.test.ts` builds and warms the index, then repeats 404 path misses, 405 method misses and automatic OPTIONS 50 times through:
- `resolveRoute` + `allowedMethods` directly (100-route table, bench generator shapes),
- `buildFetch` over the same table,
- `app.fetch` on a decorated app.
It asserts that `compilePattern` calls and index builds stay at **0** during the repeats, while status (404/405/204) and `Allow` stay correct. A first test checks that the counters do see a build (1 index build, 1 `compilePattern` call per route), so the zeros are not vacuous.
**Seam (minimal `src/` change):** `compilePattern` is called inside `router.ts`, and `vi.spyOn` on the module export cannot see an intra-module call. So `router.ts` gets two internal counters, incremented at the top of `compilePattern` and on an index cache miss in `routeIndex`. They are exposed as `@internal routerSeamCounts()`, following the existing `walkStackSize` test seam. `src/http/router.ts` is not a package entry. The counters are off the lookup hot path. In the attribution run in `bench/results/router-b128139/`, `b128139` (with counters) matches `cb123e3` (without them).
**Proof that the test fails when the behaviour breaks** (both mutations made locally, then reverted):
| Mutation | Result |
|---|---|
| Index cache disabled (`routeIndex` rebuilds on every call) | 3/3 miss tests fail. Direct: 40,000 compiles / 400 builds; `buildFetch`: 30,000 / 300; `app.fetch`: 900 / 300 |
| Linear-style recompile in `allowedMethods` (`for (r of routes) compilePattern(r.pattern)`) | 3/3 fail. 20,000 / 15,000 / 450 compiles |
## 2. Formal D4 run (`bench/results/router-ed19f16/`)
| routes | workload | radix / oracle | 95% CI | D4 rule | verdict |
| ---: | --- | ---: | --- | --- | --- |
| 10 | static hit | −57.7% | −58.8% … −55.9% | lower ≤ +5% | pass |
| 10 | late param hit | +5.6% | +4.9% … +6.6% | lower ≤ +5% | pass (0.1 pt) |
| 10 | method miss | −6.1% | −6.9% … −5.2% | lower ≤ +5% | pass |
| 10 | path miss | −2.5% | −3.2% … −2.0% | lower ≤ +5% | pass |
| 100 | static hit | −55.4% | −55.8% … −55.2% | lower ≤ +5% | pass |
| 100 | late param hit | −57.9% | −58.1% … −57.7% | lower ≤ +5% | pass |
| 100 | method miss | −70.6% | −70.7% … −70.6% | lower ≤ +5% | pass |
| 100 | path miss | −80.1% | −80.2% … −80.1% | lower ≤ +5% | pass |
| 500 | static hit | −54.2% | −54.7% … −53.8% | lower ≤ +5% | pass |
| 500 | late param hit | −87.3% | −87.4% … −87.3% | upper ≤ −20% | pass |
| 500 | method miss | −93.8% | −93.8% … −93.8% | upper ≤ −20% | pass |
| 500 | path miss | −96.1% | −96.1% … −96.1% | upper ≤ −20% | pass |
### A/A noise band (same settings)
| routes | static hit | late param hit | method miss | path miss |
| ---: | --- | --- | --- | --- |
| 10 | +7.9% (+5.2 … +14.1) | −0.6% (−6.4 … +5.4) | −0.7% (−1.9 … +0.9) | −0.6% (−1.1 … −0.0) |
| 100 | −2.4% (−3.0 … −2.0) | −0.4% (−1.5 … +1.3) | +0.2% (−0.5 … +0.6) | +0.0% (−0.3 … +0.5) |
| 500 | −2.1% (−2.7 … −0.9) | −0.0% (−0.4 … +0.3) | +0.5% (+0.0 … +1.0) | +0.1% (−0.1 … +0.7) |
The 10-route static hit is still noisy. It is the cheapest cell, at about 80 ns. The radix router is −58% on it, so the noise does not affect the verdict.
## Gates (at `ed19f16`)
| gate | result |
| --- | --- |
| lint | 0 errors |
| format | clean |
| build, typecheck, typecheck:bench | clean |
| `npm test` | 822 pass |
| `npm run parity:mutants` | 21/21 killed |
| Deno | 36 passed |
| Bun | 26 pass |
| edge | PASS |
| complexity | ok |
| `npm audit --audit-level=moderate` | 0 |
## Deviations
- 16 × 21 rounds instead of the minimum 8 × 21, so each cell has 336 paired rounds.
- `bench/lookup.ts` changed the order method. The owner approved it, and the reason is above.
- Containers ran with `--user 1000:1000 -e HOME=/tmp`. Otherwise the run matches the baseline.
- End-to-end req/s A/B was not run (optional per the card).
The linear matcher answered every 404, 405 and automatic OPTIONS by compiling
the whole route table. The radix index compiles each pattern once, when the
index for an array is built. Nothing asserted that, so a regression to
per-request compilation or per-request index builds would only show up as a
slower benchmark.
compilePattern is called inside router.ts, where a spy on the module export
cannot see it, so the router gains two internal counters (compilePattern calls,
index builds), exposed as @internal routerSeamCounts() next to walkStackSize.
router.ts is not a package entry. The new test warms the index, then repeats
404, 405 and OPTIONS misses through resolveRoute/allowedMethods, buildFetch and
app.fetch, and asserts both counts stay constant while status and Allow stay
correct.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Formal D4 run on jarvis with the baseline's harness, image, and cpuset:
oracle (pre-radix linear matcher) against the radix router at b128139,
16 processes x 21 rounds = 336 paired rounds per cell, plus an A/A
run (oracle against a byte-identical copy) at the same settings.
D4 fails at 10 routes: late param hit +52.5%, method miss +31.8% and path
miss +101.9%, with every CI lower bound far above +5%. 100 routes improve
in every cell, and all 500-route targets are met (-82.5% to -92.1%). A
diagnostic run with three router revisions traces the 10-route regression
to a2b71e2 (try/finally stack reset in the walk). The seam counters
added for the no-recompilation test change nothing.
No threshold was relaxed and no src/ change was made. The raw samples
are committed for an owner decision.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Only the import order alternated between processes; warm-up order and
the shared lookup call site always saw the first-listed router first.
CARD-10's A/A run (oracle vs a byte-identical copy) showed a steady bias
of up to +8.3% against the second-listed router at 10 routes. Reversing
the whole order per process brings the same A/A to -0.1% (8 x 21
rounds on jarvis). Owner-approved D4 method change (2026-10-12).
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Formal D4 run after the walk-stack fix (#131) and the router-order fix in
the harness, 16 x 21 rounds on jarvis. Every cell passes; the 10-route
late param hit passes with its CI lower bound at +4.9%. Marks the
b128139 evidence as superseded.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
CARD-10 (FPRD-001b, #109) adds two things:
Result: D4 passes at
ed19f16, which is rebased ondevelop72f591dand so includes #131. The 10-route late param hit passes by 0.1 point: its CI lower bound is +4.9% against the +5% limit.History
b128139): D4 failed at 10 routes: late param +52.5%, method miss +31.8%, path miss +101.9%. This branch's attribution run traced the regression toa2b71e2. That commit reset the walk stacks'lengthin afinallyon every lookup. #131 fixed it, and it is merged.bench/lookup.ts, which alternated only the import order between processes; warm-up and the sharedlookupcall site always saw the first-listed router first.ed19f16reverses the whole order per process. With that change, the 8 × 21 A/A for that cell went from +8.3% to −0.1%. The owner approved this method change on 2026-10-12.ed19f16, 16 × 21 = 336 paired rounds per cell, on jarvis. It used the baseline's image (sha256:5647be70…) and cpuset 6,7,14,15. Load was about 1.bench/results/router-b128139/is kept and marked superseded, as the record of both findings.1. No miss-time recompilation
test/router-miss-compilation.test.tsbuilds and warms the index, then repeats 404 path misses, 405 method misses and automatic OPTIONS 50 times through:resolveRoute+allowedMethodsdirectly (100-route table, bench generator shapes),buildFetchover the same table,app.fetchon a decorated app.It asserts that
compilePatterncalls and index builds stay at 0 during the repeats, while status (404/405/204) andAllowstay correct. A first test checks that the counters do see a build (1 index build, 1compilePatterncall per route), so the zeros are not vacuous.Seam (minimal
src/change):compilePatternis called insiderouter.ts, andvi.spyOnon the module export cannot see an intra-module call. Sorouter.tsgets two internal counters, incremented at the top ofcompilePatternand on an index cache miss inrouteIndex. They are exposed as@internal routerSeamCounts(), following the existingwalkStackSizetest seam.src/http/router.tsis not a package entry. The counters are off the lookup hot path. In the attribution run inbench/results/router-b128139/,b128139(with counters) matchescb123e3(without them).Proof that the test fails when the behaviour breaks (both mutations made locally, then reverted):
routeIndexrebuilds on every call)buildFetch: 30,000 / 300;app.fetch: 900 / 300allowedMethods(for (r of routes) compilePattern(r.pattern))2. Formal D4 run (
bench/results/router-ed19f16/)A/A noise band (same settings)
The 10-route static hit is still noisy. It is the cheapest cell, at about 80 ns. The radix router is −58% on it, so the noise does not affect the verdict.
Gates (at
ed19f16)npm testnpm run parity:mutantsnpm audit --audit-level=moderateDeviations
bench/lookup.tschanged the order method. The owner approved it, and the reason is above.--user 1000:1000 -e HOME=/tmp. Otherwise the run matches the baseline.ed19f16(CARD-10, #109)c5c2c99b18to2e2c68de07