owner-mesh-lifetime.json froze phase B2 (teapot absent at boot, then up)
at 404 for GET and POST /api/remote/ping. The table was built once at
boot, so a late teapot was never spliced in. CARD-19 (#124, D15) changes
that. B2 now answers GET 200 {"from":"teapot"} and POST 405 with
Allow: GET, HEAD, OPTIONS, the same as A1.
Only those two entries change. A1, A2 and B1 are identical.
The fixture's teacup goes from reconnect: false to reconnect with a fast
backoff (20-60ms). Under D15, reconnect: false makes a dropped teapot
"gone" (404), and an absent one is not retried. The card's phases
describe the reconnecting teacup: A2 stays 503 and B2 becomes 200. B2
now waits for the mesh:routes event before probing. The fixture comment
and the corpus README line describing "built once at boot" are updated.
Owner approval required (CARD-08 rule): this edits a frozen file and the
fixture under test/router-parity/.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The teacup built its route table once at boot. A teapot that started
late was never served, and one that was gone for good stayed advertised.
Implement D15 (accepted 2026-10-18):
- A teapot that missed bootTimeoutMs is retried in the background with
the reconnect backoff (not with reconnect: false). On connect its
routes join the remote table. Its steps do not, because the graph
was validated at boot without them.
- While a link is reconnecting, its routes stay and answer 503, now
with retry-after (seconds until the next attempt).
- A link that gives up for good (dropped with reconnect: false, or a
permanent refusal while reconnecting) has its routes removed: 404,
and Allow drops its methods. A refused reconnect no longer retries
forever.
- A returning manifest replaces the teapot's routes. missingFromManifest
now checks steps only, so a dropped route is removed instead of
refusing the reconnect.
- A late route that conflicts with another teapot's is refused and
logged. The table keeps serving. At boot the same conflict still
fails boot.
- Each change emits mesh:routes with { url, added, removed }.
- The reserved-path check from CARD-21/CARD-17 (#141, #145) runs in
the table for every remote route: at boot a route on /__mesh__/control
(or /__live__ and /__ready__ with health on) fails boot as before. A
late or returning one is refused and logged, and the teapot's other
routes are served.
Mechanics: the remote table publishes a new array per change
(copy-on-write). app.fetch and listen() share one table through a
getter, and buildFetch/createHttpServer read it once per request, so a
request sees the old table or the new one, never a mix. The router
reuses local trees when the local entries are identical, so a
membership change rebuilds only the remote trees. Dev routes now sit
before remote ones in the table to keep the local positions stable.
Tests cover T1-T8 on Node (test/mesh/membership.test.ts), plus the
local-tree build counter and late reserved-path routes, and T1/T2 on
Deno and Bun.
The frozen owner-mesh-lifetime.json capture changes in the next commit.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
owner-mesh-allow.json froze HEAD /api/x at 404 on both adapters: the
teacup forwarded HEAD to the teapot, which has no HEAD plan for the
route. CARD-20 (#125, D16) fixes that, so HEAD now answers 200 with the
GET's headers and an empty body, like a local route.
Only those two entries change (fetch and node), status 404 -> 200.
Headers and the empty body are identical. The fixture comment in
owner.test.ts that described the old behaviour is updated to match.
Owner approval required (CARD-08 rule): this edits a frozen file under
test/router-parity/.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The teacup's router resolves HEAD to a remote buffered GET through the
implicit-HEAD fallback, and OPTIONS advertises HEAD. But the remote
route handler forwarded req.method, so the teapot got a HEAD envelope,
found no HEAD plan in resolveRoute, and answered 404.
Forward a HEAD that matched a remote GET as GET. dispatch already drops
the body for HEAD, so the client gets the GET's status and headers and
no body, the same as a local route. An explicit remote HEAD route is
matched first and is still forwarded as HEAD.
The fix is teacup-side (D16, accepted 2026-10-22): the teapot and the
wire protocol are unchanged, so a new teacup works against an older
teapot during a rolling deploy.
Tests cover app.fetch and the Node listener (200 + GET headers + empty
body, OPTIONS, explicit HEAD precedence, 404/500 kept with no body, the
teapot handler called once as GET) and Deno and Bun.
The frozen owner-mesh-allow.json capture changes in the next commit.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
createApp({ health: true }) serves GET/HEAD /__live__ and /__ready__.
Ready reports booting until boot() resolves, ok or degraded (from
app.degraded()) after that, and draining from the moment close() starts.
Probes are answered by the adapters, ahead of the request gate and of
handle(): Node in serve() (src/http/server.ts), the Fetch path in
app.fetch before it awaits the boot. Otherwise ready could never say
booting. Being ahead of the gate means maxConcurrentRequests never sheds
a probe (D14). Being ahead of handle() means no step, provider, plugin or
onError runs, and no lifecycle event is emitted, so logRequests and
metrics never see a probe. Security headers still apply, plus
cache-control: no-store. Other methods get 405 with Allow: GET, HEAD.
A probe through app.fetch before any boot starts the boot without
awaiting it. On the edge, or under a bare Deno.serve(app.fetch), nothing
else may boot the app, and an orchestrator that waits for ready before
sending traffic would wait forever.
health: { drainDelayMs } (D14) marks the app draining and keeps the
listener open for that long before connections drain. Without it, Node
closes idle keep-alive sockets at once, and a probe sees a reset rather
than the 503. The window is spent out of the close budget. serveDeno and
serveBun start the same window, through a symbol-keyed hook on the app,
before server.shutdown() / server.stop(false). workerd has no close(),
so it never reports draining.
While health is on, /__live__ and /__ready__ join the reserved-path
boot check that CARD-21 introduced, for local and mesh-spliced routes.
Invalid health values throw at createApp.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Golden update for ws-node-upgrade.json, needs owner approval (CARD-08
rule). The WS parity fixture declared @Ws('/__mesh__/control') to
capture the old adapter split: the Node listener served it (101, the
route's frame, close 1005), app.upgrade refused it (1008). Under D17
that route fails createApp, so the fixture drops it and keeps the path
in UPGRADE_PATHS. The Node row now matches the app.upgrade row: 101, no
frame, close 1008 with the shared reason.
ws-app-upgrade.json is unchanged: app.upgrade already refused the path
before matching, so removing the route does not change its answer.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The Node upgrade listener only intercepted /__mesh__/control when a mesh
control channel was configured; otherwise a user @Ws route there was
served. app.upgrade (Deno, Bun, edge) always checked the path first and
closed 1008. The same app therefore worked on Node and was refused
everywhere else.
D17 makes the path reserved in every app, mesh or not:
- createApp fails when a @Ws, @Stream or HTTP route claims the path,
naming the declaration. A literal pattern is checked by equality, a
parameterised one (/__mesh__/:x, /__mesh__/:rest*) by matching the
reserved path against it. Patterns whose first segment is not the
literal __mesh__ (/:org/:repo, /:rest*) still boot: the adapters
answer the path before route matching, so those routes never see it.
- A route exported by a teapot is checked during the teacup splice.
- The Node listener, with no control channel, accepts the upgrade and
closes 1008 with the reason app.upgrade gives. The reason is now one
shared constant.
The check lives in src/http/reserved-paths.ts so CARD-17 can add
/__live__ and /__ready__ to the same list.
BREAKING CHANGE: an app that declares a route at /__mesh__/control, or a
pattern under /__mesh__/ that matches it, now fails createApp.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
topoSort, topoLevels and subgraphFor built their token -> node map with
producedBy.set(key, node), so the last node registered for a token won.
Plugin nodes are registered after module nodes, which let a plugin's
scope.add({ name: 'shadow', provides: ['user'] }) silently replace the
app's own @Provider({ provides: 'user' }) for every route that needed
it. setRunner only rejects duplicate names, and scope.add is the one
path where a name and its tokens differ.
D9 settles it graph-wide: topoSort now throws when a token already has
a producer, naming both nodes and their origins (module:..., plugin,
mesh:<url>, builtin). One check on the whole node set covers every
current and future registration path. It also protects the built-ins
(logger, rooms, events) by rule rather than by registration order.
topoSort runs at finalize, after the mesh splice, so remote steps are
checked too. topoLevels and subgraphFor only ever see nodes topoSort
has already validated, so they keep their plain maps.
overrides replace the runner of an existing token and add no node, so
they are unaffected. Steps that provide nothing (plugin observers) are
not producers. The official plugins (jwt, metrics, rate-limit) pass
their suites against this build.
BREAKING CHANGE: an app whose graph has two nodes providing one token,
e.g. a plugin scope node providing a token a module or built-in
already provides, now fails createApp instead of letting the later
node win.
Refs: GitHub #35
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
edgeHandler copied cf-connecting-ip into ctx.ip on every WebSocket
upgrade, so any client that sent the header chose its own address, and
it never read the header for HTTP, so IP-keyed plugins saw '' there.
D21 settles both: the header counts only under trustProxy, on both
paths, with no new option.
The adapter cannot make that call, because trustProxy is an app option.
So edgeHandler records the header against the object it hands the app
(the Request for HTTP, the WsRequest for an upgrade) in an internal
registry next to the Deno/Bun peer one, and app.fetch and app.upgrade
both consult it through one helper, trustedProxyClient(), which returns
'' unless trustProxy is on. Under trustProxy it takes precedence over
x-forwarded-for, since Cloudflare sets it itself and XFF can carry
client-supplied hops.
Nothing else records into the registry, so the Node, Deno and Bun
adapters, and a bare app.fetch or app.upgrade, ignore the header as
before.
BREAKING CHANGE: an edge WebSocket upgrade no longer takes ctx.ip from
cf-connecting-ip unless the app sets trustProxy: true; without it,
ctx.ip is ''.
Refs: #119
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
parseQuery took `url.split('?')[1]`, so a second `?` ended the query
string and `/search?q=what?now` gave `q: 'what'`. RFC 3986 §3.4 allows
`?` inside a query. The query string is now everything after the first
`?` and before `#`, if one is present. The early return for URLs without
a query is kept, and so is its measurement note. The comment that
deferred this behaviour question is removed because the question is now
decided (D23).
Path extraction already split on the first `?` and is unchanged.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
`npm audit --audit-level=moderate` failed on develop: vite <=6.4.3 (high:
cross-origin script execution in custom middleware, fs.allow bypass,
launch-editor), vitest/@vitest/mocker <=4.1.11 (moderate: code injection via
manual mock registration) and fastify 5.12.2-5.12.5 (low, benchmark only).
All are devDependencies; the published package is unaffected. Lockfile-only:
vite 6.4.5, vitest 4.1.12, fastify 5.12.7, all inside the existing ranges.
Generated with npm 11 because npm 10.9.7's arborist crashes on this tree
(`Cannot read properties of null (reading 'edgesOut')`).
Verified: npm ci, audit (0), lint, format, typecheck, test (915),
build, complexity, test:deno, test:bun, test:edge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
CI picked up Bun 1.4.4 (`oven-sh/setup-bun@v2`, latest), which now sends a
real `1009` close frame when `maxPayloadLength` refuses a frame. Bun 1.3
dropped the connection instead, so the peer saw `1006` — the difference D1
documented and these two assertions pinned on purpose so a Bun upgrade would
be noticed. It was: `runtimes (bun)` fails on develop.
The assertion now follows `Bun.version` (1006 before 1.4, 1009 from 1.4), so a
further change in either direction still fails. JSDoc, README and the #107
CHANGELOG entry say which Bun versions do what.
Verified with Bun 1.3.14 and 1.4.4 (26/26 each); lint, format, typecheck,
npm test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
actions/checkout and actions/setup-node v4 -> v5, softprops/action-gh-release
v2 -> v3; all three run on Node 24. setup-deno@v2, setup-bun@v2 and
crates-io-auth-action@v1 already resolve to Node 24 releases. Jobs keep
node-version 22.
Refs #103
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The README still said matching was a linear scan with a radix tree as
post-beta work; CARD-07 (#128) shipped the radix index.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Before, when two sibling routes could match the same request, the router
picked one by registration order or precedence, and nothing reported it.
Boot now refuses two cases between routes of the same method that branch at
the same segment under the same prefix:
- ambiguous: both params are constrained, the constraints accept a common
segment, and the rest of both patterns can match one request. The error
names both declarations and a witness segment with an example path.
- unreachable: a plain param sits next to a constraint that accepts every
segment, and the constraint wins every request the plain param could take.
A plain param next to a constraint that leaves some segments over is the
documented fallback pattern and still boots.
The check is exact. assertSafeConstraint admits only a linear, group-free
subset, so every constraint reads back as a sequence of (character set, min,
max) blocks. Atom sets follow u-flag semantics. \p{...} is the one construct
that is not modelled, and for it the engine is asked once per code point. A
product walk over two block sequences finds a common segment, or proves none
exists, in O(|A|*|B|*(|A|+|B|)*K) with K <= 2048. "Accepts every segment" is
a closed-form test on the blocks. Both are measured against what the router
hands a param: a decoded, non-empty segment that is never "." or "..".
The check runs per table under that table's own precedence. HTTP ranks by
specificity. WebSocket takes the first declared match. @Stream routes sit in
both tables. Routes exported by different teapots are checked against each
other. Local against remote keeps the local override and its warning.
The lookup path is unchanged. router.ts only exports the two token regexes,
so the boot check and assertSafeConstraint read atoms the same way.
BREAKING CHANGE: an app that declares two overlapping constrained siblings
(e.g. /u/:id(\d+) and /u/:n(\d{1,3})), or a plain param beside a constraint
that accepts every segment, now fails createApp. So do a plain WebSocket param
declared before a constrained sibling, and such pairs across mesh teapots.
Refs: #127
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The frozen app fixture declares GET /n/:num(\d+) and GET /n/:code([0-9a-f]+).
Both constraints accept digits, so CARD-13 (#127) makes this pair a boot error,
and the fixture app could no longer start. That would fail app-fetch.json and
app-node.json, and the Deno, Bun and workerd parity runs that boot the same app.
Narrow nCode to [a-f]+. The two frozen requests on this pair still get the
captured answers: /n/42 goes to nNum and /n/ff goes to nCode, with the same
params. No frozen JSON file changes.
What is lost at app level is the equal-rank registration tie between two
overlapping constraints. CARD-13 now forbids that tie at boot. The tie stays
covered by matcher-hand.json, which calls the matcher without booting an app.
Owner approval required (CARD-08 rule): this edits a file under
test/router-parity/.
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>
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 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>
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>
The finally block added in a2b71e2 wrote both stacks' length on every
lookup, which drops their backing storage and made every walked lookup
pay for reallocation: +50% late param hit, +33% method miss and +104%
path miss at 10 routes on jarvis (CARD-10). A normal walk already ends
at base, so reset only in a catch and rethrow.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The frozen CARD-08 goldens already hold graph(), explain(), openapi() and
the mesh teacup. This adds what they do not cover, with expectations
captured from the pre-radix code at ed47836 in a detached checkout:
- explain()/inspect() on a pattern shared by several methods with a
non-GET declared first, and a concrete path that is not a declaration;
- /__graph__ and /__openapi__ on app.fetch, a Node listener and a mesh
teacup, and their agreement with the direct API;
- a structural check that graph/explain/inspect/openapi never call the
router lookup, return the same output before and after the index is
built, and keep declaration order where the index ranks differently.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The walk stack is shared across lookups. A malformed % escape threw out
of decodeSegment with frames still pushed, so repeated direct matcher
calls on such paths retained them. Truncate both arrays back to the
entry length in a finally block, and check it with a test.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Same four mutants (no-backtrack, catch-all-needs-segment,
prune-bound-off-by-one, zero-catch-all-after-static-dead-end), patched
at their new sites in the stack-based walk. 21/21 still killed.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The lookup walk recursed once per path segment, so a valid deep route
such as 4,999 static segments followed by /:x threw RangeError where the
linear matcher matched. Walk on an explicit stack instead, visiting
frames in the same order, and cover the case through buildFetch.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The owner approved editing this one file under test/router-parity/ so
the PR ends with a single mutant check. The original search texts
targeted lines of the linear scan that CARD-07 removed, so the script
refused to run against the new router. The parity tests, oracle,
frozen JSON and manifest are untouched.
The twelve original mutants keep their names and the bug each models;
six apply their original edit, six are rewritten against the index.
Nine new mutants cover risks the index introduced: the static-route
map ignoring the method or shadowing an earlier route, an off-by-one
pruning bound, the empty-collection skip pruning a real match, a
local/remote tie going remote, Allow and implicit HEAD from the local
tree only, the stale-index guard removed, and a zero-segment
catch-all skipped where the path ends on a static continuation.
The suite now also runs test/router-index.test.ts, which covers the
local/remote split and index lifetime the corpus cannot reach. Each
edit must match exactly once and must change the file; a failed edit
restores the copy before the run aborts. The script still ends with
git diff --exit-code src.
Removes test/router-index-mutants.ts and parity:mutants:index, which
this replaces.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The walk takes the static branch first, so for `GET /a/:rest*` and
`GET /:x/b` it reaches the catch-all on `/a/b` before the exact param
route that outranks it. The corpus has no such pair, and a pruning
bound off by one went unnoticed there. Checked against the oracle in
both declaration orders.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
An internal change with no behaviour difference, recorded under
Changed with the lookup numbers from the jarvis run.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Replace the linear, specificity-sorted scan behind matchRoute,
resolveRoute and allowedMethods with a segment trie per HTTP method,
built once per route array from the compiled segments compilePattern
already produces.
Ranking stays global: every terminal carries its position in the old
sorted bucket (moreSpecific, declaration order on ties), and the walk
keeps the lowest rank it can reach, pruning subtrees that cannot beat
it. The tree decides which routes can match; the rank alone decides
which one does. A static branch that dead-ends deeper backtracks into
its param, constrained and catch-all siblings.
All-static routes are also kept by exact path per method. A hit there
is provably the tree's best match, so a static request is answered
without splitting the path; a miss falls through to the walk.
Mesh-spliced remote routes go in a second tree, per the owner's
design decision. Both trees answer, the more specific match wins and
an equal one goes to the earlier declaration, so local still beats
remote on a tie. Allow, 405 and implicit HEAD run over the union. An
app without remote routes does one lookup.
allowedMethods walks the index instead of recompiling every route on
a miss, and an implicit HEAD no longer builds a fresh index from a
filtered array on every request.
The frozen parity corpus passes unchanged. The frozen mutant script
cannot run against the new layout by design, so
test/router-index-mutants.ts re-targets its twelve bug classes at
the new code and runs the same untouched suite.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
CARD-07 will index local and remote mesh routes as two radix trees and keep
today's unified precedence: the most specific route wins across both trees, a
tie goes to the local route, and Allow is the union. This freezes that behaviour
from ed47836, through app.fetch and a Node socket, in a new file
(owner-mesh-allow.json); existing captures are untouched.
- Local GET and remote POST on one path: PUT is 405 and OPTIONS is 204, both
with Allow GET, HEAD, POST, OPTIONS. HEAD uses the local GET.
- Local static GET /api/v/b with remote POST /api/v/🆔 the same union on
/api/v/b, and only POST, OPTIONS on /api/v/c.
- A remote GET with no local route: OPTIONS advertises GET, HEAD, OPTIONS, but
HEAD answers 404. The teacup resolves HEAD to the remote GET implicitly,
forwards it as HEAD, and the teapot finds no plan for (pattern, HEAD). That
is the mesh proxy, not the matcher, and is captured as observed.
The mutation check still kills 12 of 12.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The first baseline came from a laptop on battery, with one router per process,
run one after the other. It moves to battery-run/ for reference. The new
baseline is the interleaved A/A run (live matcher as A, byte-identical oracle
as B) on jarvis.
Setup: Ryzen 7 3700X, cpuset 6,7,14,15 (two idle physical cores and their SMT
siblings), node:22 container, Node 22.23.1, load average 0.27-0.79, no CI job
running. 4 processes x 21 rounds give 84 paired rounds per cell.
Live medians in ns per lookup (static hit, late param, method miss, path miss):
10 routes: 185, 328, 800, 626
100 routes: 201, 878, 2525, 3054
500 routes: 202, 2931, 11904, 15514
A/A noise floor (oracle/live median ratio, 95% CI): at 10 routes, static hit
-13.7..+11.9% and late param -1.6..+9.8%; misses within +-4.4%. At 100 and 500
routes, offsets are systematic but within about 3%.
In-process, the module imported first runs about 20% faster on the 10-route
static hit. Alternating import order per process removes the bias from the
median but not from that cell's CI. A 5% limit there cannot be resolved with
this method and sample size, so this is recorded for the D4 decision. The 20%
improvement target at 500 routes is far outside the noise.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The first baseline ran each router in its own process, one after another, so
drift and background load landed on whichever side ran later. Comparing two
medians taken minutes apart cannot resolve a 5% threshold.
bench:lookup now loads every router into one process. In each cell it warms
every router, then takes one sample from each per round, alternating the
order: AB, BA, AB. There are at least 15 rounds per cell per run (default 21)
over 4 fresh processes, and module import order also alternates per run.
Every router after the first is reported against the first as the median of
the per-round paired B/A ratios, with a percentile-bootstrap 95% CI (4000
resamples, fixed seed, so the same samples always give the same interval).
With a single router it reports absolute medians as before.
The record now includes hostname, the effective cpuset when run in a Linux
container, and any LOOKUP_* note variables. The harness still runs on any
machine with Node 22.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
A frozen corpus is only worth what it catches. npm run parity:mutants applies 12
targeted mutants to a temporary copy of src/, one at a time, and runs the parity
suite against each. Every mutant models a bug a radix rewrite could plausibly
introduce:
no backtracking to a param branch static/param precedence swapped
equal-rank tie to last-registered constraint ignored
decode before splitting (%2F) catch-all needs a segment
implicit HEAD from a streaming GET Allow from one pattern only
Allow in discovery order trailing slash not normalized
WS ranked like HTTP case-insensitive static match
All 12 are killed (4 to 74 failing tests each), so no corpus case had to be
added. A mutant whose search text is not found exactly once fails the run rather
than silently testing an unmutated copy. The real src/ is never written, and
the run ends with git diff --exit-code src. It is not part of npm test because
it runs the suite once per mutant.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The matcher comparison does not depend on the runtime, so it should run on every
runtime core supports. Only the Node suite ran it before.
The comparison and the app.fetch fixtures move into differential.ts and
app-fixture.ts, which use neither vitest nor a file API. Each runtime passes in
a loader for the frozen JSON. The vitest files use the same modules, plus a
Node check that the neutral runners report no mismatch, so the two paths cannot
drift.
- Deno and Bun: test/{deno,bun}/router-parity.test.ts run all 1158 frozen
matcher cases (hand-picked, owner, generated v1 and v2, WS) through the oracle
and the live router, plus the 55 app.fetch cases.
- workerd: test/edge/parity-worker.ts bundles the frozen JSON and runs the
same checks; test/edge/run.ts adds the phase after its existing assertions.
The Node-socket, WS-upgrade, boot and mesh captures stay Node-only: they need
http.request, the ws client, or a mesh peer on a port.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
The baseline CARD-10 compares the radix index against, captured before any
router change. Kept with its environment record and every raw sample.
bench:lookup on the linear matcher, five runs of 105 samples per cell. Median
ns per lookup:
routes static hit late param method miss path miss
10 61.3 123.3 313.1 247.1
100 67.6 343.4 1263.7 1463.3
500 67.8 1326.8 6732.2 8973.4
Run-to-run spread of the per-run medians is 2.0-17.5%. An A/A run (live
router against the byte-identical oracle, same protocol) differs by +5.2% on
the 10-route static hit and by at most 2.7% elsewhere, so D4's 5% limit at 10
routes sits at the noise floor for that cell. That is recorded for the D4
decision, not resolved here.
bench:compare, run once A/A, is stored separately as end-to-end req/s only:
every case within 1.9%.
Measured on an Apple M4 Max on battery power, load average 2.4-3.4 on 16
cores; the comparison run should use the same power source.
Refs #109
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>