Commit 8760128
fix(codegen-spring): collision-scoped payload record naming (ADR-0044, #219 stage 3a)
The Java payload generator named every nested payload record after the VO's bare
short name and wrote it to `<prompts-pkg>/<Short>Payload.java`. Dedupe is
FQN-keyed (getName() is the FQN), so two `object.value` `Note`s in different
packages both reached emission — but both were named `NotePayload` and written to
the same file path, so the second silently CLOBBERED the first (last-wins),
binding the wrong shape (the xpkg-collision fixture lost the alpha shape).
Ports ADR-0044's collision-scoped naming (mirroring the TS/C#/Python reference),
adapted for Java's one-record-per-file emit — the collision domain is the OUTPUT
PACKAGE, not one file:
- `computePayloadNameMap` — a pure function of the loaded templates: walk each
template's nested-payload closure (`collectNestedClosure` / `nestedTargetOf`,
the same two edge types the emitter resolves), assign each nested VO to its
output prompts package, then per (package, short-name) group emit
`<Short>Payload` when unique (byte-identical to before) or every colliding
member as `<PkgSegmentsPascal><Short>Payload` (`AcmeAlphaNotePayload`). A
still-colliding derived name fails loud with ERR_PAYLOAD_NAME_COLLISION.
- The name map threads through the emit chain alongside the existing dedupe set,
driving the record declaration, the file name, and every reference. The api-docs
caller (JavaFieldShapes) passes an empty map → bare fallback (unchanged).
ERR_PAYLOAD_NAME_COLLISION is a per-port local constant for now (as in
TS/C#/Python), promoted to the shared ledger when the Kotlin half lands.
Gated by a new SpringPayloadGeneratorTest case that loads the SHARED xpkg
corpus and asserts two distinct package-qualified records (never a clobbered
NotePayload.java). Non-colliding output byte-identical: full codegen-spring
suite green (175). Kotlin (stage 3b), #220 render-helper coverage, the ledger
promotion, and the coordinated release follow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XeGSV3StPCcJGZNNJ4ZfAb1 parent a59c471 commit 8760128
3 files changed
Lines changed: 264 additions & 16 deletions
File tree
- server/java/codegen-spring/src
- main/java/com/metaobjects/generator
- apidocs
- spring
- test/java/com/metaobjects/generator/spring
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | | - | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| |||
Lines changed: 181 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
| |||
124 | 134 | | |
125 | 135 | | |
126 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
127 | 164 | | |
128 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |