fix(core): reuse retrieval for stable rerank pagination - #1560
phernandez wants to merge 2 commits into
Conversation
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Closing as superseded, together with its base #1559. The retrieval path this PR changes is being extracted into a scope-parameterized What carries over from here when that happens: the sqlite-vec repeatable tie universe for reranker-enabled requests, the deterministic tail ordering by earliest eligible source rank, |
Why
Fixes #1557. Expanded hybrid/vector pages currently repeat retrieval to reconstruct the fixed reranker prefix. This adds a second query embedding and vector query (and a second FTS pass for hybrid) before the one reranker call.
Stacked on #1559, with base
feat/1558-multi-project-searchat0159119c7328729b7ac69be342031e072c073a6d. Neither PR is to be merged as part of this task.What Changed
stable_pool_refetched=false.Implementation Details
The request-local vector window carries prefix rows and original chunk ranks; it is not cached or stored on the repository. Hydration and filter evaluation are shared by prefix and tail.
SQLite vec0's equal-distance top-k membership changes with k, so simply slicing a larger retrieval is insufficient. Reranker-enabled SQLite requests use vec0's existing 4,096-candidate ceiling as a repeatable tie universe, then trim the requested chunk window in SQL before project/manifest filtering. Original positions survive dropped matches. The disabled path retains its existing k sizing. PostgreSQL retrieval SQL is unchanged.
Testing
[18, 8]and hybrid limits[90, 80]; the fixed path uses[18]and[90].just fast-check: passed (ruff, formatting, full ty check).just doctor: passed.just fast-checkpassed, the fixture-dependent SQLite selection passed 51 tests, and standalonetest-int/test_stable_rerank_pagination.pypassed 2 tests on each of SQLite and Postgres. ty uses pytest's existingtestsimport root.The real FastEmbed/Postgres test passed, including a 101-result request and deep pages. New regressions exercise real sqlite-vec/pgvector, API/MCP probes and later empty pages, tied similarities, mixed lexical/vector matches, multi-chunk collapse, fixed reranker document text, pending manifests, thresholds, filters, and reranking enabled/disabled. Stage-span assertions require exactly one embedding/vector span per request and one FTS span for hybrid. All 55 added executable production lines were covered by the selected SQLite run.
Risks / Follow-ups
SQLite reranker-enabled shallow requests do more bounded vec0 selection work to make ties repeatable. A local synthetic microbenchmark (384 dimensions, seed 1557, five warm iterations) compared the old two k queries (890 + 80) with one fixed-4096 query trimmed to 890: 10k vectors, 9.39 ms versus 9.98 ms; 50k vectors, 45.79 ms versus 45.48 ms. This isolates retrieval and is not a production latency or model-inference benchmark. A substantially slower scalar-distance scan was rejected.
Existing best-effort chunk headroom and backend candidate ceilings remain. No Cloud configuration, production reranker enablement, cache, locking, or admission system changes.