← Back to Pull requests

NodeQueue.rerank: handle topK == 0 #812

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

Fixes #811.

What

NodeQueue.rerank no longer tries to evict from the reranked queue when topK == 0. The eviction branch is now else if (topK > 0 && exactScores[i] > reranked.topScore()), so with topK == 0 every candidate falls through to the existing else and goes to the unused pile, and the method returns Float.POSITIVE_INFINITY as it already does when fewer than topK results were reranked.

Previously, with an empty reranked queue, topScore() and topNode() read a stale heap slot and the following approximateScoresById.get(evictedNode) returned null, which threw while unboxing.

Results

2,000 x 64-d Gaussian vectors, 200 queries, a fresh GraphSearcher each, search(ssp, 0, 10, NEGATIVE_INFINITY, 0.0f, Bits.ALL):

| | main | this branch |
|---|---|---|
| EUCLIDEAN, DOT_PRODUCT, COSINE; reranker only, and PQ + reranker | NPE in 200 / 200 each | 0 / 200 each, empty result |

The reproducer in #811 throws on main and prints topK=0 rerankK=10: 0 results on this branch.

Tests

TestNodeQueue.testRerankWithZeroTopKLeavesEverythingUnused calls rerank(0, ...) on a queue of five candidates and asserts that nothing is reranked, all five end up in the unused pile and the return value is POSITIVE_INFINITY. It fails on the previous condition with the same NullPointerException and passes with this change (checked by restoring the original condition).

Also run and passing: TestNodeQueue, TestVectorGraph, GraphIndexBuilderTest, TestDeletions, TestLowCardinalityFiltering, OnHeapGraphIndexTest, TestOnDiskGraphIndex, TestFusedGraphIndex (69 tests, 2 skipped as before). I did not run the full suite or the native module.

Diff: 212 lines (+159 / -53) across 2 files Reviewer: MarkWolters Review duration: 1851m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 212 lines diff across 2 files
0.37
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.321
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #812"
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: 36.5% (MEDIUM) · Higher = larger blast radius
36.5%
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: 14.4% · Safe to merge
14.4%