Skip to content

brain search: vector signal never fires in a fresh process (VECTOR_CACHE never loaded from disk) #545

Description

@ajianaz

What

cora brain <query> (and MCP cora.brain_search) never include the vector signal in a fresh process. Every query returns signals=fts (+ graph) only, despite a valid cora_index.usearch on disk.

Root cause

vector_search (src/index/brain.rs:360-366) only reads VECTOR_CACHE:

rust let cache = VECTOR_CACHE.read().unwrap(); let vi = match cache.as_ref() { Some(v) if !v.is_empty() => v, _ => return Vec::new(), // ← fresh process: cache is None → bail };

The cache is populated only by embed_project (the cora index path, src/index/brain.rs:150-159). CodeVectorIndex::load_or_create has no caller on the search path. cora brain and cora index are separate processes, so the vector index built by index is invisible to brain.

Repro (develop @ 55f965c, isolated CODECORA_HOME)

$ printf 'fn alpha() {}\nfn beta() {}\n' > lib.rs
$ cora index
✅ Indexed 2 symbols from 2 files
$ ls ~/.codecora/cora-code/
cora_index.usearch  cora_index.keys  cora.db
$ cora brain alpha
🧠 1 results for 'alpha'
  alpha (lib.rs)  [function]  score=0.0164 signals=fts   ← no vector signal

Cross-process check: rename cora_index.usearchcora_index.usearch.bak, run cora brain alpha again — identical output, no warning. Search never touches the file.

Impact

Suggested fix

In vector_search, on cache miss load the index from disk before giving up (respecting current_vector_store() for the extension), e.g.:

rust let vi = match cache.as_ref() { Some(v) if !v.is_empty() => v, _ => { drop(cache); // populate cache from disk (load_or_create), then re-read } };

Mind the write-lock ordering with embed_project and the dimension-mismatch handling (check_dimension_compat). A user-visible notice when the store is empty but symbols exist would also help diagnosis.

Found while reviewing #543 (that PR is opt-in vecq; this bug is pre-existing on develop).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions