spacedb-vector
SpaceDB Layer 4 — the private-RAG substrate.
A native, on-node vector index co-located with the data: a query embedding goes in, and only the top-k results come out. The corpus never leaves the home.
Part of SpaceDB. Dual-licensed MIT OR Apache-2.0.
[]
= "0.5"
The model
use ;
use Decision;
let embedding_a: = .map.collect;
let embedding_b: = .map.collect;
let query_embedding = embedding_a.clone;
let decision = Allow; // from spacedb-access `authorize`
let mut index = new;
index.insert.unwrap;
index.insert.unwrap;
// An AI agent's retrieval is gated by an mID capability decision.
let hits = retrieve.unwrap;
for m in hits
retrieve refuses with VectorError::Denied unless the
spacedb-access Decision allows it. That is the concrete
mechanism behind "inaccessible by default, accessible by mID-gated consent":
an authorized agent gets semantic access to results, not bulk data.
Metrics: Cosine (magnitude-invariant, [-1, 1]), Dot, and Euclidean
(negated, so higher is always better and k-selection is uniform).
What ships today
An exact flat k-NN index — insert / remove / search, dimension-checked on
every operation. Sub-linear ANN (HNSW / IVF) is a future optimization behind
the same surface: exactness first, so correctness is never traded for a
recall knob nobody measured.
Open-core boundary
Depends only on spacedb-access, for the capability gate.
No MATA crate.
Testing
The workspace defaults to wasm32; this crate is native. Test on your host
triple:
Suite: vector.rs — metric correctness, top-k ordering, dimension mismatch, and
the denied-without-capability path.
License
MIT OR Apache-2.0, at your option. See LICENSE-MIT and LICENSE-APACHE.