Jelajahi Sumber

docs: audit a syntax incompatibility by DESTINATION, not by construct

Two lessons from a consumer checking their exposure to the RE2 move.

The audit question is not "do we use lookaround" but "which engine is this
particular regex destined for". Their sweep found two lookbehinds - word
boundaries written because JavaScript's \b is ASCII-only and matched inside
a Hungarian compound - but both are JS regexes on local text that never
reach our store. A sweep answering "yes, we use lookaround" would have been
true and useless, and one that only counted constructs could equally have
missed a single store-bound pattern among them.

And a test that scans generated pattern text must strip the escaping the
generator itself emits, or correct output reads as a defect: a typed ( is
correctly emitted as \(, whose ( looks like an unescaped group opener, and a
typed \1 becomes \\1, whose second backslash looks like a backreference.
That is the mirror of the usual trap here - not a check that cannot fail, but
one that fails on correct behaviour, which is more convincing while wrong.
fszontagh 1 bulan lalu
induk
melakukan
8831d8c9c6
1 mengubah file dengan 3 tambahan dan 0 penghapusan
  1. 3 0
      CLAUDE.md

+ 3 - 0
CLAUDE.md

@@ -75,6 +75,9 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   **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.
   **THE QUESTION TO ASK A CONSUMER IS NOT "DO YOU RETRY ON STATUS" BUT "DOES ANYTHING ABOVE THE CALL SITE CONVERT A THROW INTO A DEFAULT".** novitax-6c's framing, 2026-10-16, when asked whether the `/invoke` 422 would reach them. Their retry set is keyed on STATUS (`RETRYABLE = new Set([429, 502, 503, 504])`, 3 attempts at 500 ms) and never on the error code, which is the design that makes a widening slug set safe - but they pointed out the half a retry question misses, from their own live code: their public portal answers an identical 202 whether the mail went out or not, so the loud failure exists and something ABOVE it flattens the signal. A status-keyed retry is only safe while nothing wraps a broad catch around the call. **toloajto is the clean instance of that same shape being the RIGHT design rather than a bug:** `postValidate()` is `if (!res.ok) return null;`, so every non-2xx including a 422 degrades to the local client-side price - deliberate, because server-authoritative pricing is an optional hardening layer with an intended fallback. So one shape is a defect in one codebase and a feature in another, only the owner can tell you which, and neither answer is visible from our side of the call.
   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. **CLOSED ON THEIR SIDE THE SAME DAY, and the lesson is KEPT because the shape recurs rather than because the instance is open:** told that the 180 s ceiling was ours and not theirs, they added an 8 s `AbortSignal.timeout` to both offer-flow inserts and the copy-link insert, so a stall now lands in the harmless path a failure already had - the design still goes out through the CRM push, the quote simply is not persisted to rag, and the link falls back to a self-contained URL. A three-minute freeze became an 8 s fail-fast. Worth noting WHAT unlocked it: they had the timeout problem in their own code and could not see the number, because the ceiling lived in our nginx config. **A latency budget split across two owners is invisible to both of them**, so saying out loud which side holds the ceiling is cheap and is the thing that made the fix obvious.
+- **THE AUDIT QUESTION FOR A SYNTAX INCOMPATIBILITY IS NOT "DO WE USE THIS CONSTRUCT" BUT "WHICH ENGINE IS THIS PARTICULAR REGEX DESTINED FOR", AND THE FIRST QUESTION PRODUCES A TRUE, USELESS ANSWER.** From a consumer checking their exposure to database 2.20.0 refusing lookaround and backreferences under RE2, 2026-10-16. Their sweep found two lookbehinds - `(?<![\p{L}\p{N}_])` word boundaries, written because **JavaScript's `\b` is ASCII-only and matched inside `áfaszázalék`** - but both were JS regexes applied to local text before masking and never reach our store, so they are unaffected. A sweep answering "yes, we use lookaround" would have been accurate and would have sent them looking for a problem they do not have, while a sweep that only counted constructs could equally have missed a single store-bound pattern among them. The partition that matters is by DESTINATION, not by syntax. The same shape applies to us: a lookaround in a `webui` regex and one in a `?filter=` value have nothing in common but their spelling.
+- **A TEST THAT SCANS GENERATED PATTERN TEXT MUST STRIP THE ESCAPING THE GENERATOR ITSELF EMITS, OR CORRECT OUTPUT READS AS A DEFECT - IN BOTH DIRECTIONS.** Same consumer, same day, and it caught their own assertions twice before it caught anything else. A typed `(` is correctly emitted as `\(`, whose `(` reads to a naive scan as an unescaped group opener; a typed `\1` is correctly emitted as `\\1`, whose second backslash reads as a backreference. Both outputs are RIGHT and a plain-text scan reports both as faults, so the test sends you hunting for a bug in a generator that was already correct. Strip escaped pairs first. Worth keeping because it is the mirror of the usual trap in this file: not a check that cannot fail, but a check that fails on correct behaviour - equally expensive, and more convincing while it is wrong.
+  Their generator test is also the shape to copy over "I read it and it looks fine": assert the PROPERTY over adversarial inputs (every lookaround spelling, a backreference, `(a+)+$`, `\p{L}`, an emoji) that the output contains no lookaround, no backreference and **no capture group at all, so there is nothing a backreference could refer to** - then mutation-check it, which they did: emitting a lookahead fails 5 tests, a capturing group 3, dropping an escape 3.
 - **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`.