C++20 REST API fronting smartbotic-database (gRPC) for n8n + other clients. Stores RAG vectors + JSON, organized into projects with multi-key per-project-grant auth. React admin UI. Ships as Debian .debs.
# Backend + web UI (Release)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_WEBUI=ON -S .
cmake --build build -j"$(nproc)"
# Tests (GoogleTest). Integration tests need a running smartbotic-database on localhost:9004;
# they GTEST_SKIP() cleanly if it's unreachable. BUILD_WEBUI=OFF to skip the npm build during test cycles.
cmake -B build -G Ninja -DBUILD_TESTS=ON -DBUILD_WEBUI=OFF -S . && cmake --build build -j"$(nproc)"
ctest --test-dir build --output-on-failure
# Run locally (use the repo's api/ for /openapi.json,/llms.txt,/docs and the built UI)
SMARTBOTIC_VECTORAPI_KEY=dev ./build/src/smartbotic-vectorapi \
--config config/config.json --share-dir "$PWD/api" --webui-dir "$PWD/build/webui/dist"
# Native host build: clang, the whole repo including the runner, ~100 s, and the
# compile_commands.json that clangd reads. Development only - it links the
# host's protobuf/gRPC, not the versions the .deb is built against.
scripts/host-build.sh --client # --client also rebuilds libsmartbotic-db-client into the prefix
scripts/host-build.sh --test # + ctest, SERIALLY (see the ApiFixture note below)
# Web UI only
cd webui && npm install && npm run build # → webui/dist ; `npm run dev` for the :3000 proxy dev server
# Local backend for UI work, or when you want Debian's exact toolchain
# packaging/devstack: DB + API from the release .debs in a Debian 13 container.
docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svapi-devstack
src/ - the server. vectorapi_core static lib + main.cpp. Namespace svapi. Flat headers, quoted includes.
db_gateway (qualify(project,coll) + DbGateway over smartbotic::database::Client), settings_store (global settings and per-project embedding overrides, hot-reload, one subscribe stream for both), project_settings (ProjectEmbeddingSettings + the pure resolveEmbedding()), outbound_http (User-Agent + TLS defaults for every external call), key_store (API keys, hot-reload, bootstrap admin key), collection_registry (per-project metadata), embeddings (OpenAI), auth (sessions, bearer/cookie), server (ApiServer + auth helpers), handlers/* (one file per route group)./api/* (401); each handler authorizes via requireKey → requireAdmin / requireProjectAccess (403). Keys are referenced by a stable id (not the secret).webui/ - React 19 + Vite + TS (strict, erasableSyntaxOnly) + Tailwind + Monaco. npx tsc --noEmit is NOT the build check - it passed on a malformed import that npm run build (tsc -b && vite build) rejected, because the project build uses different settings. Verify a UI change with npm run build.
Functions settings tab exists and is ADMIN-ONLY, matching its route (requireAdmin, not requireProjectManage): it bounds what one project may take from a runner every other project shares. It carries the per-kind wall caps and network_egress, both of which were previously reachable only by curl - and a control nobody can see is a control nobody knows exists, which mattered most for egress, where an operator could not tell whether a project's functions had outbound access. Egress renders THREE states, because network_egress is the effective value and network_egress_set says whether it was chosen or inherited: "allow (inherited)" is a different statement from "allow, set here". An empty wall-cap field means NO project cap, which is not a cap of zero, so it is held as a string to keep an empty input and a zero distinguishable all the way to the request.search, rather than annotating it. search ignores the field - it is a case-insensitive substring over the whole document, id and keys included - and the three inputs read as field/op/value, which asserts a scope it does not have. A control that cannot affect the result must not look like it can. The hint points at regex for a field-scoped substring, and contains gets its own hint because array membership is equally easy to misread as a substring.SaveButton IS a <button type="submit">, so it belongs inside a <form onSubmit> and must not be wrapped in another button. The toast store's push takes (msg, kind) positionally, not an options object. pages/Functions.tsx holds fn/tab in the URL (a draft is ?new=1 and carries no source, so it is deliberately not shareable); components/ScopeRules.tsx is the rules/ops editor shared by key scopes and function policies, with allowEmpty for the latter because an empty function policy is legal. require_human_token is hidden for function policies: it is a captcha header check in requireCapability, and a function is authorized through requireCapabilityCore, which never sees an HTTP request - offering it would store a field that silently does nothing. Cookie-session auth (credentials:'include'). Pages read currentProject/admin from useAuthStore; all calls go through src/api/client.ts. Documents keeps collection, the filter triple (field/op/value) and open in the URL, so relation links are ordinary links and any filtered view is shareable; changing collection closes an open editor (it belongs to the collection being left). pages/Settings.tsx is a tab shell over pages/settings/* (Embeddings, Cache & performance, Access & security, Web UI are admin-only; the per-project embeddings tab is not, so /settings is not admin-gated in App.tsx). Shared controls live in components/form.tsx.runner/ - the function runner service, a second binary (smartbotic-vectorapi-runner). Four layers split by what they must link, which is also what decides where each can be tested: runner_core (QuickJS engine + pool, no database), runner_protocol (/run, /validate, /health as JSON in / JSON out, no transport and no database - which is why its 30 tests run on the dev host), runner_net (libcurl + the IMAP/MIME parsers + the mail budget + the error map; links neither vectorapi_core nor the database client, so its ~200 tests run on the dev host too), runner_host (the ctx.* surface; links vectorapi_core AND runner_net). src/main.cpp is the only part that links the world and the only part the dev host cannot build. The QuickJS execution core (runner_core). Builds as its own top-level project (cmake -S runner -B build-runner), which is the one part of this repo that compiles on the Void dev host, since it links neither vectorapi_core nor the database client. BUILD_RUNNER=ON wires it into the root build; it is OFF by default because it vendors QuickJS from GitHub at configure time and an ordinary build must not start depending on a network fetch.api/ - openapi.json (3.1), llms.txt (llmstxt.org), docs/ (Redoc page). Served at /openapi.json, /llms.txt, /docs. Shipped in the server .deb. Keep these in sync when changing routes.packaging/ - build.sh (--local + Docker trixie), deb/create-debs.sh, control templates, systemd unit, maintainer scripts. docs/superpowers/ - design spec (esp. Addendum A) + the 3 implementation plans.nlohmann/json, spdlog, cpp-httplib (FetchContent, OpenSSL on). Handlers throw svapi::ApiError; a global exception handler maps to {error:{code,message}} + HTTP status (errors.hpp: 400/401/403/404/422/503/500).field:op:value (op ∈ eq/ne/gt/gte/lt/lte/in/contains/exists/regex/search). Used by /documents (?filter=, repeatable) and vector /search (filters body array) - both parse with parseFilter() and are evaluated by the DB, so semantics never diverge. contains is array membership. This documentation's own wrong sentence about search PROPAGATED into two consumers' notes - one copied "use search for substrings" from here into their CLAUDE.md and had not called it yet, the other followed it and shipped a live bug where a keyword fallback matched a chat id and a category instead of the field it named. A wrong sentence in a doc is a defect with a blast radius, not a tidiness problem, and it travels to places that never read the code. search IGNORES THE FIELD NAME: it is a case-insensitive substring over the WHOLE document - the id, the keys, and every string and number in it - so name:search:foo matches a document with "foo" anywhere, not in name. Measured on prod with controls: nosuchfield:search:webber returns rows while nosuchfield:eq:webber returns none, and departmentKey:search:szamla returns rows while departmentKey:eq:szamla returns none. A consumer's control is stronger than either of mine and worth reusing: status:search:webber returns rows where status only ever holds draft or approved - that proves the operator read a value out of a DIFFERENT field, where a nonexistent-field control only proves it tolerates an unknown name. They also confirmed regex passes both controls, so it genuinely is the field-scoped replacement. They re-verified rather than taking our correction, on the principle that if the upstream source of an error is also the source of its correction, the correction needs its own evidence. The field is syntactically required and semantically discarded, which this note previously described as "the substring op" in a field:op:value sentence - implying a scope it never had. For a field-scoped substring use regex on that field. This matters because a search filter written as a scoping or tenancy boundary admits rows the author believed it excluded, which is the same failure as a dropped filter and in the same direction. Vector search intersects the DB's filter result with the similarity ranking (scores stay identical to an unfiltered query), scanning at most 10000 candidates.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.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.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".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./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 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.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).feat/fix/build/docs/test). Branch for feature work; main is pushed to ssh://git.smartbotics.ai:10022/fszontagh/smartbotic-vectorapi.git.principal.hpp). requireCapabilityCore() answers project/scope/rate-limit questions for any caller; the ApiKey overload adds the things only an HTTP request has (Origin allow-list, captcha), because those are meaningless for a cron or event run. One implementation, so function access and HTTP access cannot drift.mergeForCodePush() (function_record.hpp, pure) takes policy and enabled from the stored row and never reads the ones in the payload - not unioned, not used as a fallback. A first registration inherits the project default. Identity is function_id from the script's on block and path carries no meaning, so a rename keeps the row and its policy.builtinDefaultFunctionPolicy() grants nothing: unreviewed code reaches no collection until an admin says so. Widening it is a security-posture change, and a test asserts the current floor.functions/descriptor.hpp, pure): a script author's typo is data. Unknown keys are ignored so a script written for a later server still loads. 404 and 405 stay distinct, so a 405 can carry its Allow: union./api/v1/projects/{p}/functions* (project-manage; policy is admin-only) and served to the world at /fn/{project}/*, which is unauthenticated - the project segment is therefore hostile input: charset-restricted (no :, the qualify() separator), confirmed against listProjects() before anything qualifies a collection, and a .. segment is refused anywhere (httplib percent-decodes before the handler sees the path, and .. can be captured by a :name param). Disabled and invalid functions are absent from the descriptor list, so they 404 rather than 403, and function error text never reaches the caller - it goes to the run log, with the run_id in the response.RunnerPool retry is three-way, not two. Never connected → retry (nothing ran). Answered, whatever the answer → never retry (the runner did its job). Delivered then unanswered (read timeout, non-200, unparseable body) → do not retry, mark unhealthy: the handler may be running right now, and a retry would run a side-effecting function twice. validate() retries everything, because compiling has no side effects. Also: RunnerPool::Options::readTimeoutSec must exceed the runner's max_wall_time_ms, or our read times out before the runner can report its own timeout and the caller gets a misleading 503 instead of a 504.ctx.collections(...) is a direct gateway call, never loopback HTTP, and ctx.fetch pins the connection to the single address the guard approved (set_hostname_addr_map) rather than re-resolving - re-resolving IS the rebinding window. One resolution, one classification.http (a route), cron (a schedule, with an IANA tz validated against the host tz database at PUSH time - an unknown zone is refused, never silently UTC), db (an INSERT/UPDATE/DELETE on a watched collection) and job (reached only by being enqueued, which is where slow work belongs). The scheduler and the event watcher live in vectorapi, because there must be exactly one of each; N runners each firing every cron is the obvious bug.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.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..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./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.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.ctx.fetch included, so without a lane N slow jobs leave one runtime for every interactive route and the second overlapping HTTP run blocks until the read timeout fires - a 503 from a healthy runner. Worst-case memory is (pool + job_pool) x memory_limit_bytes, so the two lanes ADD.fn:<project>/<id>:<depth> via the actor parameter, and Event::actor carries it back - so provenance costs nothing and lives in the audit trail, NOT in a field inside user documents (which would travel into every export forever). A chain is refused past events.max_depth generations and logged at error.singleFlight (default true for cron) skips a tick while the previous run is still going, which bounds stacking but is not exactly-once.jobs.enabled is OFF by default in the runner, so a runner upgrade never starts draining a queue in a deployment whose server has no scheduler. On a host that wants cron it MUST be turned on, or the scheduler enqueues work nothing ever runs - the most confusing possible way for cron to look broken.file_store.hpp), so everything customer-specific - a logo, a signature image - is tenant DATA rather than something bundled into a function's source. PROJECT ISOLATION IS OURS, NOT THE DATABASE'S: the database namespaces files by Client::Config::project, this service runs ONE client configured for default (collections are qualified per call instead), and the file API has no per-call project argument - so every project's files share one database namespace and are separated only by the related_id we stamp and filter on. Every lookup must therefore filter on BOTH project and name, and nothing outside file_store.cpp may address a file by its database id. A bug there is a cross-tenant leak, not a mis-sorted list._files pseudo-collection, so requireCapabilityCore is the one implementation and file access cannot drift from collection access. The leading underscore makes it unshadowable - collection-create rejects _-prefixed names. ctx.files is read only: writing a tenant's asset is a management act and the HTTP route requires project-manage for it.max_file_bytes (global settings, default 2 MiB) bounds what can be STORED; kCtxFileMaxBytes (1 MiB) bounds what one function run may LOAD. A file stored when the limit was generous must not be able to pull megabytes into a 64 MiB JS heap on every run afterwards. The database imposes a cap of its own (storage.files.max_file_size_mb, default 500), which is far above either.FileStore::put deletes the previous ones itself, uploading FIRST so a failure leaves the old file intact. Reads take the NEWEST record, because an interrupted put can leave two and a read that picked arbitrarily would serve stale bytes some of the time.vectorapi_keys, field key), the global OpenAI credential (vectorapi_settings) and every project secret including mail passwords (<project>:vectorapi_secrets) are readable by anyone with access to the database's data directory or to any backup of it - including the pre-upgrade tarballs under /var/backups/ on prod. On every version we have ever run.
The mechanism we believed in does not exist. Each store creates its collection with createCollection(..., encrypted=true, ...), and nothing in the database's write path reads that flag - CollectionOptions::encrypted is stored, reported by getCollectionInfo and never acted on. The database's actual mechanism is pattern matching on sensitive FIELD PATHS (*.password, *.api_key, ...), which requires a dot before the name, so our top-level value and key never matched - and key is not in the pattern list at any nesting.
Measured here, not taken on report: a project secret written through our own HTTP route was found in plaintext in wal/wal-current.log and in the project's env/data.mdb. AStoredSecretIsCurrentlyPLAINTEXTatRest does exactly that, and asserts the DEFECT so the suite stays honest and green while being self-correcting: when the database ships encryption at rest, that test fails and says to flip it.
AND I HAD A TEST ASSERTING THE OPPOSITE. It read getCollectionInfo()->encrypted and presented a flag as evidence about bytes, which is the same proxy-not-the-thing failure this file is full of warnings about. It is now named EachCredentialStoreSetsTheEncryptedFLAG_whichProtectsNothing and says so. A flag that records an intention is not a measurement of the outcome - if a security property matters, assert the property: write a canary and look for it on disk.
Until the database ships encryption at rest, the only reliable protection is encrypting CLIENT-SIDE before the value is stored.
THE COMING FIX IS SAFE FOR US, and the reason is worth keeping because it is not obvious: NOTHING queries a credential collection by value. The database asked before releasing, because full-value encryption uses a random IV, so a FILTER on an encrypted field never matches and an INDEX on one indexes ciphertext. Audited: KeyStore::lookup() scans an IN-MEMORY snapshot (k.key == key) loaded by a find() carrying only a limit, so authentication is a full read compared in process - it never asks the database to match a key. Settings and project secrets are addressed by DOCUMENT ID throughout (the secret's NAME is its id). The global settings document is told apart from the per-project ones by p.project.empty(), evaluated in our process after a full read, which LOOKS like a value query and is not. opts.filters is set in exactly three places service-wide - vector_search.cpp, function_run_log.cpp (function_id) and host_context.cpp (ctx.collections) - none of them a credential collection, and no index is declared on any of the three.
The adjacent hazard that WOULD break: vectorapi_function_runs is filtered by function_id. It, the job queue, the function registry and the collection registry are all deliberately encrypted=false, and user collections are always created encrypted=false (handlers/collections.cpp:74) so a user's index is never over ciphertext. If anyone ever flips the flag on those, that filter stops matching silently.
THE FLAG WAS ASKED FOR AND NEVER APPLIED, AND THIS NOTE USED TO CLAIM THE OPPOSITE. It said our startup calls createCollection(..., encrypted=true, ...) "unconditionally", so the three stores would "repair themselves on the next restart". Both halves were false. Every call site was guarded by if (!getCollectionInfo(...).has_value()), so the create was skipped for a collection that ALREADY EXISTED - which is exactly the case that needed it, because the collection had been created implicitly by an earlier write, with the default flag of false. Measured on the dev database: vectorapi_keys and vectorapi_settings report encrypted: no while the code reads as though it had asked for true, and only <project>:vectorapi_secrets (a later store, whose collection our code did create) reports yes. A guard that skips the repair in precisely the broken case is worse than no guard, and the suite could not see it because the flag test deliberately points each store at a FRESH collection name - correct for testing the creating path, and the reason it was blind to this one.
THAT UNCONDITIONAL CALL COSTS A SECOND WINDOW ON 2.17.x, AND IT MUST BE PLANNED RATHER THAN DISCOVERED. Under 2.17.x, re-issuing createCollection(existing, encrypted=true) performs the ONLINE encryption upgrade when it changes anything - and a collection reaching encryption through the bare-alias option merge still has its OWN flag unset, so our call does change something: it moves the flag where it belongs. That requests a RESEAL at the next boot, and the reseal compacts every project, which is the 167-second term measured above. Seen for real: the dev box's restart onto 2.17.1 took ~3.5 minutes instead of ~15 seconds, caused by our own bootstraps having flipped those flags under 2.17.0. It is a ONE-OFF, not a standing tax: the reseal is requested only when createCollection actually CHANGES the options, so once the flag is set every later startup does nothing and asks for nothing. The cost is one compacting restart per collection that gains its flag. Upstream is also considering requesting the reseal only when the upgrade actually REWROTE something - our keys and settings were already ciphertext through the alias, so their flag change wrote no plaintext anywhere and arguably need not cost a compaction at all - but that is NOT in 2.17.1, so plan step 3 as written.
So the prod sequence has THREE steps and two compactions, not one: upgrade the database (first-boot migration, 190 s measured), start vectorapi so the bootstraps move the flags, then restart the database inside the SAME window so the reseal happens while everyone is expecting an outage. Skip that last step and a routine restart weeks later silently takes three minutes with no visible cause - the same shape as the /etc mode 0751 trap below, and the reason "under 10 minutes" is the right thing to ask consumers to approve for that window rather than three.
Today's release is unaffected: prod runs 2.14.0, where the upgrade branch does not exist and the re-call is a plain no-op. The cost arrives only with 2.17.x.
So KeyStore::bootstrap and SettingsStore::bootstrap now call createCollection UNCONDITIONALLY, which puts the flag on the collection we actually read and write. Read the correction two paragraphs down before relying on the reasoning that motivated it. Re-issuing it against an existing collection switches encryption ON (never off), encrypting the stored rows and their history; against an older server it is a no-op, so it is safe on every version we support. Verified safe before shipping, not reasoned about: MemoryStore::createCollection's existing-collection path only acts on a vectorDimension > 0 and on defaultTtlSeconds, and we pass 0 for every option but the flag, while upgradeEncryptionOptions only ever flips false to true and appends sensitive fields. BootstrapAsksForEncryptionOnAnAlreadyEXISTINGCollection pins it with a CONTROL collection that is never bootstrapped, so the assertion cannot pass for an unrelated reason, and it asserts the pre-existing row survives the re-call.
ProjectSecretStore::ensure deliberately KEEPS its guard, and the difference is the call path rather than the intent: it runs on every secret READ (the runner builds ctx.env through it) and CreateCollection is REFUSED by a read-only database, so making it unconditional would turn every function run into a 503 during read-only recovery - trading a live outage for a hardening step that collection does not need.
What database 2.17.0 actually does, confirmed from their source and then independently by them: collection-level encrypted=true encrypts EVERY non-null value in the collection whatever the field is called (isEncryptedPath returns true for any non-empty path when the rule is whole-document). Strings become $ENC$..., and numbers, bools, objects and arrays become $ENCJ$... and read back with their original type. The built-in sensitive-name patterns match a WHOLE path segment, so openai_api_key does NOT match api_key - which is why the collection flag, not the field name, is the only thing that was ever going to protect us. Grep a data file with grep -F: a bare $ENC$ pattern is a regex anchor and matches nothing.
I PREDICTED THOSE TWO COLLECTIONS WOULD SURVIVE THE MIGRATION UNENCRYPTED, AND THEY DID NOT. The prediction was written down before the upgrade, which is the only reason it could be checked rather than quietly reinterpreted afterwards. Measured after 2.17.0: default:vectorapi_keys and default:vectorapi_settings are both [encrypted] with plaintext-required 0, and the boot log shows their rows and history versions being encrypted. The cause is an accident of history. The encrypted=true our code asked for landed on the BARE-name collections (vectorapi_keys, not default:vectorapi_keys), almost certainly through the pre-2.4.5 client bug where createCollection sent the unqualified name and the options went to a phantom collection - and 2.17.0 MERGES a collection's options with those of its bare alias, because migration files use bare names, so the qualified collections inherited the flag. The exposure was real and the guard was real; the rescue came from somewhere I had not looked, so my conclusion was wrong in the direction of alarm. The fix remains right for a reason that does not depend on the accident - encryption no longer rests on an alias merge surviving a future cleanup - but it is HARDENING, not the rescue its commit message claims.
getCollectionInfo / info IS NOT THE ENFORCED RULE, and that is how the wrong prediction happened. info default:vectorapi_settings still reports encrypted: no on 2.17.0 while that collection's data IS encrypted, because it reports the collection's OWN options rather than the merged rule in force. So the flag can be wrong in BOTH directions: false while encryption is active, and (before 2.17.0) true while nothing was encrypted at all. Treat encryption-verify's [encrypted] marker as authoritative and the flag as a hint; the database is fixing info in 2.17.1. This is the lesson this file keeps relearning, with a new edge: a field recording an intention is not a measurement of the outcome, and when it disagrees with the bytes it can disagree in the REASSURING direction as easily as the alarming one.
encryption-verify BLOCKS WRITES SERVER-WIDE before 2.17.1, so never run it against a shared database. It audits history through the same routine the migration uses to rewrite it, and that routine holds the GLOBAL history mutex for the whole scan, so every write recording a history version - update, patch, upsert of an existing row, delete, in ANY collection - waits for it. Measured at ~10 minutes on the live box, during which a consumer saw a collection wedged with Deadline Exceeded. Use a scratch server until 2.17.1.
A tenant can now reach encrypted_field through the INDEX route, and we answer 503 for it. After 2.17.0 the name patterns match at top level in every collection, user collections included, so a tenant declaring an index on a field named token or password is refused with INVALID_ARGUMENT / encrypted_field. But CreateIndexResult carries no reason: the client turns a non-OK status into success = false with only the message text (client.cpp in Impl::createUniqueIndex), discarding the trailer detail, so indexDeclineError falls through to 503 db_error - "retry as-is" for something no retry can fix. The mirror image of the FailedPrecondition bug: that told a caller a read-only database was its own mistake, this tells a caller its own permanent mistake is our outage. It cannot be fixed on our side, because the only distinguishing signal is the message text and matching on that is forbidden here. Fixed in database 2.17.0 as FailureDetail& OVERLOADS, and my proposed fix was rejected for a good reason worth keeping: adding fields to CreateIndexResult would change its SIZE under soname 2, which is the case that crashed a consumer in 2.7.1. A struct a client returns by value is ABI, so the additive shape is an overload, never a new member - and I argued it was safe by citing their comment that the struct was standalone, which was about not disturbing IndexDefinition's shape rather than a licence to grow this one. Use createUniqueIndex(coll, field, FailureDetail&), createCompositeUniqueIndex(coll, fields, FailureDetail&) and createIndex(coll, field, rowsIndexed, FailureDetail&), map reason == "encrypted_field" to our 422, and keep the duplicate-values path keyed on duplicateExamples; an in-band refusal arrives as code Unknown. For the setAdd/setRemove overloads failure.code == Ok means the call worked and the member simply was or was not there. The same "non-OK status becomes a success flag, detail discarded" shape is worth grepping for elsewhere.<project>:vectorapi_secrets, encrypted and deliberately NOT in the collection registry - so the documents API and ctx.collections both 404 it, and even a policy granting every collection cannot read it. Writes are admin-only; no GET ever returns a value. A SVAPI_FN_<project>__<NAME> host variable WINS over a stored secret of the same name, which is the break-glass a stolen API credential cannot shadow.ProjectWallMax wraps a SettingsStore with reloadAll() plus startWatch(), so a changed cap reaches the next run immediately. It used to be a hand-rolled cache on a project_budget_ttl_sec TTL, which made clearing a cap look broken for up to 15 s and produced a false bug report. reloadAll(), never bootstrap() - bootstrap WRITES, seeding the settings document, and a runner must never author configuration it only reads.runtime ceilings are boot-time only, unlike every hot-reloading setting in the server: QuickJS fixes a runtime's memory limit at creation, so changing one live would mean draining and recreating the whole pool. Editing them means restarting the runner - cheap, because vectorapi answers 503 for that moment and stores nothing unvalidated. By contrast function_egress_blocked_cidrs / function_egress_allow_private DO hot-reload, because they are read per run.ctx.env comes from the runner's environment, scoped per project: SVAPI_FN_<project>__<NAME> in /etc/smartbotic-vectorapi/runner.env reaches that project's functions as ctx.env.<NAME>. The project is part of the variable name because one runner serves every project; nothing outside the SVAPI_FN_ prefix is ever exposed, so the runner's own token and database address stay invisible to functions. Matched exactly and case-sensitively; the split is at the first __, so a project whose name contains __ cannot carry secrets.isLoopbackBind() answers "not loopback" for anything it cannot parse, so an unrecognised address produces the refusal. The comparison is constant-time, /health is authenticated too, and both sides prefer SVAPI_RUNNER_TOKEN in the .env over the conffile.network_egress belongs to the /settings/functions PUT, which is requireAdmin - NOT the /settings/embeddings PUT, which is requireProjectManage. It shipped in the wrong one in 0.10.1: a scripted edit replaced the first match of a line both handlers share, so an admin-only control was silently ignored on its documented route AND writable on a non-admin one, which would have let a project-manage key re-enable egress an admin had denied. The suite did not catch it because no test exercised the route at all; prod acceptance did, by noticing that a deny PUT answered "allow" and that an invalid value answered 200 instead of 422. Five integration tests now pin it, including that the embeddings route cannot touch it and that clearing an embedding override does not drop it. Two lessons: a settings key is not done until a test drives its ROUTE, and when patching one of several near-identical handlers, assert WHICH one the edit landed in.network_egress on PUT /projects/{p}/settings/functions (admin only, stored as function_network_egress) gates ctx.fetch AND ctx.mail through one requireNetworkEgress(), checked before the SSRF classifier and before any resolution - a denied project must not emit a DNS query either, since a lookup is an observable side effect and a channel of its own. Gating one surface and not the other would let an operator believe a tenant was offline while the other stayed open, and mail is the one carrying credentials. It is NOT a _network pseudo-collection scope rule: a scope rule answers "may this principal touch that data of ours", which is why _files is one, whereas reaching a third party the tenant already has credentials for is a capability rather than an access decision - and a pseudo-collection would put it in range of a * rule, exactly the widening that had to be fixed once already. The default is ALLOW (kFunctionNetworkEgressDefault, pinned by a test): ctx.fetch shipped ungated, so a default of deny would break every deployed function that fetches the moment the setting appeared, which is an outage caused by ADDING a control. The control that was missing is the ability to revoke. Note the runner needs its own test seam (HostContextConfig::networkEgress) rather than riding on egressPolicy, because that one means "there is no database to read" and a test setting it would skip the gate while appearing to exercise it.ctx.fetch egress goes through the SSRF guard (functions/net_guard.hpp): fail closed on anything unparseable, and classify every address a name resolves to, not the first. A settings blocklist is UNIONED with the built-in defaults by SsrfPolicy::fromSettings(), never substituted for them - an operator adding one CIDR must not silently reopen loopback, RFC1918 and the metadata endpoint. function_egress_allow_private is the explicit opt-out and relaxes only privateBlockedCidrs(); 169.254.0.0/16, link-local, multicast, reserved space and the IPv6 spellings of an IPv4 destination (NAT64, 6to4, ::/96) stay blocked whatever it is set to. Note the opt-out does expose loopback, where our own API listens.ctx.mail, IMAP + SMTP)ctx.fetch is cpp-httplib with its own guard, its own pinning and its own outbound defaults, and two HTTP clients with two sets of defaults is exactly how the two drift. Re-enabling it also brings redirects back, which then need CURLOPT_REDIR_PROTOCOLS_STR set separately and FOLLOWLOCATION off.runner_net is a separate target for testability, not tidiness. runner_host links vectorapi_core and the database client, so putting the IMAP and MIME code there would make the largest and most defect-prone part of the feature the one part only the Docker path can compile. The division at the boundary is strict: runner_host converts JS values to a plain request struct and back, and does nothing else - no curl call, no IMAP knowledge, no timeout arithmetic above that line.curl-8_22_0 (SVAPI_CURL_TAG, SVAPI_VENDOR_CURL=ON; OFF links the system one and is what the dev loop uses, because vendoring costs minutes). The pin comment carries the obligations, and they are real: CVE tracking is ours now, a statically linked curl is invisible to apt, and a fix means a rebuild and a republish of both binaries rather than an unattended upgrade. Judge an advisory against what this service reaches - exactly imaps/imap/smtps/smtp - the same discipline the httplib pin uses. PROXY is compiled out rather than disabled per handle, because curl reads *_proxy from the environment where httplib does not and runner.env is a file an operator edits; a stray proxy variable would silently reroute a destination the SSRF guard had already approved. NETRC is out so credentials can only come from project secrets. Cookies/ALTSVC/HSTS are out because each is persistent cross-request state, which a multi-tenant pool must not accumulate. A build from a git tag reports its version as 8.22.0-DEV.CURLOPT_CUSTOMREQUEST with BODY.PEEK[], NEVER curl's ;UID= URL form. Measured against a live server elsewhere: the URL form always sets \Seen. Undoing it afterwards with a UID STORE -FLAGS is worse than the disease - it removes a flag it may not have set, so a message the user had already read comes back unread, and a timeout between the fetch and the undo leaves the message read anyway, which is the exact outcome peek exists to prevent. A test asserts no STORE, +FLAGS or -FLAGS ever reaches the wire.) AND the tagged completion line; untagged response lines are what reach the write callback. Measured by byte count, which is the only way to see it: a fetch whose fake response was a 30-byte untagged line plus a 50-byte literal plus )\r\n plus the tagged OK delivered exactly 80 bytes. An earlier version of this note claimed the tagged line DOES arrive, and that was wrong - it came from a substring check for " OK " that matched * OK [UIDVALIDITY 1], an untagged line. The consequence is real: a successful fetch's raw buffer legitimately parses as NeedMore, because the framing it was told to expect was never sent, so the binding restores the framing and re-parses rather than treating that as a short read. Restoring framing is safe only because it cannot satisfy an unsent {n}, so a genuinely truncated literal still reports NeedMore. Never resolve this with a terminator search. Separately: a BODY.PEEK[...] fetch comes back labelled BODY[...] without the .PEEK, so a parser looking for the string it sent finds nothing.{n} LARGER than the body it sends corrupts silently, and only its CONTENT gives it away. curl counts the response's own framing toward the announced count and reports success: measured against 8.22.0, an announce of 50 for a 40-byte body yielded CURLE_OK and a 50-byte literal ending )<CRLF>A003 OK, which ctx.mail then returned as a 200 whose header and text both carried those ten octets. It cannot be caught structurally - curl strips the real framing in the healthy case too, so a padded response and a correct one are byte-for-byte the same SHAPE (untagged line, literal header, exactly n bytes, nothing after). literalEndsWithFraming() (net/imap_fetch.cpp, pure) therefore matches the tail, and parseCurlFetch refuses a body that ends in framing. The tag it matches is CURL'S, not ours: customRequestFor strips the tag from every command, so curl re-tags on the wire (measured: A001, A002, ... sequential) and our own ImapTagger value never reaches the server at all. Malformed, not NeedMore - a truncated transfer is transient and worth retrying, while a server that miscounts its own literal will miscount it again, so this is mail_protocol_error 502 and NOT retryable. An earlier note here described this defect as the DIRECT parse returning Ok; measured, the direct parse returns NeedMore and the corruption arrives through the framed re-parse, so a fix aimed at the direct path would have aimed at nothing.UID FETCH naming more than one uid delivers ZERO bytes to the write callback (7,9 and 7:9 both; a single 7 delivers normally). So a read is one command per uid, all on the one session and the one LOGIN. Measured; it is why the obvious batching optimisation does not work.Ok with no messages. The caller skips it. Nothing a returned message carries ever comes from the raw buffer, which is what makes the "tagged completion line returned as the e-mail body" bug structurally impossible here rather than merely absent... The renderer additionally emits a leading period as =2E in quoted-printable, so the protection holds either way.SEARCH CHARSET UTF-8 with the term as an octet-counted literal, which is a multi-step exchange the one-shot transport does not drive. Sending the raw bytes is worse than failing: the server matches nothing and zero results is indistinguishable from "there is no such mail". That shipped elsewhere and produced silently wrong answers against Hungarian mail. The refusal names the field and says to filter on an ASCII-safe criterion and match the accented text after fetching. Mailbox NAMES are unaffected and still go out as modified UTF-7.CURLcode 8 (WEIRD_SERVER_REPLY) with CURLINFO_RESPONSE_CODE 550. So a reply code the server actually sent wins over curl's generic transport complaint for the generic codes; otherwise a bad recipient was reported as a protocol fault. Codes that already carry more meaning than a reply code, such as a denied login, keep their own answer. A 4xx reply is transient (mail_server_busy, 503), a 5xx is the caller's problem (mail_rejected, 422 - a 550 is overwhelmingly a bad recipient or a rejected sender, and blaming the server sends them looking in the wrong place).sideEffecting is the caller saying whether the operation changes anything at the far end, for the same reason the run kind is a parameter to RunService::run. A failure is retryable only when nothing can have happened: DNS and connect failures are, a mailbox read that times out is, and a send is never retryable past the point delivery was possible, because a duplicate cannot be recalled. A rejected login is not retryable either - repeating it is how an account gets locked or an IP blocked, which is far more expensive than the failure being retried. A timeout is 504, not 503, because 503's whole meaning is "retry as-is".totalMs. An embedding call is one request/response, so bounding connect and read bounds it. A mailbox read is several round trips on one connection, and a read timeout bounds each quiet period and not their sum - a server answering every command just inside the read timeout holds a pooled runtime far past the run's budget without ever tripping it. resolveMailBudget() (net/mail_budget.hpp, pure) otherwise mirrors resolveEmbedBudget(), connect capped at half.mailGlobalInit() is called once from the runner's main before any worker starts, and FAILS CLOSED. curl_global_init is not thread-safe and a lazy first-use from two pool threads is a real race. It also checks CURL_VERSION_THREADSAFE and refuses to start without it, in the same spirit as the runner refusing to start with no token on a non-loopback bind. CURLOPT_NOSIGNAL on every handle, or curl uses SIGALRM for resolution timeouts, which is unsafe off the main thread and can longjmp out of a worker - and a single-threaded test never shows it.CURLSH, no cross-tenant reuse. A handle carries connection state and credentials. A fresh handle per command would mean a TCP connect, a TLS handshake and a LOGIN for every command, which is both slow and what gets an account throttled; a test asserts one LOGIN serves three commands.mailboxes decoded 6 folders in 263 ms; read with a smallerThanBytes criterion returned 3 of 9 matches in 312 ms; criteria: {unseen:true} worked; and the non-ASCII SEARCH refusal fired in production as mail_bad_argument 422 naming the field, which is the single most important safety behaviour here because the alternative shipped elsewhere as silently empty results. Credentials came from project secrets via passwordSecret, never from source. A function whose policy grants nothing (rules: []) can still use ctx.mail, which confirms the deliberate decision that an outbound surface is gated by network_egress and the SSRF guard rather than by scope rules.subject/from/from_address/to/cc/date/message_id beside the raw header (putDecodedHeaderFields, over the pure functions/unfoldHeaders + the RFC 2047 decoder this service already owns). Built because the raw header is folded and every consumer would get it wrong - see the next bullet. header is ALWAYS still returned raw: a decoded field is a convenience and must never become the only way to see what arrived. An undecodable value passes through as it came rather than raising, matching what the mailbox-name decoder does and for the same reason. Decoded from the HEADER rather than from IMAP's ENVELOPE deliberately: ENVELOPE would make the value depend on the provider's parsing, and we would own neither the bug nor the fix.header is RAW and FOLDED, and the naive regex truncates it SILENTLY. Measured through the deployed runner: a long accented subject arrived as Subject:<CRLF> =?UTF-8?B?...?=<CRLF> =?UTF-8?B?...?= - nothing on the Subject: line at all, the value split across two continuation lines as two encoded words. /Subject:.*=\?UTF-8\?/ is then false (. cannot cross the CRLF) while /^Subject:\s*(.*)$/m matches but captures only the FIRST encoded word, so one check fails loudly and the other lies. Both of my probe's checks were wrong, in opposite directions. Consumers must unfold before parsing and decode every encoded word, which api/llms.txt now says. Candidate improvement: expose a decoded subject on each message so no consumer has to get this right - deliberately NOT built, since it is a new surface.ctx.mail.send CANNOT WORK on the DigitalOcean prod droplet: outbound 25, 465 and 587 are blocked by the provider (2525 is NOT - an earlier version of this note said it was, which was wrong: 2525 merely had nothing listening at the time, and I folded it into the block without the second host that would have told the two apart), confirmed as the host's policy rather than the mail server's by smtp.gmail.com:587 and smtp.sendgrid.net:587 being blocked too. IMAP 993 and 143 are open. A send therefore fails as mail_timeout 504 after ~7 s with retryable: false - which is the right answer and worth noting: a send is never retryable even when the timeout proves nothing could have been delivered, because the guarantee has to hold without knowing. The ~7 s is also live confirmation that connect is capped at HALF the run budget (15 s descriptor timeout). Sending from prod WORKS over port 2525 with STARTTLS, verified end to end through the deployed runner: send accepted in ~1.3 s, then found by UID SEARCH and fetched back, with the message arriving \\Recent and NOT \\Seen - which is BODY.PEEK proven in production against a genuinely new message, the strongest form of that test. A send over 587 still fails as mail_timeout 504 with retryable: false.status, headers or body is read as a response ENVELOPE, and an envelope may contain nothing else. A diagnostic object with a field called status therefore fails the run with invalid_return - and if that object was built in a catch, it HIDES the error it was meant to report. Cost me a debugging round on prod.mail.onmail.hu, IMAP 993 implicit TLS and SMTP 587 STARTTLS, credentials in /data/dev/.env). Everything below was measured against that server, not a fixture, and every fake-server claim in this section survived it: LIST and modified-UTF-7 decoding, EXAMINE reporting PERMANENTFLAGS () read-only, UID SEARCH including UNSEEN, a peek fetch of a genuinely UNSEEN message leaving it unseen (the weak version of this test uses an already-seen message and proves nothing), the direct parse of a good fetch returning NeedMore while the framed re-parse returns Ok, no tagged line in the buffer, and a multi-uid UID FETCH delivering zero bytes. A full send-and-read-back round trip confirmed an accented Hungarian subject surviving as two =?UTF-8?B? encoded words and decoding back exactly, quoted-printable chosen for the accented text, a lone . body line arriving intact and not double-stuffed, an RFC 2231 attachment filename, and BODYSTRUCTURE part numbering of 1.1 for the text inside a multipart/alternative inside a multipart/mixed with the attachment at 2. Note EXAMINE alone prevents a flag change, so that test confirms the read path is safe but does NOT isolate BODY.PEEK's own contribution.runner/tests/fake_mail_server.hpp): in-process TCP listeners on ephemeral ports. Ephemeral because a fixed port collides - twice during development a test reached a stale server from an earlier run and "passed" against the wrong process. They mask credentials before recording a transcript, and the SMTP one answers a bare AUTH PLAIN with a 334 challenge, not 235: answering 235 made an earlier harness report a working login for a client that had sent no credentials. It also un-stuffs the leading period during DATA, as a real receiver does, or a correct client looks like it double-stuffed.{n} are NOT a fixed shape. Measured against a real mail provider: when a fetch sets flags, the provider volunteers the new FLAGS in the SAME untagged line as the body, so the items before the literal vary in number and order. Anchoring on the first { after FETCH is safe; counting fields or assuming a prefix length is not. Our parser walks name/value pairs over a parsed s-expression, so order is already irrelevant and unrecognised items land in unknownItems rather than breaking the parse - three tests pin that instead of assuming it.mime_words tests arrived with a real person's name and a real work address in nine places, because the cases were ported verbatim and the accented display name is the entire point of the RFC 2047 cases. The substitute must therefore stay ACCENTED - a plain-ASCII placeholder would quietly stop testing what the case exists for. When replacing one, recompute any pre-encoded =?UTF-8?Q?...?= literal rather than hand-editing it, and let the decode assertion verify the new encoding: a one-byte corruption of the encoded word must fail that case, which is how you know it checks the encoding and not your arithmetic.src/functions/mime_words.* is adapted from an existing internal implementation, is owned elsewhere, and changes flow one way INTO this repo. If a decoding bug turns up here, report it rather than fixing only this copy.config.json is minimal: log_level, http.{bind_address,port}, database.address. Everything else lives in the DB and hot-reloads (subscribe + atomic snapshot swap).default project, no leading underscore - see gotcha): vectorapi_keys, vectorapi_settings. The settings collection holds the global doc (current) and one project_<name> doc per project carrying that project's embedding overrides (empty field = inherit; the body repeats project because the DB strips id). Per-project registry: <project>:vectorapi_collections. The vectorapi_ prefix is reserved (collection-create rejects _ and vectorapi_).projects:["*"], admin:true) and logs it once; SMARTBOTIC_VECTORAPI_KEY seeds it, OPENAI_API_KEY seeds embeddings._-prefixed collections misroute when project-qualified. Writes land in MemoryStore (mirror skips _-names) but reads of default:_foo route to LMDB → null. → service collections use no leading underscore (vectorapi_*). Suspected DB bug.dropCollection left the collection's indexes declared, before database 2.12.2. The documents and the metadata went; the declared indexes, unique ones included, stayed. A collection later created under the same name inherited a constraint nobody declared - a legitimate write refused as a duplicate, measured directly: a recycled name on 2.12.0 answered unique constraint violated on recyc#sku. Collection-create and collection-delete therefore undeclare indexes explicitly, which is idempotent on 2.12.2 and the correct behaviour against anything older. The create-time repair must be gated on "is anything still attached to this name", NOT on getCollectionInfo (anythingAttachedTo() in handlers/collections.cpp): a poisoned name has no collection, so a presence check skips the repair in exactly the case that needs it. 2.12.2 also made dropIndex work on an absent collection, which is what lets an already-poisoned name be repaired at all - on 2.12.1 nothing could clear one.svapitest_apiproj), so ctest must run serially - -j makes them delete each other's state - and the fixture has to purge the previous run itself. It drops each of the project's indexes before its collection, because neither dropProject nor dropCollection does (see the two caveats here). None of this shows up in packaging/devstack, whose database is new every time; it only appears once the suite runs against a persistent one, which the native host build now does.dropProject does not physically purge collection data. A recycled project name is otherwise blocked by stale collections/registry → the project-delete handler drops the registry + collections first, and collection-create drops invisible orphans (after the registry "exists" check).id from a document body, not the database client. This note used to say the client did it, and that is measured as false on client 2.12.1: inserting {"id":"body-id-value"} with an explicit document id stores the body field verbatim and it reads back alongside the real _id metadata. The stripping is ours, in documentBody() (documents_util.hpp), which erases id and then calls stripDbMetadata() to drop the six reserved keys. Keep doing it: the database stores a reserved key as an ordinary user field while every read overwrites it with the real metadata, so a body carrying _version would put an invisible shadow copy on disk that no read ever shows and no filter can reach. Our layer is what keeps stored documents clean (the database is fixing this server-side in 2.13.0, for every other client). API keys store their stable id as key_id in the body (exposed as id externally) - that predates this and the stored rows are not worth migrating, but it was never forced by the client.protobuf-compiler-grpc + libgrpc++-dev + libprotobuf-dev are installed - find_package(gRPC CONFIG) (used transitively by smartbotic-db-clientConfig.cmake) fails on a gRPCTargets.cmake referencing missing plugin files. The Docker base installs them.smartbotic-database/client debs must be built against the system's current Abseil; a stale build crash-loops on libabsl_*.so.<old>. Rebuild the DB if it won't start.--rebuild-base is required when DB_CLIENT_VERSION moves. The client version is baked into the Docker BASE image, so bumping the variable alone leaves the release build compiling against the old headers - it fails on the new entry points, or worse, silently links the old ones. Note devstack/run-tests.sh installs the client debs explicitly, so the TEST path can be on a newer client than the RELEASE path: a green suite is not evidence about the packages.systemctl start on an already-running unit is a no-op. A package postinst starts the service, so any config written AFTER apt needs a restart, not a start - otherwise the process keeps the config that existed at install time and the file on disk disagrees with the running state. Compare the file mtime against systemctl show -p ActiveEnterTimestamp when a setting appears not to apply.DB_CLIENT_VERSION (packaging/Dockerfile.base). Every 2.x client shares one SONAME, so a deb built against a newer client installs fine and only segfaults on the next restart - keep the pin equal to the deploy target, and ship a DB upgrade and a vectorapi rebuild together.pkg=<old version> uninstallable the moment anything newer was published - and that was never retention, only indexing: dpkg-scanpackages emits one version per package unless given -m, while the pool had kept every .deb all along (a publish reported "3 added, 309 unchanged"). Fixed 2026-10-08 in the deb-repo tooling; the trixie index went from 33 stanzas to 1191. A downgrade needs --allow-downgrades (apt-get install --allow-downgrades pkg=0.7.1-1 ...), and downgrade the three app packages TOGETHER or apt resolves a split version set. A plain apt install pkg still picks the newest, so ordinary installs are unaffected. The backup step still stages the installed .debs out of /var/cache/apt/archives/, which stays the right belt-and-braces for a rollback when the repo itself is unreachable.protoc. The host builds everything natively; use scripts/host-build.sh. The old symptom was real: generated protos wanted google/protobuf/map_field_inl.h, a header protobuf 35 removed. But nothing in the database's tree includes that header - an old protoc emits the include. The host had libprotobuf 35.1 and gRPC 1.83 from the distro, and a hand-dropped static protoc 25.2 in ~/.local/bin shadowing everything, while the distro's compiler package (protobuf-35.1, separate from protobuf-devel, which ships no protoc) was never installed. find_program(PROTOC protoc REQUIRED) took the 25.2 binary from PATH, generated code for a protobuf 25 runtime and compiled it against 35 headers. With a matching protoc the client and all of vectorapi compile and link natively. host-build.sh therefore picks protoc by version rather than PATH order and refuses to run on a mismatch, because the failure otherwise surfaces as a missing header deep in generated code rather than as a version complaint.encrypted_field (422) is its own slug, not validation. Database 2.17.0 encrypts any field named password, secret, token, api_key, apiKey or credentials at ANY depth in EVERY collection, and then REFUSES a filter, sort, index, unique constraint, relation or increment on one. It needs its own slug because the remedy is unlike every other validation failure: the request is well formed, the field name is correct, and no correction of the body helps - the caller must stop querying that field, storing a non-sensitive duplicate (a hash, or a boolean "set") or renaming it if it was never a credential. Folding it into validation would send them hunting a typo. Note what it REPLACES is worse than itself: before 2.17.0 a top-level field of those names was plaintext and filterable, and a NESTED one compared ciphertext and silently matched nothing - so the refusal turns a silently empty result into a visible error. Our /documents filter grammar, ?sort= and the index route all accept ANY field name with no validation, so a TENANT can trigger this; we cannot. Our own tests use password only as a ctx.mail option key, never as a stored field being queried.createCollection(..., maxVersions = 0, ...) and 0 means "keep unlimited history", not "keep none" - so every code push to a function has appended a full copy of the script forever. Measured on prod: justice-pa:vectorapi_functions.hlog 114 MB (the function REGISTRY, a handful of rows), default:vectorapi_function_jobs.hlog 14 MB, justice-pa:vectorapi_function_runs.hlog 4.7 MB - about 133 MB of the box's 192 MB of history, roughly 69%, none of it data anyone would ever read. A consumer's 47 MB of kb_chunks history is retention of the same kind on a collection that has not changed size in days.
IT IS A DISK AND GROWTH PROBLEM ONLY. I claimed history bytes dominate the at-rest encryption migration, and measured on prod's own data they do not matter to it at all. That claim was inherited from the database team's sizing model and amplified by me, and one measurement would have settled it before I asked them for a boot mode and asked a consumer to weigh an escape hatch. Measured with 2.17.1 on a copy of prod's data directory (1.6 GB, 24753 docs, 65 collections, prod's own config, 900 MB cap): 190 seconds total, of which the ENCRYPTION pass was 13 seconds (24733 rows scanned, 19 encrypted, 26 history versions) and compaction was 176 seconds, 167 of them novitax's single 339 MB env. The seal was under a second.
The structural reason, which is what makes it general rather than a quirk of this dataset: the migration only rewrites history belonging to ENCRYPTED collections. Our 114 MB vectorapi_functions.hlog and the consumer's 47 MB kb_chunks.hlog sit on encrypted=false collections, so they are scanned and left alone - encryption-verify reports novitax:kb_chunks with history 18648, plaintext-required 0. So the migration's cost tracks the largest project's data.mdb, through compaction, and almost nothing else. An operator with a huge history and a small env would read the old model and expect the opposite of what happens.
Memory: plan with ANONYMOUS memory, not RSS, and expect RSS to look alarming. Same run: anon 364 MiB, page cache 295 MiB, cgroup memory.peak pinned at the 900 MiB cap, and the process's VmHWM 1122 MiB - above the cgroup limit - with oom_kill 0. That is not a contradiction: the LMDB mmap is file-backed, so resident mapped pages count toward the process high-water mark while the cgroup treats them as reclaimable cache and evicts rather than killing. "It needed 1.1 GB" and "it needed 364 MB" are both readable off one run and only the second is the planning number. Anyone watching RSS cross 1 GB on a 2 GB box mid-credential-migration will reach for the kill switch; the page-cache explanation is not something they will derive at that moment.
PRUNING IS NOT BACKGROUND HYGIENE. It takes a GLOBAL lock. From database 2.17.1, createCollection(existing, maxVersions = N) with a lower N rewrites that collection's history keeping the newest N per document - but it runs synchronously while holding the store's global collection lock exclusively AND the global history-append lock, so essentially every operation that resolves a collection waits, in every collection, for its whole duration. Expect seconds to tens of seconds on a 100 MB file (unmeasured). So: never loop it under live traffic, give it a quiet moment or put it inside a window, and prune the big one alone. Moving it out of that lock is an upstream follow-up and is NOT in 2.17.1.
And it cannot be done BEFORE the encryption migration. There is no mode that boots 2.17.1 without migrating - it runs before the listener opens - so "prune first to shorten the migration" is unreachable. Just as well: the prune path has no test against an unmigrated store (its test runs on a fresh 2.17.1 store and asserts only counts, not that surviving versions decrypt), so the escape hatch would have exercised new code against old on-disk format in a configuration nobody upgrades into. The consumer who would have gained most from it was the one who decomposed the question correctly - "can it be deferred" is the easy half, "is the prune path safe against an unmigrated store" is the half that bites - and said they would rather have the long window. Worth remembering as a pattern: when an optimisation needs a state that only the optimisation produces, the question is never whether you can get into that state.
What disabling versioning costs, confirmed from their code rather than assumed, because the plan is to turn it OFF for the queue and the run log and keep a small N (5-10) on the registry: version history and restoreVersion/restoreToDate stop working for new writes, and a DELETED row can no longer be restored, because restore-after-delete reads the pre-delete state from history. That is why the REGISTRY keeps versions - an accidentally deleted function is exactly the row worth recovering - while a claimed-and-deleted queue row has no reader. It does NOT touch the WAL, replication, the event stream (actor included) or _version, which still increments; none of them read history, and recovery is snapshots plus WAL.FailedPrecondition means three different things and must be branched on FailureDetail.reason: missing_parent and delete_restricted are 422, read_only is 503, and an absent or unrecognised reason is 500, never a guessed 422. Mapping the bare code to 422 told a caller that a read-only database was its own validation mistake, so it would fix its payload and retry forever instead of waiting. Use the FailureDetail& overloads wherever a call offers one - the reason-less Failure form cannot tell these apart.ErrorCode::Aborted (client 2.12.0) carrying currentVersion, and maps to 409 version_conflict. It used to arrive as Unknown and fold into 503 "retry as-is", which is the opposite of the required instruction: re-read first. Never match on the message text for this.patch with a field set to null REMOVES the field (RFC 7396 merge), it does not store null. Use update for an explicit null.relations_enforced is readable since client 2.11.4 via tryGetRelationsEnforced(), which DECLINES to answer on a failed read rather than defaulting (getRelationsEnforced() is the fail-to-enforced variant, for code deciding whether it may rely on enforcement). The collection GET surfaces it, omitting the field when undetermined - absence never means disabled, so the web UI renders three states, not two.Client::get returns nullopt for BOTH "absent" and "transport failed" - it throws only for PERMISSION_DENIED - so a registry lookup cannot tell them apart from the return value. Unhandled, that reaches a caller as 404 "no such collection" for a collection that exists, and a 404 is unretryable BY DESIGN for a careful client, because adding it to a retry set would retry every genuine absence. A consumer lost a 6-minute ingest of an 8 GB mailbox to exactly this. CollectionRegistry::get therefore retries once (a transient failure usually succeeds, and logs a warning saying so) and then asks healthCheck() before reporting absence, throwing 503 when the database is unreachable. Reported upstream too: the client should distinguish, the way it already does for a permission denial.query_vector. Pinning query_text is NOT enough. query_text is embedded server-side through the external provider on every call - there is no query-embedding cache (emb.embed(cfg.model, text) in handlers/vectors.cpp), so the same text can yield a different vector on a different day and every score and row count moves with it. Measured by a consumer across one deploy over a byte-identical collection (12447 rows unchanged): an unfiltered top score went 0.7221 to 0.7175 and a filtered count 424 to 426, while five consecutive calls agreed to six decimals - so it is drift in text→vector, not per-call noise. The isolating test: a fixed explicit query_vector returned bit-identical results three times, which proves the RANKING is deterministic given a vector. So nothing in a release has to change for such a baseline to move, and it is therefore not evidence about the release either way. Corollary worth stating because it bit us: scan_capped is query-dependent too and so is also a measurement, not a property of the collection - it is set only when the walk hit the cap while still short of top_k, so a query that fills top_k reports false where a query that falls short reports true. Read all three of the useful assertions (scan_capped/scanned/the nested error envelope) as "this query, this filter", never as facts about the data.query_vector stays the only reproducible baseline.query_text is 0.49-0.95 s, essentially all of it the provider round trip; the SAME text repeated is 0.022 s, because the provider caches it. That cache is useless to a workload of unique queries such as a voice assistant, which is therefore permanently on the 0.5-1.0 s path. Eight samples in one window is a MEDIAN, not a tail: a 12-15 s text search was observed earlier the same day and did not reproduce, so the bad tail is real and unexplained rather than bounded at 0.95 s. Quote these as medians and say so.query_vector search returned in 3.4 s against 12-15 s for the same filter and top_k via query_text. There is no query-embedding cache, so every repeated search pays the provider again.topK 500 took 51 ms indexed against 187 ms for the same search unfiltered - the filter makes it CHEAPER, because only matching rows are scored. Our emulation took 3.21 s for that shape on prod.
scan_capped is emitted EXPLICITLY as false on this path, never omitted, and scanned is 0 because no walk happened - which here is literally true rather than a sentinel. A consumer maps an absent scan_capped to "this server cannot report truncation, so completeness is unknown" and shows that to an operator; on this path that is both false and PERMANENT, and a warning that always fires is one people learn to skip. Absence is also already spoken for by the 0.8.3 agreement, where a missing field means "old server" and nothing else.filters_applied response field, not a version check we have to get right. A pre-2.14.0 server would silently answer UNFILTERED, so the client throws FailedPrecondition / filters_unsupported instead - which is the only reason the new path can be tried optimistically. The refusal is LATCHED per process, so a deployment on an older database pays one refused round trip rather than one per search; one-way on purpose, since the emulation is correct and merely capped, and it clears on the restart a database upgrade involves anyway.filter_mode is on the response now, and a function's .search() carries it too. "server", "walk" or "none", from the single filterModeName() so the HTTP route and the runner cannot spell it differently. On the function surface the return stays an ARRAY and the flags ride as NON-ENUMERABLE properties, so indexing, length, iteration, spread and JSON.stringify are byte-identical to before and a script written earlier is unaffected - tests assert each of those, and that the flags do NOT appear in JSON.stringify. The prelude also tolerates a host answering the old bare-array shape, so the two halves deploy in either order. The console warning STAYS: it is what an author reading a run log sees, and the structured flag is for the function's logic and for any model downstream of it - a consumer's own bug was exactly that their assistant was never told a search had degraded and said "nothing in memory" with confidence.VectorSearchResult::serverFiltered records which path answered, because scanCapped == false means two different things: false BY CONSTRUCTION here (a sweep of a filtered set is sound) versus "complete this time" on the walk (it is not). A caller cannot infer it from /api/v1/version, which reports the CLIENT library version while the path depends on the SERVER - a 2.14 client against a 2.13 server reads as the new path while running the old capped one. Whether to expose it to callers is still open.Depends floor had to move to >= 2.14.0, and that is load-bearing. Verified rather than assumed, with nm on both shipped .so files: the 5-argument symbol exists only in 2.14.0, while 2.13.1 carries just the 4-argument form. Since every 2.x client shares one SONAME, leaving the old >= 2.12.0 floor would have let apt install this binary against a client that cannot resolve the call - the failure that "installs fine and only breaks on the next restart".collection_schema is introduced in 2.16.0, and capability names gate features from 2.15.0 onward, so serverSupports(Capability::kCollectionSchema) answers correctly; a 2.16.0 client calling the schema methods against an older server gets FailedPrecondition / server_unsupported. filtered_similarity is NOT gated that way because it predates the capability API and a 2.14.0 server reports no capabilities at all while fully supporting filters. The rule: a capability name is sound for a feature introduced in 2.15.0 or later, and unsound for anything older.
Design as the database team specified it, for when we implement: a JSON Schema SUBSET with draft 2020-12 meanings (type incl. ["string","null"] for nullable, required, additionalProperties, lengths, ranges, enum, const, pattern as RE2, format, items, nested properties), and anything outside it REFUSED at set time with invalid_schema so a schema can never look stricter than what is enforced. _vector is NOT part of the validated body - dimension stays the collection's vector_dimension. A violation is INVALID_ARGUMENT / schema_violation whose fields carry the violating PATHS (addr.zip, tags[2]) and whose message names the rule and size, with values deliberately not echoed. getCollectionSchema() is a separate call (a read grant suffices) so no public struct changes size. A schema may be set, replaced or removed at any time in enforce mode (every existing row validated FIRST, refused with counts and up to 10 example ids if any violate) or audit mode (applied regardless, violations counted and let through) - and it is armed under the collection's write lock BEFORE the scan, so no write slips past. Validated on insert/update/upsert/patch (on the MERGED result)/increment/batch/set ops/restoreVersion; NOT on WAL replay or replication apply, which replay already-accepted writes. suggestCollectionSchema() generates one from the data, which suits a button in the editor.GetServerInfo, serverInfo(), serverSupports(name) and Client::Capability constants, and from it the client and server release independently (2.15.0 is the last lockstep release; the server no longer pins libsmartbotic-db-client (= VERSION)). Nothing in it changes our 2.14.0 alignment. The trap, flagged by the database team: serverSupports(Capability::kFilteredSimilarity) is FALSE against a 2.14.0 server, which has no GetServerInfo but fully supports filters. Capability names gate only features introduced in 2.15.0 or later, so a capability check there would silently drop us onto the emulation against the very server we just deployed. Keep what is built: call the filtered overload, and fall back only on FailedPrecondition with reason filters_unsupported. Adopting 2.15.0 would also make serverInfo() a cheaper answer than a filter_mode response field, because it finally exposes the SERVER version - which is the thing that decides support, and the gap that made version inference unsound. Note it costs one cached GetServerInfo per client per 60 s.minScore 0.0 DROPS rows whose cosine is negative, so "fewer matches than topK returns all of them" means all that score at or above minScore - pass a negative minScore to see genuinely every match. And from 2.14.0 rows with EQUAL scores are ordered by id, lower first, including when a tie straddles the cut; that applies to the unfiltered search too and was previously unspecified, so it is observable only on duplicate vectors.similaritySearch, so a filtered search fetches the filter's ids with find() and then re-runs the WHOLE similarity search with a growing limit, intersecting in our process. Measured on prod with an explicit query_vector (no embedding in the path), on 12447 rows at dim 4096: unfiltered top_k 500 is 0.26 s, filtered top_k 500 is 3.21 s having issued three searches (2000, 8000, 10000), and a filter matching nothing is 0.05 s. Time tracks rows fetched almost linearly, ~0.3 ms per candidate - neither the vector arithmetic nor the 1 MB response is the cost. firstScanDepth()/nextScanDepth() (vector_search.hpp, pure, 8 tests) therefore go straight to the cap when the filter matches fewer rows than topK (the early exit can never fire, so every step before the cap is certain waste) and otherwise widen by the hit rate the previous pass actually measured. scan * 4 stays the FLOOR, so a mis-estimate can only skip steps and never shrink one - progress stays guaranteed and nothing can get slower. The RESULT is unchanged in every case: each pass is a prefix of the same ranking, so the first topK matches within it are the same rows whatever depth the walk stopped at. The real fix is a server-side filtered similarity search, requested and designed for database 2.14.0; this emulation must keep working regardless, as the path for any older server.kVectorFilterScanCap (10000) deep into the ranking, so on a larger collection a filter whose matches lie deeper is silently short - measured at 455 returned of 553 true matches on 12448 rows. VectorSearchResult::scanCapped is set ONLY when the walk hit the cap while still short of topK and the ranking was not exhausted, so a filter that merely matches fewer rows than top_k is correctly reported as complete rather than crying wolf. The HTTP route adds scan_capped/scanned; ctx...search() keeps its ARRAY return and warns in the run console instead.db_errors.hpp, client 2.11.4). Client::Error::code() on the throwing calls and the Failure& overloads on update/patch/remove feed one translate(): AlreadyExists → 409 duplicate_values, or duplicate_id when reason says so (database 2.12.1: a taken document id and a taken unique field value are the same code but different remedies), FailedPrecondition → 422 relation_violation, NotFound → 404, Unavailable/DeadlineExceeded/Unknown → 503, everything else → 500. ErrorCode::Ok on a call that returned false means "did not apply", not an error - map it to 404, or a plain missing document becomes a 500 with an empty message.nlohmann::json STORES invalid UTF-8 and throws only when you serialise it. A binary /fn request body therefore reached the run request intact and blew up at dump() with type_error.316, which surfaced as a 500 with nothing pointing at the body while the function never ran. triggerBodyFields() (functions/trigger_body.hpp, pure) now offers unserialisable bytes as base64 under their OWN keys - body stays null, bodyBase64 carries them, bodyEncoding is "base64" - because base64 placed in body would hand an unprepared function a plausible-looking string that is not what was sent, and silent corruption is worse than a visible null. bodyEncoding is absent for a text body, so an existing function's trigger shape is unchanged. isValidUtf8() (utf8_text.hpp) must agree with nlohmann's own decoder, not with a reading of RFC 3629 - a sequence it accepted and nlohmann rejected would only move the 500 - so it refuses overlongs, the surrogate range and anything past U+10FFFF, and the tests cross-check it against a real dump() over every single byte and all 65536 two-byte sequences rather than trusting either side alone.vector/_vector hole, a consumer verified their pipeline could not hit it - one definition, one call site, the embedding route, no vector field - and then corrected my reassurance: their original junk row came from a MANUAL PROBE, a query body posted to the documents route by hand during an investigation. So the gap sits on debugging activity, not on deployed code, and it is WORSE there: a hand-written write is read back by id, the row is present, and the operator concludes success. One character between vector and _vector, a 201, and a row findable by nothing, forever. The question to ask a consumer about this class of defect is not what their code sends but what their operators type while debugging - and hand-writing a document into a vector collection is something people do precisely when something is already wrong. Their mitigation until the guard reaches prod is the right one and applies to us: read back a manual vector write BY SEARCH, never by id.vector_missing accepted a body carrying either _vector OR vector, while the documents route stores the body verbatim and a search reads _vector. So a row written with vector got a 201 and was then findable by NO search - the unsearchable junk row the guard was written for, admitted by the guard. Measured with two rows inserted under the two spellings from the same vector: only the underscored one came back. Now refused, with a message that also says to REWRITE any row already stored that way, because a caller who hit this has unfindable rows behind them and silently fixing only their next write would leave those while looking solved. Found by a consumer asking which field a RESTORE should write - the question exposed it, not a test.vector_b64 back into the documents route used to answer "a document must carry _vector" - accurate, and read by someone restoring a 294 MB file at 3am as "my backup has no vectors", which is indistinguishable from real data loss and will be believed. A consumer named that misreading after doing the restore. The message now names the export's own field, states that the backup is FINE, and says to expand the base64 - and a test asserts the ORDINARY missing-vector case does NOT mention a backup, so the reassurance cannot be given where it would be a lie. The general rule: when an error can be read as "your data is gone", say explicitly that it is not.vector_format=base64 emits vector_b64; POST .../documents wants _vector as a number array and POST .../vectors wants vector as a number array. So the one path a backup exists for does not round-trip without expanding the base64 first, and the 422 a caller gets names what is MISSING rather than the good vector sitting in the field the exporter wrote. Documented in api/llms.txt; whether to accept a base64 write form is open.query_vector must score a row identically in the restored and original collections (they measured a delta of 0.00e+00). Only retrieval BY SIMILARITY exercises what a vector is for - which is the same lesson as a digest that matched while the ordering was wrong.documentBody() in handlers/documents.cpp is used by POST, PUT and PATCH: it unwraps {"data":{...}}, strips id (the document's identity, from the body on POST and from the URL on PUT/PATCH), and rejects data alongside any other top-level key with 422 ambiguous_body. Before 0.3.3 only POST unwrapped, so a {"data":...} PUT stored the wrapper as a literal field and a data-plus-siblings POST dropped the siblings silently. A literal top-level data field is still writable as {"data":{"data":...}}.SVAPI_QUICKJS_TAG, runner/CMakeLists.txt). QuickJS bytecode carries no version stamp, so a silent upgrade makes a cached blob misread rather than fail. quickjs-ng, not Bellard's tree: the module/promise/stack entry points the core needs (JS_GetModuleNamespace, JS_PromiseState, JS_SetMaxStackSize, JS_IsJobPending) are public API there. JsBytecode is an in-process cache only - never persist it without a QuickJS build fingerprint.JSRuntime, not the JSContext. A fresh context per run is therefore not enough to isolate tenants: a run that times out mid-microtask leaves its jobs queued, and they would execute inside the next tenant's run. The core flushes them with the deadline forced into the past and marks the runtime poisoned() if anything survives; the pool destroys a poisoned runtime instead of leasing it out. An OOM poisons it too./etc/smartbotic-vectorapi must stay mode 0751, not 0750. The runner runs as its own user and needs +x to traverse the directory to runner.json; it still cannot list it, and the server's 0640 files stay unreadable to it. Both server.postinst and runner.postinst set it, and a server upgrade resetting it to 0750 breaks the runner on its next restart - a failure that surfaces weeks later with no obvious cause.imapUidFetch is viable for BOTH overloads - {7, 9} is either the set 7,9 or the single range 7:9, and {uid} is either one uid or the range uid:0 - so the two readings are DIFFERENT COMMANDS. clang silently picks one, GCC refuses the call, and the whole mail surface therefore compiled cleanly on the host for days and then failed the first release build it ever saw. Call such an overload set with an explicit vector type. The lesson is bigger than the call: scripts/host-build.sh passing is not evidence that the .deb will build, so a feature is not finished until the Docker path has compiled it.Depends lists are HAND-MAINTAINED - create-debs.sh copies each control.* template verbatim and never runs dpkg-shlibdeps, so a new shared-library dependency does not appear by itself; it surfaces as a service that refuses to start on a customer box. The mail surface added two to control.runner, both confirmed with ldd against the built binary rather than guessed: ca-certificates, because the vendored curl detects the CA bundle at CONFIGURE time and bakes the path in, and with TLS verification always on a missing bundle makes every mail connection fail as mail_tls_untrusted (which reads as a broken mail server, not a missing package); and libidn2-0, because the vendored curl keeps IDN support. IDN is deliberately not compiled out - mail hostnames are usually ASCII, but breaking an internationalised one to save a dependency is the wrong trade. zlib, zstd and brotli are deliberately absent: they are HTTP content encodings, HTTP is compiled out of the vendored curl, and leaving them enabled made them real package dependencies for capabilities the code cannot reach.config.json ships with no functions.runners endpoints, and the server disables the function routes when the list is empty (answering 503). An operator has to add the endpoint by hand, and set the same SVAPI_RUNNER_TOKEN in both vectorapi.env and runner.env.PROXY is compiled OUT, and CVE-2026-80230 (public-key pinning not enforced when peer verification is disabled) cannot apply because verification is always on and we pin no keys. The HIGH one is unknown. Since we VENDOR curl, a fix means rebuilding and republishing both binaries - apt cannot see a statically linked curl - so this is ours to do.applyOutboundDefaults() disables; the WebSocket subprotocol and ping fixes need WebSockets, which we do not use; the SSE stale-event-id fix needs SSE, likewise. v0.60.1 is Windows certificate handling and an MSVC compile error. So the 0.59.0 pin stays deliberately, for the same reason it was not moved for the regex stack-overflow fix. Worth upgrading for hygiene when something else forces a rebuild, not before.cmake/Dependencies.cmake) and the pin carries its reasoning. Currently v0.59.0. Check for an upgrade periodically: it serves the public HTTP surface AND every outbound call, upstream ships security fixes most releases, and we were 17 releases behind before anyone looked. When evaluating one, judge each fix against what this service actually reaches rather than the changelog's severity - CPPHTTPLIB_REQUEST_URI_MAX_LENGTH (8192, enforced before routing) means a long-path attack answers 414 before routing and never reaches the regex matcher, so the headline regex stack-overflow fix was never our exposure (verified against a running server, after first proving which process held the port - an earlier run of this test hit an unrelated service listening on the port I had picked), while the request-PARSING fixes (chunked transfer-coding matching, Content-Length truncation, chunk-size control characters) are. Deliberately NOT on the newest release when its fixes are for backends or features we do not use.webui/src/monacoSetup.ts) so the editor works offline - do not revert to the CDN loader.Type=notify; the binary must be built with libsystemd (it is, when libsystemd-dev is present) or change to Type=exec.VERSION and api/openapi.json's info.version must agree, and packaging/build.sh now refuses to build unless they do (scripts/check-version-sync.sh, run at the top level so it covers the local, Docker and publish paths alike). They drifted once: 0.10.0 was published with the docs claiming 0.9.2, and since openapi.json ships in the server package and is served at /openapi.json, the stale value was live. Correcting it cost a whole release, because a published version number is never reused for different content - which is why 0.10.0 exists but must never be deployed. A release step that relies on remembering is a release step that gets skipped, so it is a check rather than a checklist line.
./packaging/build.sh # Debian-13 .debs → dist/debian13/ (3 packages: server, webui, runner)
./packaging/build.sh --no-runner # skip the runner package
./packaging/build.sh --repo --suite trixie --sync # + publish to repository.smartbotics.ai (outward-facing!)
Publishing uploads to the live apt repo - only with explicit confirmation. The deb-repo tooling is /data/dev/smartbotics/smartbotics-deb-repo/scripts/ (override with DEB_REPO_DIR).
Release packages always come from the Docker path. The dev host (zeus) runs Void Linux, so --local there compiles, runs the tests and leaves a runnable binary in build/src/ but refuses to build .debs (and refuses --install/--repo/--sync) - a Void-linked package would not install on Debian 13. --local still packages normally on a Debian-family host.