fix(mesh): answer HEAD on a remote GET route (CARD-20, #125) #137

Merged
chrnx merged 2 commits from feature/fprd-001c-mesh-remote-head into develop 2026-10-23 06:04:37 +00:00
Owner

What and why

CARD-20 (FPRD-001c), issue #125, decision D16 (accepted 2026-10-22: fix it in the teacup).

A teacup resolved HEAD on a remote buffered GET through the implicit-HEAD fallback, and OPTIONS advertised HEAD. But the remote route handler in spliceRemoteScopes forwarded req.method, so the teapot got a HEAD envelope. resolveRoute on the teapot found no HEAD plan and answered 404.

The fix is one line in the teacup's remote route handler: a HEAD that matched a remote GET is forwarded 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 teapot and the wire protocol don't change, so a new teacup works against an older teapot during a rolling deploy.

Commits

  1. fix(mesh): answer HEAD on a remote GET route (CARD-20, #125): the fix, tests, and the CHANGELOG ### Fixed entry.
  2. test(router-parity): HEAD on a remote GET answers 200 for CARD-20 (owner approval required): needs owner approval (CARD-08 rule). In test/router-parity/frozen/owner-mesh-allow.json, the two HEAD /api/x entries (fetch and node) go from status 404 to 200. Headers and the empty body are unchanged. The fixture comment in owner.test.ts that described the old behaviour is updated to match. Commit 1 alone fails that frozen test, so review the two commits together.

Tests (card cases)

test/mesh/remote-head.test.ts:

  • T1 app.fetch: 200, same content-type as the GET (application/json), empty body
  • T2 Node listener: same
  • OPTIONS still GET, HEAD, OPTIONS (both adapters)
  • T3 explicit remote HEAD + GET: the explicit HEAD handler runs and is reached as HEAD
  • T4 remote GET throws NotFound: HEAD → 404, empty body, and the teapot handler did run
  • remote GET throws: HEAD → 500, empty body
  • T5 one HEAD calls the teapot handler once, with method GET
  • T6: new cases in test/deno/mesh.test.ts and test/bun/mesh.test.ts (HEAD over a real socket → 200, JSON content-type, empty body)

Evidence (local, Node 22, after rebasing on develop)

  • npm run lint: 0 errors, 50 warnings (all pre-existing no-explicit-any, none added)
  • npm run format:check: clean
  • npm run typecheck: clean
  • npm test: 922 passed
  • npm run build: ok
  • npm run complexity:check: every function ≤ 25
  • npm run test:deno: 37 passed, 0 failed
  • npm run test:bun: 27 pass, 0 fail
  • npm run test:edge: PASS (1158 matcher cases + 55 app.fetch cases)
  • npm audit --audit-level=moderate: found 0 vulnerabilities (rebased on origin/develop after #134 and #135 merged)

Unsure / notes

  • The condition is req.method === 'HEAD' && route.method === 'GET', not simply route.method. It is narrower and makes the intent explicit.
  • The scope-step envelope (envelopeFrom) still carries HEAD for a local HEAD route that needs a remote step. Teapot scope resolution doesn't look up by method, so it works, and the card doesn't cover it. I left it alone.
  • No public API change, so no JSDoc changes.

Docs follow-up (CARD-12)

  • guides/mesh.md: if it describes remote routes and methods, add that HEAD on a remote GET answers like a local one (the GET's status and headers, no body), and that the teacup forwards it to the teapot as GET.
## What and why CARD-20 (FPRD-001c), issue #125, decision **D16** (accepted 2026-10-22: fix it in the teacup). A teacup resolved `HEAD` on a remote buffered `GET` through the implicit-HEAD fallback, and `OPTIONS` advertised `HEAD`. But the remote route handler in `spliceRemoteScopes` forwarded `req.method`, so the teapot got a `HEAD` envelope. `resolveRoute` on the teapot found no `HEAD` plan and answered `404`. The fix is one line in the teacup's remote route handler: a `HEAD` that matched a remote `GET` is forwarded 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 teapot and the wire protocol don't change, so a new teacup works against an older teapot during a rolling deploy. ## Commits 1. `fix(mesh): answer HEAD on a remote GET route (CARD-20, #125)`: the fix, tests, and the CHANGELOG `### Fixed` entry. 2. `test(router-parity): HEAD on a remote GET answers 200 for CARD-20 (owner approval required)`: **needs owner approval (CARD-08 rule).** In `test/router-parity/frozen/owner-mesh-allow.json`, the two `HEAD /api/x` entries (fetch and node) go from status `404` to `200`. Headers and the empty body are unchanged. The fixture comment in `owner.test.ts` that described the old behaviour is updated to match. Commit 1 alone fails that frozen test, so review the two commits together. ## Tests (card cases) `test/mesh/remote-head.test.ts`: - T1 app.fetch: `200`, same `content-type` as the GET (`application/json`), empty body - T2 Node listener: same - `OPTIONS` still `GET, HEAD, OPTIONS` (both adapters) - T3 explicit remote `HEAD` + `GET`: the explicit HEAD handler runs and is reached as HEAD - T4 remote GET throws `NotFound`: `HEAD` → `404`, empty body, and the teapot handler did run - remote GET throws: `HEAD` → `500`, empty body - T5 one HEAD calls the teapot handler once, with method `GET` - T6: new cases in `test/deno/mesh.test.ts` and `test/bun/mesh.test.ts` (HEAD over a real socket → 200, JSON content-type, empty body) ## Evidence (local, Node 22, after rebasing on develop) - `npm run lint`: 0 errors, 50 warnings (all pre-existing `no-explicit-any`, none added) - `npm run format:check`: clean - `npm run typecheck`: clean - `npm test`: 922 passed - `npm run build`: ok - `npm run complexity:check`: every function ≤ 25 - `npm run test:deno`: 37 passed, 0 failed - `npm run test:bun`: 27 pass, 0 fail - `npm run test:edge`: PASS (1158 matcher cases + 55 app.fetch cases) - `npm audit --audit-level=moderate`: found 0 vulnerabilities (rebased on `origin/develop` after #134 and #135 merged) ## Unsure / notes - The condition is `req.method === 'HEAD' && route.method === 'GET'`, not simply `route.method`. It is narrower and makes the intent explicit. - The scope-step envelope (`envelopeFrom`) still carries `HEAD` for a local HEAD route that needs a remote step. Teapot scope resolution doesn't look up by method, so it works, and the card doesn't cover it. I left it alone. - No public API change, so no JSDoc changes. ## Docs follow-up (CARD-12) - `guides/mesh.md`: if it describes remote routes and methods, add that `HEAD` on a remote `GET` answers like a local one (the GET's status and headers, no body), and that the teacup forwards it to the teapot as `GET`.
chrnx force-pushed feature/fprd-001c-mesh-remote-head from c865c2a418 to d9b0fe09d6 2026-10-23 04:56:19 +00:00 Compare
chrnx force-pushed feature/fprd-001c-mesh-remote-head from d9b0fe09d6 to 3b124fb05b 2026-10-23 05:03:01 +00:00 Compare
Author
Owner

Owner decision (2026-10-23): frozen capture change in 3b124fb (owner-mesh-allow.json, HEAD /api/x 404 → 200) approved. Not merging yet: an implementation review of the 1c sprint comes first.

Owner decision (2026-10-23): frozen capture change in 3b124fb (`owner-mesh-allow.json`, `HEAD /api/x` 404 → 200) **approved**. Not merging yet: an implementation review of the 1c sprint comes first.
Author
Owner

Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.

Implementation review done on 2026-10-23: a Codex review of all 12 sprint PRs, with each finding verified. The P1s in #142 and the P3 in #149 are fixed. The owner (Chrnx) authorized merging in order, each one rebased on develop with CI green. This supersedes the earlier "not merging yet" note.
chrnx added 2 commits 2026-10-23 06:00:32 +00:00
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>
test(router-parity): HEAD on a remote GET answers 200 for CARD-20 (owner approval required)
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 16s
CI / build (pull_request) Successful in 26s
CI / runtimes (edge) (pull_request) Successful in 14s
CI / runtimes (deno) (pull_request) Successful in 20s
ae9e5529e8
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>
chrnx force-pushed feature/fprd-001c-mesh-remote-head from 3b124fb05b to ae9e5529e8 2026-10-23 06:00:32 +00:00 Compare
chrnx merged commit c9e76fde2d into develop 2026-10-23 06:04:37 +00:00
chrnx deleted branch feature/fprd-001c-mesh-remote-head 2026-10-23 06:04:38 +00:00
Sign in to join this conversation.