Repository navigation
Commit 26aa999
fix(runtime,hono): an exact /approvals/act dispatcher domain for kernels with no raw app, and a catch-all that leaves the raw request readable (#22693)
Fixes #22576
Clause-②: no
Segment 2 of ruling A on #22438 (maintainer ruling recorded verbatim as
「A + 扫类」). A hosted tenant kernel owns no socket, so it has no raw Hono
app for `plugin-approvals` to mount the ADR-0043 action page on: on that
shape `GET`/`POST /api/v1/approvals/act` answered `404 ROUTE_NOT_FOUND`,
and every approve / reject link in every approval message was dead. This
PR gives the dispatcher that route and makes the Hono catch-all stop
eating the body the route needs.
## What changed
**`@objectstack/runtime`**
- New dispatcher domain `packages/runtime/src/domains/approvals.ts`,
registered in `HttpDispatcher` the way `/auth` is (ADR-0076 D11: the
dispatcher owns registration, one route bridges to one service slot). It
claims exactly `/approvals/act` (`match: 'exact'`) for `GET`, `HEAD` and
`POST`, resolves the request kernel's `approvals` slot, and forwards
`context.request` unread to `IApprovalService.handleActionPage`,
returning that `Response` untouched.
- `HEAD`: forwarded to the member as a `GET` and answered with that
page's status and headers and no body, which is what the self-hosted
mount answers (measured, below). It renders; it never decides.
- Absent slot, or a service without `handleActionPage`: `501
NOT_IMPLEMENTED` (an existing standard code), with a message naming
which. Never `ROUTE_NOT_FOUND`.
- A member that throws: sanitised `500 INTERNAL_ERROR`, original error
logged (the `/auth` discipline). A `POST` whose body a transport already
consumed: also `500`, logged, and the member is not asked; otherwise the
member would show the approver an "invalid link" page for a live link.
- `enforceProjectMembership` skips the exact act path (unscoped or
`/environments/:id`-scoped), and only it. See decision 3.
- `route-ledger.ts`: two `public` rows (`GET`/`POST /approvals/act`),
census 82 to 84.
**`@objectstack/hono`**
- The `${prefix}/*` catch-all and the `/auth/*` legacy fallback parse
the JSON body from `c.req.raw.clone()` instead of `c.req.json()`, so
`context.request` reaches the dispatcher with its body unread, for every
content type, JSON included. The parsed `body` domains get is unchanged
for every input (same `text()` then `JSON.parse`, same `{}` on any
failure). A body something upstream already read through `c.req` falls
back to `c.req.json()` (Hono's cache), as before.
**Pins and bookkeeping (no published surface)**
- `scripts/check-route-envelope.mjs`: declares `approvals.ts` with
`handBuilt: 0`.
- `packages/qa/http-conformance`: devDependency on
`@objectstack/plugin-approvals` (aliased to source in its vitest config)
so one suite can boot the real plugin on both doors; `pnpm-lock.yaml`
gains the 3-line importer link.
-
`packages/qa/dogfood/test/route-ledger-live-mount-parity.dogfood.test.ts`:
the two new rows are pinned as unobservable on the self-hosted showcase
boot, where `plugin-approvals` serves the path from
`rawApp.get`/`rawApp.post`, never through the `IHttpServer` port (the
same reason the `/auth/**` row is pinned).
No new error code, no new package-entry export (the domain module is not
exported from `@objectstack/runtime`'s index), no spec, `packages/core`
or `plugin-approvals` source change.
## The claim's four decisions, as measured
1. **Hono, option A.** Premise "the parsed body domains see is
unchanged" is pinned per input against a reference Hono app running the
old line: spaced JSON object, array, `null`, number, string,
BOM-prefixed JSON, JSON sent as `text/plain`, invalid JSON, empty body,
form body, plain text, no content type. All unchanged; every one now
also reads back byte for byte from the request at dispatch. Nothing
measured broke.
2. **HEAD.** Measured first on the real composition (real
`HonoServerPlugin` socket + real `ApprovalsServicePlugin` raw-app
mount): `HEAD /api/v1/approvals/act` answers `200`, the `GET` page's
headers minus `content-length`, empty body, for a live and a dead token.
The hosted door (real `createHonoApp`, real dispatcher, real member)
answers identically. One conformance pin holds both doors equal.
3. **Membership gate.** Premise measured TRUE before any skip existed:
through `dispatch()` on a multi-tenant host, a signed-in caller who is
not a member of the resolved environment got `403
PROJECT_MEMBERSHIP_REQUIRED` and the member never ran, while an
anonymous caller with the same link reached it. So the exact act path
joined the skip; pins cover GET, POST, the scoped spelling, an anonymous
control, and five neighbours that are still checked (`/approvals/act/x`,
`/approvals/actx`, `/approvals`, `/approvals/requests`, `/data/task`).
No other auth change.
4. **Cross-segment ablation.** On the real `ApprovalService`,
`handleActionPage` removed on purpose: the hosted door answers `501
NOT_IMPLEMENTED` on GET, HEAD and POST; with no `approvals` slot: `501
NOT_IMPLEMENTED`, while the control path `/approvals/actx` on the same
door is the route miss `404 ROUTE_NOT_FOUND`.
## Pins
- `packages/runtime/src/domains/approvals-act.test.ts` (12): real
`HttpDispatcher` on a kernel with no `http.server` and a stub member
that reads its own token.
- `packages/adapters/hono/src/hono-catch-all-raw-request.test.ts` (17):
the catch-all's preservation and raw-body halves, PUT/PATCH, GET/DELETE
unchanged, the upstream-consumed fallback, the `/auth/*` fallback.
-
`packages/qa/http-conformance/src/hono-approvals-act.conformance.test.ts`
(4): the real plugin on both doors; a form POST through the hosted door
redeems a live token (the decision lands in the store), HEAD parity, the
cross-segment 501s.
## Ablations (one-off, committed state, restore proven by blob hash
equal to HEAD and empty `git diff HEAD`)
- Hono fix reverted to `c.req.json()` in the catch-all: 14 of 17 hono
pins red on `bodyUsed` (preservation assertions held), 3 unrelated
green.
- Domain registration removed, runtime `dist/` rebuilt,
`ablation-dist-preflight --absent` green: all 4 hosted conformance pins
red with `404`; the runtime suite on source shows the body:
`ROUTE_NOT_FOUND`, "Route Not Found: /approvals/act" (11 of 12 red, the
neighbour control green). Restore leg: rebuilt, marker present in 2 dist
files, mutation marker absent, 4 of 4 green.
- Dogfood pin key renamed: the parity gate reports `GET /approvals/act —
LEDGERED BUT NOT MOUNTED` plus the stale pin (2 of 8 red), so the pin is
load-bearing.
## Verification
Measured on ``427772e14``, origin/main `ee3ae0360` merged in.
- `@objectstack/runtime`: `local` project in three chunks, 143 + 106 +
97 files, 2569 + 1281 + 1071 tests passed (19 skipped); `repo` project 3
files, 751 passed; `typecheck` (src + test layer) 0.
- `@objectstack/hono`: `test` 6 files, 139 passed; `typecheck` 0.
- `@objectstack/http-conformance`: 10 files, 110 passed; `typecheck` 0.
- `@objectstack/dogfood`:
`route-ledger-live-mount-parity.dogfood.test.ts` 8 of 8; `typecheck` 0.
The rest of that suite is CI's.
- Gates: all 100 families `dispatch-gates --commands` derives for this
diff (the dispatch list's 49 plus 51 the diff adds) exit 0 at
`427772e14`; `dispatch-gates --ran` with each exit recorded: 100
derived, 100 run, 0 NOT-MEASURED, 0 UNRUN. Two needed a prerequisite on
the way, now met: `check-plugin-teardown-shape --self-test` needed its
pinned fixture commit `621a48760` fetched into this shallow checkout,
and `check:dual-build-cjs-loads` needed the whole workspace built (107
entries across 66 packages load). Two were red on this diff and fixed in
it: `check:route-envelope` (the new domain file declared) and
`check:route-ledger-census` (82 to 84).
- Lint, narrowed and proven: the population is `eslint.config.mjs`'s own
`files` globs minus `NEVER_LINTED`; `eslint --no-inline-config --format
json` over the 10 touched lintable files reports 10 files, 0 errors, 0
warnings (none ignored). Invariance: the config enables no type-aware
linting (no `parserOptions.project`, no typed rules, stated in the
config itself), and the diff touches none of the config's own inputs, so
it cannot move the verdict of an untouched file. The full `pnpm lint` is
CI's.
## Acceptance notes
- The question on AGENTS.md route rule 5 (closed query-parameter set).
Measured on both doors: `?token=LIVE&utm_source=mail&zzz=1` renders the
same confirm page as `?token=LIVE`, `200`. The self-hosted mount reads
`token` and ignores the rest, and so does the member; this domain reads
no query parameter at all. Rule 5's subject is a REST handler that reads
`req.query` and can silently drop a filter. Here the reader is the
member, and a mail link may legitimately carry parameters a gateway or
tracker appended. So no closed set is invented here; whether the member
should declare one is the approvals contract's call.
- Methods other than GET/HEAD/POST on the act path: the hosted door
answers the dispatcher's `404 ROUTE_NOT_FOUND`, the self-hosted door
plugin-hono-server's `404 ENDPOINT_NOT_FOUND`. Both are 404 with
different codes. Pre-existing on the self-hosted side, out of this
card's scope.
- The scoped spelling `/api/v1/environments/:id/approvals/act` reaches
the domain through the dispatcher's generic scope strip; the self-hosted
mount has no such spelling. The membership skip and the ADR-0069
allow-list (#22577's) both treat it like the unscoped path.
- Cost of option A: a body-carrying request through the catch-all is
buffered twice for the life of the request (the tee), and on
`@hono/node-server` the direct-read fast path is no longer taken for
POST/PUT/PATCH. These are API bodies the old path already buffered
whole.
- The log window noted by segment 4 (#22578): the plugin's hosted log
line says the pages "are served through the HTTP dispatcher's
/approvals/act domain". That sentence becomes true when this lands.
- The branch was not re-merged after `ee3ae0360`; the commits since
touch none of these files. CI's merge ref covers the rest.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01HGa2XMKBRUqPrZFxQavBwH)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 61bea24 commit 26aa999
17 files changed
Lines changed: 1120 additions & 24 deletions
File tree
- .changeset
- packages
- adapters/hono/src
- qa
- dogfood/test
- http-conformance
- src
- runtime/src
- domains
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
282 | 331 | | |
283 | 332 | | |
284 | 333 | | |
| |||
685 | 734 | | |
686 | 735 | | |
687 | 736 | | |
688 | | - | |
| 737 | + | |
689 | 738 | | |
690 | 739 | | |
691 | 740 | | |
| |||
727 | 776 | | |
728 | 777 | | |
729 | 778 | | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
730 | 782 | | |
731 | 783 | | |
732 | | - | |
| 784 | + | |
733 | 785 | | |
734 | 786 | | |
735 | 787 | | |
| |||
0 commit comments