|
|
@@ -80,6 +80,9 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
|
|
|
- **A blocking host call cannot be interrupted, so host timeouts ARE the enforcement.** The wall budget is enforced by a QuickJS interrupt handler that fires between bytecode ops; while an embedding or `ctx.fetch` request is in flight the engine never regains control, so the deadline is noticed only once the call returns. Bounding a host call therefore means handing the HTTP client timeouts that already fit the remaining budget - which is what `resolveEmbedBudget()` (`functions/embed_budget.hpp`, pure) does. It exists because a 10 s-budget run took **14314 ms**: the READ timeout was clamped to the budget and the CONNECT timeout was not, and the two are additive, so a connect stall burned the full `embedding_connect_timeout_sec` outside the budget. Connect gets at most HALF the available time (a reachable provider connects in well under a second, and a large connect allowance only starves the read phase). Below a 2 s budget the 1 s floor on each phase dominates and the worst case is 2 s - bounded, and stated rather than glossed over.
|
|
|
- **Embedding timeouts are per-project and NARROWING ONLY**, resolved by the same `resolveEmbedding()` that picks the endpoint, so a project's override applies identically to a function and to an HTTP vector route. The effective value is `min(project, global)`: these govern a shared provider connection and a pooled runtime waiting on it, so an override that could RAISE them would let one tenant hold both longer than the operator allowed. A stored value above the global is kept rather than refused - it becomes effective if the global is later lowered. A zero override is "unset", never "no timeout", because 0 means no timeout to the HTTP client and that is precisely the unbounded call the split prevents.
|
|
|
- **THE FUNCTION SURFACE NEEDED THE SAME FIX, AND NEEDED IT MORE.** `.search()`/`.store()` build their payload in `host_prelude.js` from an EXPLICIT key list, so an unrecognised option is discarded in the prelude **before the host can ever see it** - the host cannot refuse what never arrives, so a host-side check is no protection at all there. That is precisely how `embedTimeoutMs` came to be honoured host-side and never sent by the prelude while a consumer was told a bound was in force. `onlyKnownKeys()` (renamed from `mailOnlyKeys`, since the job is not mail's) now refuses by name in the prelude, and `expectRefused()` asserts the host was never reached rather than only that something threw. A consumer's call sites were ALL on this surface and none on the HTTP route, so fixing only the route would have left the real callers exposed while looking finished.
|
|
|
+- **THAT FIX WAS APPLIED TO ONE HANDLER AND NOT TO THE CLASS, AND A SIBLING IS STILL BROKEN.** Audited 2026-10-13: `unknownKeys()` is called in exactly ONE place service-wide, `handlers/vectors.cpp:121`, on the search BODY. **Six handler files read query parameters and none of them refuse an unknown one** (`indexes`, `files`, `collections`, `documents`, `export`, `functions`). The live consequence a consumer measured: `GET .../indexes/{field}/values?offset=1000` answers **200 with the first page**, because the handler reads only `limit` and `order` and the client has no offset parameter to honour. A caller paginating that route loops forever believing it is progressing - see task #72.
|
|
|
+ **The general form, which a consumer put better than I did: a fix applied in the handler where the lesson was LEARNED, rather than to the CLASS of handler, is how one correction leaves its siblings broken - and the silent-wrong-answer family is the one where nobody notices the sibling, because every sibling answers 200.** When a defect of this kind is fixed, grep for the shape rather than patching the instance.
|
|
|
+ **But the query string CANNOT take the body's blanket treatment, and that is why this needs design rather than a copy-paste.** Every key in a JSON body is deliberate, so refusing all unknowns is safe. A query string legitimately collects things nobody meant as options - a cache-buster, a proxy's addition, a UI's `_=<timestamp>` - so a blanket 422 would break callers for params that were never asking for behaviour. The defensible line is to refuse the params a caller plausibly sends EXPECTING AN EFFECT and that we do not implement (`offset`, `page`, `cursor`, `sort`, `fields`), and to keep ignoring genuinely incidental ones. Refusing `offset` is the point; refusing `_=1760000000` is a regression.
|
|
|
- **An unknown key on a vector `/search` body is REFUSED (422 `unknown_option`), not ignored** (`functions/known_keys.hpp`, pure). It was ignored until 0.10.3, and measured on prod that produced silently wrong answers rather than errors: `topK: 3` returned the DEFAULT five rows, `minScore: 0.99` returned rows where the correct spelling returns none, and **`filter:` in the singular returned the rows the caller meant to EXCLUDE** - a dropped filter is frequently a tenancy boundary in the caller's mind, which is what makes this a defect and not an ergonomic wish. Every unrecognised key is named at once, and the accepted set is listed, because the usual cause is a plausible spelling of a real option. Matching is exact and case-sensitive on purpose: accepting `Top_K` would give the service two spellings for one option, which is how the next drift starts. `ctx.fetch`, `ctx.mail` and `ctx.jobs` already behaved this way; this brought the HTTP surface in line.
|
|
|
- **`embedTimeoutMs` on `.search()`/`.store()` is validated, not coerced.** A non-integer or non-positive value is 422, and exceeding it is **504** `embedding_timeout` (distinct from the run simply running out of budget, because the remedies differ). It went unnoticed for a release while being silently accepted and ignored, which is exactly why an unsupported option must be refused rather than dropped.
|
|
|
- **Wall time has TWO ceilings** (`functions/wall_budget.hpp`): an HTTP one (~2 s, which `RunnerPool::readTimeoutSec` must exceed) and a JOB one, which is exempt because a queue-claimed run holds no socket. `RunService::run` takes the kind as a PARAMETER, never inferred from the descriptor, and defaults to Http - the narrow budget - so a caller that forgets is slow rather than dangerous. Precedence: `min(descriptor timeoutMs or default, project max or kind ceiling, hard ceiling)`, resolved by the pure `resolveWallBudget()`. **The project cap is per kind** (`{http, job}` on `PUT /projects/{p}/settings/functions`): one number could not express "10 s for routes, 60 s for jobs", so capping a project's routes also cut its cron work and the only safe setting was no cap. `FunctionView` carries BOTH and `RunService::run` selects, because `lookup()` does not know how a run was triggered. The engine's `JsLimits::wall_time_ms` is raised to the highest ceiling at construction, or the clamp inside `JsRuntime::run` would kill every job at the HTTP value.
|