Returns a process-wide, in-memory-backed connection for api_version:
on first access, opens the on-disk file read-only via open_store,
copies its entire contents into a fresh :memory: connection (via
SQLite’s backup API), then drops the on-disk connection immediately —
so its file handle/lock is held only for that brief copy, not for the
process’s lifetime. This means an external process (a fresh
github-mcp-populate-embeddings run, a deployment replacing the file) can update
mcp_store.db without hitting “database is locked” against a live
server, at the cost of the running process only picking up such an
update on its next restart.
Opens mcp_store.db read-only: this crate’s binaries only ever read
it, except github-mcp-populate-embeddings (a separate [[bin]]), which uses
open_store_read_write instead.
Read-write counterpart to open_store — for bin/populate_embeddings.rs,
the one binary that actually writes to mcp_store.db (backfilling
semantic_endpoints, whose table every other caller only ever reads
from).
Resolves the active api_version (from the config cascade) to its
store file. Every .db this crate supports is embedded into the
compiled binary via include_bytes! (VERSION_STORE_BYTES) exactly
like validator.rs embeds each version’s schema — there is no
filesystem fallback chain to reason about, and this crate never
depends on any particular .db file existing anywhere on disk after
cargo install. The one difference from a schema lookup: SQLite
needs a real file to open a Connection against (unlike a &[u8]
JSON schema, read directly from memory), so this extracts the
embedded bytes to a fixed path in the OS temp dir on every call —
cheap, since it only runs once per process start, and it means a
rebuilt binary with different embedded bytes (a populate_embeddings
re-run, an add-version update) can never be shadowed by a stale
leftover from a previous install at that same path.
k-nearest-neighbor search over semantic_endpoints (sqlite-vec’s
documented MATCH ... AND k = ... query form). query_embedding must
come from the same model as the vectors it’s compared against — see
services::embedding_service. Bound as a raw little-endian f32 blob,
the same wire format bin/populate_embeddings.rs writes (sqlite-vec
accepts either that or a JSON array per-call, independent of how any
given row was originally inserted, so this is a consistency choice, not
a correctness requirement).