Repository navigation
feat(codegen): render metamodel vocabulary reference from shared Mustache templates in every port - #670
Merged
Conversation
…tache templates in every port The metamodel reference pages (INDEX.md, providers.md, types/<family>.md) were about 600 lines of TypeScript string builders and existed only in TypeScript. They are now one template set, templates/metamodel/, rendered over page data each port builds from its own registry vocabulary manifest and its embedded provider definitions (the manifest is provider-blind, so ownership and defaults come from spec/metamodel), plus a shared provider-descriptions.json. - TypeScript: buildMetamodelDocsPages / coreMetamodelDocsPages replace renderMetamodelDocs and buildMetamodelProvenance; metamodelDocsFile() renders the pages and takes a project template override. - C#, Java, Kotlin, Python and Rust gain a metamodel-docs generator; the generator registry manifest lists every port. - fixtures/metamodel-docs gains data/ (each page's template data); every port's suite holds its data and its bytes to the corpus. - sync-doc-templates.sh ships the metamodel group to every port, and the doc-template drift gate covers the new copies. - Fix: index.lookup now names its owning provider; the index definition was missing from the provenance list (two corpus pages and the site reference change).
dmealing
added a commit
that referenced
this pull request
Nov 28, 2026
…Node (#671) * feat(codegen): record each generated file's source node in C#, Java and Python manifests After a write run, the hash manifest entry of a per-object file now names its generator and the node's resolution key ({hash, generatedBy, sourceNode}, after the JVM's generator/outputDir), as TypeScript already did, so a docs view built from any of these ports lists each node's generated files. A whole-model file keeps the plain hash. A shared 'provenance' vector in fixtures/codegen-skip-conformance/manifests.json holds TypeScript, C#, Java and Python to the same entries. * no-mistakes(review): Stamp provenance in remaining per-object generators * no-mistakes(document): Docs for C#/Java/Python provenance already updated on branch; one wording fix. * no-mistakes(test): Stop identifier renaming in explorer bundle build * feat(java): build the docs view and write the model explorer on the JVM, with no Node The JVM builds the port-neutral docs view from its loaded model (DocsView), byte for byte what TypeScript builds for every fixtures/explorer-conformance case, gated in the metadata suite. A docs-site generator (DocsSiteGenerator, registered in the Java and Kotlin registries, eject-exempt like TypeScript's) writes explorer.json, the shared explorer app, explorer-model.js and explorer-stamp.js, and lists each node's generated files from the hash manifest's provenance. Kotlin runs the same class, and its suite gates every corpus case through its own registry. MetaEndpoint gains the /_meta/docs helpers (body, ETag, If-None-Match), mounted by the host as /_meta is. Needs the HashManifest.loadProvenance API from #669. * fix(ci): clear stale unpacked workspace crates before the Rust publish dry-run cargo publish --workspace unpacks its overlay-registry dependencies into a per-checkout directory and never re-unpacks while the version is unchanged, so the self-hosted runner verified metaobjects-codegen against a metaobjects-1.3.0 unpacked before metamodel_docs existed. Main has been red on the rust lane since #670 for this reason; the crate itself packages correctly. * fix(java): keep the explorer data scripts out of codegen-base's layout, and hold docs-site to the inert line The model and stamp scripts move beside the docs view serializer (com.metaobjects.docsview.ExplorerModelScript), so codegen-base types no line breaks (LayoutRatchetTest). The codegen-noop inert tests hold docs-site to the line TypeScript's rules-inert test draws: the explorer documents every node, so only its data payload may differ, and only by the new nodes and members. * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): Build JVM docs-site file lists from the run's output * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): List other executions' files in the JVM docs site * no-mistakes(review): Re-run skip when manifest loses a file * no-mistakes(document): Stale docs-view claim fixed; Java/Kotlin now build explorer.json
dmealing
added a commit
that referenced
this pull request
Nov 28, 2026
* feat(codegen): record each generated file's source node in C#, Java and Python manifests
After a write run, the hash manifest entry of a per-object file now names its
generator and the node's resolution key ({hash, generatedBy, sourceNode}, after
the JVM's generator/outputDir), as TypeScript already did, so a docs view built
from any of these ports lists each node's generated files. A whole-model file
keeps the plain hash. A shared 'provenance' vector in
fixtures/codegen-skip-conformance/manifests.json holds TypeScript, C#, Java and
Python to the same entries.
* no-mistakes(review): Stamp provenance in remaining per-object generators
* no-mistakes(document): Docs for C#/Java/Python provenance already updated on branch; one wording fix.
* no-mistakes(test): Stop identifier renaming in explorer bundle build
* feat(java): build the docs view and write the model explorer on the JVM, with no Node
The JVM builds the port-neutral docs view from its loaded model (DocsView), byte for byte
what TypeScript builds for every fixtures/explorer-conformance case, gated in the metadata
suite. A docs-site generator (DocsSiteGenerator, registered in the Java and Kotlin
registries, eject-exempt like TypeScript's) writes explorer.json, the shared explorer app,
explorer-model.js and explorer-stamp.js, and lists each node's generated files from the
hash manifest's provenance. Kotlin runs the same class, and its suite gates every corpus
case through its own registry. MetaEndpoint gains the /_meta/docs helpers (body, ETag,
If-None-Match), mounted by the host as /_meta is.
Needs the HashManifest.loadProvenance API from #669.
* fix(ci): clear stale unpacked workspace crates before the Rust publish dry-run
cargo publish --workspace unpacks its overlay-registry dependencies into a
per-checkout directory and never re-unpacks while the version is unchanged,
so the self-hosted runner verified metaobjects-codegen against a
metaobjects-1.3.0 unpacked before metamodel_docs existed. Main has been red on
the rust lane since #670 for this reason; the crate itself packages correctly.
* fix(java): keep the explorer data scripts out of codegen-base's layout, and hold docs-site to the inert line
The model and stamp scripts move beside the docs view serializer
(com.metaobjects.docsview.ExplorerModelScript), so codegen-base types no line
breaks (LayoutRatchetTest). The codegen-noop inert tests hold docs-site to the
line TypeScript's rules-inert test draws: the explorer documents every node, so
only its data payload may differ, and only by the new nodes and members.
* no-mistakes(review): apply reviewer inline fixes
* no-mistakes(review): Build JVM docs-site file lists from the run's output
* no-mistakes(review): apply reviewer inline fixes
* no-mistakes(review): List other executions' files in the JVM docs site
* no-mistakes(review): Re-run skip when manifest loses a file
* no-mistakes(document): Stale docs-view claim fixed; Java/Kotlin now build explorer.json
* feat(docs-site): build the model explorer in C# and Python without Node
Each port builds the port-neutral docs view from its loaded model
(MetaObjects.DocsView, metaobjects.docs_view), byte-identical to TypeScript
for every fixtures/explorer-conformance case and gated in each suite. A
docs-site generator in both registries writes explorer.json, the shared
explorer app, explorer-model.js and explorer-stamp.js; it runs after every
other generator and lists this run's files over the committed manifest's,
so verify --codegen renders what gen wrote. MetaEndpoint.MetaDocs (C#) and
meta_docs (Python) serve the same view at /_meta/docs with a strong ETag.
C# and Python provenance now records the generator's registry name.
* no-mistakes(review): Match verify docs-site render to gen; pin ETags
* no-mistakes(review): Run docs-site targets last; carry plan provenance
* no-mistakes(review): Carry only files the orphan sweep keeps
* no-mistakes(review): apply reviewer inline fixes
* no-mistakes(review): Treat an empty run file list as unknown
* no-mistakes(review): Keep empty run file lists known, as TypeScript
* no-mistakes(document): Docs: C# and Python explorer now documented
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.
What Changed
INDEX.md,providers.md, andtypes/<family>.md) now render from the sharedtemplates/metamodel/Mustache set. Each port builds the page data from its registry vocabulary manifest and embedded provider definitions.metamodel-docsgenerator. Every port is checked againstfixtures/metamodel-docs/(page data indata/, expected bytes inexpected/). A project can override a page with its owntemplates/metamodel/<page>.mustache.@metaobjectsdev/metadatadropsrenderMetamodelDocs,renderCoreMetamodelDocs,buildMetamodelProvenanceandMetamodelProvenance. It exportscoreMetamodelDocsPages()andbuildMetamodelDocsPages()instead, and codegen-ts renders them. An ejectedmetamodel-docsgenerator that calls the removed functions must be re-ejected. The TypeScript output changes in one place:index.lookupnow lists its owning provider and the provider of its@fields.Validation
Risk Assessment
✅ Low: The latest fix round fixes the Python owned-copy subDir bug correctly. build_owned now converts subDir to the sub_dir keyword and passes template_root, and the new test compares the owned output against the packaged output under ref/. All six template copies are byte-identical to templates/metamodel/, the corpus carries the port-neutral header, and the Rust, C#, Java and Kotlin generators are consistent thin shells over the shared page data.
Testing
Drove the three most user-visible paths. TypeScript builder and Python CLI both reproduce the 23 expected pages byte for byte, with the Python run executed through the real
metaobjects genin a disposable project. The ejected Python copy honours subDir per the focused CLI test that passed. Rust, Java, Kotlin and C# pages were not rendered live in this turn; their byte-match is covered only by the configured affected-lane run that already passed. No source changed, the worktree is clean, and scratch output was removed.metaobjects genwith a metamodel-docs target writes the 23 vocabulary pages matching the corpus (local CLI, disposable project)metaobjects genexit 0, wrote 23 files under generated/metamodel/; diff vs expected emptyEvidence: TS render diff vs corpus (live)
Evidence: Python metaobjects gen CLI diff vs corpus (live)
Evidence: Python ejected subDir focused test
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/rust/metaobjects-codegen/src/metamodel_docs.rs:31- The Rust generator names its output-directory optiondir. Every other port names the same optionsubDir: TypeScriptmetamodelDocsFile({ subDir }), Java and Kotlin argsubDir, Python registry optionsubDir(generator_registry.py:551), and C# init propertySubDir.docs/ports/rust.mdand the testthe_dir_option_moves_the_pages_and_a_project_template_wins(tests/metamodel_docs.rs:106) recorddir. It is the first option any shipped Rust generator takes, so renaming it after release becomes a breaking config change. Recommendation: rename it tosubDirnow, unless the Rust option-naming convention is meant to differ.server/python/src/metaobjects/codegen/generators/metamodel_docs_generator.py:35- Simplification:_provider_descriptions(template_root)lets a project override the provider descriptions with its ownmetamodel/provider-descriptions.json. The generator docstring (line 11) and docs/ports/python.md describe this. No other port does it. TypeScript readscoreProviderDescriptions(), C#ReadDescriptions()reads only the embedded resource, Java reads only the classpath resource, and Rust reads onlyshipped_provider_descriptions(). The intent asks for one shared Mustache set with data pinned to the corpus. The changelog promises only page-template overrides, and no requirement needs a per-project override of the description data. Recommendation: remove the project lookup and always read the bundled file, as the other ports do.server/java/codegen-base/src/main/java/com/metaobjects/docs/metamodel/MetamodelDocsEmitter.java:49-MetamodelDocsEmitter.render(Page, Provider)has no callers. Its Javadoc says "the corpus test builds from pinned inputs", butMetamodelDocsCorpusTestcalls onlyMetamodelDocsPages.build()andMetamodelDocsEmitter.emit("", null). Remove the method, or pointemitat it so one render path exists.docs/ports/csharp.md:357- Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.🔧 Fix applied.
4 infos still open:
docs/ports/csharp.md:357- Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23- Applied inline. The class Javadoc and the eject note named the override argumenttemplateDir. The generator actually readsmetamodelTemplateDir(ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments tometamodelTemplateDir. The code is unchanged.docs/ports/rust.md:81- Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator exceptservice-routes. Both statements became false when this change addedmetamodel-docs, which takessubDirand is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to namemetamodel-docsand itssubDiroption, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.templates/metamodel/index.md.mustache:3- Every page in the shared template set starts with the header 'Regenerate with: meta gen (the metamodel-docs generator, metamodelDocsFile())'. The affected templates are templates/metamodel/index.md.mustache:3, providers.md.mustache:3 and type-page.md.mustache:3. C#, Java, Kotlin, Python and Rust now write these pages byte for byte, so the generated docs in those ports tell users to run the Nodemeta genand a TypeScript factory. Those ports actually regenerate withdotnet meta gen,mvn metaobjects:generate,metaobjects genandcargo meta gen. Recommended fix: use port-neutral wording, for example 'Regenerate with your port's gen command (the metamodel-docs generator)'. That wording changes the corpus bytes in fixtures/metamodel-docs/expected/ and the codegen-ts header test (codegen-ts/test/metamodel-docs.test.ts:75). The change needs a regen and a sync, so the author should decide whether the byte-identical pages may carry port-neutral text.🔧 Fix applied.
5 issues (1 warning, 4 infos) still open:
docs/ports/csharp.md:357- Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23- Applied inline. The class Javadoc and the eject note named the override argumenttemplateDir. The generator actually readsmetamodelTemplateDir(ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments tometamodelTemplateDir. The code is unchanged.docs/ports/rust.md:81- Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator exceptservice-routes. Both statements became false when this change addedmetamodel-docs, which takessubDirand is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to namemetamodel-docsand itssubDiroption, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.server/python/src/metaobjects/codegen/generators/metamodel_docs_generator.py:74- The factorymetamodel_docs_generator(ctx)readsoptions.get("sub_dir", ...). The two Python paths fillctx.optionsdifferently. The packaged path (cli.py:900-904) runsresolve_optionsand passes snake_case keys, sosub_diris found. The owned path is whatmetaobjects eject metamodel-docsproduces:build_owned(cli.py:889, eject.py:382-404) passes a one-argument context factory the options "as written", so the key is camelCasesubDir. Concrete sequence: eject metamodel-docs, then wire the copy as{name: "codegen.generators.metamodel_docs:metamodel_docs_generator", options: {subDir: "ref"}}. The pages still land undermetamodel/, with no error. The registry option and docs/ports/python.md both documentsubDir, so the owned copy breaks a documented setting without warning. The Python test calls only the constructor (MetamodelDocsGenerator(sub_dir=...)), so it covers neither path. Fix: read both spellings, e.g.options.get("sub_dir", options.get("subDir", DEFAULT_SUB_DIR)). Also add a test that builds the generator through the ownedmodule:symbolpath with{subDir: ...}. This bug comes from the original commit, not from a fix round.server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts:38- Applied inline. TheALL_PROVIDER_DEFINITIONSdoc comment said "The order is irrelevant". The new page builder records the first definition that declares an attr on a type as that attr's provider and default. The C#, Java, Python and Rust ports copy this walk order for that reason; RustDEFINITION_SOURCESsays "the order is part of the contract". I rewrote the comment to say the order is part of the contract and every port walks it. This is a comment-only change.🔧 Fix applied.
📝 4 wording or comment-placement notes left for the author (no fix round spent):
docs/ports/csharp.md:357- Applied inline. The metamodel-docs sentences sat in the middle of the eject paragraph, between the api-docs eject sentence and the eject version-pin warning. I moved them to a separate "The metamodel reference" paragraph after the eject paragraph. Wording is unchanged.server/java/codegen-base/src/main/java/com/metaobjects/generator/MetamodelDocsGenerator.java:23- Applied inline. The class Javadoc and the eject note named the override argumenttemplateDir. The generator actually readsmetamodelTemplateDir(ARG_TEMPLATE_DIR), and docs/ports/java.md uses that name. I changed both comments tometamodelTemplateDir. The code is unchanged.docs/ports/rust.md:81- Applied inline. docs/ports/rust.md said 'The shipped generators take none'. It also said that a project with no list file runs every generator exceptservice-routes. Both statements became false when this change addedmetamodel-docs, which takessubDirand is opt-in (eject.rs opt_in: true; generator_list test asserts !runs_unlisted("metamodel-docs")). I updated that paragraph to namemetamodel-docsand itssubDiroption, and to say it runs only when listed. I applied the same correction to the module doc comment in server/rust/metaobjects-codegen/src/generator_list.rs:14 ('The shipped generators take none yet'). These are documentation-only changes.server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts:38- Applied inline. TheALL_PROVIDER_DEFINITIONSdoc comment said "The order is irrelevant". The new page builder records the first definition that declares an attr on a type as that attr's provider and default. The C#, Java, Python and Rust ports copy this walk order for that reason; RustDEFINITION_SOURCESsays "the order is part of the contract". I rewrote the comment to say the order is part of the contract and every port walks it. This is a comment-only change.✅ **Test** - passed
✅ No issues found.
metaobjects genwith a metamodel-docs target writes the 23 vocabulary pages matching the corpus (local CLI, disposable project)metaobjects genexit 0, wrote 23 files under generated/metamodel/; diff vs expected emptyscripts/ci-local.sh --affected --strict-toolchainsScratch render of coreMetamodelDocsPages() through renderDocPage with templates/metamodel, diffed withdiff -ragainst fixtures/metamodel-docs/expected (TypeScript reference, live, 23 files)metaobjects gen(Python console script, server/python/.venv) in a disposable project under $DEV_SCRATCH withtargets.docs.generators: [metamodel-docs]; exit 0, 23 files written under generated/metamodel/, diffed against fixtures/metamodel-docs/expected (live CLI)Python generator direct render with sub_dir='' and sub_dir='ref' viapython -Iin scratch; default output byte-identical to corpus, subDir output lands under ref/pytest -q tests/codegen/test_eject.py -k sub_dir(test_an_ejected_metamodel_docs_copy_honours_its_sub_dir_option; runs the CLI main() in disposable projects, both packaged and ejected, subDir=ref) -> 1 passedChecked templates/metamodel/index.md.mustache header wording in expected/INDEX.md: port-neutral ('Regenerate with your port's gen command'), matching the round-3 fixRust option name isdirin server/rust/metaobjects-codegen/src/metamodel_docs.rs, reading OPTION_SUB_DIR; not driven live (cargo not run in this turn)Baselinescripts/ci-local.sh --affected --strict-toolchains(already passed at target commit, not re-run; no source changed in this turn)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
no-mistakes: 1 run (review took three fix rounds before approval).