Skip to content

feat(codegen-ts): Hono service transport and service test lanes - #644

Merged
dmealing merged 8 commits into
mainfrom
fm/mo-130-lane-ts-2-b9
Nov 22, 2026
Merged

dmealing merged 8 commits into
mainfrom
fm/mo-130-lane-ts-2-b9

Conversation

@dmealing

@dmealing dmealing commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds the service-routes-hono generator (serviceRoutesHonoFile(), with a reference twin, a registry entry and meta eject support). It writes <pkg>/transport/hono.ts, exporting <pkg>ServiceHonoRoutes(app, { service, getActor }), which serves the same routes as the Fastify transport. Routes are registered so a fixed path segment comes before a parameter wherever two routes could match one request. The new @metaobjectsdev/runtime-ts/service/hono entry supplies readBody, sendOpResult, and re-exports of guardRoute and the list-query parser.
  • Runs the service on three lanes in integration tests: flat routes, service behind Fastify, and service behind Hono. The shared src/api-lane.ts helper drives this. The list-query, api-settings, enum-default, jsonb and duration corpora now run on every engine their routes lane uses, including D1 with interactiveTransactions: false. The root blog and rules corpora also run on the Hono lane. The service compile gate compiles both transports.
  • Updates docs for the Hono transport: business-rules.md, ports/typescript.md, own-your-codegen.md, the ADR-0067 status and transport table, and CHANGELOG Unreleased entries.
Validation

Risk Assessment

✅ Low: The change adds a Hono twin of the existing Fastify service transport and widens test lanes; the route-ordering comparator, body reading and result sending trace correctly against the Fastify behavior, and I found no source defect. The only finding is stale doc text in two README files.

Testing

Baseline scripts/ci-local.sh --affected --strict-toolchains already passed at the target commit and was not re-run. Three live scenarios were driven against the real generated code and real Postgres testcontainers (Docker available): the rules corpus on the Hono lane, including the requestTotals route-order adversarial case, the list-query corpus on the Hono lane, and the service compile gate, which compiles both transports. All passed (17 + 4 + 21 + 28 tests, 0 failures). Not driven in this turn: the Hono lane under the package layout for the full rules corpus, the duration/enum-default/jsonb/api-settings corpora on Hono, and the D1 service variant. Those rely on the configured baseline run.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rules API served by the generated service behind the emitted Hono transport, over HTTP against real Postgres (rules corpus, service-hono lane, flat layout) ✅ pass live gate evidence s1-rules-hono-flat.log — bun test test/api-contract-rules.test.ts -t &#39;service lane on Hono \[flat\]&#39;: 17 pass, 0 fail
Adversarial route order: GET /purchase_requests/requestTotals answers the totals, not invalid_id, on the Hono lane (public-query scenario) ✅ pass live gate evidence s1b-rules-hono-public-query.log — bun test test/api-contract-rules.test.ts -t &#39;public-query&#39;: 4 pass, 0 fail (service + service-hono lanes…
List-query corpus served on the generated service lane behind the Hono transport ✅ pass live gate evidence s2-listquery-hono.log — bun test test/api-contract-list-query.test.ts -t &#39;on Hono&#39;: 21 pass, 0 fail
Service compile gate: emitted service plus Fastify and Hono transports compile with zero diagnostics under the real TypeScript compiler ✅ pass live gate evidence s3-service-compile.log — bun test test/service-compile.test.ts: 28 pass, 0 fail
Evidence: Rules corpus, service-hono lane, flat layout (17 pass)
bun test v1.3.14 (0d9b296a)

 17 pass
 51 filtered out
 0 fail
Ran 17 tests across 1 file. [19.83s]
Evidence: Rules corpus public-query route-order scenario (4 pass)
bun test v1.3.14 (0d9b296a)

 4 pass
 64 filtered out
 0 fail
Ran 4 tests across 1 file. [5.49s]
Evidence: List-query corpus, service-hono lane (21 pass)
bun test v1.3.14 (0d9b296a)

 21 pass
 42 filtered out
 0 fail
Ran 21 tests across 1 file. [2.16s]
Evidence: Service compile gate, Fastify and Hono transports (28 pass)
bun test v1.3.14 (0d9b296a)

 28 pass
 0 fail
 164 expect() calls
Ran 28 tests across 1 file. [40.73s]

Gate and scope

One gate run. Review raised one info finding (two fixture READMEs not naming service-routes-hono), and the document step added the remaining one-word mentions (docs/CONFORMANCE.md, the porting rule); both are in this branch. Local: ci-local --quick green; codegen-ts 3902, runtime-ts 1160, cli 2187 pass; the six entity sub-corpora 248 pass across the three lanes; rules 68 and root service 68 pass.

