Skip to content

Rank bounded file evidence before span projection - #205

Open
Skyline-23 wants to merge 5 commits into
NanoNets:mainfrom
Skyline-23:feat/bounded-file-evidence
Open

Rank bounded file evidence before span projection#205
Skyline-23 wants to merge 5 commits into
NanoNets:mainfrom
Skyline-23:feat/bounded-file-evidence

Conversation

@Skyline-23

Copy link
Copy Markdown
Contributor

Context

The selection-only projection merged in #137 prevents sibling spans from consuming a bounded prefix, but it intentionally preserves the existing file order. A relevant file whose query evidence is split across sibling symbols can still rank below a less complete single-symbol match.

This PR ranks complete file candidate groups before projecting their exact spans, while keeping score ownership on one real candidate.

Fixes #204.

This branch is based directly on current main and is independent of #203. It uses the existing filtered PageRank path, so either PR can be reviewed and merged first.

Retrieval effect

A 186-case fixed-base comparison across Django, Nest, PocketBase, and Spring Boot produced:

metric current this PR change
Natural R@10 53.6% 56.6% +3.0pp, 95% CI +1.0 to +5.6pp
Recall within 400 tokens 46.6% 54.3% +7.7pp
Median pack tokens 668 366 -45.3%
Stem-blind R@10 34.1% 34.9% +0.8pp

R@10 improved in 7 cases and regressed in 0. The first result was exact in 186/186 cases, with no repository-level or stem-blind regression.

This is a retrieval-quality and context-budget result, not a query-latency claim.

Changes

  • Pool complementary query-term coverage into one lexical anchor per file.
  • Bound the residual gain by anchor coverage and remaining lexical headroom.
  • Preserve graph-only, residual, singleton, and sibling candidates at baseline.
  • Carry lexical, graph, and rank-factor components through comparable-scope fusion.
  • Collapse complete candidate sets to one representative per file before scope participation and final ranking.
  • Project distinct file leaders first, then retain exact secondary span queues.
  • Lock the exact baseline top hit.

Safety invariants

  • One real candidate owns every score; maxima from different candidates are never combined.
  • Duplicate terms and raw sibling magnitude cannot amplify a file.
  • Test-file priors remain outside the pooled lexical component.
  • Concepts and non-file structural results remain singleton groups.
  • Equal-score files and secondary queues preserve the existing deterministic tie order.
  • There is no hard per-file quota.

Validation

  • npm ci / package prepare build: passed
  • Focused ask, file-rank, selection, and fusion tests: 68/68 passed
  • Full local suite: 933/934 passed
  • git diff --check: passed

The sole full-suite failure is the existing viz --tabs: a bad tab name fails loudly clean-worktree failure. It is unchanged from current main, whose CI is already red on Ubuntu and Windows: https://github.com/NanoNets/Graft/actions/runs/32722784307

Final diff: 8 files, +1519/-58.

- Pool complementary query coverage into one lexical anchor per file
- Keep graph-only, residual, and sibling candidates at their baseline scores
- Preserve score bounds, deterministic queues, and anchor-owned evidence
- Preserve lexical, graph, and rank-factor components until final combination
- Add an optional candidate-collapse seam before comparable-scope participation
- Keep the default scalar fusion path unchanged when no collapse is supplied
- Add a bounded round-robin projector for already ranked file queues
- Stop projection as soon as the requested result prefix is complete
- Keep the existing grouping helper and ordering semantics unchanged
- Collapse complete candidate sets into one bounded representative per file
- Preserve the exact baseline top hit while projecting distinct file leaders first
- Keep concepts, residual nodes, test priors, and multi-scope score ownership intact
- Carry the existing final-list tie key into bounded file ranking

- Keep equal-score representatives and secondary queues aligned with baseline order

- Cover conflicts between lexical strength and the caller's tie order
github-actions Bot added a commit that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ask: complementary evidence split across sibling symbols is not ranked at file level

1 participant