← Back to Pull requests

GraphIndexBuilder: search with NEGATIVE_INFINITY, not 0.0f #814

Closed
unknown closed this pull request without merging on Nov 21, 2026 16:13 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 22:22 UTC
Author

Fixes #813.

What

GraphIndexBuilder now searches with Float.NEGATIVE_INFINITY instead of 0.0f in addGraphNode (searchOneLayer for the upper layers and the layer-0 resume) and in improveConnections: five constants. GraphSearcher.internalSearch already does this for the same reason.

For COSINE and EUCLIDEAN nothing changes, since their scores are never negative (and NaN fails >= 0.0f and >= -Infinity alike). For DOT_PRODUCT the scores are (1 + dot) / 2, negative for non-normalized vectors, and a 0.0f floor discarded every candidate of a node that is dissimilar to everything else.

git diff main shows only those five arguments and the comments that explain them.

Results

200 x 2-d vectors around (10, 0) plus one (-10, 0), DOT_PRODUCT, M=8, beam=40, flat, measured right after insertion (no cleanup()); the entry node is node 0 in every run:

| odd vector inserted at | main: its out-degree / mean out-degree / results of a 10-result query | this branch |
|---|---|---|
| 0 (it is the entry node) | 0 / 0.00 / 1 | 5 / 4.52 / 10 |
| 25 | 0 / 3.84 / 10 | 2 / 4.42 / 10 |
| 50 | 0 / 3.84 / 10 | 5 / 4.39 / 10 |
| 100 | 0 / 3.84 / 10 | 2 / 4.21 / 10 |

The reproducer in #813 prints exactly these. When the dissimilar vector is not the entry node only that vector is affected. When it is the entry node, main builds an index with no edges at all and a search returns one result.

I make no claim about reachability from the entry node: this data set is poorly connected with or without the odd vector (18 of 200 nodes reachable from the entry before cleanup(), identically on both), which is a separate matter.

Recall is unchanged on ordinary non-unit data (20,000 x 128-d clustered Gaussian, DOT_PRODUCT, M=32, beam=100, data scaled by 1.0 / 0.3 / 0.1 / 0.03): 1.0000 / 0.9997 / 0.9997 / 0.9993 on main, 1.0000 / 1.0000 / 0.9997 / 0.9993 here.

Tests

GraphIndexBuilderTest.testNodeWithOnlyNegativeSimilaritiesGetsNeighbors inserts the odd vector at positions 0, 25, 50 and 100 and asserts it has at least one neighbor right after insertion. It fails on main ("node 0 has no neighbors") and passes with this change.

Also run on this branch, all passing (108 tests, 2 skipped as before): GraphIndexBuilderTest, TestVectorGraph, TestDeletions, OnHeapGraphIndexTest, Test2DThreshold, TestHierarchyDotProductSearch, TestLowCardinalityFiltering, TestConcurrentReadWriteDeletes, TestConcurrentBufferedGraphConstruction, TestOnDiskGraphIndex, TestOnDiskGraphIndexCompactor, TestBufferedGraphCompatibility, TestGraphIndexBuilderConfig, TestNeighbors, TestPruningCompatibility, TestFusedGraphIndex. I did not run the full suite or the native module.

Notes

This is independent of #805 (different lines in GraphIndexBuilder). Callers that pass a threshold of 0 to GraphSearcher.search themselves are not affected by this change.

Diff: 366 lines (+274 / -92) across 4 files Reviewer: MarkWolters Review duration: 1070m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 366 lines diff across 4 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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.353
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #814"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 42.7% (MEDIUM) · Higher = larger blast radius
42.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.9% · Safe to merge
16.9%