docs(agent-context): teach granular codegen control and the runtime→Fastify mount API#78
Merged
Merged
Conversation
…umption + the runtime→Fastify API
Benchmark validation showed the agent now searches the vocabulary (meta types) but
still hand-wrote the relational logic — it treated codegen as all-or-nothing and
reverse-engineered node_modules for the runtime→Fastify wiring. Three skill fixes:
- metaobjects-codegen: a "you don't have to generate everything — pick your layers"
section: generate the data layer + skip routes (omit routesFile()), mix generated
and hand-written routes, declare a projection AND consume its generated query for
derived/aggregate data (the missing half), and copy/customize or write your own
Generator. `meta gen --list` for the stable names.
- metaobjects-runtime-ui (typescript): document the real
@metaobjectsdev/runtime-ts/drizzle-fastify mount API — mountCrudRoutes({ expose }),
mount<Verb>Route, mountReadOnlyCrudRoutes, CrudRoutesOptions ({ routeOptions } for
auth, updateMethod) — so the agent mounts some verbs + hand-writes the custom ones
instead of reverse-engineering the package.
Regenerated the agent-context conformance fixtures; conformance + byte-identity green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuZWKnWzYGVnESijL7uuky
…d for projection codegen
dmealing
added a commit
that referenced
this pull request
Jun 26, 2026
Skills-only release: ships the granular-codegen-control + projection-consumption + runtime->Fastify mount API agent-context skill guidance (#78) in the bundled agent-context, so adopters' agents get it via meta init / meta agent-docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LuZWKnWzYGVnESijL7uuky
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Teach the agent that MetaObjects codegen is granular, not all-or-nothing — the next layer after the meta-types fix. Benchmark validation (Recipes, npm 0.12.2) showed the agent now SEARCHES the vocabulary (meta types) and declares identity.reference FKs, but still hand-wrote the joins + AVG() because it treated codegen as all-or-nothing (abandoned data-layer codegen when generated routes didn't fit the custom API) and reverse-engineered node_modules for the runtime->Fastify wiring (an old, still-unfixed docs gap). Three skill/docs fixes, all documenting REAL verified APIs (no fabrication): (1) metaobjects-codegen SKILL.md — a 'you don't have to generate everything, pick your layers' section: omit routesFile() from the generators array to generate the data layer (entityFile/queriesFile/barrel) and hand-write only the routes; mix generated + hand-written routes; declare an object.projection with origin.aggregate AND consume its generated query from your route (the missing consumption half); copy/customize a @generated file or write your own Generator; meta gen --list for stable names. (2) metaobjects-runtime-ui/references/typescript.md — document the real @metaobjectsdev/runtime-ts/drizzle-fastify mount API (verified from source): mountCrudRoutes({fastify,path,db,table,insertSchema,updateSchema, expose?, routeOptions?, updateMethod?}), individual mountListRoute/mountGetRoute/mountReadOnlyCrudRoutes — so the agent mounts the standard verbs + hand-writes only the custom routes instead of reading node_modules. Regenerated the agent-context conformance fixtures (the assembled skills are byte-gated cross-port); verified locally: agent-context-conformance + content-root byte-identity green (7/7). Pure docs/skills change — no code, no metaobjects feature added to win the benchmark; teaches using existing capabilities with the right granularity. CI must keep the cross-port agent-context fixtures byte-identical.
What Changed
metaobjects-codegenskill: codegen is granular, not all-or-nothing — omitroutesFile()to generate only the data layer (entityFile/queriesFile/barrel) and hand-write routes, mix generated and hand-written routes, declare anobject.projectionwithorigin.aggregate/passthrough/collectionchildren and consume its generated query from a custom route, copy/customize a@generatedfile or write a customGenerator, and usemeta gen --listfor stable names.@metaobjectsdev/runtime-ts/drizzle-fastifymount API in themetaobjects-runtime-uiTypeScript reference (mountCrudRoutes,mountListRoute,mountGetRoute,mountReadOnlyCrudRoutes) so the agent mounts standard verbs and hand-writes only custom routes instead of reverse-engineeringnode_modules; clarified in themetaobjects-authoringskill that projection codegen requires a read-onlysource.rdb(@kind: view) child.agent-contextskill fixtures (all 5 port copies) to stay byte-identical to the source skill files, keeping the conformance gate green.Risk Assessment
✅ Low: Pure docs/skills change with all cited APIs verified accurate against source and conformance fixtures byte-identical; the single finding is a minor doc-example option-shape mismatch, not a code or behavior risk.
Testing
Ran the cross-port agent-context-conformance suite plus the full agent-context sdk tests (37 pass) after fixing two environment prerequisites (workspace bun install for the jsdom test preload, and running the bundle-agent-context build step that copies content into the sdk package — neither a product defect). Independently confirmed byte-identity of the changed codegen and runtime-ui skill files across the source and all four port fixtures via md5, demonstrating the CI byte-gate holds. Verified the documented runtime mount API (mountCrudRoutes/mountListRoute/mountGetRoute/mountReadOnlyCrudRoutes and every CrudRoutesOptions field) exists verbatim in drizzle-fastify source, confirming the docs describe real, non-fabricated APIs. Captured the as-delivered skill sections (what a consumer's .claude/skills receives) as reviewer-visible artifacts. This is a docs-only change with no rendered UI surface, so evidence is the delivered markdown content plus source-verification transcripts rather than screenshots. All checks green; transient build/install artifacts removed and the worktree is clean.
Evidence: agent-context tests pass (conformance + content-root byte-identity)
37 pass 0 fail 175 expect() calls Ran 37 tests across 9 files.Evidence: New 'pick your layers' codegen-skill section as delivered to a consumer's .claude/skills (byte-identical in every port fixture)
Evidence: New runtime mount-API doc section as delivered (java-react fixture copy)
Evidence: Source verification: every documented mount symbol/option exists in drizzle-fastify (no fabrication)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
agent-context/skills/metaobjects-codegen/SKILL.md:81- The new projection bullet tells the agent to 'declare an object.projection with origin.aggregate/passthrough/collection children' and says 'meta gen emits a read-only query for it (and meta migrate its DB view).' But codegen's projection detection and view emission key off a read-only SOURCE child, not the object.projection subtype or origin children: isProjection (codegen-ts/src/projection/projection-detector.ts:16-18) returns true only when the object has a read-only MetaSource and no writable one, and extractViewSpec (extract-view-spec.ts:55-57) derives the view name from that read-only source. An object.projection declared with only origin.* children and no read-only source.rdb (@kind: view) child will not be detected as a projection, so meta gen emits no query/view — re-triggering the exact 'codegen didn't fit so I hand-wrote it' failure the skill aims to fix. The guidance should include the required read-only source.rdb @kind: view child. (The companion authoring SKILL.md describes object.projection as 'a derived read model over a view/proc' but its example also omits the explicit source child, so the requirement is under-documented in both.)agent-context/skills/metaobjects-codegen/SKILL.md:64- Pure docs/skills change; mount API, --list, three-way-merge, and origin subtypes were all verified against source as accurate, and all 12 cross-port fixture copies are byte-identical to their source skill files, so the agent-context byte-identity conformance gate should pass.🔧 Fix: document required read-only source.rdb view child for projection codegen
2 issues (1 warning, 1 info) still open:
agent-context/skills/metaobjects-runtime-ui/references/typescript.md:113- The example mountsmountReadOnlyCrudRoutes({ ...opts })reusing the sameoptsobject the preceding lines build formountCrudRoutes({ fastify, path, db, table, insertSchema, updateSchema }). ButmountReadOnlyCrudRoutestakes a different options type,MountReadOnlyOptions(mount-read-only.ts:19), which requires a Drizzleview(plus optionalidColumn/filterAllowlist/sortAllowlist/dialect) and has NOtable/insertSchema/updateSchema. An agent copying the{ ...opts }spread verbatim would passtableand omit the requiredview, producing the wrong call — which undercuts the doc's stated goal of letting the agent call the helpers without reverse-engineering node_modules. ThemountCrudRoutes({ ...opts, expose: ["list","get"] })line directly above already covers the table-based read-only case, so this line conflates two distinct option shapes. Clarify thatmountReadOnlyCrudRoutesis the view/projection-backed helper with its own{ ...path, db, view, idColumn? }shape.agent-context/skills/metaobjects-codegen/SKILL.md:64- Pure docs/skills change. Every cited API (mount helpers, CrudRoutesOptions fields, drizzle-fastify export subpath, generator factory names, origin subtypes, meta gen --list, projection read-only-source requirement) was verified against source — no fabrication. All 12 cross-port agent-context fixture copies are byte-identical to their source skill files, so the byte-identity conformance gate should pass.✅ **Test** - passed
✅ No issues found.
cd server/typescript && bun test packages/sdk/test/agent-context-conformance.test.ts(4 per-port byte-identity cases pass)bun test packages/sdk/test/agent-context/ packages/sdk/test/agent-context-conformance.test.ts(37 pass after running thebundle-agent-contextbuild step)md5sumof metaobjects-codegen/SKILL.md and runtime-ui/references/typescript.md across source + all 4 port fixtures — all identicalgrep-verified every documented symbol (mountCrudRoutes/mountListRoute/mountGetRoute/mountReadOnlyCrudRoutes, CrudRoutesOptions + its fields) exists in runtime-ts/src/drizzle-fastify sourceSetup fixes: workspacebun install+bun run bundle-agent-contextto satisfy the jsdom preload and bundle prerequisites✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.