Skip to content

feat(codegen-ts): cover projections, reports, write-through, TPH and m2m in the service - #645

Merged
dmealing merged 20 commits into
mainfrom
fm/mo-130-lane-ts-2-b10
Nov 23, 2026
Merged

dmealing merged 20 commits into
mainfrom
fm/mo-130-lane-ts-2-b10

Conversation

@dmealing

@dmealing dmealing commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • codegen-ts service walk now covers every object the flat routes serve. Projections and served reports get list (and get when keyed) operations, reports keep their row cap through the new serviceFile({ reportMaxRows }) option, and write-through entities read through their replica view. Single-table (TPH) hierarchies get polymorphic base reads and per-subtype operations scoped to the discriminator, and each many-to-many relationship gets a traversal query. The service templates emit these, and the Fastify and Hono transports answer writes on read-only objects with 405.
  • runtime-ts: readOnlyList, readOnlyGet and m2mRelated are framework-neutral functions in read-only-read.ts and m2m-read.ts. The flat Fastify mounts and the service both call them. The examples/ owned runtime copies follow.
  • codegen-ts: runGen with no project removes its meta-gen-state-<pid> directory on normal process exit (removeTreeAtExit in scratch-dir.ts), so it no longer accumulates in the scratch root.
  • Api-contract projection/, report/, write-through/, tph/, m2m/, decimal/ and secret-fields/ sub-corpora run on both service lanes. The service compile gate covers a TPH lifecycle fixture. The "not covered yet" list in service-walk.ts is removed, and docs, ADR-0067 and CHANGELOG are updated.
Validation

Risk Assessment

✅ Low: The change meets every numbered intent item. The runtime-ts read extraction is behavior-preserving. The owned example copies are byte-identical to runtime-ts. The new service paths mirror the flat routes' semantics, and I found no reachable wrong-result or authorization path.

Testing

Drove three scenarios against the real codegen-ts and service codegen with real compilers: typed-create compile test now uses scratch dirs and leaves no tmp folders (pass); runGen with no project removes its meta-gen-state directory after process exit (pass, spawns real process); service compile gate builds generated service incl. TPH lifecycle fixture with real TypeScript compiler (40 pass). Not re-run in this turn: service-lane api-contract sub-corpora (report SQLite/D1 405 writes, reportMaxRows, ?format=, Postgres projection/write-through/TPH/M:N/decimal/secret-fields); prior round worker reported 1,095 pass, unverified here. Verdict inconclusive. No background processes left running.

  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
