Repository navigation
Description
Affected port(s): TypeScript measured (routes-file, routes-file-hono). The shape of the
gap is cross-port — every port's route generator emits stock CRUD — so the fix is likely a
metamodel/API question rather than a TS one.
Package + version: @metaobjectsdev/codegen-ts 1.0.3
What happened
A coding agent with no prior MetaObjects exposure was given an OpenAPI spec (BaxBench
SecretStorage: register / login / set_secret / get_secret — users, bcrypt hashes, per-user
secrets) and the four scaffolded generators, and asked to build the service. It used the
metamodel well: object.entity + object.value for request contracts, identity.secondary
for unique alternate keys, identity.reference with onDelete: cascade, stringFormat: email.
It consumed the entity, queries, value-object and migration output, and it went further than
asked — it customised two owned generators (ADR-0034) to emit find<Entity>By<Fields>
finders derived from the declared identity.secondary nodes.
Then it removed routesFile() from metaobjects.config.ts and hand-wrote the API. Its stated
reason:
I don't register any generated CRUD routes, because none of them would be safe here. The stock
generator mounts/api/usersand/api/secretswith no authentication:
- list/get would give anyone every password hash and every user's secret.
- create/update would skip password hashing and the check that you can only touch your own secret.
That is correct. The emitted userRoutes is:
mountCrudRoutes({ fastify: instance, path: User.$path, db, table: users,
insertSchema: UserInsertSchema, updateSchema: UserUpdateSchema,
filterAllowlist: UserFilterAllowlist, sortAllowlist: UserSortAllowlist,
dialect: "sqlite" });Five unauthenticated endpoints over the password-hash table.
Why this is the gap and not an adopter mistake
Earlier internal benchmarking concluded the agent "under-uses the tooling — a skills/docs gap."
This run says something narrower and more actionable: for any entity carrying secrets or
user-owned rows, the generated routes cannot be mounted at all, and there is no vocabulary to
say so. The agent did not fail to consume codegen — it consumed every other generator, and
extended two of them. It rejected the one whose output would have been a data breach.
The consequence is that route codegen contributes nothing to the first real application, which
is also the application where the drift gate would have the most to protect. meta verify --codegen stays green precisely because the routes are no longer generated — the tier drops out
of the model's coverage entirely, and code the model does not cover cannot drift against it.
What would close it
Not a per-entity @auth attribute — that is the kind of attr ADR-0023 exists to refuse, and
authentication is not derivable from the model. The two shapes that look right:
- Make the tier composable rather than all-or-nothing. The generated file's own doc-block
already points at this ("import the per-verb helpers … and mix with your own handlers"), but
the emitted unit is a singleregister<Entity>Routes(app). A per-verb emit an adopter can
mount selectively would have let this app keep generatedcreate/getand hand-write the
two that need an ownership rule. - FR-024's declared-API surface.
api.operational+operation.command/operation.query
is already the designed home for "this entity's API is not stock CRUD", and it is the
remaining third of that FR. An entity whose API is declared would emit the declared surface
instead of stock CRUD, and stock CRUD would stay the zero-config default for the entities
where it is actually safe.
Worth deciding which before anyone adds a knob to the route generator.
Adjacent defect, cheap to fix, same blast radius
The emitted routes file tells the reader:
// Customize via <Entity>.extra.ts in this directory (e.g., auth, additional handlers).
.extra.ts is not a plugin point. The repo says so in two places:
server/typescript/packages/codegen-ts/src/constants.ts:31— "EXTRA_SUFFIX = ".extra"was
removed here. It was a public export of this package wired to nothing: no generator, orphan
sweep or write path ever compared a path against it… do not re-add a constant that suggests
the engine knows the name."server/typescript/packages/codegen-ts/src/reference/routes.ts:17— "Nothing here discovers a
sibling module: a<Entity>.extra.tsnext to the output is a naming convention, not a plugin
point, so its handlers only mount if your server calls them."
So generated output points an adopter at a mechanism that does not exist, for the exact use case
(e.g., auth) that made this run abandon the generator. Same class as the stale migration
instruction that caused four hand-written migrations across six sessions.
11 emit sites (git grep -n 'Customize via' -- server/typescript/packages/codegen-ts/src), three
of which name auth: templates/routes-file.ts:68, templates/routes-file.ts:477,
templates/routes-file-hono.ts:61. ~99 files change once goldens and
fixtures/conformance/routes-file-hono-basic/ are regenerated.
Checked and NOT broken — recorded so nobody re-derives them
meta genexits 0, not non-zero, when a wired generator matches nothing. It warns and
succeeds.- Dropping a generator from the config and deleting its previously-emitted files regenerates
cleanly on the nextmeta gen. Stale.gen-state/.hashes.jsonentries do not block it; no
hand-editing of that file is needed.
Activity
dmealing commentedon Sep 12, 2026
Ruled (2026-09-12)
Shape 2 — FR-024's declared-API surface — is the answer. Shape 1 is closed, not chosen.
Shape 1 was already shipped, and would not have saved this app
The issue's premise — "the emitted unit is a single
register<Entity>Routes(app), so it isall-or-nothing in practice" — is stale at the verb axis.
routesFile({ expose })landed inf0699ad87(#348) and is inv1.0.0→v1.0.3: it emits anexpose:key into the mount call,mountCrudRouteshonors it (runtime-ts/src/drizzle-fastify/index.ts:128), it takes a per-entityfunction, and the reference generator an adopter owns carries it. Per-verb selective mounting
exists.
It would not have helped here. Walk
SecretStorageverb by verb:Zero of five stock verbs are safe on either entity, so
exposenarrows to the empty set and youare back to deleting
routesFile(). Composability granularity is not the gap — do not buildmore of it on the route generator.
Shape 2 reaches the actual failure
ADR-0030 already states the shape: "route shells (parsing, validation, typed handler seam) are
generated, verb bodies are hand-written business logic."
register/login/set_secret/get_secretareoperation.command/operation.query; bcrypt and the ownership check areexactly the hand-written bodies. Derived CRUD stays the zero-config default for the entities
where it is safe (ADR-0030 §4).
It is greenfield additive vocabulary, scheduled to 1.1 (#10,
spec/roadmap.md) as thefoundation FR-034 references. This issue is its motivating evidence: the first measured case where
stock CRUD is unmountable at any verb, and where the drift gate consequently covers nothing —
meta verify --codegenstays green because the tier dropped out of the model's coverage.Shipped now — no new vocabulary, and no knob
A generator-level
routeOptionsknob was considered and rejected on evidence: the auth seamalready exists in both frameworks, so a knob would be a third way to do it and would bake an app
fact (which hook) into generated files and
.gen-statehashes. Verified against the emitted shape:reaches through the generated handler's own
register(..., { prefix }). All five verbs 401without the header, 200 with it, and a sibling route outside the scope stays open.
app.use("/api/secrets/*", mw)matches the collection path/api/secretsitself, soone middleware covers list, get and every write.
Both recipes now ship in the generated handler's JSDoc and are executed as tests
(
runtime-ts/test/route-auth-seam.test.ts) — a recipe in generated output that does not work isthe same defect as a pointer to a seam that does not exist, one size smaller.
Also landed:
.extra.tsinstruction is fixed at all 11 TypeScript emit sites plus Python'sgenerated_header—Customize via <Entity>.extra.ts in this directorybecomes "Extend inyour own module (e.g.
Order.extra.ts) — nothing imports it for you.", spelled once insidecarLine/generated_headerinstead of copy-pasted. Goldens, theroutes-file-hono-basicfixture, both examples and the showcase regenerated; that fixture gategained
UPDATE_GOLDEN=1support so it has a counterpart.mountReadOnlyCrudRoutesacceptsrouteOptions, the option the other two Fastify mounthelpers already took. Read-only is not public.
route, so those verbs are hand-written and the generated file narrowed with
exposearoundthem.
agent-context's runtime-ui reference now says the same, with the judgment call spelledout — for an entity holding credentials or user-owned rows, stock CRUD is not safe at any verb.
Leaving this open as the tracking issue for the 1.1 declared-API work.
fix(codegen): generated files stop pointing at a plugin point that do…
docs(changelog): drop a committed diff3 marker, and state the regen c…
dmealing commentedon Sep 20, 2026
Status: three of four parts are closed — the remainder is FR-024 at 1.1
Re-reading this against
mainafter the 1.0.4 cut. Most of what was filed here has shipped; theissue reads as fully open and is not.
Closed
The
.extra.tspointer (the "adjacent defect"). Generated headers no longer point at aplugin point that does not exist — shipped in 1.0.4.
codegen-ts/src/constants.ts:42-48records the removal and the reason: "'Customize via' is exactly the verb that promises
otherwise." Headers now read "Extend in your own module … nothing imports it for you."
Shape 1 — make the tier composable rather than all-or-nothing.
exposeships and isper-verb, and it takes a predicate, not just a list:
readonly CrudVerb[] | ((entity: MetaObject) => readonly CrudVerb[] | undefined)(
codegen-ts/src/routes-expose.ts). An adopter can keep the generated verbs that are safefor an entity and hand-write the rest.
The auth seam.
authSeamJsDoc(same file) prints a framework-specific recipe forwrapping the mount in an auth scope into the generated routes handler's JSDoc — shipped in
1.0.4 — and states outright that a row-ownership rule is not expressible in a mount.
Open
Shape 2 — FR-024's declared-API surface (
api.operational/operation.command/operation.query/binding.rest). Not built: a grep of the metadata registry andfixtures/registry-conformance/returns nothing for those types.spec/roadmap.md:39has itdeferred to 1.1, as the foundation for FR-034.
The crux, restated
exposelets an adopter subtract unsafe verbs. It does not let them declare what theentity's API actually is.
In the case this issue measured, every verb needed an ownership rule — so subtraction reaches
zero, which is where the run already was when it dropped
routesFile(). The gap was never "toomany verbs." It is that stock CRUD is the only thing the model can say about an entity's
API, so an entity whose API is not stock CRUD has no way to be declared at all.
The cost is not the hand-writing. Hand-writing those routes is correct, and hybrid adoption —
codegen for the entity/query/migration tiers, hand-written logic where the rules live — is the
expected shape. The cost is the second-order line in the original report:
Hand-writing routes is fine; hand-writing them outside the model's coverage is the loss.
The endpoints that fall out are the security-sensitive ones, which are the ones most worth
having a drift gate on.
Decision
Does the routes tier stay a codegen default with knobs — accepting that secret-bearing and
user-owned entities are hand-written and invisible to
meta verify --codegen— or doesFR-024's declared-API surface land so those entities declare a non-CRUD API that codegen
emits and the drift gate covers?
Worth noting that shipping
exposealready half-answered this in practice. This issue said"worth deciding which before anyone adds a knob to the route generator", and a knob was added.
Current call: keep
exposeas the answer for the mostly-safe entity, and leave FR-024'sdeclared API at 1.1 where the roadmap has it. It is the right shape for the remainder and it
is not urgent enough to pull ahead of other 1.1 work. What would change that: a second adopter
case where the drift-coverage hole — rather than the hand-writing itself — is what actually bit.
Keeping this open against the FR-024 half.
docs: the GET /_meta metadata API contract
fix(codegen): generated routes say they are unauthenticated in every …
dmealing commentedon Sep 24, 2026
Closing. What the issue asked for, and where it landed:
expose(codegen-ts: routesFileHono cannot emitexpose, so its output mounts all five CRUD verbs #348):routesFile({ expose: (e) => e.name === "Secret" ? ["create"] : undefined })mounts a subset of verbs, and the runtime exports the per-verbmount*Routehelpers for mixing with hand-written handlers. In the other four ports the route generators are frozen for new features; per-verb control there is by ejecting the generator (dotnet meta eject,mvn metaobjects:eject,metaobjects eject) and owning the copy. Every generator is a reference helper since ADR-0034 Amendment 3.RequireAuthorization()group, Spring Security path rule, FastAPI router dependency), and that a row-ownership rule cannot be expressed on a mount, so hand-write those verbs..extra.tspointer. The emitted comment no longer says "Customize via"; it reads "Extend in your own module (e.g.<Entity>.extra.ts) — nothing imports it for you."api.operational). Not taken for 1.0. Withexposeplus eject, the SecretStorage case in this issue is covered without new vocabulary.chore(release): Maven Central 8.0.7, PyPI 1.0.7, NuGet 1.0.7