Browse Source

docs: with the TTL restore gap, the diff is what hides it

The consumer's framing and better than mine. The operator at risk is not
the one who reads the docs, it is the one whose restore looks perfect:
every id back, every count matching, the verifier green, and a set of
permanent markers quietly suppressing the work they were meant to guard.
Their run reported '1341 already present' and said nothing about the one
row that mattered. Every reassuring signal a careful operator checks is
intact while the damage is done.
fszontagh 1 tháng trước cách đây
mục cha
commit
fd6c8629b3
1 tập tin đã thay đổi với 1 bổ sung và 0 xóa
  1. 1 0
      CLAUDE.md

+ 1 - 0
CLAUDE.md

@@ -307,6 +307,7 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **TTL EXPIRY IS LAZY, SO A BACKUP LEGITIMATELY HOLDS ROWS THE LIVE PROJECT NO LONGER HAS - AND ANY BACKUP-VERSUS-LIVE COMPARISON READS THAT AS DATA LOSS.** Found by a consumer verifying their own backup right after a platform window, which is the worst possible moment to meet it: their tool reported `reminders_sent: 1 NOT in the live project`, which reads exactly like we lost a row during the maintenance. We had not. The row was an idempotency marker with a 48-hour TTL that expired 2026-10-10, was **still physically present in a backup taken 121 hours past its deadline**, and had been reaped by the time they verified an hour later. So the same row is present or absent depending on when the reaper happened to run, not on whether anything was lost.
   **There is NO supported way to read a document's REMAINING TTL** - audited in `client.hpp`: `ttlSeconds` appears on insert/upsert, `patchWithTtl` and `setFileTtl`, all WRITE paths, and `CollectionInfo::defaultTtlSeconds` is the COLLECTION's default rather than a row's expiry. So inferring from row age against a table of known TTLs is currently the only method, which is sound but needs the caller to know every TTL they ever set. Requested upstream.
   **THE SHARP EDGE IS ON RESTORE, AND IT IS OURS TOO: A RESTORED ROW CARRIES NO TTL, SO PUTTING AN EXPIRED ROW BACK MAKES IT IMMORTAL.** For their idempotency markers that meant a restore would permanently suppress the work the marker guards. Our own export has the same shape - nothing in it carries a TTL, because nothing can read one - so **a restore through `POST .../documents` resurrects expired rows as permanent ones**, and the more faithful the restore looks (every id back in place) the more complete the damage. Their fix is the right pattern for anyone restoring from our export: leave expired rows OUT, and say so in the output (`0 row(s) put back, 1341 already present, 1 expired left out`) rather than silently.
+  **IF ONLY ONE SENTENCE OF THIS IS EVER DOCUMENTED, MAKE IT THIS: THE DIFF IS WHAT HIDES IT.** The consumer's framing, and it is better than mine. The operator at risk is not the one who reads the docs - it is the one whose restore LOOKS perfect. Every id back, every count matching, the verifier green, and a set of permanent markers quietly suppressing the work they were meant to guard for 48 hours. Their own run reported `1341 already present` and would have said nothing at all about the single row that mattered. So every reassuring signal a careful operator would check is intact while the damage is done, which is the same shape as a digest that matched while the ordering was wrong.
 - **VERIFYING A RESTORE: a row count and an id set cannot see the failure that matters.** They prove something was stored under the right names. A vector can be byte-perfect in the file, stored under the wrong field or in the wrong form, read back flawlessly and rank nowhere. A consumer's restore test is the model: every restored row must be **its own nearest neighbour at score 1.000000**, and the same `query_vector` must score a row **identically** in the restored and original collections (they measured a delta of 0.00e+00). Only retrieval BY SIMILARITY exercises what a vector is for - which is the same lesson as a digest that matched while the ordering was wrong.
 - **Document write bodies accept two shapes, via one reader.** `documentBody()` in `handlers/documents.cpp` is used by POST, PUT and PATCH: it unwraps `{"data":{...}}`, strips `id` (the document's identity, from the body on POST and from the URL on PUT/PATCH), and rejects `data` alongside any other top-level key with **422** `ambiguous_body`. Before 0.3.3 only POST unwrapped, so a `{"data":...}` PUT stored the wrapper as a literal field and a `data`-plus-siblings POST dropped the siblings silently. A literal top-level `data` field is still writable as `{"data":{"data":...}}`.
 - **QuickJS is pinned to an exact quickjs-ng tag** (`SVAPI_QUICKJS_TAG`, `runner/CMakeLists.txt`). QuickJS bytecode carries **no version stamp**, so a silent upgrade makes a cached blob *misread* rather than fail. quickjs-ng, not Bellard's tree: the module/promise/stack entry points the core needs (`JS_GetModuleNamespace`, `JS_PromiseState`, `JS_SetMaxStackSize`, `JS_IsJobPending`) are public API there. `JsBytecode` is an in-process cache only - never persist it without a QuickJS build fingerprint.