Prechádzať zdrojové kódy

docs: for one consumer a HANG costs more than a FAILURE, which is backwards

Measured on the only public write path on prod, stated by its owner.
toloajto's offer-submission INSERT is best-effort - try/catch, no retry,
no fetch timeout - so a FAILED insert is genuinely harmless: it is
swallowed and the CRM push that actually delivers the offer still runs.
But it is awaited sequentially BEFORE that delivery push, so a HUNG
insert blocks delivery for the full stall with nothing to cut it short.
The button spins, and if the customer closes the tab mid-hang the offer
is lost outright.

So our cheapest failure for that caller is an error and our most
expensive one is latency, the opposite of the usual reading. When pricing
a window or any slow path, "what does your error handling do" is only
half the question - the other half is what the code does while waiting,
and what sits downstream of the await.

A caller with no client-side timeout does not experience a slow
dependency as slowness. It experiences it as an abandoned transaction:
silent, unlogged on both sides, and indistinguishable from a customer who
changed their mind. Our /rag/ mount sets proxy_read_timeout 180s, so the
ceiling on that spin is ours rather than theirs.
fszontagh 1 mesiac pred
rodič
commit
d3fd285dc1
1 zmenil súbory, kde vykonal 2 pridanie a 0 odobranie
  1. 2 0
      CLAUDE.md

+ 2 - 0
CLAUDE.md

@@ -69,6 +69,8 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   **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.
+  **THE SIBLING QUESTION, AND IT INVERTS THE USUAL ASSUMPTION: ASK WHETHER A HANG IS WORSE THAN A FAILURE FOR THAT CALLER, BECAUSE SOMETIMES IT IS.** Measured on the only public WRITE path on prod, toloajto's offer submission, and stated by its owner 2026-10-15. Their `quotes` INSERT is best-effort - try/catch, no retry, **no fetch timeout** - so a FAILED insert is swallowed with a console warning and is genuinely harmless, because the MiniCRM/n8n push that actually DELIVERS the offer still runs. But that insert is `await`ed SEQUENTIALLY BEFORE the delivery push, so a HUNG insert blocks the delivery for the full stall with no timeout to cut it short: the button spins, and **if the customer closes the tab mid-hang the CRM push never runs and the offer is lost outright**. So for that caller our cheapest failure is an error and our most expensive one is latency - the opposite of the usual reading, where an error is the bad outcome and a slow success is tolerable.
+  Two consequences worth carrying. When pricing ANY window or slow path, "what does your error handling do" is only half the question; the other half is **"what does your code do while waiting, and what is downstream of the await"**. And a caller with no client-side timeout does not experience a slow dependency as slowness - it experiences it as an abandoned transaction, which is silent, unlogged on both sides, and indistinguishable from a customer who simply changed their mind. Note our own `/rag/` mount sets `proxy_read_timeout 180s`, so the ceiling on that spin is ours, not theirs.
 - **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.
 - TS: no `any`, no TS `enum`, no constructor parameter-property shorthand (tsconfig `erasableSyntaxOnly`). Iterating parsed JSON: bind to a named var first (range-for over `nlohmann::json::parse(...)[...]` dangles).
 - Commits: conventional prefixes (`feat`/`fix`/`build`/`docs`/`test`). Branch for feature work; `main` is pushed to `ssh://git.smartbotics.ai:10022/fszontagh/smartbotic-vectorapi.git`.