Reconnect nodes left unreachable by cleanup() #805
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #805"
general
weight: 0.35
MarkWolters
Fixes #804.
What
GraphIndexBuilder.cleanup()now repairs nodes that pruning left unreachable from the entry node in layer 0, asreconnectOrphanedNodes()did before it was removed in #402.After
enforceDegree(), each unreachable node gets an in-edge from the closest reachable neighbor it already links to, or, if none is usable, from the best reachable search result that is not yet a connection target. The edge goes through the existingConcurrentNeighborMap.insertEdgeNotDiverse(), which evicts the target's worst neighbor, so the degree cap still holds. Because an eviction can orphan another node, this repeats for up to five passes and stops early when a pass reconnects nothing.Details that matter, several of them found by mutation testing the first version of this PR (PIT, then hand-applied mutants):
Float.NEGATIVE_INFINITY, not0.0f, for the search and its resumes. DOT_PRODUCT scores are(1 + dot) / 2, negative for non-normalized vectors, asGraphSearcher.internalSearchalready handles.insertEdgeNotDiverseis exposed on the package-privateMutableGraphIndexinterface (one implementor,OnHeapGraphIndex). No public API changes.This is a port adapted to the current layer/view API, not a restore of the old code.
Results
Nodes unreachable from the entry node after
cleanup(),mainvs this branch (JDK 26, macOS arm64, Panama provider):| Build |
main| this branch ||---|---|---|
| 100k x 1024-d, cosine, M=32, beam=100, flat (two runs) | 55, 45 | 0, 0 |
| 100k x 1024-d, M=16, beam=200 | 856 | 0 |
| 50k x 128-d | 4 | 0 |
| 600 x 32-d uniform, M=8, beam=16, 20 seeds, flat and hierarchical (reproducer in #804) | 20 of 20 graphs affected | 0 |
| 600 x 32-d uniform, 20 seeds, flat: nodes that never return themselves when queried with their own vector (k=10, rerankK=200) | 205 of 12,000 | 20 |
| same, hierarchical | 193 of 12,000 | 23 |
| 1600 x 2-d, 8 tight clusters, M=8, 6 seeds, flat: layer-0 reachable / never return themselves | 4,937 / 5,440 of 9,600 | 9,600 / 2,395 |
| same, hierarchical | 2,398 / 10 of 9,600 | 9,600 / 3 |
| 200 x 2-d DOT_PRODUCT around (10, 0) plus one (-10, 0) inserted at positions 25, 50, 100, 150, 200 | the odd node unreachable at all five | reachable at all five |
Cost:
cleanup()on the 100k x 1024-d build took 601 and 656 ms onmainand 722 and 780 ms on this branch (the machine was busy, so treat as order of magnitude; the repair is a single-threaded reachability walk plus one search per unreachable partition).Randomized fuzzer (random dimension, M, beam, overflow, alpha, similarity function, hierarchy, parallel vs sequential build, duplicates, two waves of deletions with
cleanup()after each), 300 graphs: no exceptions and no structural violations (degree bound, self or duplicate edges, edges to deleted nodes, entry node validity) on any version. Unreachable nodes: 26,977 in 202 graphs onmain, 51 in 11 graphs on this branch; exhaustive-beam searches returning too few or worse results: 292 onmain, 5 here. What remains is mostly M=2 graphs.Tests
testCleanupLeavesEveryNodeReachable: 600 x 32-d uniform, M=8, six seeds, flat and hierarchical.testCleanupReconnectsDisconnectedClusters: 1200 x 2-d points in 8 tight clusters, six seeds, flat and hierarchical.testCleanupReconnectsNodeWithOnlyNegativeSimilarities: the DOT_PRODUCT case above.Each fails without the corresponding change (the cluster test on the previous version of this PR: 296 of 1200 reachable for the hierarchical seed 0; the dot-product test: 200 of 201) and passes with it. The first one fails with
reconnectOrphanedNodes()removed (599 of 600).Also run on this branch, all green (116 tests, 2 skipped as before):
GraphIndexBuilderTest,TestVectorGraph,TestDeletions,OnHeapGraphIndexTest,Test2DThreshold,TestHierarchyDotProductSearch,TestLowCardinalityFiltering,TestConcurrentReadWriteDeletes,TestConcurrentBufferedGraphConstruction,TestOnDiskGraphIndex,TestOnDiskGraphIndexCompactor,TestBufferedGraphCompatibility,TestGraphIndexBuilderConfig,TestNeighbors,TestPruningCompatibility,TestBuildScoreProviderAnchorReads,TestBuildScoreProviderBorrowedVectors,TestFusedGraphIndex. I did not run the full suite or the native module.Known limits
main(10 of 9,600 nodes never return themselves, despite 7,202 being unreachable in layer 0); and in the flat cluster case, with every node reachable, 2,395 of 9,600 still do not return themselves withk=10,rerankK=200, so reconnecting does not make weakly connected clusters fully searchable, only reachable.cleanup(); a graph with very many separate unreachable partitions would cost one search each. I have not measured 1M+ nodes.addGraphNodeandimproveConnections(existing code, not changed here). With non-normalized DOT_PRODUCT data this can leave a graph badly fragmented beforecleanup()runs, which this PR then repairs, but it is better not to create the fragmentation; I will file that separately.