Repository navigation
fix: correct derived-field names, verify --db signature checks, and extender warnings - #600
Merged
Merged
Conversation
…function matching, widened-extender warning, test the stringValueMap codec L3: Java and Python names generators emit no entry for a derived field of a table-read entity. L4: declared origin.function check allows integer widening, any* wildcards and variadics. L5: warn whenever an extender's base differs from the pre-rc.21 derivation. L8: JdbcCodecRoundTripTest covers the @stringValueMap enum.
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
<Entity>Namesno longer emits a column constant for a derived (origin.*) field of an entity read from its table, matching the TypeScript and C# generators. Projections and write-through entities keep their derived-field entries, since those fields are columns of their view. Java and Kotlin also stop re-declaring inherited derived fields on abstract-base fragments where needed.meta verify --db(TypeScript,migrate-ts): theorigin.functionsignature check now follows Postgres call rules. Anintegerargument is accepted forbigint,numeric,realanddouble precisionparameters,any*polymorphic parameters match any type, and a variadic function's trailing parameter count and type are not checked (its required fixed parameters still are). Genuine mismatches still fail, and the limits text printed with findings is updated.identity.primary { extends: ... }that restores the old base. The branch also adds a Java OMDB round-trip test for the@stringValueMapenum codec.Validation
Risk Assessment
✅ Low: The four low-severity fixes (L3 to L5, L8) are implemented in the paths the intent names. I found no new defect in the fix-round code. The only edit this pass was a stale diagnostic string.
Testing
Three scenarios were driven live against the real product: the TS
meta verifywidened-extender warning (positive and negative cases),meta verify --dbon a disposable Postgres 16 for origin.function matching (widening, polymorphic and variadic accepted, genuine mismatch still reported), and the Pythonmetaobjects gennames generator for derived fields (fixed tree omits the constant; base tree reproduces the bug). All three passed. Two intent items were not driven live: the Java names generator (L3) and the Java EnumCodec test (L8). The L8 change is test-only, and the Java lanes were not built here. The baseline affected run covered the change at the target commit. Overall: go, with those two untested.meta verifyon a disposable non-TPH projection extender whose base changed (InvoiceRow over CustomerBase, own field extends Invoice.ref) prints the widened-extender warning naming…bun server/typescript/packages/cli/bin/meta.ts verifyin a scratch projectmeta verify --dbon a disposable Postgres 16 accepts Postgres-valid calls (integer arg for bigint param, polymorphic anyelement, VARIADIC trailing) and still reports a genuine declared-type mism…metaobjects gennames generator for a table-backed entity with a derived field no longer emits a column constant for it, while the projection keeps its own columnEvidence: L5 positive: meta verify emits the widened-extender warning for a non-TPH extender whose base changed
Evidence: L5 input model (positive case)
Evidence: L5 negative: no warning when the extender's own field names the super's base
Evidence: L4: meta verify --db against disposable Postgres 16 reports only the genuine origin.function mismatch
Evidence: L4 input model (probe functions: widen, poly, variadic, mismatch)
Evidence: L3 Python: account_names.py from the base commit still emits IS_HIGH_COLUMN (pre-fix)
Evidence: L3 Python: account_names.py from the fixed tree omits the derived-field constant
Evidence: L3 Python: account_view_names.py from the fixed tree keeps the projection's doubled column
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:254- The derived-field skip is ported without the M8 compensation both reference implementations pair it with (TS codegen-ts/src/names.ts:386-394, C# CSharpNaming.cs:626-631): when the names super fragment is an abstract ENTITY (whose derived fields the fragment now drops), an object whose derived fields ARE columns must re-declare the inherited derived fields as its own. Concrete sequence: an abstract object.entity declares a derived (origin.*) field; a write-through entity (or a projection) extends it. Java: the fragment drops the constant (SpringNamesGenerator.java:464), the child keeps the field in its full fields map (columnless=false at :254) but declares only ownFields when it has a base (:586), so COLUMNS_BY_FIELD (:630) references a <FIELD>_COLUMN no emitted class declares — the generated .java does not compile. Python: the child marks the field carried_by_super (names_generator.py:485) and re-exports it from the super module that no longer defines it — ImportError at import. Both are regressions vs the base commit (the fragment previously carried the constant) and break the change's own parity claim (CHANGELOG.md 'They now match'). Sibling sites of the same invariant: SpringNamesGenerator.java:464-468 (fragment skip) and names_generator.py:473-480 (both paths).server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:169- The new variadic branch of signatureMatches checks only the leading fixed parameters' types and drops the required-arity check entirely, so it reports a match for a call Postgres rejects: a declared origin.function with no @params (params: [], reachable per declaredFunctions at declared-functions.ts:122-131) against pg_proc f(text, VARIADIC integer[]) with pronargdefaults=0 returns true, because fixed = min(1, 0) = 0 and the empty slice trivially matches — the drift verify --db exists to catch goes unreported. Postgres requires every non-defaulted fixed parameter and a VARIADIC parameter cannot itself carry a default, so the branch needsdeclared.params.length >= fn.args.length - 1 - fn.defaultsbefore the type check. The DECLARED_FUNCTION_CHECK_LIMITS text (:186-190) also says only 'arity is not checked' while trailing parameter types are unchecked too; update it with the fix.🔧 Fix applied.
4 issues (2 warnings, 2 infos) still open:
server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:254- The derived-field skip is ported without the M8 compensation both reference implementations pair it with (TS codegen-ts/src/names.ts:386-394, C# CSharpNaming.cs:626-631): when the names super fragment is an abstract ENTITY (whose derived fields the fragment now drops), an object whose derived fields ARE columns must re-declare the inherited derived fields as its own. Concrete sequence: an abstract object.entity declares a derived (origin.*) field; a write-through entity (or a projection) extends it. Java: the fragment drops the constant (SpringNamesGenerator.java:464), the child keeps the field in its full fields map (columnless=false at :254) but declares only ownFields when it has a base (:586), so COLUMNS_BY_FIELD (:630) references a <FIELD>_COLUMN no emitted class declares — the generated .java does not compile. Python: the child marks the field carried_by_super (names_generator.py:485) and re-exports it from the super module that no longer defines it — ImportError at import. Both are regressions vs the base commit (the fragment previously carried the constant) and break the change's own parity claim (CHANGELOG.md 'They now match'). Sibling sites of the same invariant: SpringNamesGenerator.java:464-468 (fragment skip) and names_generator.py:473-480 (both paths).server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:169- The new variadic branch of signatureMatches checks only the leading fixed parameters' types and drops the required-arity check entirely, so it reports a match for a call Postgres rejects: a declared origin.function with no @params (params: [], reachable per declaredFunctions at declared-functions.ts:122-131) against pg_proc f(text, VARIADIC integer[]) with pronargdefaults=0 returns true, because fixed = min(1, 0) = 0 and the empty slice trivially matches — the drift verify --db exists to catch goes unreported. Postgres requires every non-defaulted fixed parameter and a VARIADIC parameter cannot itself carry a default, so the branch needsdeclared.params.length >= fn.args.length - 1 - fn.defaultsbefore the type check. The DECLARED_FUNCTION_CHECK_LIMITS text (:186-190) also says only 'arity is not checked' while trailing parameter types are unchecked too; update it with the fix.server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:63- Fix-round code (L4):isPolymorphicclassifies anyformat_typeoutput whose bare name starts with "any" as a polymorphic pseudo-type, so a user-defined Postgres type literally named e.g.anyflagswould be treated as a wildcard parameter and a genuine type mismatch on it would go unreported (silent false negative in the drift gate). Postgres has a closed set of polymorphic pseudo-types (any,anyarray,anyelement,anyenum,anynonarray,anycompatible,anycompatiblearray,anycompatiblenonarray,anycompatible range types,anyrange,anymultirange); the module already states closed sets as constants (TEXT_TYPESat :46). Reachability is very low (requires a user type whose bare lower-case name begins with "any"), hence info. The variadic branch's trailing-type skip (:171-175) is unaffected.server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:266- Fix-round note (no action demanded): the M8 compensation fires only when the names super is an ABSTRACT entity. A write-through extender whose names super is a CONCRETE plain entity declaring a derived field would still reference a<FIELD>_COLUMNno emitted class declares — the same class of defect — because the concrete super's own module drops the constant (plain-entity columnless) and the child does not re-declare it. This scoping is byte-for-byte the TS (names.ts:390) and C# (CSharpNaming.cs:629) reference behavior, so it is a deliberate reference tradeoff this port correctly mirrors, not a porting defect; Java/Python pre-change emitted a constant naming a nonexistent column there instead. Recording it so the abstract-only scope is a known, symmetric boundary rather than an oversight. Sibling sites, all matching the reference: SpringNamesGenerator.java:266-272, names_generator.py:478-486.🔧 Fix applied.
4 issues (2 warnings, 2 infos) still open:
server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:266- Fix-round note (no action demanded): the M8 compensation fires only when the names super is an ABSTRACT entity. A write-through extender whose names super is a CONCRETE plain entity declaring a derived field would still reference a<FIELD>_COLUMNno emitted class declares — the same class of defect — because the concrete super's own module drops the constant (plain-entity columnless) and the child does not re-declare it. This scoping is byte-for-byte the TS (names.ts:390) and C# (CSharpNaming.cs:629) reference behavior, so it is a deliberate reference tradeoff this port correctly mirrors, not a porting defect; Java/Python pre-change emitted a constant naming a nonexistent column there instead. Recording it so the abstract-only scope is a known, symmetric boundary rather than an oversight. Sibling sites, all matching the reference: SpringNamesGenerator.java:266-272, names_generator.py:478-486.server/csharp/MetaObjects/Loader/ValidationPasses.cs:1435- Sibling site the L5 fix left behind. The change widened validateExtenderSubtypeScope (validation-passes.ts:1082) so the warning fires whenever the extender's base differs from the pre-rc.21 derivation, and added the preRc21 re-derivation to _deriveBaseEntity — but only in TypeScript. The C# copy, whose doc comment claims "TS validateExtenderSubtypeScope, message for message" (ValidationPasses.cs:1420), still bails atif (discriminator is null) continue;(:1435) and still requires a subtype-bound own field before warning. Concrete sequence: the exact model of the new TS test (InvoiceRow extends an abstract projection anchored on Customer, own fieldrefextends Invoice.ref) loads through the C# loader with NO warning, while TS warns 'its base entity is now Customer, where before it was Invoice' — the same silent view replacement the L5 criterion ('the warning fires for every extender with no identity of its own') exists to surface, unreported on the C# port. Sibling sites needing the port: ValidationPasses.cs:1422-1463 (the pass) and the C# DeriveBaseEntity (needs the preRc21 flag mirroring validation-passes.ts:1017-1020). Fix round provenance: this is a gap the author's original L5 change (b06cb5a) left, not something a fix round moved.server/java/codegen-kotlin/src/main/kotlin/com/metaobjects/generator/kotlin/KotlinGenUtil.kt:583- Sibling port the L3 fix skipped. The change makes Java and Python names generators drop the column constant for a derived (origin.*) field of a table-read entity, and the CHANGELOG entry frames the result as the four ports matching ('The TypeScript and C# names generators already left out... They now match') — but the fifth port's KotlinNamesGenerator never got the fix: KotlinGenUtil.resolveObjectNames (:583) and resolveSuperFragmentNames (:521) both call fieldMap(obj.metaFields, strategy) with no derived-field skip and no M8 compensation. Concrete sequence: an object.entity with a source.rdb table and a field.boolean isHigh carrying origin.computed still emits IS_HIGH_COLUMN = "is_high" in the generated Kotlin names object — a constant naming a column the table does not have, which a hand-written SQL consumer binds and fails on at runtime. That is exactly the L3 defect ('still emitted a column constant naming a column that does not exist'), surviving in the one port the intent did not name. The intent text (and the independent review it cites) names only Java and Python, so extending to Kotlin is a scope decision, not a mechanical given — hence ask-user. Sibling sites: KotlinGenUtil.kt:521 (fragment), :583 (object), and the M8 compensation would land beside whichever skip is added.CHANGELOG.md:53- Inline fix applied this pass: the verify --db entry said the fix 'does not check a variadic function's arity', but the change checks a variadic function's required fixed arity (declared-functions.ts:174-175) — only the trailing variadic count and type are unchecked, as DECLARED_FUNCTION_CHECK_LIMITS states precisely. Reworded to 'does not check a variadic function's trailing arity (its required fixed parameters still are)' so the changelog and the emitted diagnostic agree.🔧 Fix applied.
3 issues (1 warning, 2 infos) still open:
server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:266- Fix-round note (no action demanded): the M8 compensation fires only when the names super is an ABSTRACT entity. A write-through extender whose names super is a CONCRETE plain entity declaring a derived field would still reference a<FIELD>_COLUMNno emitted class declares — the same class of defect — because the concrete super's own module drops the constant (plain-entity columnless) and the child does not re-declare it. This scoping is byte-for-byte the TS (names.ts:390) and C# (CSharpNaming.cs:629) reference behavior, so it is a deliberate reference tradeoff this port correctly mirrors, not a porting defect; Java/Python pre-change emitted a constant naming a nonexistent column there instead. Recording it so the abstract-only scope is a known, symmetric boundary rather than an oversight. Sibling sites, all matching the reference: SpringNamesGenerator.java:266-272, names_generator.py:478-486.CHANGELOG.md:53- Inline fix applied this pass: the verify --db entry said the fix 'does not check a variadic function's arity', but the change checks a variadic function's required fixed arity (declared-functions.ts:174-175) — only the trailing variadic count and type are unchecked, as DECLARED_FUNCTION_CHECK_LIMITS states precisely. Reworded to 'does not check a variadic function's trailing arity (its required fixed parameters still are)' so the changelog and the emitted diagnostic agree.server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:55- Residual instance of the exact L4 defect class the intent required fixed ('Postgres-valid calls ... are reported as mismatches'). The fix round (acd363f) closed the integer family only: WIDER_NUMERIC maps integer→[bigint, numeric] and bigint→[numeric]. Postgres's implicit-cast set (pg_cast castcontext 'i') also accepts integer→real, integer→double precision, bigint→double precision, and real→double precision. Concrete sequence: an origin.function whose declared parameter is a field.int (pgTypeNames → ["integer"]) called against a function whose pg_proc parameter is double precision —parameterAccepts(["integer"], "double precision")returns false, so verify --db reports a signature mismatch for a call Postgres executes fine; same for a field.float ("real") against a double-precision parameter. The CHANGELOG's own claim ('It now allows ... widening' framed as accepting what Postgres accepts) and the L4 criterion both cover this case. This is a gap the fix round left behind, not a new defect it introduced. Fix: extend WIDER_NUMERIC with integer→["real", "double precision"], bigint→["double precision"], real→["double precision"], plus one unit-test line in declared-functions-match.test.ts mirroring the existing widening tests.🔧 Fix applied.
5 issues (1 warning, 4 infos) still open:
server/java/codegen-spring/src/main/java/com/metaobjects/generator/spring/SpringNamesGenerator.java:266- Fix-round note (no action demanded): the M8 compensation fires only when the names super is an ABSTRACT entity. A write-through extender whose names super is a CONCRETE plain entity declaring a derived field would still reference a<FIELD>_COLUMNno emitted class declares — the same class of defect — because the concrete super's own module drops the constant (plain-entity columnless) and the child does not re-declare it. This scoping is byte-for-byte the TS (names.ts:390) and C# (CSharpNaming.cs:629) reference behavior, so it is a deliberate reference tradeoff this port correctly mirrors, not a porting defect; Java/Python pre-change emitted a constant naming a nonexistent column there instead. Recording it so the abstract-only scope is a known, symmetric boundary rather than an oversight. Sibling sites, all matching the reference: SpringNamesGenerator.java:266-272, names_generator.py:478-486.CHANGELOG.md:53- Inline fix applied this pass: the verify --db entry said the fix 'does not check a variadic function's arity', but the change checks a variadic function's required fixed arity (declared-functions.ts:174-175) — only the trailing variadic count and type are unchecked, as DECLARED_FUNCTION_CHECK_LIMITS states precisely. Reworded to 'does not check a variadic function's trailing arity (its required fixed parameters still are)' so the changelog and the emitted diagnostic agree.server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:55- Residual instance of the exact L4 defect class the intent required fixed ('Postgres-valid calls ... are reported as mismatches'). The fix round (acd363f) closed the integer family only: WIDER_NUMERIC maps integer→[bigint, numeric] and bigint→[numeric]. Postgres's implicit-cast set (pg_cast castcontext 'i') also accepts integer→real, integer→double precision, bigint→double precision, and real→double precision. Concrete sequence: an origin.function whose declared parameter is a field.int (pgTypeNames → ["integer"]) called against a function whose pg_proc parameter is double precision —parameterAccepts(["integer"], "double precision")returns false, so verify --db reports a signature mismatch for a call Postgres executes fine; same for a field.float ("real") against a double-precision parameter. The CHANGELOG's own claim ('It now allows ... widening' framed as accepting what Postgres accepts) and the L4 criterion both cover this case. This is a gap the fix round left behind, not a new defect it introduced. Fix: extend WIDER_NUMERIC with integer→["real", "double precision"], bigint→["double precision"], real→["double precision"], plus one unit-test line in declared-functions-match.test.ts mirroring the existing widening tests.server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:198- Inline fix: the DECLARED_FUNCTION_CHECK_LIMITS diagnostic printed under verify --db findings still described only 'implicit integer widening (integer to bigint to numeric)', although the last fix round also widens onto real and double precision. Reworded to 'implicit numeric widening (integer to bigint to numeric, and each onto real or double precision)'. Message text only, and no test asserts it.server/typescript/packages/migrate-ts/src/introspect/declared-functions.ts:12- The inline diff has a second hunk that the recorded fix does not mention. It rewords the header comment (lines 12-15) to describe implicit numeric widening onto real and double precision. It is comment-only and matches the WIDER_NUMERIC table at lines 56-61, so it is inside the allowed class and correct. The recorded entry describes only the diagnostic message and says 'Message text only', which understates the change. No revert is needed.✅ **Test** - passed
✅ No issues found.
meta verifyon a disposable non-TPH projection extender whose base changed (InvoiceRow over CustomerBase, own field extends Invoice.ref) prints the widened-extender warning naming…bun server/typescript/packages/cli/bin/meta.ts verifyin a scratch projectmeta verify --dbon a disposable Postgres 16 accepts Postgres-valid calls (integer arg for bigint param, polymorphic anyelement, VARIADIC trailing) and still reports a genuine declared-type mism…metaobjects gennames generator for a table-backed entity with a derived field no longer emits a column constant for it, while the projection keeps its own columnscripts/ci-local.sh --affected --strict-toolchainsbun server/typescript/packages/cli/bin/meta.ts verifyon a disposable project (non-TPH projection extender whose base changed: InvoiceRow extends CustomerBase, own field extends Invoice.ref) -> warning printed naming Customer vs Invoice and the identity.primary remedy; exit 0bun server/typescript/packages/cli/bin/meta.ts verifyon the negative variant (InvoiceRow own field extends Customer.id, base unchanged) -> no widened-extender warning; exit 0Started disposable postgres:16 container on tmpfs with fsync/synchronous_commit/full_page_writes off (port bound to 127.0.0.1), created schema verify_fn with f_widen(bigint), f_poly(anyelement), v_join(text, VARIADIC integer[]) and f_mis(bigint); ranbun .../cli/bin/meta.ts verify --db postgres://...-> origin.function findings only for f_mis (declared string vs bigint); widening int->bigint, polymorphic and variadic calls not reported; exit 1 driven only by the genuine mismatch (plus the expected unmigrated table/view create lines)Scratch venv with PyYAML;PYTHONPATH=server/python/src python -m metaobjects.cli genon a disposable project (Account entity with derived isHigh, AccountView projection, names generator) -> fixed tree: account_names.py has no IS_HIGH constant, account_view_names.py keeps ACCOUNTVIEW_DOUBLED_COLUMNSamemetaobjects genagainstgit archive 4c4658b89 server/python/srcextracted to scratch -> base tree emits ACCOUNT_IS_HIGH_COLUMN = "is_high" (the pre-fix defect), confirming the scenario reproduces the reported failure before the fixBaseline (not re-run):scripts/ci-local.sh --affected --strict-toolchainsalready passed at f4a081c15; no source or test files changed in this turn, so broad regression was not re-run.agent-context/skills/metaobjects-codegen/references/java.md:219- Java, Kotlin and Python names reference docs (java.md:219, kotlin.md:227, python.md:161) still say the artifact carries a<FIELD>_FIELD/<FIELD>_COLUMNpair 'per field' and a complete COLUMNS_BY_FIELD. The change (fd45b0a / b06cb5a) makes those ports omit the column constant for a derived (origin.) field of an entity read from its table, as TypeScript and C# already do. The TypeScript (typescript.md:192) and C# (csharp.md:121) entries carry the same unqualified 'per field' wording, so the imprecision predates this change. The fixtures/agent-context-conformance//expected/.claude/skills/... copies of java.md, kotlin.md, python.md and physical-names.md are byte-identical to the source, so editing the source requires regenerating those expected outputs through the TS-owned agent-context emitter; they must not be hand-edited. Unresolved here because it needs that regeneration and a decision on one wording for all five ports.🔧 Fix applied.
1 info still open:
agent-context/skills/metaobjects-codegen/references/typescript.md:192- Resolved in this pass: the names entry in all five reference docs (typescript.md:192, csharp.md:121, java.md:219, kotlin.md:227, python.md:161) now states that a derived (origin.*) field of an entity read from its table has no names entry (no field or column constant, not in COLUMNS_BY_FIELD / ColumnsByField / the fields map), while a projection's or write-through entity's derived field keeps both. Two deviations from the recorded driver guidance, both to match the code: (1) the driver said the artifact 'carries a field constant for every field'. The code (fieldMap/FieldNames in Java, fieldNamesOf in TS, the NamesGenerator in C#, the names generator in Python) drops the whole per-field entry for a columnless derived field, so the _FIELD constant goes too; the wording says so. (2) docs/ports/python.md:285 carried the same flat 'per field' claim and was corrected with the same exception. docs/ports/java.md:448 has a summary-table cell 'per-field columns' that is not a contract statement and was left unchanged.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.