fix(rag): reject explicit bm25_k1 = 0 and rrf_k = 0 instead of substituting defaults (#1056)

AD
3d ago
+818-52

0 is the "unset" sentinel from QueryOverrides down to BM25Index/fuse_rankings, so an explicit bm25_k1 = 0 or rrf_k = 0 was silently replaced by 1.2 / 60. This takes the issue's second option: both are now rejected (> 0 required) at the session-config and per-query ABI boundaries and in the retrieve operator params, and the four binding doc comments (Swift, Kotlin, Python, Web) state > 0. bm25_b = 0 stays valid. Tests: ABI search with zero bm25_k1 / rrf_k returns INVALID_ARGUMENT; solution-runner retrieve params reject 0.

Stacked on #1048 (which is stacked on #1017), so the diff includes their commits until they merge.

Closes #1056


Summary by cubic

Rejects explicit bm25_k1 = 0 and rrf_k = 0 instead of silently substituting the 1.2 / 60 defaults, because 0 is the "unset" sentinel all the way down the stack; both must now be > 0. bm25_b = 0 stays valid.

Validation

  • BM25 and RRF values are checked at the session-config and per-query ABI boundaries and in retrieve operator params: zero, non-finite, and out-of-range values are rejected.
  • Floats parse and format with the classic locale, so malformed strings ("30junk", "0,8") fail rather than being silently defaulted.
  • The on-device vector store is whitelisted to USEARCH; PGVECTOR is rejected and unknown enum values are invalid arguments.
  • RRF accumulates in double sortable precision so tuned scores don't tie.

Threading

  • BM25 k1/b, RRF k, and vector-store knobs are wired through the retrieve backend, graph inputs, and the Swift, Kotlin, Python, and Web bindings; VectorStore moved into an enum in rag.proto (schema 1.7.0), replacing the one in solutions.proto.

Closes #1056. Also includes the stacked changes from #913 and #1019.

Summary by CodeRabbit

  • New Features
    • RAG queries can override BM25 tuning, reciprocal-rank fusion settings, and vector-store selection. Unspecified options continue to use session defaults.
    • The on-device USEARCH vector store is available through the Kotlin, Python, Swift, and web SDKs.
  • Validation
    • Invalid retrieval settings are rejected, including out-of-range BM25 values, non-positive RRF values, and unsupported vector-store selections.
  • Improvements
    • Retrieval results with equal scores now appear in a consistent order.