Kaynağa Gözat

docs: "what else would produce this exact result?" - the question that catches it

Three instances of one defect appeared this afternoon, two of them mine, and
a consumer distilled the diagnostic that would have caught all three in a
single line.

The vector-encryption test read rows written before the flag flip and
concluded about writes after it. A consumer's page probe returned 200 at
5.4 MiB and concluded the limit was per document, when a per-response limit
above 5.4 MiB produces exactly that result. And the db_client check already
recorded here proposed to detect a server path from a client version.

The common form is an observation that is true and a claim strictly wider
than the observation could discriminate. Scepticism does not help: in every
case the observation was correctly made. Nothing in a passing result flags
the gap, which is why the question has to be asked deliberately.

Filed above the existing "a check that cannot tell" note, since those are
instances of the same family and the family now has a cheap test.
fszontagh 1 ay önce
ebeveyn
işleme
a194d07b03
1 değiştirilmiş dosya ile 5 ekleme ve 0 silme
  1. 5 0
      CLAUDE.md

+ 5 - 0
CLAUDE.md

@@ -53,6 +53,11 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **Embedding config precedence:** collection `embedding_model` pin → project override → global default; endpoint + API key are the project override when set, else global. Resolved by the pure `resolveEmbedding()` (`project_settings.hpp`) - unit-test precedence there, not through the handlers.
 - **Every outbound request to an external provider goes through `applyOutboundDefaults()`** (`outbound_http.hpp`): `User-Agent: smartbotic-vectorapi/<version>` and nothing else, TLS verification on, redirects off. Never let cpp-httplib's default UA reach a provider.
 - **A PERMISSIVE TEST ASSERTION'S STRENGTH DEPENDS ON THE SERVER'S STRICTNESS, so tightening a contract can silently promote a sloppy test elsewhere into a blind spot.** A consumer found this while checking whether the `unknown_option` refusal would break them: a test asserting their outgoing body with `expect.objectContaining({...})` tolerated extra keys by construction, so it could only ever fail in the direction that was already safe - add a stray key and the test stays green while production starts refusing every search with 422. They tightened it to an exact match. The lesson for asking consumers about a breaking change: the question is not only "do you send an extra key" but **"would your tests notice if you started"**.
+- **THE ONE QUESTION THAT CATCHES THIS WHOLE FAMILY: "WHAT ELSE WOULD PRODUCE THIS EXACT RESULT?"** It is one line, it costs nothing, and on 2026-10-12 three separate instances of the same defect appeared in a single afternoon - two of them mine - every one of which it would have stopped:
+  - **A vector-encryption test** read rows written BEFORE the flag was flipped and concluded about writes after it. What else would produce three rows still searching at 1.0? Pre-flip vectors living in the vector sub-db rather than the body. Which is exactly what was happening, and the new-insert path was broken.
+  - **A consumer's page probe** returned 200 at 5.4 MiB and they concluded the size limit was per DOCUMENT. What else would produce that? A per-RESPONSE limit anywhere above 5.4 MiB - which is what it is, 100 MB. A test that passes under both hypotheses cannot choose between them.
+  - **A `db_client` version check** proposed to detect whether a filtered search ran on the uncapped server path. What else would return "2.14.0"? A 2.14 client against a 2.13 server, where the capped emulation runs.
+  **The common form is an observation that is TRUE and a claim drawn from it that is strictly WIDER than the observation could discriminate.** More scepticism is no defence, because in each case the observation really was made and really was correct - what fails is the inference, and nothing in a passing result flags it. The companion rule, from the same afternoon: **a measurement has to COVER the claim, not merely sit next to it.** Stating what the measurement covered before using it is the habit; asking what else would produce it is the check.
 - **A CHECK THAT CANNOT *TELL* IS A DIFFERENT FAILURE FROM A CHECK THAT CANNOT FAIL, and it is harder to see.** Most of the traps recorded here are checks that could not fail. This is the other kind: a check that fires reliably and answers a DIFFERENT question than the one asked of it. The specimen: a consumer proposed detecting whether a filtered search ran on the uncapped server path by reading `db_client` from `/api/v1/version`. That field would have been returned every time, correctly, and it reports the CLIENT library version - so a client at 2.14 against a server at 2.13, where the filtered call is refused and the capped emulation runs, reads 2.14.0 throughout. The answer was dependable and about something else. Their own documentation already carried the line "`db_client` is the RUNTIME library version", written by them, three paragraphs above the proposal. **The defence is to verify when asked to confirm**: they asked me to confirm the mapping was version-deterministic and it was checking rather than agreeing that found it.
 - **Tightening a contract only helps if the consumer's failure path is LOUDER than the behaviour it replaced.** A STRICTER ERROR IS ONLY LOUD IF THE CALLER DOES NOT SWALLOW IT. Tightening `/search` to refuse an unknown option was meant to turn a silently wrong answer into a visible failure. A consumer then checked and found their `recall_memory` catches EVERY search error and falls back to keyword matching - so the new 422 would have silently degraded their search instead, with nothing logged anywhere. The defect would have moved rather than been fixed: from our silence to theirs. They now rethrow `unknown_option` specifically, and a deliberately misspelled option fails four of their tests. So when tightening a contract, "would your tests notice if you started?" has to be paired with **"does your error handling swallow it?"** - a caller with a broad catch converts a loud contract violation into a quiet capability loss, which is strictly worse than the original bug because it looks like a working system. Note what the defect becomes rather than merely where it goes: a dropped filter stops being a dropped filter and becomes a silently different retrieval strategy - still 200, still wrong, and now one layer further from the cause. In a RAG path that is a wrong answer delivered confidently, which is the single failure a knowledge base cannot afford.
 - **clangd, clang-format and clang-tidy are configured** (`.clangd`, `.clang-format`) and read `build-host/compile_commands.json`, so they cover `src/`, `tests/` and `runner/` including `runner/src/main.cpp`. The tidy set is narrow on purpose (`bugprone`/`cert`/`clang-analyzer`/`misc`/`performance`): the broad `modernize`/`readability` families bury real findings under thousands of style notes. `.clang-format` **describes the style the code already uses** rather than imposing one, so it is close to a no-op; `LambdaBodyIndentation: OuterScope` is the setting that matters, since every route handler is a lambda whose body is indented from the statement. Even so the codebase is hand-laid-out and not formatter-clean, so format **new or changed code only** (`git clang-format`), never whole files.