You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Integrate sqlite-vec for HNSW vector search (follow-on to #1219) #1221
Issue #1219 migrated the local DB from SurrealDB to SQLite (libsql). The migration is complete and all operations are working correctly and faster.
One item was intentionally deferred: the search_embeddings method currently uses a linear scan (load all non-stale embeddings, decode in Rust, compute cosine similarity in a loop). SurrealDB used an HNSW index via the `<|K,EF|>` KNN operator.
What needs to be done
Add `sqlite-vec` to workspace `Cargo.toml` and `packages/core/Cargo.toml`
In `SqliteStore::initialize_schema`: load the `sqlite-vec` extension and create the `vec_embeddings` virtual table:
```sql
CREATE VIRTUAL TABLE IF NOT EXISTS vec_embeddings USING vec0(
embedding_id TEXT PRIMARY KEY,
vector FLOAT[768]
);
```
In `upsert_embeddings`: after inserting into `embedding`, also insert into `vec_embeddings`
In `delete_embeddings`: also delete from `vec_embeddings`
Rewrite `search_embeddings` to use the `vec0` KNN query instead of linear scan:
```sql
SELECT ve.embedding_id, ve.distance
FROM vec_embeddings ve
WHERE ve.vector MATCH ? AND k = ?
```
Then group by node_id and compute composite score (same density formula as current).
Why deferred
Linear scan is correct and fast enough for current corpus sizes
sqlite-vec extension loading needs testing across macOS/Windows/Linux builds
SurrealDB HNSW search was O(log N). Current linear scan is O(N). For a 10k-node corpus with ~3 chunks/node (~30k vectors × 3072 bytes = ~90MB) the linear scan takes ~100ms. With sqlite-vec HNSW it would be ~5ms.
Activity
WIP: Phases 4-5 complete — all compile errors fixed, all tests passing
Migrate local DB from SurrealDB embedded to SQLite (libsql) (#1222)
malibio commentedon May 28, 2026
Frontend baseline: 130 test files, 3936 tests passed (Duration 37.1s)
Migrate local DB from SurrealDB embedded to SQLite (libsql) (#1222)
Integrate sqlite-vec for vector search (closes #1221) (#1224)