Scope is the bounded first half of L-TS-6: the service lanes (Fastify and Hono) on the entity sub-corpora, plus the service-routes-hono transport. Projections, reports, TPH, M:N and write-through on the service, and with them the decimal/ and secret-fields/ sub-corpora, are the following PR; the service-walk "not covered yet" list stays until then.

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ fixtures/generator-registry-conformance/README.md:138 - Stale docs after adding a third TypeScript-only service generator. fixtures/generator-registry-conformance/README.md line 138-140 says "Two names are TypeScript only for now: service ... and service-routes", and the layer table at line 38 lists service-routes but not service-routes-hono. fixtures/codegen-noop/rules/README.md ~line 32 describes only service-routes changing the transport. registry.json itself is correct. The README files are outside this change's file list, so I did not edit them.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rules API served by the generated service behind the emitted Hono transport, over HTTP against real Postgres (rules corpus, service-hono lane, flat layout) ✅ pass live gate evidence s1-rules-hono-flat.log — bun test test/api-contract-rules.test.ts -t &#39;service lane on Hono \[flat\]&#39;: 17 pass, 0 fail
Adversarial route order: GET /purchase_requests/requestTotals answers the totals, not invalid_id, on the Hono lane (public-query scenario) ✅ pass live gate evidence s1b-rules-hono-public-query.log — bun test test/api-contract-rules.test.ts -t &#39;public-query&#39;: 4 pass, 0 fail (service + service-hono lanes…
List-query corpus served on the generated service lane behind the Hono transport ✅ pass live gate evidence s2-listquery-hono.log — bun test test/api-contract-list-query.test.ts -t &#39;on Hono&#39;: 21 pass, 0 fail
Service compile gate: emitted service plus Fastify and Hono transports compile with zero diagnostics under the real TypeScript compiler ✅ pass live gate evidence s3-service-compile.log — bun test test/service-compile.test.ts: 28 pass, 0 fail
  • scripts/ci-local.sh --affected --strict-toolchains
  • Baseline (not re-run): scripts/ci-local.sh --affected --strict-toolchains passed at target commit 9682efa61347b361c4016bf1887d96b4b5da7e86.
  • cd server/typescript/packages/integration-tests &amp;&amp; bun test test/api-contract-rules.test.ts -t &#39;service lane on Hono \[flat\]&#39; — 17 pass, 0 fail (rules corpus, GENERATED service lane on Hono, flat layout, one Postgres testcontainer per scenario, Bun.serve Hono app over HTTP).
  • bun test test/api-contract-rules.test.ts -t &#39;public-query&#39; — 4 pass, 0 fail (adversarial route-order scenario GET /purchase_requests/requestTotals; name filter does not separate lanes, so the 4 include the Hono lane under flat and package layouts).
  • bun test test/api-contract-list-query.test.ts -t &#39;on Hono&#39; — 21 pass, 0 fail (list-query corpus, GENERATED service lane on Hono, Postgres testcontainer).
  • bun test test/service-compile.test.ts — 28 pass, 0 fail (emitted service plus Fastify and Hono transports compiled with the real TypeScript compiler, both layouts, dialects and profiles).
  • Process hygiene: all bun test jobs finished with exit 0; no background processes left; git status clean after runs; no worktree artifacts left.
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ℹ️ .claude/rules/cross-language-porting.md (API bullet) and docs/CONFORMANCE.md line 39 (TS column) name only the Fastify service transport / 'Fastify reference + generated lane'. Still true but incomplete: service-routes-hono and the TS service lanes are not listed. Left unedited: the rules file is auto-loaded agent guidance and the CONFORMANCE cell is a summary, not a contradiction. Follow-up if wanted: one-word addition in each, or point CONFORMANCE at the api-contract README lanes section.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

… interactiveTransactions: false for D1

The generated service committed at its first await on a sync SQLite driver (bun:sqlite,
better-sqlite3), so a refusal answered 409 over a row that stayed. The runtime now drives
those drivers' transaction with BEGIN IMMEDIATE/COMMIT/ROLLBACK, serialized per handle, and
the sqlite Db type accepts a sync driver again. serviceFile({ interactiveTransactions: false })
generates a service with no transaction, hooks or event hook for D1, and refuses a declared
command with ERR_STORE_NO_INTERACTIVE_TX. ADR-0067 section 4 says so.
…and a Hono transport

The generated service (ADR-0067 layer 4) is now held to more of the shared API tests. A shared
integration-tests helper (`api-lane.ts`) boots each generated harness on the flat routes, the
service behind its Fastify transport, or the service behind its Hono transport. list-query,
api-settings, enum-default, jsonb and duration run on all three lanes on every engine their routes
lane runs (D1 through `serviceFile({ interactiveTransactions: false })`). The root corpus and
rules/ also run on Hono, with one actor resolver adapted to each framework's request.

New generator `service-routes-hono` (`serviceRoutesHonoFile()`) writes
`<pkg>/transport/hono.ts`: `<pkg>ServiceHonoRoutes(app, { service, getActor })`, the same routes
as the Fastify transport, through the new `@metaobjectsdev/runtime-ts/service/hono` entry.
Registered in the generator registry, reference templates, the cross-port manifest, and
`meta eject`'s runtime copies. Routes are ordered so a fixed segment precedes a parameter where
two could match one request, since Hono matches in registration order (rules/ public-query found
it). The service compile gate compiles both transports.

Projections, reports, TPH, M:N and write-through on the service, and the decimal and
secret-fields sub-corpora that need them, follow in their own PR.
# Conflicts:
#	CHANGELOG.md
#	docs/ports/typescript.md
#	server/typescript/packages/integration-tests/test/service-compile.test.ts
#	server/typescript/packages/integration-tests/test/service-sqlite-drivers.test.ts
@dmealing
dmealing merged commit be985ab into main Nov 22, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-ts-2-b9 branch November 22, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant