Documentation menu
Storage and search
Where Ktesio Build keeps its data, how search runs, and how the embedding model was chosen.
On this page
Ktesio Build keeps records in git and everything else in one SQLite file. Search is full-text plus a vector scan over that file, with no server and no vector database. This page says how each part works and what was measured before choosing it.
Where data lives
Git is the source of truth. Records are Markdown files with TOML front matter under .ktesio/, one folder per kind. They are reviewed in PRs, shared with the repo and readable without ktb.
.ktesio/cache/index.db is one SQLite file. It is git-ignored and holds two kinds of tables (dec-c01ssz).
Index tables are rebuilt from git, and dropped when the schema changes:
| Table | Holds |
|---|---|
files | path, hash, language, doc summary |
syms | name, kind, signature, line, exported, doc |
edges | module edges |
recs | copies of the records |
sym_fts, rec_fts | FTS5 full-text indexes |
emb | vectors |
packs | cached packs |
Run state is never dropped, only added to:
slices,tasksoutcomes, which routing learns fromtriage,team,asm_uses,verify_cache,meta
What gets a vector
ktb sync embeds three things:
| Source | Text embedded |
|---|---|
| Exported symbol | name split into words, kind, signature, doc, file stem |
| File | one summary: path words, doc, up to 24 exported names |
| Active record | title and the first 600 characters of the body |
A vector has 256 dimensions, stored as i8 with a 4-byte scale: 260 bytes each. Its key is a hash of the embedded text, salted with the model id. Unchanged text is never embedded again, and a different model gets different keys. Vectors that nothing refers to are dropped at the end of each sync.
Sync does the embedding. At query time only the query itself is embedded.
The model
Ktesio Build computes static model2vec embeddings inside the binary (dec-8n0gyv):
- a greedy WordPiece or unigram tokenizer;
- camelCase and snake_case identifiers split into words;
- mean pooling, then L2 normalization.
One sentence takes a few microseconds. There is no ONNX runtime.
The default model is minishlab/potion-base-8M. It is fetched once per machine with the system curl into the user cache folder (KTESIO_HOME overrides the folder). It is then converted to model.kte, which stores i8 rows and is about a quarter of the original size. Every repo on the machine shares that file. A failed fetch is retried at most once an hour.
Set [index] model to off, or to a local folder that holds a model.
How search runs
Search lives in crates/ktesio-context. Every query takes the same steps:
- Full text. FTS5 ranks symbol or record words by BM25. Stop words are dropped and the remaining terms are OR-ed.
- Vector scan, if a model is loaded. A brute-force integer dot product runs over the stored
i8vectors and keeps the top k. A hit is dropped when its cosine is 0.25 or less, or when it is more than a band below the best hit. - Merge. The ranked lists are merged by reciprocal-rank fusion.
| Searched | Band below the best hit |
|---|---|
| records | 0.12 |
| symbols | 0.25 |
| files | 0.2 |
The two commands use the pipeline differently:
ktb recall --textsearches records.ktb packsearches symbols and file summaries. It then adds the module neighbours of the hit files (a graph walk) and the records whosepathscover them, and cuts the result to the tier budget. See Index and context packs.
Without a model, FTS5 and the graph walks still work.
Why vectors stay in SQLite
Vectors are rows in index.db, not in a vector database (dec-0ncvrj). Measured 2026-11-28 on 4 cores with 256-dimension vectors, top 40:
| Vectors | SQLite i8 scan (Ktesio Build) | LanceDB 0.41, no index | LanceDB, IVF_PQ index |
|---|---|---|---|
| 10k | 4 ms | 22 ms | – |
| 100k | 26 ms | 150 ms | 4–15 ms |
| 1M | 220–350 ms | 1.45 s | 6–30 ms |
Size on disk, vectors only:
| Vectors | SQLite (i8) | LanceDB (f32) |
|---|---|---|
| 10k | 2.7 MB | 10 MB |
| 100k | 27 MB | 103 MB |
| 500k | 137 MB | 513 MB |
| 1M | 274 MB | 1,026 MB |
The LanceDB index adds about 2%.
A typical repo has a few thousand to tens of thousands of vectors. This repo has 493.
What LanceDB would cost:
- 538 crates in the lockfile, against 72 for
ktb; - a 240 MB stripped binary, against about 22 MB;
- a clean release build of about 27 minutes on 4 cores;
protocat build time;- index builds of 14 s at 100k vectors and 35 s at 1M, refreshed as code changes;
- vectors split from the symbols and records they belong to.
Revisit this past about 500k vectors. The scan spends about 75 ms per 1M vectors on dot products. The rest is reading rows, so a memory-mapped vector file would come before a vector database.
Models evaluated
ONNX transformer embedders (fastembed). Not adopted (dec-8n0gyv). They need the ONNX runtime and tens of MB of native code, and take milliseconds per sentence.
Static models. Published MTEB scores, from the model2vec results:
| Model | Kind | MTEB average | MTEB retrieval |
|---|---|---|---|
| all-MiniLM-L6-v2 | transformer baseline | 55.93 | 42.92 |
| potion-base-8M | static | 51.08 | 31.11 |
| blink-8m | static | 55.35 | 38.86 |
On this repo, blink-8m did not carry its MTEB lead over (dec-xr8xqw). Results from the benchmark below, 2026-11-28, full pipeline, hit@1 / hit@5:
| Model | Records (58) | Code (44) |
|---|---|---|
| potion-base-8M | 79% / 95% | 57% / 86% |
| blink-8m | 60% / 88% | 59% / 86% |
| no model | 60% / 81% | 55% / 77% |
On the second question set alone, records hit@1 is 86% for potion-base-8M and 62% for blink-8m (n=29).
It is not a loader issue: the embeddings match the model2vec reference library, with a median cosine of 1.000. These were tried for blink-8m and dropped:
- zipf, IDF and norm-power token weighting: all worse;
- title-only and per-sentence record vectors: the best reached 69% hit@1 on second-set records, still under potion-base-8M, at several vectors per record.
Both models cost the same: 256 dimensions and a vocabulary of about 30k, with sync at about 230 ms and a pack at about 35 ms on this repo.
Why potion-base-8M: best on records, tied on code, same cost. The sets are small, so a few points either way is noise.
The retrieval benchmark
python3 scripts/bench-recall.py target/release/ktb [--model SPEC]scripts/bench-recall.json holds 58 paraphrased record questions and 44 code-search tasks, each with a known answer. 47 of them were written as a second set after the first results and before any tuning.
The script runs the real ktb recall and ktb pack on a clone of HEAD. It reports hit@1, hit@3, hit@5, MRR and median ms, and fails when a target is stale.
CI floors for the repo's own model:
| Command | Floor |
|---|---|
ktb recall | hit@1 ≥ 70%, hit@5 ≥ 88% |
ktb pack | hit@5 ≥ 80% |
Each floor is above the no-model result, so broken embeddings fail CI.
--model compares another model, or off, and only reports.
To evaluate a new model:
- Run
python3 scripts/bench-recall.py target/release/ktb --model org/name. - If it wins, record a decision with
--supersedes dec-xr8xqw.