Quellcode durchsuchen

docs: measured in the devstack - search ranks correctly with every vector released from memory

fszontagh vor 1 Monat
Ursprung
Commit
589a1a356f
1 geänderte Dateien mit 4 neuen und 0 gelöschten Zeilen
  1. 4 0
      CLAUDE.md

+ 4 - 0
CLAUDE.md

@@ -650,6 +650,10 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   **THE DROP-IN FIRST CARRIED ALL TWELVE KEYS OF THE `memory` OBJECT AND NOW CARRIES ONE, AND THE CORRECTION INVERTS THE REASON RATHER THAN RELAXING IT.** Twelve was chosen because whether the loader merges drop-ins deeply INSIDE a nested object was unknown: a one-key file is correct under a deep merge and would have reset the eviction thresholds to defaults under a shallow one, which is the shape of a key PATCH replacing a whole scope, and of `createCollection` clearing a default TTL when 0 is passed back. Carrying every current value made the question moot rather than answered, which was the right call while it was open. **The merge is RFC 7396 - objects merge recursively, arrays replace - so twelve was unnecessary, and keeping it would have been actively WRONG for a reason neither of us raised at the time: eleven duplicated values FREEZE against the package's future defaults.** A later release that lowers `eviction_threshold_percent` in `config.json` would be silently overridden by a stale copy in our drop-in, and nothing would report it - the same stale-duplicate failure this file records everywhere else, manufactured by a safety measure. Now one key, swapped after a control PROVED the other eleven were byte-identical to `config.json` so the removal could not change the effective config, with the old file backed up to `/var/backups/` and **never beside it in `conf.d`, which the loader globs**. The boot log confirmed `Merging drop-in: .../60-memory.json` and `Config assembled from 3 file(s)`. **A defensive duplicate is only free while the thing it duplicates never changes.**
   **VERIFICATION, and the one that counts is the SEARCH rather than the counts.** 2.21.2 rewrites the snapshot's vector section, so a count cannot see the failure that matters. A **fixed explicit `query_vector`** (seeded, dim 4096) was run against all five vector collections before and after: **top-5 ids AND scores identical to 8 decimal places in every one**. Counts unchanged on seven collections, a body read back with `_created_by` still `fn:justice-pa/compress` at `_version` 8, a negative control 404, and a deliberate write probe (create collection, insert, read back, delete, control 404) proving writes are accepted - which is the precise thing an emergency-pressure boot would have refused. Swap in use FELL 1147 -> 521 MB.
   **PROD HAS NOT EXERCISED THE VECTOR-RELEASE PATH, AND I WRONGLY WROTE THAT NOBODY HAD: IT IS TESTED UPSTREAM, AND THE DISTINCTION IS "UNMEASURED HERE" RATHER THAN "UNTESTED".** Prod sits at `0 evicted, pressure=normal`, so the behaviour is dormant on this box and its first episode here is still unmeasured. But the database owner exercised it before tagging, against a real LMDB mirror at zero drift: unit coverage (21 checks) asserting the vector share falls by exactly the released vectors, a reload restoring each vector BYTE-EXACT, a delete of an evicted row leaving no vector anywhere, and **an unhealthy mirror keeping vectors resident** - which is the precondition itself under test; plus an e2e on a real server where 300 dim-4096 rows under a 16 MB budget evicted 893 rows, the line went to `of which vectors 0 MB`, and after two snapshots and a restart it read exactly 4 MB with search intact. Reverting each part fails a check. **"Deployed, not tested" was a claim about THEIR work that I had no evidence for and did not ask about before writing** - the measurement I was missing was mine, and the fix was one question. Say "unmeasured in our deployment", which is what was actually true.
