Repository navigation
fix: Filter SQLite semantic candidates before KNN cap - #716
rupayon123 wants to merge 6 commits into
Conversation
|
Thanks for this. It's a careful fix, and it holds. A review checked it in a throwaway tree with the patch applied, with the KNN ceiling set to 8 over 120 entries in two KBs:
Three small things before merge:
One note, not for this PR: the readable-KB scope is still applied after KNN, so a scoped search without Automated review by an agent for the maintainer; comment only. |
The small candidate budget now exercises each supported caller filter, zero matches, and hybrid search. Keep the sqlite-vec floor at the original supported version after testing the filtered query on 0.1.0.
|
Updated on |
Thank you for working through the review points so quickly. I read the new head (c369825); its checks pass (gate, test 3.12, verify-red, experimental). Matches the issue
Differs from the groom
Overlaps another open pull request
Housekeeping
This is a first pass for the maintainer, who makes the review decision. Generated by Claude Code |
|
Thanks for catching the remaining coverage gap. I restored the declared On the current head, I added small-cap regressions where nearer candidates from another knowledge base and archived entries would otherwise fill the KNN budget before an eligible result is considered. The existing The exact PR head is |
|
Thanks for the second pass. I checked the two special filters against the current branch rather than folding them into the generic value-filter matrix: I also confirmed the version-specific wording you flagged is gone; the backend comment now only documents the sqlite-vec 0.1.9 If you intended a separate small-cap assertion for |
|
Thanks for the follow-up. I added an explicit |
Thank you for the quick, thorough rounds on #194. I read the current head (d4f18db); its checks pass (gate, test 3.12, verify-red, experimental). Matches the issue
Differs from the groom
Overlaps another open pull request
Tests
Housekeeping
This is a first pass for the maintainer, who makes the review decision. Generated by Claude Code |
Summary
Filtered SQLite semantic search previously applied caller predicates after sqlite-vec's KNN candidate limit. On large indexes, nearby rows outside the filter could exhaust the 4096 ceiling and hide matching rows. This change adds the same candidate predicate to the KNN query, keeps the outer checks, preserves the unfiltered query shape, and raises the declared sqlite-vec minimum to 0.1.6, the lowest version verified here.
Fixes #194.
Plan / claim
Claim: #194 is fixed by applying the SQLite entry filters inside KNN before sqlite-vec applies its candidate budget. The regression test injects a small ceiling and verifies matches beyond that budget. Postgres is unchanged.
The maintainer's sqlite-vec 0.1.6 spike showed
rowid IN (SELECT ...)works in the KNNWHERE. This branch also exercised it throughSQLiteBackendwith the extension at 0.1.6 and confirmed matchingentryandvec_entryrowids.Testing
scripts/test-affected --run -n 4gate: passed.ruff check,ruff format --check,git diff --check, and commit hooks: passed.Notes for the reviewer
The subquery is used only when caller filters are supplied; the unfiltered hot path remains unchanged. It avoids a schema migration or embedding rebuild. The existing escalation remains necessary for
max_distanceculling and is now tested separately. I found no cap-specific warning in the semantic service to remove; the SQLite backend documentation now describes the remaining cap and distance-culling limits.