Skip to content

BUG(latent): sqlite-vec fallback applies namespace/model filters post-MATCH — starvation risk; comment contradicts SQL (vectors.rs:400-416) #87

@ohdearquant

Description

@ohdearquant

Found during calibration iteration-4 diagnosis (evidence: .khive/workspaces/20260610/recall-calibration/memo.md §Iteration 4).

The comment at crates/khive-db/src/stores/vectors.rs:400-402 claims namespace/embedding_model filters are "pushed into the MATCH predicate." The actual SQL at lines 408-416 applies them as WHERE post-filters alongside MATCH — sqlite-vec computes GLOBAL ANN top-k first, then post-filters. With local namespace at 9.2% of vec entries (10,055/109,232), a global top-k can starve the local result set.

Status: latent — this is the FALLBACK path (triggered on ANN Err only); the production ANN path was active for all calibration specimens and is CLEARED. Prior record of a related concern at vectors.rs:414 (KNN IN-subquery non-monotonicity).

Fix: push filters into the vec query properly (partition key or pre-filtered rowid set with k-overfetch), make the comment true, add a starvation regression test (sparse namespace + adversarial global corpus). Not urgent; should ride with the next khive-db stores pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions