Parcourir la source

docs: a search baseline needs an explicit query_vector, not a pinned query_text

fszontagh il y a 1 mois
Parent
commit
d1d038e759
1 fichiers modifiés avec 2 ajouts et 0 suppressions
  1. 2 0
      CLAUDE.md

+ 2 - 0
CLAUDE.md

@@ -131,6 +131,8 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **Null and absent are both unconstrained on a unique index** since database 2.12.0 - only real values collide. Before that, two nulls collided.
 - **`relations_enforced` is readable since client 2.11.4** via `tryGetRelationsEnforced()`, which DECLINES to answer on a failed read rather than defaulting (`getRelationsEnforced()` is the fail-to-enforced variant, for code deciding whether it may rely on enforcement). The collection GET surfaces it, omitting the field when undetermined - absence never means disabled, so the web UI renders three states, not two.
 - **`Client::get` returns nullopt for BOTH "absent" and "transport failed"** - it throws only for PERMISSION_DENIED - so a registry lookup cannot tell them apart from the return value. Unhandled, that reaches a caller as 404 "no such collection" for a collection that exists, and a 404 is unretryable BY DESIGN for a careful client, because adding it to a retry set would retry every genuine absence. A consumer lost a 6-minute ingest of an 8 GB mailbox to exactly this. `CollectionRegistry::get` therefore **retries once** (a transient failure usually succeeds, and logs a warning saying so) and then asks `healthCheck()` before reporting absence, throwing **503** when the database is unreachable. Reported upstream too: the client should distinguish, the way it already does for a permission denial.
+- **A REPRODUCIBLE vector-search baseline needs an explicit `query_vector`. Pinning `query_text` is NOT enough.** `query_text` is embedded server-side through the external provider on *every* call - there is no query-embedding cache (`emb.embed(cfg.model, text)` in `handlers/vectors.cpp`), so the same text can yield a different vector on a different day and every score and row count moves with it. Measured by a consumer across one deploy over a byte-identical collection (12447 rows unchanged): an unfiltered top score went 0.7221 to 0.7175 and a filtered count 424 to 426, while five consecutive calls agreed to six decimals - so it is drift in text→vector, not per-call noise. The isolating test: a fixed explicit `query_vector` returned bit-identical results three times, which proves the RANKING is deterministic given a vector. **So nothing in a release has to change for such a baseline to move, and it is therefore not evidence about the release either way.** Corollary worth stating because it bit us: `scan_capped` is query-dependent too and so is also a measurement, not a property of the collection - it is set only when the walk hit the cap *while still short of `top_k`*, so a query that fills `top_k` reports false where a query that falls short reports true. Read all three of the useful assertions (`scan_capped`/`scanned`/the nested error envelope) as "this query, this filter", never as facts about the data.
+- **The embedding call IS essentially the whole vector-search latency.** Measured on prod with the ranking doing identical work both ways: a fixed `query_vector` search returned in 3.4 s against 12-15 s for the same filter and `top_k` via `query_text`. There is no query-embedding cache, so every repeated search pays the provider again.
 - **A filtered vector search can return FEWER hits than match, and the response now says so.** The walk goes only `kVectorFilterScanCap` (10000) deep into the ranking, so on a larger collection a filter whose matches lie deeper is silently short - measured at 455 returned of 553 true matches on 12448 rows. `VectorSearchResult::scanCapped` is set ONLY when the walk hit the cap while still short of `topK` and the ranking was not exhausted, so a filter that merely matches fewer rows than `top_k` is correctly reported as complete rather than crying wolf. The HTTP route adds `scan_capped`/`scanned`; `ctx...search()` keeps its ARRAY return and warns in the run console instead.
 - **Database failures keep their classification** (`db_errors.hpp`, client 2.11.4). `Client::Error::code()` on the throwing calls and the `Failure&` overloads on `update`/`patch`/`remove` feed one `translate()`: AlreadyExists → 409 `duplicate_values`, or `duplicate_id` when `reason` says so (database 2.12.1: a taken document id and a taken unique field value are the same code but different remedies), FailedPrecondition → 422 `relation_violation`, NotFound → 404, Unavailable/DeadlineExceeded/Unknown → 503, everything else → 500. **`ErrorCode::Ok` on a call that returned false means "did not apply", not an error** - map it to 404, or a plain missing document becomes a 500 with an empty message.
 - **`nlohmann::json` STORES invalid UTF-8 and throws only when you serialise it.** A binary `/fn` request body therefore reached the run request intact and blew up at `dump()` with `type_error.316`, which surfaced as a **500 with nothing pointing at the body** while the function never ran. `triggerBodyFields()` (`functions/trigger_body.hpp`, pure) now offers unserialisable bytes as base64 under their OWN keys - `body` stays `null`, `bodyBase64` carries them, `bodyEncoding` is `"base64"` - because base64 placed in `body` would hand an unprepared function a plausible-looking string that is not what was sent, and silent corruption is worse than a visible `null`. `bodyEncoding` is absent for a text body, so an existing function's trigger shape is unchanged. **`isValidUtf8()` (`utf8_text.hpp`) must agree with nlohmann's own decoder, not with a reading of RFC 3629** - a sequence it accepted and nlohmann rejected would only move the 500 - so it refuses overlongs, the surrogate range and anything past U+10FFFF, and the tests cross-check it against a real `dump()` over every single byte and all 65536 two-byte sequences rather than trusting either side alone.