+  **NOW MEASURED IN OUR OWN STACK, IN THE DEVSTACK, AND IT IS A DIFFERENT TEST FROM THEIRS: SEARCH THROUGH OUR HTTP API RANKS CORRECTLY WITH EVERY VECTOR RELEASED FROM THE DATABASE'S MEMORY.** Their e2e covers the database alone; the question that is ours crosses the layer boundary, because `similaritySearch` has to rank rows whose vectors are no longer resident. Built with the real debs at prod's exact versions (database 2.21.2-1, client 2.20.0-1, vectorapi 0.18.0-1) in `packaging/devstack`, 492 rows at dim 4096, budget forced to 8 MB through a `conf.d` drop-in.
+  **The design is a true before/after where eviction is the ONLY variable**, because a post-eviction pass on its own cannot say whether the ranking was already wrong: boot at a 256 MB budget so all 492 vectors are resident (`of which vectors 7 MB, 0 evicted`), take the ranking, then boot the same volume at 8 MB so eviction must fire, and take it again. Boot at 8 MB logged `Eviction chunk: 492 docs evicted, 8133620 bytes freed` and the line after the probe read **`0 MB estimated (0%), of which vectors 0 MB, 0 docs, 491 evicted`** - nothing resident at all.
+  **Result: six self-neighbour probes at exactly 1.0 and a 10-deep fixed-vector ranking, IDENTICAL to 6 decimal places between all-resident and all-released.** And the searches did not quietly undo the condition: vectors stayed at 0 MB with 0 docs resident across repeated full-collection searches, so the ranking really was served from LMDB rather than from a hot-load. **FALSIFIED before being believed:** deleting the top-ranked row changed the ranking and dropped that row, with rank 10 backfilling - so the probe tracks live vector state and the identical result was a real pass rather than a frozen answer. The eviction accounting is visible per document at **16,622 bytes freed** - 16,384 of vector plus a ~240-byte body - which is the release itself, not an inference.
+  **TWO INCIDENTAL FINDINGS FROM THE SAME RUN, BOTH ABOUT OUR SIDE.** First, **memory emergency reaches a caller as HTTP 429 `memory_pressure`**, measured: `{"error":{"code":"memory_pressure","message":"Insert rejected: memory pressure emergency (95% of max, threshold 95%). Retry after backoff."}}`. That is the right class - it is retryable and says so - but it lands in novitax's `RETRYABLE = {429, 502, 503, 504}` at 3 attempts and 500 ms, which is far shorter than an eviction drain, so they would exhaust their retries and surface a failure, while toloajto's `postValidate()` returns null on any non-2xx. So the 512-budget option would not have been silent for consumers; it would have been a burst of retried 429s. Second, **vectorapi's own startup `createCollection` bootstraps are REJECTED under emergency pressure** (`Client::createCollection failed: CreateCollection rejected: memory pressure emergency`), logged at error and tolerated, startup continuing normally. That is the same shape as the read-only case `ProjectSecretStore::ensure` keeps its guard for, with a new cause - and the consequence is that the unconditional `KeyStore`/`SettingsStore` encryption-flag repair silently does not happen on such a boot. It is self-healing on the next healthy boot, so it is a note rather than a defect, but "the bootstrap ran" must not be inferred from a successful start.
   **AND MY PROBE SWALLOWED AN ERROR WHILE TAKING THE BASELINE, WHICH WOULD HAVE POISONED THE COMPARISON.** The first pre-upgrade run reported `novitax:kb_fact_answers` as `top: []` with a null `filter_mode`; that was an error envelope with no `results` key, not an empty result, and the parser turned it into a legitimate-looking empty baseline that the post-upgrade run would have "matched" or "fixed" for reasons unrelated to the upgrade. A retry succeeded immediately. The rewrite distinguishes a missing `results` key from an empty one, records the envelope verbatim and retries three times - **an absent field and an empty field must never render the same in a baseline you intend to diff.**
   **RSS IS DELIBERATELY NOT QUOTED AS THE COST: 1232 MB was a 19-hour-old process and 1595 MB is a fresh boot**, so that difference is the restart. `VmHWM` moving 1,771,136 -> 1,780,676 kB is the only clean statement available and says the boot peak barely changed. Box-wide swap in use FELL, 646 MB to 259 MB.
   **Provenance survives adoption, and it had to be checked rather than assumed:** `justice-pa:facts/01a116ef1b2edf735dd281c3f564` reads back at `_version` 2 with `_created_by` still `fn:justice-pa/compress`, control a neighbouring id that never existed still `not found`. An adoption that took the insert path would have re-created rows at version 1 with a fresh creator - which is exactly the pre-2.20.2 ghost-clobber behaviour, and novitax now depends on `_created_by` as their only after-the-fact attribution channel.