Skip to content

Simplify expand_beam_accept_only pre-filter predicate#1192

Open
hildebrandmw wants to merge 1 commit into
mainfrom
mhildebr/filtered-followup
Open

Simplify expand_beam_accept_only pre-filter predicate#1192
hildebrandmw wants to merge 1 commit into
mainfrom
mhildebr/filtered-followup

Conversation

@hildebrandmw

@hildebrandmw hildebrandmw commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

#1141 introduced the FilteredAccessor trait with two expand_beam style methods. This split existed because evaluation of the HybridPredicate differed subtly between the "all" and "accept only" paths, but this difference was sufficient to completely tank recall in multi-hop filtered search if rejected IDs were passed to the PredicateMut. The two-method solution made this harder, but at the cost of needing to create a new Accept type to pass to Predicate even before a decision had been made, which is confusing.

I think this cleans up that confusion by changing the bound on expand_beam_accept_only from

P: HybridPredicate<Accept<Self::Id>>

to

P: Predicate<Self::Id> + PredicateMut<Accept<Self::Id>>

This makes it clear that raw, unclassified IDs can be used for the non-mutating evaluation while only accepted IDs can be passed to eval_mut. The docs have been updated to reflect that the rules of HybridPredicate also apply to this pair of traits.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the FilteredAccessor::expand_beam_accept_only predicate contract to make the “pre-filter vs accepted-only mutation” distinction explicit, reducing confusion around when Accept<Self::Id> must be constructed and passed to eval_mut.

Changes:

  • Change expand_beam_accept_only from P: HybridPredicate<Accept<Self::Id>> to P: Predicate<Self::Id> + PredicateMut<Accept<Self::Id>>.
  • Update the labeled FilteredAccessor adaptor (ext/labeled.rs) to match the new predicate bounds and evaluation flow.
  • Remove now-unneeded NotInMut impls for Predicate<Accept<T>> / HybridPredicate<Accept<T>>.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
diskann/src/graph/glue.rs Updates expand_beam_accept_only trait bounds/docs and prunes NotInMut impls that are no longer required by the new API.
diskann/src/graph/ext/labeled.rs Adapts the QueryLabelProvider-based FilteredAccessor wrapper predicate logic and bounds to the new accept-only predicate split.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread diskann/src/graph/glue.rs
Comment on lines +457 to +460
/// The [`Predicate`] bound takes unclassified IDs and is side-effect-free, so it can
/// pre-filter IDs before paying the cost of classification. As with [`HybridPredicate`],
/// implementors can assume that [`Predicate`] and [`PredicateMut`] "get along" with
/// respect to `eval(id)` and `eval_mut(Accept::new(id))`.
@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.07%. Comparing base (3aa44ac) to head (47d7c4f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1192      +/-   ##
==========================================
+ Coverage   89.46%   90.07%   +0.61%     
==========================================
  Files         487      487              
  Lines       92170    92322     +152     
==========================================
+ Hits        82460    83160     +700     
+ Misses       9710     9162     -548     
Flag Coverage Δ
miri 90.07% <100.00%> (+0.61%) ⬆️
unittests 89.73% <100.00%> (+0.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann/src/graph/ext/labeled.rs 95.91% <100.00%> (-1.54%) ⬇️
diskann/src/graph/glue.rs 86.02% <ø> (+1.36%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

5 participants