Repository navigation
feat(codegen): uniform entity selection across ports and a linear Java metadata loader - #588
Merged
Merged
Conversation
…oss ports Java loader (also Kotlin): - Remove the quadratic child-key check (list -> set) and resolve references through the per-type name index. 20 copies of the canonical model (1,160 objects) load in about 2 s CPU; it previously exceeded the 30 s timeout. - The 30 s init timeout is now a setting: LoaderOptions.setInitTimeoutMs, loader arg initTimeoutMs, -Dmeta.loaderTimeoutMs on the Maven plugin, or -Dmetaobjects.loader.initTimeoutMs. LargeModelLoadTest holds a CPU budget. Selection parity: - codegen-spring and codegen-kotlin generators now honour <filters> (confirmed by running that they ignored them before). - mvn metaobjects:generate -Dmeta.entities=A,B narrows per-object output for Java and Kotlin; whole-model files still render from the whole model, a narrowed run sweeps no orphans, and blank or unknown names fail the goal. - C# dotnet meta gen/verify --codegen --entities, with the same semantics. - Python gen lists only the files it changed and counts the rest unchanged. - Selection documented on every port page; CHANGELOG under [Unreleased].
Every other port refuses an unknown --entities / meta.entities name; TypeScript dropped it silently when another name matched and only warned when none did. Now exit 2 with the same wording, before anything is written.
…selection # Conflicts: # CHANGELOG.md # server/python/src/metaobjects/cli.py
…selection # Conflicts: # CHANGELOG.md
dmealing
added a commit
that referenced
this pull request
Nov 15, 2026
…anged (ADR-0064) (#590) * feat(codegen): skip gen when nothing changed, in every port (ADR-0064) Forward-port of #585 from release/1.2 (b9bc9c7) onto main, merged with the manifest written once per run (#584) and the uniform entity selection (#588). The skip ADR is numbered ADR-0064 here: ADR-0062 and ADR-0063 are taken on main. - gen builds a key from the loaded model (each root node in canonical effective form), the generators' identity (built engine code, config, owned generators, templates, declared extra inputs, project config) and the output-changing flags, before anything renders. A match with the last successful run, with every generated file still holding that run's bytes, renders and writes nothing. --force (Maven: -Dmetaobjects.force=true) turns it off; a generator that cannot declare its inputs opts out. - A run that names entities (positional, --entities, -Dmeta.entities) forces exactly those: it never skips, never stores a key and leaves the stored full-run key alone, in every port. - verify --codegen may answer "no drift" locally from the key; CI and --full always render, and every port compares in memory. - The hash manifest stays loaded once and written once, and only when an entry changed; identical bytes are never rewritten; TypeScript runs git merge-file only for a hand-edited file. - fixtures/codegen-skip-conformance/cases.json: the shared case table. Hand-resolved: TypeScript runner, overwrite-policy, gen/verify/args/index and codegen-drift; Python cli, runner, overwrite_policy; C# CodegenRunner, CodegenCli, CodegenDrift, Generator, Program; Java generate and verify mojos; docs, changelog and the ADR index. * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): warn unknown attrs before gen skip; add regression test * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): Carry warnings in skipped gen json/toon document * no-mistakes(test): Align C# agent-context fixture wording; sdk suite green * no-mistakes(document): align codegen-skip docs with ADR-0064
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
dotnet meta gen --entities A,B(andverify --codegen --entities), Java/Kotlin gainmvn metaobjects:generate -Dmeta.entities=A,B, matching TypeScript's positional names and Python's--entities: only the named objects' files are regenerated, whole-model files (AppDbContext, the Java/Kotlin validator registry, report export writer, binding provider) still render from the whole model, a narrowed run never deletes or forgets unselected files, and a blank selection or a name matching no object is refused (exit 2 in C#, a failed Maven goal). TypeScript'smeta gen <Name>...now refuses an unknown name with exit 2 instead of dropping it silently, and the option is documented on every port page.<filters>.codegen-springandcodegen-kotlingenerators previously ignored a generator's<filters>and wrote every object; they now respect them, ascodegen-basegenerators always did.LargeModelLoadTestbudget. The fixed 30-second init timeout is now a documented setting (LoaderOptions.setInitTimeoutMs, themetaobjects.loader.initTimeoutMssystem property, or MavenloaderTimeoutMs), defaulting to the previous 30 seconds.Validation took four no-mistakes runs: the first was stopped, the second cancelled after a minute, the third was lost when the machine rebooted, and the fourth passed. After that, main was merged in (only CHANGELOG.md conflicted, and both sides were kept). That merge was published without a fifth run: the gate's local suite (
scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains, then--only gates) passed on the merge commit before it was pushed.Validation
Risk Assessment
✅ Low: Both prior review findings are fixed with gating tests, the loader's linearization preserves resolution semantics (key precedence and declaration-order tie-break verified), and the cross-port selection refusals/whole-model invariants hold by construction in each port's mechanism; only an informational note on the C# probe's double-generation cost remains.
Testing
Drove the real codegen entry point of every port live — TS meta CLI, Java and Kotlin via the Maven plugin built from the branch, C# dotnet meta CLI with its init-scaffolded owned codegen project against locally packed 1.3.0 packages, and the Python metaobjects console script via uv — each against disposable projects in RAM scratch. Narrowing behaved identically everywhere: only selected per-object files rewritten, unselected files left untouched, orphan cleanup skipped, whole-model files (TS barrel, Java/Kotlin ReportExportWriter, C# AppDbContext + ReportExportWriter, Python enums.py) recreated byte-identical to the unfiltered run, and unknown/blank selections refused with matching per-port messages and exit 2. The Java loader work was driven live too: every documented timeout path (-Dmeta.loaderTimeoutMs, the loader arg, -Dmetaobjects.loader.initTimeoutMs) takes effect with clear failures for timeouts and invalid values, and a synthetic 1,201-object model loads and fully generates in 6.4s under the unchanged 30s default — the scale that previously blew the fixed timeout. No failures and no source changes, so the configured test command's passing baseline stands as broad regression; all scratch projects, local feeds, build servers, and background builds were torn down and the worktree is clean. Evidence transcripts are in the evidence directory.
meta gen Programnarrows per-object output while the whole-model barrel still renders whole (picks up a newly added Order export without generating Order.ts)meta gen: names 'Ordr', which matches no object in the metadata., exit 2, no files created)-Dmeta.entities=Programrewrites only selected per-object files, keeps whole-model ReportExportWriter whole, narrows a per-entity template scope, and skips the orphan sweep with…-Dmeta.entities=Programnarrows Kotlin generators' per-object output and keeps the whole-model ReportExportWriter.kt byte-identicaldotnet meta gen --entities Productnarrows per-object output; whole-model AppDbContext.g.cs and shared ReportExportWriter.g.cs are recreated byte-identical even though the selection touches neit…metaobjects gen --entities Product(pre-existing surface, parity requirement) narrows per-object output, keeps whole-model enums.py byte-identical, skips orphan cleanup with a warning, and r…Evidence: Java/Kotlin narrowed-run transcript (selection, refusals, mustache warning)
Evidence: Java loader timeout knobs + 1,201-object scale run
Evidence: Kotlin narrowed run with byte-identical whole-model writer
Evidence: C# --entities narrowed run and refusals (whole-model files sha256-identical)
Evidence: TypeScript + Python selection and refusal transcripts
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/csharp/MetaObjects.Codegen/CodegenRunner.cs:323- Informational, no defect: under--entities,Emitruns every non-WholeModel generator twice (whole-model pass + narrowed probe), so a narrowed C# run costs roughly a full pass plus a small extra pass rather than a fraction of one. The plan's stated aim is a fast develop loop, so it is worth knowing that in C#--entitiesis a safety/parity feature, not a speedup — unlike TypeScript, wherectx.selectednarrows without a second pass. The tradeoff is documented in the method's own comment and is the price of the 'whole-model files render whole' invariant held by construction (content always comes from the whole run), so no change is requested.✅ **Test** - passed
✅ No issues found.
meta gen Programnarrows per-object output while the whole-model barrel still renders whole (picks up a newly added Order export without generating Order.ts)meta gen: names 'Ordr', which matches no object in the metadata., exit 2, no files created)-Dmeta.entities=Programrewrites only selected per-object files, keeps whole-model ReportExportWriter whole, narrows a per-entity template scope, and skips the orphan sweep with…-Dmeta.entities=Programnarrows Kotlin generators' per-object output and keeps the whole-model ReportExportWriter.kt byte-identicaldotnet meta gen --entities Productnarrows per-object output; whole-model AppDbContext.g.cs and shared ReportExportWriter.g.cs are recreated byte-identical even though the selection touches neit…metaobjects gen --entities Product(pre-existing surface, parity requirement) narrows per-object output, keeps whole-model enums.py byte-identical, skips orphan cleanup with a warning, and r…scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchainsBaseline broad regression: scripts/ci_local not applicable — configured command scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains (passed at target commit before this step; no source files were changed in this turn)TS: bun <branch cli>/dist/bin/meta.js init/gen in a disposable project — full baseline, narrowedgen Programwith a mid-test new entity (barrel rewritten whole, per-object files not generated),gen Program Ordrandgen Zzzexit-2 refusals with nothing writtenJava: mvn -DskipTests install of the branch reactor, then mvn metaobjects:generate over the 116-object fitness canonical model — baseline full run; narrowed -Dmeta.entities=Program against deliberately deleted/corrupted files (whole-model ReportExportWriter recreated, unselected files untouched, per-entity template scope narrowed, orphan sweep skipped with log line); unknown and blank selection refusals; mustache cannot-narrow warningJava loader: -Dmeta.loaderTimeoutMs=1 and -Dmetaobjects.loader.initTimeoutMs=1 timeout failures, =abc refusal, and a synthetic 1,201-object model fully generating in 6.4s under the default 30s timeoutKotlin: mvn metaobjects:generate with KotlinEntity/ExposedTable/Names/FilterAllowlist/Relations/SpringController/ReportExport generators — narrowed run recreates selected files, leaves Week.kt stale, recreates ReportExportWriter.kt sha256-identicalC#: dotnet build + pack of MetaObjects, MetaObjects.Render, MetaObjects.Codegen, MetaObjects.Cli 1.3.0 into a local feed; dotnet meta init scaffold; full gen baseline; --entities Product run with sha256 checks of AppDbContext.g.cs and ReportExportWriter.g.cs against the full run; --entities Product,Zzz and blank refusals (exit 2)Python: uv run of the branch package against a disposable project — full gen, --entities Product (whole-model enums.py sha256-identical, orphan-cleanup warning), --entities Product,Zzz and --entities "" refusals (exit 2)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.