Closes the CARD-09 acceptance check (FPRD-001b, #109): route introspection is unchanged after the radix index from #128. Tests only; src/ is untouched and no file under test/router-parity/ was edited.
What the frozen CARD-08 corpus already covers
All in test/router-parity/introspection.test.ts, against goldens captured at ed47836:
Criterion / test case
Evidence
graph().routes content and order (method, transport, pattern, chain), declaration order not specificity order
golden-graph.json, test "graph() equals the golden"
explain() success for declared patterns (incl. WS and catch-all)
golden-explain.json
explain()no route: <pattern> error
golden-explain.json (/api/missing, /api/items)
Concrete request path is not a declaration lookup
golden-explain.json (/api/items/42 throws)
Duplicate pattern under several methods: first declaration wins
golden-explain.json (/api/items/:id(\d+) under GET/HEAD/OPTIONS/DELETE gives GET)
Mesh: pre-ready graph()/explain() error, openapi() before ready
golden-mesh.jsonbefore
Mesh: post-ready introspection, remote routes absent from routePlans but served
golden-mesh.jsonafter, explainRemote, lookup
What this PR adds
test/router-introspection-parity.test.ts and test/fixtures/router-introspection-ed47836.json:
Gap
Test
Duplicate pattern where a non-GET is declared first (DELETE before GET at /v1/docs/:id), for explain() and inspect()
captured fixture + "explain() and inspect() take the first declaration..."
Dev endpoints /__graph__ (HTML and text/plain Mermaid) and /__openapi__ when enabled, on app.fetch and on a Node listener
captured fixture (local.fetchDev, local.nodeDev)
Dev endpoints agree with the direct API (openapi(), toMermaid(graph()), graphHtml(graph()))
"dev endpoints agree with the direct API on app.fetch"
Mesh teacup: dev endpoints after ready() agree with the direct API; inspect() pre-ready error; remote route served but absent from graph/OpenAPI
captured fixture (mesh.*) + "...on a mesh teacup after ready()"
Introspection does not depend on the radix index
"introspection never consults the lookup index...": the router lookup entry points (matchRoute, resolveRoute, allowedMethods) are wrapped with a call counter via vi.mock; graph/explain/inspect/toMermaid/openapi make zero lookup calls, give identical output before and after requests build the index, and list routes in declaration order (remove, rest, get, latest, events, live) while the index answers GET /v1/docs/latest with the later-declared static route and GET /v1/docs/7 with get over the earlier catch-all
How expectations were captured
The new test file was copied into a temporary detached git worktree of ed47836c9820c47bf4ed5e902d91e019abdb110a (the CARD-08 pinned revision, pre-radix router) and run there with INTROSPECTION_PARITY_CAPTURE=<out.json>. The output was committed as test/fixtures/router-introspection-ed47836.json, which records that revision and is checked by the test. The temporary worktree was removed. Nothing was generated from the radix implementation. A capture from cb123e3 was byte-identical to the ed47836 one.
A sanity check (swapping two routes in the fixture locally) made the test fail as expected; the fixture was restored from the ed47836 capture.
Compatibility differences
None found.
Gates
npm run lint: 0 errors (50 pre-existing no-explicit-any warnings in src/); the new test file is also eslint-clean
npm run format:check: pass; prettier --check on the new files: pass
npm run build, then npm run typecheck: pass
npm test: 89 files, 818 tests pass
npm run test:deno: 36 passed; npm run test:bun: 26 pass; npm run test:edge: PASS (incl. 1158 matcher + 55 app.fetch parity cases)
The new tests also cover inspect() and toMermaid(), which read routePlans too, though the card names only graph/explain/OpenAPI.
Graph HTML from /__graph__ is compared by SHA-256 rather than stored in full, since it embeds a large inline SVG.
No Matcha-facing comparison: Matcha does not consume these outputs in core, so none was invented (as the card allows).
Closes the CARD-09 acceptance check (FPRD-001b, #109): route introspection is unchanged after the radix index from #128. Tests only; `src/` is untouched and no file under `test/router-parity/` was edited.
## What the frozen CARD-08 corpus already covers
All in `test/router-parity/introspection.test.ts`, against goldens captured at `ed47836`:
| Criterion / test case | Evidence |
|---|---|
| `graph().routes` content and order (method, transport, pattern, chain), declaration order not specificity order | `golden-graph.json`, test "graph() equals the golden" |
| `explain()` success for declared patterns (incl. WS and catch-all) | `golden-explain.json` |
| `explain()` `no route: <pattern>` error | `golden-explain.json` (`/api/missing`, `/api/items`) |
| Concrete request path is not a declaration lookup | `golden-explain.json` (`/api/items/42` throws) |
| Duplicate pattern under several methods: first declaration wins | `golden-explain.json` (`/api/items/:id(\d+)` under GET/HEAD/OPTIONS/DELETE gives GET) |
| `openapi()` paths, operations, parameters, schema, key order, WS excluded | `golden-openapi.json` (`/api/live/:room` absent) |
| Mesh: pre-ready `graph()`/`explain()` error, `openapi()` before ready | `golden-mesh.json` `before` |
| Mesh: post-ready introspection, remote routes absent from routePlans but served | `golden-mesh.json` `after`, `explainRemote`, `lookup` |
## What this PR adds
`test/router-introspection-parity.test.ts` and `test/fixtures/router-introspection-ed47836.json`:
| Gap | Test |
|---|---|
| Duplicate pattern where a **non-GET** is declared first (`DELETE` before `GET` at `/v1/docs/:id`), for `explain()` and `inspect()` | captured fixture + "explain() and inspect() take the first declaration..." |
| Dev endpoints `/__graph__` (HTML and `text/plain` Mermaid) and `/__openapi__` when enabled, on `app.fetch` and on a Node listener | captured fixture (`local.fetchDev`, `local.nodeDev`) |
| Dev endpoints agree with the direct API (`openapi()`, `toMermaid(graph())`, `graphHtml(graph())`) | "dev endpoints agree with the direct API on app.fetch" |
| Mesh teacup: dev endpoints after `ready()` agree with the direct API; `inspect()` pre-ready error; remote route served but absent from graph/OpenAPI | captured fixture (`mesh.*`) + "...on a mesh teacup after ready()" |
| Introspection does not depend on the radix index | "introspection never consults the lookup index...": the router lookup entry points (`matchRoute`, `resolveRoute`, `allowedMethods`) are wrapped with a call counter via `vi.mock`; `graph`/`explain`/`inspect`/`toMermaid`/`openapi` make zero lookup calls, give identical output before and after requests build the index, and list routes in declaration order (`remove, rest, get, latest, events, live`) while the index answers `GET /v1/docs/latest` with the later-declared static route and `GET /v1/docs/7` with `get` over the earlier catch-all |
### How expectations were captured
The new test file was copied into a temporary detached `git worktree` of `ed47836c9820c47bf4ed5e902d91e019abdb110a` (the CARD-08 pinned revision, pre-radix router) and run there with `INTROSPECTION_PARITY_CAPTURE=<out.json>`. The output was committed as `test/fixtures/router-introspection-ed47836.json`, which records that revision and is checked by the test. The temporary worktree was removed. Nothing was generated from the radix implementation. A capture from `cb123e3` was byte-identical to the `ed47836` one.
A sanity check (swapping two routes in the fixture locally) made the test fail as expected; the fixture was restored from the `ed47836` capture.
## Compatibility differences
None found.
## Gates
- `npm run lint`: 0 errors (50 pre-existing `no-explicit-any` warnings in `src/`); the new test file is also eslint-clean
- `npm run format:check`: pass; prettier `--check` on the new files: pass
- `npm run build`, then `npm run typecheck`: pass
- `npm test`: 89 files, 818 tests pass
- `npm run test:deno`: 36 passed; `npm run test:bun`: 26 pass; `npm run test:edge`: PASS (incl. 1158 matcher + 55 app.fetch parity cases)
- `npm run parity:mutants`: 21/21 killed
- `npm run complexity:check`: pass
- `npm audit --audit-level=moderate`: 0 vulnerabilities
## Deviations
- The new tests also cover `inspect()` and `toMermaid()`, which read `routePlans` too, though the card names only graph/explain/OpenAPI.
- Graph HTML from `/__graph__` is compared by SHA-256 rather than stored in full, since it embeds a large inline SVG.
- No Matcha-facing comparison: Matcha does not consume these outputs in core, so none was invented (as the card allows).
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>
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.
Closes the CARD-09 acceptance check (FPRD-001b, #109): route introspection is unchanged after the radix index from #128. Tests only;
src/is untouched and no file undertest/router-parity/was edited.What the frozen CARD-08 corpus already covers
All in
test/router-parity/introspection.test.ts, against goldens captured ated47836:graph().routescontent and order (method, transport, pattern, chain), declaration order not specificity ordergolden-graph.json, test "graph() equals the golden"explain()success for declared patterns (incl. WS and catch-all)golden-explain.jsonexplain()no route: <pattern>errorgolden-explain.json(/api/missing,/api/items)golden-explain.json(/api/items/42throws)golden-explain.json(/api/items/:id(\d+)under GET/HEAD/OPTIONS/DELETE gives GET)openapi()paths, operations, parameters, schema, key order, WS excludedgolden-openapi.json(/api/live/:roomabsent)graph()/explain()error,openapi()before readygolden-mesh.jsonbeforegolden-mesh.jsonafter,explainRemote,lookupWhat this PR adds
test/router-introspection-parity.test.tsandtest/fixtures/router-introspection-ed47836.json:DELETEbeforeGETat/v1/docs/:id), forexplain()andinspect()/__graph__(HTML andtext/plainMermaid) and/__openapi__when enabled, onapp.fetchand on a Node listenerlocal.fetchDev,local.nodeDev)openapi(),toMermaid(graph()),graphHtml(graph()))ready()agree with the direct API;inspect()pre-ready error; remote route served but absent from graph/OpenAPImesh.*) + "...on a mesh teacup after ready()"matchRoute,resolveRoute,allowedMethods) are wrapped with a call counter viavi.mock;graph/explain/inspect/toMermaid/openapimake zero lookup calls, give identical output before and after requests build the index, and list routes in declaration order (remove, rest, get, latest, events, live) while the index answersGET /v1/docs/latestwith the later-declared static route andGET /v1/docs/7withgetover the earlier catch-allHow expectations were captured
The new test file was copied into a temporary detached
git worktreeofed47836c9820c47bf4ed5e902d91e019abdb110a(the CARD-08 pinned revision, pre-radix router) and run there withINTROSPECTION_PARITY_CAPTURE=<out.json>. The output was committed astest/fixtures/router-introspection-ed47836.json, which records that revision and is checked by the test. The temporary worktree was removed. Nothing was generated from the radix implementation. A capture fromcb123e3was byte-identical to theed47836one.A sanity check (swapping two routes in the fixture locally) made the test fail as expected; the fixture was restored from the
ed47836capture.Compatibility differences
None found.
Gates
npm run lint: 0 errors (50 pre-existingno-explicit-anywarnings insrc/); the new test file is also eslint-cleannpm run format:check: pass; prettier--checkon the new files: passnpm run build, thennpm run typecheck: passnpm test: 89 files, 818 tests passnpm run test:deno: 36 passed;npm run test:bun: 26 pass;npm run test:edge: PASS (incl. 1158 matcher + 55 app.fetch parity cases)npm run parity:mutants: 21/21 killednpm run complexity:check: passnpm audit --audit-level=moderate: 0 vulnerabilitiesDeviations
inspect()andtoMermaid(), which readroutePlanstoo, though the card names only graph/explain/OpenAPI./__graph__is compared by SHA-256 rather than stored in full, since it embeds a large inline SVG.