Procházet zdrojové kódy

docs: a collection can exist on disk only, and four instruments that lied with orderly output refs SV-52

fszontagh před 5 dny
rodič
revize
dc71fc745d
1 změnil soubory, kde provedl 17 přidání a 0 odebrání
  1. 17 0
      CLAUDE.md

+ 17 - 0
CLAUDE.md

@@ -744,3 +744,20 @@ Publishing uploads to the live apt repo - only with explicit confirmation. The d
 
 - **THE PROJECT STATIC MOUNT'S SPA FALLBACK SWALLOWS A MISSING *FILE* AS WELL AS A MISSING ROUTE, SO ABSENCE IS NOT AVAILABLE AS A SIGNAL TO A TENANT.** `serveProjectStatic` (`src/handlers/static_files.cpp:69-75`) does one `infoByPath` lookup and, on ANY miss under the mount, serves `index` - no extension rule, no content-type rule. So an image that was never uploaded answers **200 `text/html`** with the SPA shell, exactly as `/settings` does. Both consequences are real and pull opposite ways: an unpublished file **leaks nothing**, because it is indistinguishable from a route, and a client **cannot branch on a 404** for a missing asset while a fallback is configured - an `<img>` renders broken and reports nothing. There is no way to have both; `index: ""` buys the 404 and costs the SPA. Found by novitax 2026-11-21 by CHECKING rather than assuming, because it could have made their own report moot - which is the habit worth copying: the check that would retire your finding is the one to run first. `api/llms.txt` was silent on the file-versus-route distinction while documenting `""` precisely, which is this file's standing rule about a silence propagating as confidently as a wrong sentence.
 - **A FUNCTION CANNOT RETURN BINARY, AND THE ASYMMETRY IS THE PART A READER GETS WRONG: `bodyBase64` EXISTS ON `ctx.fetch`'s REQUEST SIDE AND NOWHERE ELSE.** `kEnvelopeKeys[]` is exactly `{status, headers, body}` (`runner/src/run_service.cpp:52`), so `bodyBase64` in a return envelope is not an ignored option - it is a fourth key, which FAILS THE RUN as a mixed envelope. The consequence a tenant meets is that **no gate can be put in front of a binary asset**: the function that can check a session cannot emit the bytes, and the mount that can emit them is unauthenticated by design. `ctx.files.get()` returning base64 makes this maximally confusing, since the function can READ the file perfectly well. SV-50; documented in `api/llms.txt` beside the envelope, because the gap was discoverable only by trying it.
