Repository navigation
feat(codegen-kotlin): move the last Kotlin generators onto KotlinWriter and drop KotlinPoet - #664
Merged
Merged
Conversation
…erators onto KotlinWriter and drop KotlinPoet The last Kotlin generators that built KotlinPoet specs now write through KotlinWriter (ADR-0063): KotlinEntityGenerator (data class, Java builder, cross-field properties, TPH <Sub>Validation, abstract interface shape and MetaNetJson.kt), KotlinEnumEmitter and KotlinSpringConfigGenerator. KotlinTypeMapper answers with the writer's own KotlinTypeName / KotlinClassName, KotlinCrossFieldRules answers expression strings, and KotlinPoetFileWriter is removed. The kotlinpoet dependency leaves codegen-kotlin; kotlin-reflect, which it supplied at runtime, is declared directly so consumers' runtime classpath is unchanged. The layout ratchet's unconverted allowlist is now empty (KotlinNaming's packageHeader delegates to the writer); the ratchet itself stays. Generated output changes in layout only: the 32 regenerated goldens are identical to the old ones once imports, `public`, package qualifiers, whitespace and trailing commas are normalised, and their comment text is unchanged. MetaNetJson.kt is byte-identical. Owned entity / exposed-table / routes / relations / repository / spring-config / api-docs copies ejected before 1.3.0 named KotlinPoet types and must be re-ejected; the CHANGELOG upgrade note says so, and the four KotlinPoet frozen copies in ejected-at-base (with their ejectWith classes) are refreshed to the 1.3.0 eject output. Docs and agent-context skill references that said Kotlin codegen runs on KotlinPoet are corrected, and the shipped agent-context tree, its Python copy, the agent-context conformance fixtures and the llms mirrors are rebuilt.
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
MetaNetJson.ktsupport file, now lay out their output withKotlinWriter.KotlinPoetFileWriteris removed, and every file goes throughGeneratedFileWriter's marker guard.KotlinTypeMapper,KotlinCrossFieldRulesandKotlinGenUtilreturn the writer's ownKotlinTypeName/KotlinClassName(writer/KotlinTypeName.kt) instead of KotlinPoet types. Thekotlinpoet-jvmdependency is removed fromserver/java/codegen-kotlin/pom.xml. A test-scopedkotlin-reflectis pinned to the module's Kotlin version.public, nokotlin.*imports, four-space indent, one sorted import group. Owned copies ejected before 1.3.0 that use the removed KotlinPoet types need re-ejecting (documented inCHANGELOG.md).Live evidence (head 8cbae52; the current head 3b7f82e only adds main's one-line
tools/prerelease/candidates.mdrow, and the gate's local CI passed on it)The gate's "no live product run" test note is declined on this evidence:
mvn -pl codegen-kotlin -am -Dtest='com.metaobjects.generator.kotlin.**' test(goldens, codegen-kotlin compile gateCodegenCompileConformanceTest, layout ratchet, eject and ejected-at-base compat tests)scripts/integration-test.sh kotlin(Testcontainers Postgres, persistence + api-contract corpora through Exposed)codegen-kotlin-exposed1x-check(same script)scripts/ci-local.sh --affected --strict-toolchains(java reactor, all five conformance lanes, ts)The review fix round moved
kotlin-reflectfrom a runtime dependency ofcodegen-kotlinto a test-scope dependency ofcodegen-kotlinonly, pinned to${kotlin.version}(its own tests need it to match kotlin-stdlib); integration-tests-kotlin and the exposed1x check get it through jackson-module-kotlin, and both were re-run green on this head after that change.Layout-only proof: the 32 regenerated goldens equal the previous ones once imports,
public, package qualifiers, whitespace and trailing commas are normalised, with every comment's text unchanged;MetaNetJson.ktis byte-identical.Validation
Risk Assessment
✅ Low: The only change since the approved head adds a 7-line ADR amendment. I checked each of its claims against the source: the Kotlin ratchet allowlist has an empty
unconvertedsection, KotlinApiDocsRenderer is the onlyexemptentry, codegen-kotlin main code and pom.xml have no kotlinpoet reference, and docs/ports/kotlin.md exists and states the same facts.Testing
Baseline
scripts/ci-local.sh --affected --strict-toolchainsalready passed at this commit and was not re-run. This turn ran the focused offline codegen-kotlin Maven tests, which execute the moved generators in-process, compile emitted Kotlin, and pass. No live product scenario was driven: the Maven pluginmetaobjects:generaterun and a before/after output diff were not attempted within budget, so every scenario is untested with live=false. Verdict inconclusive, not go. No background processes left running and no source files changed.metaobjects:generatethrough the Maven plugin on a fixture, diffed before and after the change; not attempted within budget.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
♻️ Reviewed only the branch's changes since run 01M8DMDVNJTYKE4YK4KRNW4P4P approved; the rest of the branch carries that approval.
Findings carried from run 01M8DMDVNJTYKE4YK4KRNW4P4P, already decided there:
server/java/codegen-kotlin/src/main/kotlin/com/metaobjects/generator/kotlin/writer/KotlinWriter.kt:233- Simplification: the change adds a new publicKotlinWriter.packageHeader(pkg)to the writer API. Its only caller isKotlinNaming.packageHeader, which no reference generator calls (its own allowlist note says so). The only effect is to move the typed\n\nline breaks into the writer package, so the KotlinNaming entry can leave the layout-ratchet allowlist. The intent does not list KotlinNaming as a file to convert. Recommended remedy: keep the old one-line body in KotlinNaming with its allowlist entry, and drop the new writer API. If the human wants an empty allowlist, keep it as is.✅ No issues found.
metaobjects:generatethrough the Maven plugin on a fixture, diffed before and after the change; not attempted within budget.scripts/ci-local.sh --affected --strict-toolchainsMaven offline focused run:mvn -o -q -pl codegen-kotlin test -Dtest='KotlinEntityGeneratorTest,KotlinWriteGuardTest,KotlinLayoutRatchetTest,KotlinTypeMapperTest,EjectedAtBaseGeneratorsCompatTest'in server/java; surefire reports fresh, all pass (KotlinEntityGeneratorTest 12, KotlinWriteGuardTest 3, KotlinLayoutRatchetTest 20, KotlinTypeMapperTest 47, EjectedAtBaseGeneratorsCompatTest 3)Same run's surefire output: CodegenCompileConformanceTest, EjectContractTest, KotlinSpringConfigGeneratorTest, KotlinEnumConformanceTest, KotlinOutputCompilesTest, KotlinWriterConformanceTest all 0 failuresgrep of codegen-kotlin src/main for kotlinpoet: only comments and KotlinTypeName doc mention remain, no imports; pom.xml has no kotlinpoet dependency✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.