Commit 2999e44
authored
fix(neo4j): carry module.source and span byte offsets so the graph can resolve text (#255)
Canonical decision D1 makes `module.source` the primary text and every narrower
node's text a byte-slice of it — it dropped per-callable `code` from
`analysis.json` on exactly that ground. The JSON projection obeys it. The graph
projection inverted it: `:JModule` carried no `source`, while `:JCallable` kept
the one derivation D1 deleted.
The source was already in hand where the graph is written — `V2GraphProjector`
calls `module.getSource()` to slice `code` out of it — so this was an omission
rather than missing data.
The flattened span was the other half of the same defect. `putLines` emitted
`start_line` / `end_line` only, dropping the columns and the UTF-8 byte offsets,
though the JSON schema defines `span.bytes` as "[from, to) UTF-8 offsets into
module.source, so node text is an O(1) slice". Carrying `source` without the
offsets would not have made anything sliceable.
Together the two gaps meant nothing narrower than a callable resolved to text at
all: python-sdk's reconstruction reports `source=""` and hardwires
`_body_source` to `None`, both for want of these facts.
- `:JModule` carries `source`, coalesced from null to `""` so it is always
present — `RowBuilder.prune` drops nulls, and the projections would otherwise
disagree about whether the property exists.
- The flattened span carries `start_column`, `end_column`, `start_byte`,
`end_byte` beside the line pair. These four names are new shared vocabulary:
codeanalyzer-python and codeanalyzer-typescript both flatten to the line pair
alone and must adopt these spellings rather than coin their own.
- A conformance test asserts every `:JModule`'s `source` equals the
`analysis.json` module source per module, not by presence, so a truncated or
placeholder value fails.
Verified on daytrader8: 141 of 141 modules carry `source`, each hashing to the
`content_hash` its own row declares, which proves the value survives Cypher
escaping; and `source[start_byte:end_byte]` equals the node's existing `code`
byte-for-byte for all 662 callables where both are present, zero mismatches.
`JCallable.code` is now provably redundant but stays — python-sdk reconstructs
from it, so removing it is a separate breaking change. `schema_version` stays at
the held 2.0.0 baseline, so this is not detectable from the payload.
Closes #2541 parent c3d0b68 commit 2999e44
4 files changed
Lines changed: 110 additions & 13 deletions
File tree
- src
- main/java/com/ibm/cldk/neo4j
- test/java/com/ibm/cldk/neo4j
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
75 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
98 | 107 | | |
99 | 108 | | |
100 | 109 | | |
101 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
102 | 115 | | |
103 | 116 | | |
104 | 117 | | |
| |||
111 | 124 | | |
112 | 125 | | |
113 | 126 | | |
114 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
115 | 132 | | |
116 | 133 | | |
117 | 134 | | |
| |||
157 | 174 | | |
158 | 175 | | |
159 | 176 | | |
160 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
| |||
214 | 235 | | |
215 | 236 | | |
216 | 237 | | |
217 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
218 | 243 | | |
219 | 244 | | |
220 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
121 | 128 | | |
122 | 129 | | |
123 | 130 | | |
| |||
717 | 724 | | |
718 | 725 | | |
719 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
720 | 735 | | |
721 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
722 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
723 | 744 | | |
724 | | - | |
| 745 | + | |
725 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
726 | 754 | | |
727 | 755 | | |
728 | 756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
91 | 100 | | |
92 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
93 | 104 | | |
94 | 105 | | |
95 | 106 | | |
| |||
113 | 124 | | |
114 | 125 | | |
115 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
116 | 131 | | |
117 | 132 | | |
118 | | - | |
| 133 | + | |
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
| |||
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | | - | |
| 128 | + | |
| 129 | + | |
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| |||
282 | 284 | | |
283 | 285 | | |
284 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
285 | 314 | | |
286 | 315 | | |
287 | 316 | | |
| |||
0 commit comments