typed-create compile test uses scratch dirs and leaves no tmp folders (fix for ts-lane typecheck race, test-2) ✅ pass live bun test test/typed-create-compile.test.ts test/scratch-dir.test.ts in server/typescript/packages/codegen-ts: 13 pass, 0 fail; no tmp-* dirs left in test/
runGen with no project removes meta-gen-state-<pid> scratch dir on normal exit ✅ pass live codegen-ts test/scratch-dir.test.ts run in this turn (part of 13 pass)
Service codegen compile gate builds generated service incl. TPH lifecycle fixture with real compiler ✅ pass live bun test packages/integration-tests/test/service-compile.test.ts from server/typescript: 40 pass, 0 fail
Service lane serves projections/reports (405 writes, reportMaxRows cap, ?format= export), write-through, TPH, M:N via api-contract sub-corpora ⏸️ untested no Not re-driven this turn. report-sqlite alone takes about 604s, exceeding the turn budget. Can be driven by running each file in the foreground with bun test from server/typescript/packages/integration…
  • Outcome: ⚠️ 2 warnings across 3 runs (1h55m47s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • 🚨 configured test command failed with exit code 1 — resolved in a later round: the temp-dir race was fixed in 3fcb389 and the C# conformance lane reran green.
  • ⚠️ server/typescript/packages/integration-tests/test/api-contract-report-sqlite.test.ts - The service-lane api-contract run (report SQLite/D1 + Postgres projection, write-through, TPH, M:N, decimal, secret-fields on the service and service-hono lanes) has no result. The run was stopped by me before it wrote output, so the reader cannot confirm the 405 write behavior, reportMaxRows, or ?format= export on the service lanes. Re-run these api-contract files and record the outcome.
  • ℹ️ typed-create-compile.test.ts crashes with SIGTERM on the base commit too, so the affected-lane failure is pre-existing and not caused by this change.
  • ⚠️ live validation verdict: inconclusive (1 of 5 scenarios were driven live against the product); untested: Served reports, projections and write-through entities answer their reads through the service and answer writes 405 on the service and service-hono lanes; report row cap and ?format= export hold (SQLite/D1 report sub-corpus, live against bun:sqlite and Miniflare, synthetic seed), Postgres api-contract sub-corpora projection/, write-through/, tph/, m2m/, decimal/, secret-fields/ run on both service lanes (live against Testcontainers Postgres, synthetic seeds), Service compile gate builds the TPH lifecycle fixture with its real compiler (codegen-ts service-compile.test.ts), Full TypeScript regression suite (cd server/typescript && bun test)
  • Live validation: ⚠️ inconclusive - 1 of 5 scenarios driven live against the product
Scenario Result Live Evidence
runGen with no project removes its meta-gen-state-<pid> directory from the scratch root on normal exit (live: bun script calling runGen from codegen-ts src/runner.ts, DEV_SCRATCH in an isolated /mnt/s… ✅ pass live Live run output (artifact 'runGen no-project scratch cleanup'): state dir present during the run, absent after normal exit, out/one.txt written with content 1
Served reports, projections and write-through entities answer their reads through the service and answer writes 405 on the service and service-hono lanes; report row cap and ?format= export hold (SQLi… ⏸️ untested no Ran bun test test/api-contract-report-sqlite.test.ts test/api-contract-report.test.ts. It was still running after 10 minutes, and I stopped it by PID before it reported. Re-run it without a time lim…
Postgres api-contract sub-corpora projection/, write-through/, tph/, m2m/, decimal/, secret-fields/ run on both service lanes (live against Testcontainers Postgres, synthetic seeds) ⏸️ untested no Not started. Docker is reachable, so the tests can run live. Time went to the report run. Run api-contract-projection, -write-through, -tph, -m2m, -decimal and -secret-fields tests next.
Service compile gate builds the TPH lifecycle fixture with its real compiler (codegen-ts service-compile.test.ts) ⏸️ untested no Not started. This is a compile gate and runs as a focused test, so it can run live.
Full TypeScript regression suite (cd server/typescript && bun test) ⏸️ untested no Not started. The base commit already fails typed-create-compile.test.ts (SIGTERM), so attribute that failure separately from this change.
  • scripts/ci-local.sh --affected --strict-toolchains
  • Live: bun script calling runGen from server/typescript/packages/codegen-ts/src/runner.ts with no projectRoot, DEV_SCRATCH set to a fresh dir under /mnt/scratch, then checked the scratch root after the process exited normally
  • Started bun test test/api-contract-report-sqlite.test.ts test/api-contract-report.test.ts in server/typescript/packages/integration-tests; killed by PID before it wrote any results, so no pass/fail outcome
  • Not run: api-contract projection, write-through, tph, m2m, decimal, secret-fields sub-corpora (Postgres via Docker, both service lanes)
  • Not run: codegen-ts service-compile.test.ts (TPH lifecycle fixture)
  • Not run: full regression suite (cd server/typescript && bun test)

🔧 No changes applied.
3 issues (2 errors, 1 warning) still open:

  • 🚨 configured test command failed with exit code 1 — resolved in a later round: the temp-dir race was fixed in 3fcb389 and the C# conformance lane reran green.
  • 🚨 Configured test command scripts/ci-local.sh --affected --strict-toolchains still unresolved. Base attribution says this change introduced it, but the failing lane and test were not identified. Re-run the ts lane alone (ts build and typecheck, conformance: typescript, ts unit suites) to find the failing test. — resolved in a later round: the temp-dir race was fixed in 3fcb389 and the C# conformance lane reran green.
  • ⚠️ live validation verdict: inconclusive (0 of 4 scenarios were driven live against the product); untested: Affected-lane selection covers the TypeScript lanes this change touches, Intent scenario: service lane serves projections/reports, write-through, TPH, M:N with 405 writes and report row cap, Adversarial: serviceFile reportMaxRows cap and ?format= export on service lanes, runGen with no project removes its meta-gen-state-<pid> scratch directory on normal exit
  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Affected-lane selection covers the TypeScript lanes this change touches ⏸️ untested no Only a listing run (MO_CI_LIST_ONLY=1 scripts/ci-local.sh --affected --strict-toolchains) was done. It shows which lanes would run but drives no product behavior, so it does not count as a live pass…
Intent scenario: service lane serves projections/reports, write-through, TPH, M:N with 405 writes and report row cap ⏸️ untested no Not driven. The affected run did not finish. Could be driven by running the api-contract files in server/typescript/packages/integration-tests against Testcontainers Postgres; not attempted within the…
Adversarial: serviceFile reportMaxRows cap and ?format= export on service lanes ⏸️ untested no Not driven. Same blocker; needs the report SQLite/D1 api-contract sub-corpus run.
runGen with no project removes its meta-gen-state-<pid> scratch directory on normal exit ⏸️ untested no Not driven. Needs a targeted codegen-ts runGen run and a check of $DEV_SCRATCH after exit.
  • scripts/ci-local.sh --affected --strict-toolchains
  • MO_CI_LIST_ONLY=1 scripts/ci-local.sh --affected --strict-toolchains (lane selection)
  • scripts/ci-local.sh --affected --strict-toolchains run in background; no lane completed before the process group was stopped
  • Confirmed no run processes from this worktree remain after stop

🔧 Fix applied.
2 warnings still open:

  • ⚠️ server/typescript/packages/integration-tests/test/api-contract-report-sqlite.test.ts - Service-lane api-contract sub-corpora (report 405 writes, reportMaxRows cap, ?format= export, projection, write-through, TPH, M:N, decimal, secret-fields on service and service-hono lanes) not re-driven in this turn. Only prior-round worker evidence (1,095 pass) exists. Needs a foreground re-run of these single files to confirm; full-suite re-run not required.
  • ⚠️ live validation verdict: inconclusive (3 of 4 scenarios were driven live against the product); untested: Service lane serves projections/reports (405 writes, reportMaxRows cap, ?format= export), write-through, TPH, M:N via api-contract sub-corpora
  • Live validation: ⚠️ inconclusive - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
typed-create compile test uses scratch dirs and leaves no tmp folders (fix for ts-lane typecheck race, test-2) ✅ pass live bun test test/typed-create-compile.test.ts test/scratch-dir.test.ts in server/typescript/packages/codegen-ts: 13 pass, 0 fail; no tmp-* dirs left in test/
runGen with no project removes meta-gen-state-<pid> scratch dir on normal exit ✅ pass live codegen-ts test/scratch-dir.test.ts run in this turn (part of 13 pass)
Service codegen compile gate builds generated service incl. TPH lifecycle fixture with real compiler ✅ pass live bun test packages/integration-tests/test/service-compile.test.ts from server/typescript: 40 pass, 0 fail
Service lane serves projections/reports (405 writes, reportMaxRows cap, ?format= export), write-through, TPH, M:N via api-contract sub-corpora ⏸️ untested no Not re-driven this turn. report-sqlite alone takes about 604s, exceeding the turn budget. Can be driven by running each file in the foreground with bun test from server/typescript/packages/integration…
  • scripts/ci-local.sh --affected --strict-toolchains
  • cd server/typescript/packages/codegen-ts && bun test test/typed-create-compile.test.ts test/scratch-dir.test.ts (13 pass, 0 fail)
  • grep for tmp-* dirs in packages/codegen-ts/test after run (0 left)
  • cd server/typescript && bun test packages/integration-tests/test/service-compile.test.ts (40 pass, 0 fail)
  • Baseline from configured command: scripts/ci-local.sh --affected --strict-toolchains (passed per run context; not re-run)
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

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

✅ **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
# Conflicts:
#	fixtures/generator-registry-conformance/README.md
#	server/typescript/packages/runtime-ts/src/service/hono.ts
…orts read through their read model; runGen removes its no-project gen-state at exit
…ed operations address its base's table, scoped to its discriminator
@dmealing
dmealing merged commit de83eb9 into main Nov 23, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-ts-2-b10 branch November 23, 2026 00:46
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