Commit 431c0e5
committed
fix: reconnect reverse-dep edges correctly when a sibling group's size also changes
reconnectReverseDepEdges (build-edges.ts) and its native mirror
reconnect_reverse_dep_edges (detect_changes.rs) re-attach a reverse-dep
caller's edge to its purged-and-reinserted target using a saved ordinal
rank among same-(name, kind) siblings, falling back to nearest-line
matching whenever the sibling count itself changed since save (a same-named
sibling added or removed in the same edit). That fallback is exactly the
nearest-line heuristic #1752 already proved unreliable once a same-named
group shifts far enough, so the compound scenario (shift + count change in
one incremental build) still produced call edges that diverged from a full
rebuild.
Replaces the ordinal/nearest-line two-tier heuristic with a single
alignment: match old-to-new siblings by rank when the sibling count is
unchanged (subsumes #1752's fix exactly), or by the single dominant
line-shift that best explains the surviving (untouched) siblings when the
count changed. Untouched siblings' own source text is never edited, so they
all shift by the exact same delta regardless of how far the group has
moved — finding that shift correctly identifies which old sibling was
removed (or which new one was added) without guessing based on raw line
proximity, which a uniform shift can fool (confirmed against this repo's
own real #1752 fixture numbers, where a naive minimum-distance alignment
picks the wrong element to drop).
Adds `build.reverseDepAlignmentMaxGroupSize` (default 200) bounding the
alignment's shift-histogram cost for pathologically large sibling groups,
mirrored in both engines' DEFAULTS.1 parent 25ba42f commit 431c0e5
10 files changed
Lines changed: 858 additions & 166 deletions
File tree
- crates/codegraph-core/src
- domain/graph/builder
- stages
- infrastructure
- docs/guides
- src
- domain/graph/builder
- stages
- infrastructure
- tests/integration
Lines changed: 46 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
184 | 194 | | |
185 | 195 | | |
186 | 196 | | |
187 | 197 | | |
188 | 198 | | |
189 | 199 | | |
190 | | - | |
| 200 | + | |
191 | 201 | | |
| 202 | + | |
| 203 | + | |
192 | 204 | | |
193 | 205 | | |
194 | 206 | | |
195 | 207 | | |
196 | 208 | | |
197 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
198 | 215 | | |
199 | 216 | | |
200 | 217 | | |
201 | 218 | | |
202 | 219 | | |
203 | | - | |
| 220 | + | |
| 221 | + | |
204 | 222 | | |
205 | 223 | | |
206 | 224 | | |
| |||
225 | 243 | | |
226 | 244 | | |
227 | 245 | | |
228 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
229 | 252 | | |
230 | 253 | | |
231 | 254 | | |
| |||
286 | 309 | | |
287 | 310 | | |
288 | 311 | | |
| 312 | + | |
| 313 | + | |
289 | 314 | | |
290 | 315 | | |
291 | 316 | | |
292 | 317 | | |
293 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
294 | 324 | | |
295 | 325 | | |
296 | 326 | | |
| |||
528 | 558 | | |
529 | 559 | | |
530 | 560 | | |
531 | | - | |
| 561 | + | |
532 | 562 | | |
533 | 563 | | |
534 | 564 | | |
| |||
639 | 669 | | |
640 | 670 | | |
641 | 671 | | |
642 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
643 | 678 | | |
644 | 679 | | |
645 | 680 | | |
| |||
0 commit comments