Переглянути джерело

docs: say what content_sha256 does NOT cover

NOT IN THE PUBLISHED 0.12.0. That version is already built and in the apt
repo, and a published version number is never reused for different content,
so this ships in the next release.

Our docs gave the digest's exact construction, that it covers order, and
that it is not a per-row hash - everything needed to recompute it, and
nothing about its limits. It covers the ids, the vector bytes and the order,
and no other document field. A restore that reproduced every embedding
perfectly while losing every label, tenant marker and piece of text in every
document matches the digest exactly.

Found by a consumer in their OWN backup note, after a caveat I added almost
in passing. Theirs had said the digest comparison was "the only thing that
actually proves a restore" - true of the vectors, false of everything else in
the row, and false in the reassuring direction. They corrected it and pointed
at the separate copy that answers for their metadata.

It belongs here because this file is upstream of their notes: a wrong or
incomplete sentence in these docs has already propagated into two consumers'
notes once, which is why "the search operator ignores the field" is written in
capitals three bullets above. A digest documented only by its construction
invites the reader to supply its scope, and the scope they supply is "the
restore is proven".

The sharper half is the consumer's: the live retrieval check has the SAME
blind spot. A row is its own nearest neighbour at score 1.0 whatever its other
fields hold. So the two checks people naturally pair - the digest and the
similarity read-back - do not between them see a metadata loss, and both are
in our own restore-verification advice.
fszontagh 1 місяць тому
батько
коміт
307c6f190c
2 змінених файлів з 1 додано та 1 видалено
  1. 1 0
      api/llms.txt
  2. 0 1
      api/openapi.json

+ 1 - 0
api/llms.txt

@@ -82,6 +82,7 @@ Arbitrary JSON CRUD under a `kind=json` collection.
   **The exact construction, so you can recompute it rather than only echo it.** ONE rolling SHA-256 over every row in stream order, feeding exactly:
   `id` (UTF-8 bytes, not length-prefixed) || `0x1F` || the vector as float32 little-endian (ZERO bytes when the row has no vector) || `0x1E`
   The two separators are load-bearing: without them `"ab"+"c"` and `"a"+"bc"` would hash alike. It is NOT a hash per row combined afterwards, and it is NOT over the vector alone.
+  **WHAT IT DOES NOT COVER, because a digest is routinely read as proving more than it does.** It covers the ids, the vector bytes and the ORDER. It covers NO OTHER DOCUMENT FIELD. A restore that reproduced every embedding perfectly while losing every other key in every document - every label, every tenant marker, every piece of text - matches this digest EXACTLY. So `content_sha256` reproducing is not "the restore is proven"; it is "the embeddings and their order are proven". The metadata needs its own witness, and you must know which copy of your data answers that question before you need it at 3am. A consumer found this in their own backup note, which had said the digest comparison was "the only thing that actually proves a restore" - true of the vectors, false of everything else in the row, and false in the direction that looks fine. Note the live retrieval check has the same blind spot: a row is its own nearest neighbour at score 1.0 whatever its other fields say, so the two checks people usually pair do not between them see a metadata loss.
   **Because it is ONE hash across the stream, it covers ORDER as well as content:** an export carrying every correct row in a different sequence does NOT match. Per-row digests combined afterwards would have accepted that, so this is a stronger guarantee than it first looks - and it is why the recipe above must be applied in stream order rather than to a sorted set of rows. **FEED THE ROWS IN FILE ORDER; DO NOT SORT THEM.** Sorting by id is an obvious tidy-up and it produces a mismatch indistinguishable from corruption - so if this check fails, confirm you have not reordered anything BEFORE concluding the data is bad. When a check fails the first question is whether the CHECK is wrong, not whether the data is. Verified against a 12447-row production export: the recipe above reproduces the trailer's value exactly. **`rows_sent == rows_at_snapshot` with `complete: true` is your checksum** - one uninterrupted call is an exact snapshot with no row skipped or repeated, in id order. Needs BOTH the `list` and `read` grants: `list` alone could already learn the ids and must not get the contents, and `read` alone must not get an enumeration.
   **Params:** `include_vectors` (default **true** for a vector collection, and refused **422** `not_vector` on a json one), `vector_format` (`array` default, or `base64` for float32-little-endian). **Both are BIT-EXACT** - tested over 200k float32 values including denormals and the extremes - so choose on size, not on fidelity. `array` is the default because it restores directly (`_vector` on a document write takes exactly that shape) but it is ~3.7x larger: nlohmann prints a float32 widened to double with shortest-round-trip for DOUBLE, giving 16 digits where float32 needs 9, so it is verbose for precisely the same reason it is exact. Measured on 12447 rows at dim 4096: array 963 MiB, base64 261 MiB. **DO NOT ASK FOR GZIP ON VECTOR DATA.** Responses are compressible and the export inherits it, but measured at level 6 an array export costs ~121 s of SERVER CPU to save ~68 s of download, which is a net loss and a real cost on a shared host; base64 of float data compresses only 1.35x. Send `Accept-Encoding: identity` for a vector export. Gzip the json collections happily - document JSON compresses ~3.9x), `after_id` (resume), `batch_rows` (clamped, never refused).
   **`vector_state` is `present`, `none`, `missing` or `unknown`,** and a row that is not `present` carries NO `vector` field at all rather than an empty one - so a restorer cannot mistake "we do not have it" for "it is empty". **`missing` means the row HAD a vector and the entry is gone** (real data loss) and `unknown` means the row predates the database's marker, so neither should be restored as a plain document: re-embed from the source text instead, or you will store a row that reads back fine and can never be found by a search.

Різницю між файлами не показано, бо вона завелика
+ 0 - 1
api/openapi.json


Деякі файли не було показано, через те що забагато файлів було змінено