Skip to content

feat(code-intel): store vectors in one vecq file per project - #752

Merged
ajianaz merged 1 commit into
developfrom
feat/per-project-vecq
Nov 16, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/per-project-vecq

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • Each project has its own vector file, <data dir>/vectors/<project id>.<model>.vecq (vecq residual, keyed by symbol id). It is rebuilt from the project's symbols after every index run that changed them, when the model changed, or when the file is missing or built with other dimensions, and replaced atomically (temporary file, then rename).
  • A search embeds the question and scans only the current project's file, cached per process and reloaded when the file changes (so the MCP server sees a re-index). No other project's vectors are read, filtered or returned.
  • The files of the former shared index (cora_index.*) are deleted after the first successful embed; the file of a model a project no longer uses is removed; a project's files are deleted with the project (cora findings prune, index --rebuild).
  • Removed: the usearch store and dependency, the shared index lock and .keys sidecar, the global self-heal that cleared every project's fingerprints, and the per-symbol embedding fingerprints (the column stays in the schema, unused). brain.vector_store and brain.vector_bits no longer do anything; a config that still sets them loads and prints one warning.
  • Docs (configuration, code intelligence, CLI reference) and changelog describe the layout.

Why

Measured on 176 real projects (127,400 functions, the real code model, cora's own usearch and vecq settings; spike branch chore/spike-vector-layout): the shared index let other projects crowd the current one out of the candidates (the vector signal lost 11 to 29% of its MRR@10 and 16 to 34% of its recall depending on --limit, and up to 26% of the queries got no vector candidate), never freed the vectors of deleted symbols (30% of one real index), cost +148.5 MB resident and 195 ms to load in every process, and rewrote every project's vectors on each re-index. A per-project vecq file matches the exact ceiling at every size measured (even one project of 127k vectors, where HNSW lost 2 to 15% of the recall), is 4.3x smaller, loads in 0.1 ms and re-indexes in milliseconds. Closes #750.

Testing

  • Unit tests: build and save (atomic, no temporary file left), load with the same ids, a rebuild leaves no trace of old symbols, missing / wrong-dimension / corrupt files are reported and not trusted, the process cache sees a rewritten file, a wrong-sized query returns nothing, removal matches the project id exactly and can keep a model.
  • Integration tests (toy model, no network): one file per project and model; a model switch re-embeds without a file change and removes the old model's file; re-indexing leaves no vector of a deleted function; the former shared index files are removed; old config options warn and do not break indexing.
  • With the real model on this repository cora brain MRR@10 is unchanged (0.319 on 39 hand-written questions, 0.515 on 400 doc-comment queries, against 0.316 and 0.517 before). Indexing 4,492 symbols produces a 1.2 MB file instead of 5.3 MB, in 5.0 s with a 144 MB peak, as before.
  • cargo fmt --all -- --check, cargo clippy --all-targets --features tree-sitter -- -D warnings, cargo test --features tree-sitter, cora review --base origin/develop: no issues.

The shared vector index let other projects crowd the current one out of the
search candidates (on 176 projects the vector signal lost 11 to 29% of its
MRR@10 and up to a quarter of the queries found no candidate), never freed the
vectors of deleted symbols (30% of one real index) and was read into memory by
every process (+148 MB at 127,400 vectors).

Each project now has vectors/<project id>.<model>.vecq in the data directory.
It is rebuilt from the project's symbols after every index run that changed
them (or when the model changed, or the file is missing or from another
dimension) and replaced atomically, and a search reads only that file, cached
per process and reloaded when the file changes. The files are 4.3 times smaller,
load in 0.1 ms, add no resident memory and retrieval stays at the exact ceiling.

The files of the former shared index are deleted after the first index, a
project's files are deleted with the project (cora findings prune, index
--rebuild), the per-symbol embedding fingerprints and the shared lock are no
longer used, and the usearch dependency is removed. brain.vector_store and
brain.vector_bits no longer do anything: a config that still sets them loads and
prints one warning.
@ajianaz
ajianaz merged commit 4677cb0 into develop Nov 16, 2026
16 checks passed
@ajianaz
ajianaz deleted the feat/per-project-vecq branch November 17, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(code-intel): store vectors in one vecq file per project instead of one shared index

1 participant