+
+- **A COLLECTION CAN EXIST ON DISK AND NOT IN MEMORY, AND THEN EVERY ENUMERATING CALL FAILS WHILE `get` BY ID AND `count` BOTH WORK - THE REPAIR IS ANY WRITE TO IT.** Found 2026-11-21 from a novitax report; cause diagnosed by the database owners, repair tested by them and applied by us. Four novitax collections (`kb_settings`, `ntapi_departments`, `ntapi_products`, `aliz_leads`) answered `collection not found` to `info` and `find` while their rows read back perfectly by id.
+  **The cause is the WAL damage of 2026-11-19 one level up.** The 2.21.4 boot that ended the 15-day snapshot stall replayed 193,776 of 354,089 entries and stopped at the damaged record; the `CREATE_COLLECTION` entries were among the 160,261 never replayed. LMDB already held the rows, mirrored at write time, so **the rows survived and memory never learned the collections existed**, and the next snapshot made that permanent. Same incident as the stale `justice-pa:facts` rows, applied to a collection's own record instead of a document.
+  **THE REPAIR IS A THROWAWAY INSERT AND A DELETE. No tool, no tunnel, no restart.** A write creates the in-memory collection with default options; the WAL insert entry recreates it on replay so nothing depends on a CREATE entry; the snapshot writes every in-memory collection including empty ones; LMDB is never touched by the create. Two conditions: **default options only** (an implicit create gets ttl 0, not encrypted, maxVersions 0, dimension 0 - a vector or encrypted collection needs an explicit `createCollection`), and **an id that exists nowhere on disk**, or the insert adopts the colliding row and answers `AlreadyExists`, which still repairs the collection but means the delete must not be sent. Applied on prod: counts went 0->1->0, 1->2->1, 9->10->9, 37->38->37, matching the boot audit's id counts exactly, and `sos_notice` came back at `_version 3` with its original `_created_at` - loaded unchanged, so provenance and version history survive.
+  **THE PREDICTOR IS TRAFFIC, NOT THE CREATION DATE, AND THE OBVIOUS SEARCH KEY OVER-REPORTS BY A FACTOR OF THREE.** All five affected collections were created 2026-11-10, after the gap opened - and so were eight healthy ones. `kb_manual` was created in the **same minute** as `kb_settings` and is fine. The resolving observation was accidental: the consumer wrote one throwaway row to `aliz_callbacks` to prove inserts still landed, and **it repaired itself**. Every same-window survivor takes traffic and was silently repaired by its own first write after the boot; the ones that stayed broken are exactly the quiet ones - static reference tables, a settings row read only by id, an empty table. **The damage persisted precisely where nothing was writing, which is the hardest place to look.**
+  **To find them: the boot's `consistency-report.json` entries with `collection_in_memory: false` are the exact list for collections WITH rows. A collection with no rows on either side is invisible to that audit and can only be found by diffing our own registry against `info` per collection**, which is the sweep that found `aliz_leads`.
+  **Our `POST /collections` cannot repair this and must not be used to try**: it refuses at its own registry guard (`collection already exists`) before reaching the client, and its create path drops whatever is still attached to the name - which here is the only copy of the rows.
+
+- **FOUR INSTRUMENTS LIED WITH ORDERLY, PLAUSIBLE OUTPUT IN ONE EVENING, AND THE NASTIEST ONE HAD WORKING-LOOKING CONTROLS.** All four produced tables a careful reader would have believed, and three were caught by an impossible number rather than by care.
+  - **An ABSENT EXECUTABLE returns the same thing as an empty result.** `strings -a` is not installed on prod; a content check over a snapshot printed a clean table of zeros for every collection **including the positive controls**, and the only reason nobody went hunting a bug in the database's snapshot writer is that the controls being zero was impossible. The consumer's formulation is the one to keep: **the controls did not improve the measurement, they were the only reason anyone knew there had not been one.** This file already demands positive controls; the new mechanism is that a missing binary and a genuine absence are byte-identical output.
+  - **`cp -a` PRESERVES THE SOURCE MTIME**, so reading a backup directory's timestamp to date the operation that followed it returned a date a DAY BEFORE the backup was taken.
+  - **`journalctl` RENDERS LOCAL TIME WHILE `date -u` DOES NOT.** On a CET box that is one hour, which was enough to make a snapshot appear to follow a repair it actually preceded - and the whole durability question turned on which side of it the repair fell.
+  - **A LITERAL SEARCH OVER A COMPRESSED FILE IS BLIND IN BOTH DIRECTIONS, NOT MERELY ASYMMETRIC - WHICH CORRECTS THIS FILE'S OWN EARLIER RULE.** The existing entry says a hit in an LZ4 snapshot is real evidence and a miss is not. The miss half is right. **The hit half is wrong whenever anything else in the data can carry the same string**: stored FUNCTION SOURCES are ordinary resident documents and mention collection names constantly (`portal-sos-notice`'s source contains `kb_settings` four times), so "the name is in the file" was being read as "the collection is in the file" on the unstated assumption that only a collection's own header carries its name. The disproof is internal and decisive: **`ntapi_departments` appears five times in `aliz-gateway`'s stored source, that row is resident and is in the snapshot, and the snapshot shows ZERO literal hits for it.**
+  - **AND THE CONTROL WAS ITSELF CONFOUNDED, which is worse than the `strings` case because nothing screamed.** `kb_manual` and `portal_config` came back non-zero and read as healthy controls proving the instrument worked. They were hits of the same ambiguous kind - possibly header, possibly function source - so they confirmed the search was RUNNING while saying nothing about what it measured. **A control has to be confounded-free in the same way the measurement needs to be, or it only proves the tool executed.**
+  **The generalisable pair, from the consumer: a positive result needs its ALTERNATIVE CAUSES listed before it counts as evidence** - which is this file's "what else would produce this exact result?" applied to a hit rather than to a pass - **and a control that shares the measurement's confound cannot rescue it.**
+
+- **MOVING A CLOSING CONDITION AFTER IT HAS BEEN MET IS ITS OWN FAILURE, AND IT IS QUIETER THAN THE ONES THIS FILE USUALLY RECORDS.** The consumer set the bar for the collection repair as "the boot audit reporting `disk_only: 0`, OR anyone reading the snapshot writer's collection iteration, whichever comes first". The database owners then read `serializeStore` and reported the iteration, so the bar was met; I offered to wait for the audit anyway and they **declined deliberately**, on the grounds that raising a bar you have already cleared is a failure mode of its own. What tipped their reading past bare restatement is worth the note: **their explanation PREDICTED an observation it was not constructed to explain** - that three of the four repaired collections show zero literal hits in the snapshot, because a collection with no resident rows has its name written exactly once, in a run of similar `novitax:` prefixes, which is where LZ4 back-references it. A claim that accounts for a measurement nobody offered it is doing more than agreeing.