You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PayloadCodegen.FindObject bare-name match can pick the wrong object.value on cross-package short-name collision #219
The just-merged fix strips the package qualifier off a resolved @payloadRef before calling FindObject — correct for the common case, but it means the top-level payload lookup now inherits the same cross-package short-name collision risk that fixtures/template-output-render-conformance/xpkg-collision/ was built to describe (see that fixture's README: "the two colliding VOs share the BARE payload-record type name Note; each port's runner hand-authors ... the payload record for that reason").
Failure scenario
Two different packages each declare an object.value named Note with different fields. A template.output's bare @payloadRef resolves (ADR-0042) to pkgB::Note, gets stripped to Note, and FindObject returns whichever Noteroot.Children() enumerates first — silently emitting the WRONG package's shape under the right file/record name, with no error.
Note
This is a pre-existing, systemic characteristic of the C# port's bare-name-match convention — the SAME pattern (CSharpNaming.StripPkg + bare FindObject) is used by ~7 other generators (RoutesGenerator, EntityGenerator, M2MNavigation, OutputParserGenerator, DbContextGenerator, ReverseFinders, PackageBindingResolver), so this isn't unique to PayloadCodegen — fixing it properly likely means auditing/fixing the pattern port-wide, not just here. PayloadCodegen already has an FQN-exact resolver (ResolveObjectRef, used by the verify field-tree path) that could be a model for a safer variant.
Suggested fix direction
Prefer FQN-exact resolution when the ref contains :: (mirroring ResolveObjectRef's own logic) before falling back to bare-name match, across the affected generators — scoped as its own effort given the number of call sites.
Stage 1 landed on main: 44d7d885 (ADR-0044) + 89b10c36 (TS + C# fix). Not yet released.
Scope correction — this is a five-port bug, not a C# one
Investigating turned up that every port is broken, by three different mechanisms, and none of them was caught because the corpus works around the collision:
Port
Failure
C#
bare lookup + bare dedupe → wrong shape, first-wins
TS
resolves correctly, then bare-name dedupe drops the second VO
Java
correct resolution, but both write NotePayload.java → silent file clobber, last-wins
Kotlin
same clobber; its xpkg test only asserts "file exists" and notes it cannot compile
Python
both classes emitted into one module → class shadowing, last-wins
The reason this stayed invisible: every port's runner hand-authors a merged Note { alphaText?, betaText? } rather than using generated output, because no generator could emit two same-named records. So payload record emission was ungated everywhere — the bug lived exactly in the gap the fixture papered over.
Also note this issue's premise is stale: 389255c5 is not on main — it sits unmerged on origin/fix/csharp-payload-generator-bare-payloadref. That branch's strip-then-bare-lookup band-aid should not merge as-is; ADR-0044 supersedes it (its test is worth keeping).
The ruling — ADR-0044
One distinct emitted type per resolved VO FQN. Bare short name when unique in the artifact's reference closure; on collision every colliding member takes a package-derived name (AcmeAlphaNote) in its declaration, file name, and all references. Resolution always FQN-exact, dedupe always FQN-keyed, naming a pure function of the closure (order-independent — no first-wins/last-wins). If derived names still collide, fail loud with ERR_PAYLOAD_NAME_COLLISION.
Rejected: language-native namespacing (TS has no in-file namespace, and it breaks layout/imports for the common case), fail-loud-alone (ADR-0041/0042 made this metadata valid — refusing it would be a regression), and the merged/union record (erases @required; it is a shape no metadata declares).
Not breaking — names change only where output is silently wrong today; non-colliding output is byte-identical, pinned by new exact-string no-churn tests on both ports.
Stage 1 (done)
ADR-0044 · TS payload codegen (FQN-keyed dedupe + closure-scoped naming) · C# EmitRecord now resolves through the FQN-exact resolver BuildTree already used, plus the GenerateRenderHandle raw-FQN-as-type fix · the corpus contract now prohibits hand-authored payload records, and the TS and C# runners were switched to real generated types with the render pins kept byte-exact — so the gate got stronger, not weaker.
Stage 4 — coordinated patch release across all four registries.
Carry-over:ERR_PAYLOAD_NAME_COLLISION is currently a per-port local constant, deliberately NOT yet in the shared fixtures/conformance/ERROR-CODES.json ledger — registering it now would redden Python's error-code coverage test. It must be promoted to the shared ledger when stage 2 lands, or it will be silently forgotten.
Follow-up: C# has the same bare-lookup pattern at 8 other grep-confirmed call sites; worth its own issue.
Closed — ADR-0044 collision-scoped payload-record naming is complete across all five ports and released.
What shipped, per port
Stage
Ports
Mechanism fixed
Commit / release
1
TypeScript, C#
bare-keyed dedupe drop (TS) / wrong-node bare resolution (C#)
89b10c36 — npm + NuGet 0.19.2
2
Python
fqn() dedupe collapsed the two Notes (bare name when own-package unset), dropping the second shape
a59c4719 — PyPI 0.19.3
3a
Java
one-record-per-file: both wrote NotePayload.java → silent file clobber, last-wins
87601286 — Maven 7.11.2
3b
Kotlin
same clobber via KotlinPoet FileSpec + #220 test upgrade
753143d9 — Maven 7.11.2
All ports now run ADR-0044's three-pass pipeline: FQN-keyed reference-closure walk → collision-scoped naming (bare <Short>Payload when unique in the artifact's collision domain; AcmeAlphaNotePayload for every colliding member; hard ERR_PAYLOAD_NAME_COLLISION if a derived name still collides) → emit through the name map. Not breaking — non-colliding output is byte-identical, pinned per port; each port gates the xpkg-collision/ oracle (construct/compile + assert two distinct classes).
Ledger
ERR_PAYLOAD_NAME_COLLISION promoted from per-port local constants to the shared fixtures/conformance/ERROR-CODES.json + the central registries that gate it — TS errors.ts (exact bidirectional), Python errors.py (superset), Java ErrorCode.java (b743634e).
Released
Coordinated 0.19.3 (npm / NuGet / PyPI) · 7.11.2 (Maven Central) — release b85ce889, tag v0.19.3, all four registries verified live. (NuGet was a version-parity bump: the C# fix shipped in 0.19.2 and C# was unchanged here.)
Known follow-up (out of scope — the ADR's stated sibling-generator gap)
The extract / output-parser tier still resolves and imports nested payload classes by bare name (Python: extractor_generator.py / extract_delegate_emitter.py; equivalents in the other ports). This is latent — the only cross-package collision fixture is @kind: document, which never routes through the json/xml extract path, so no shipped output is wrong today. It is exactly the "same disease in sibling generators" follow-up ADR-0044 §Consequences calls out. Recommend a dedicated issue with a json/xml collision fixture when that tier is next touched.
Activity
dmealing commentedon Jul 20, 2026
Stage 1 landed on
main:44d7d885(ADR-0044) +89b10c36(TS + C# fix). Not yet released.Scope correction — this is a five-port bug, not a C# one
Investigating turned up that every port is broken, by three different mechanisms, and none of them was caught because the corpus works around the collision:
NotePayload.java→ silent file clobber, last-winsThe reason this stayed invisible: every port's runner hand-authors a merged
Note { alphaText?, betaText? }rather than using generated output, because no generator could emit two same-named records. So payload record emission was ungated everywhere — the bug lived exactly in the gap the fixture papered over.Also note this issue's premise is stale:
389255c5is not onmain— it sits unmerged onorigin/fix/csharp-payload-generator-bare-payloadref. That branch's strip-then-bare-lookup band-aid should not merge as-is; ADR-0044 supersedes it (its test is worth keeping).The ruling — ADR-0044
One distinct emitted type per resolved VO FQN. Bare short name when unique in the artifact's reference closure; on collision every colliding member takes a package-derived name (
AcmeAlphaNote) in its declaration, file name, and all references. Resolution always FQN-exact, dedupe always FQN-keyed, naming a pure function of the closure (order-independent — no first-wins/last-wins). If derived names still collide, fail loud withERR_PAYLOAD_NAME_COLLISION.Rejected: language-native namespacing (TS has no in-file namespace, and it breaks layout/imports for the common case), fail-loud-alone (ADR-0041/0042 made this metadata valid — refusing it would be a regression), and the merged/union record (erases
@required; it is a shape no metadata declares).Not breaking — names change only where output is silently wrong today; non-colliding output is byte-identical, pinned by new exact-string no-churn tests on both ports.
Stage 1 (done)
ADR-0044 · TS payload codegen (FQN-keyed dedupe + closure-scoped naming) · C#
EmitRecordnow resolves through the FQN-exact resolverBuildTreealready used, plus theGenerateRenderHandleraw-FQN-as-type fix · the corpus contract now prohibits hand-authored payload records, and the TS and C# runners were switched to real generated types with the render pins kept byte-exact — so the gate got stronger, not weaker.Proof:
Digest.fromAlpha→AcmeAlphaNote,fromBeta→AcmeBetaNote— two distinct emitted types. TS 1001/1001 · C# 310/310 + 808/808 · workspace build/typecheck green.Remaining
ERR_PAYLOAD_NAME_COLLISIONis currently a per-port local constant, deliberately NOT yet in the sharedfixtures/conformance/ERROR-CODES.jsonledger — registering it now would redden Python's error-code coverage test. It must be promoted to the shared ledger when stage 2 lands, or it will be silently forgotten.docs(decisions): ADR-0044 payload-record naming under cross-package c…
fix(codegen): FQN-keyed payload record emission with collision-scoped…
chore(release): 0.19.2 (npm) · 0.19.2 (NuGet) — #227 form edit schema…
fix(codegen-python): FQN-keyed payload naming with collision-scoping …
fix(codegen-spring): collision-scoped payload record naming (ADR-0044, …
fix(codegen-kotlin): collision-scoped payload class naming (ADR-0044, #…
chore(errors): promote ERR_PAYLOAD_NAME_COLLISION to the shared ledge…
chore(release): 0.19.3 (npm/NuGet) · 0.19.3 (PyPI) · 7.11.2 (Maven) — #…
docs: propagate 0.19.3 (npm/NuGet/PyPI) · 7.11.2 (Maven) version refs
dmealing commentedon Jul 21, 2026
Closed — ADR-0044 collision-scoped payload-record naming is complete across all five ports and released.
What shipped, per port
89b10c36— npm + NuGet0.19.2fqn()dedupe collapsed the twoNotes (bare name when own-package unset), dropping the second shapea59c4719— PyPI0.19.3NotePayload.java→ silent file clobber, last-wins87601286— Maven7.11.2FileSpec+ #220 test upgrade753143d9— Maven7.11.2All ports now run ADR-0044's three-pass pipeline: FQN-keyed reference-closure walk → collision-scoped naming (bare
<Short>Payloadwhen unique in the artifact's collision domain;AcmeAlphaNotePayloadfor every colliding member; hardERR_PAYLOAD_NAME_COLLISIONif a derived name still collides) → emit through the name map. Not breaking — non-colliding output is byte-identical, pinned per port; each port gates thexpkg-collision/oracle (construct/compile + assert two distinct classes).Ledger
ERR_PAYLOAD_NAME_COLLISIONpromoted from per-port local constants to the sharedfixtures/conformance/ERROR-CODES.json+ the central registries that gate it — TSerrors.ts(exact bidirectional), Pythonerrors.py(superset), JavaErrorCode.java(b743634e).Released
Coordinated
0.19.3(npm / NuGet / PyPI) ·7.11.2(Maven Central) — releaseb85ce889, tagv0.19.3, all four registries verified live. (NuGet was a version-parity bump: the C# fix shipped in0.19.2and C# was unchanged here.)Known follow-up (out of scope — the ADR's stated sibling-generator gap)
The extract / output-parser tier still resolves and imports nested payload classes by bare name (Python:
extractor_generator.py/extract_delegate_emitter.py; equivalents in the other ports). This is latent — the only cross-package collision fixture is@kind: document, which never routes through the json/xml extract path, so no shipped output is wrong today. It is exactly the "same disease in sibling generators" follow-up ADR-0044 §Consequences calls out. Recommend a dedicated issue with a json/xml collision fixture when that tier is next touched.docs(roadmap): record the #210 ruling and its two blocking preludes