RuVector

July 17, 2026 ยท View on GitHub

RuVector

Crates.io npm npm monthly downloads npm all-time downloads License

Persistent, adaptive memory for AI agents

RuVector is a Rust native memory substrate for agents that need to remember across sessions. It combines local semantic embeddings, persistent vector retrieval, graph relationships, explicit feedback learning, memory lifecycle controls, and optional shared memory.

The default retrieval path runs locally. Learning happens from recorded outcomes and feedback, not from reads alone. Hosted services remain optional and create a separate data boundary.

Remember and recall in 30 seconds

No database server or API key is required.

npx ruvector hooks remember --semantic --type decision \
  "The customer requires all inference to remain in Canada."

npx ruvector hooks recall --semantic --top-k 3 \
  "Where may customer data be processed?"

Memory is stored under the current project and remains available to later processes. The first semantic command downloads and caches the local all-MiniLM-L6-v2 model. Keep one embedding model and dimension per store; use npx ruvector hooks reembed before changing an existing store from hash to semantic embeddings. Use npx ruvector hooks stats to inspect the store.

Embed persistent memory in Node.js

npm install ruvector
const { OnnxEmbedder, VectorDB } = require('ruvector');

async function main() {
  const embedder = new OnnxEmbedder();
  await embedder.init();

  const db = new VectorDB({
    dimensions: 384,
    distanceMetric: 'cosine',
    storagePath: './agent-memory.db',
  });

  const memories = [
    {
      id: 'decision-1',
      text: 'The customer requires all inference to remain in Canada.',
      kind: 'decision',
    },
    {
      id: 'episode-1',
      text: 'The Toronto pilot passed its privacy review on Tuesday.',
      kind: 'episode',
    },
    {
      id: 'procedure-1',
      text: 'Escalate production access through the security owner.',
      kind: 'procedure',
    },
  ];

  for (const memory of memories) {
    const vector = await embedder.embedPassage(memory.text);
    await db.insert({
      id: memory.id,
      vector,
      metadata: {
        text: memory.text,
        kind: memory.kind,
        tenant: 'acme',
        createdAt: Date.now(),
      },
    });
  }

  const query = await embedder.embedQuery(
    'Where may the customer data be processed?',
  );

  const results = await db.search({
    vector: query,
    k: 3,
    filter: { tenant: 'acme' },
  });

  console.log(results.map(({ score, metadata }) => ({ score, ...metadata })));
}

main().catch(console.error);

Reopen the same storagePath in another process to recover the stored vectors, metadata, configuration, and searchability. Search score is a distance, so lower values are closer. See the Node.js API and Rust API for the complete interfaces.

The memory loop

flowchart TD
    A[Capture an event, fact, or outcome] --> B[Create a local or external embedding]
    B --> C[Persist vectors, metadata, and relationships]
    C --> D[Recall by similarity, filters, time, or graph]
    D --> E[Use memory in an agent decision]
    E --> F[Record outcome and feedback]
    F --> G[Adapt ranking or learning state]
    G --> C
    C --> H[Compact, snapshot, branch, or replicate]

RuVector provides primitives for this loop. Your application remains responsible for deciding what is worth remembering, which evidence is trusted, when a memory expires, and which actions recalled context may influence.

What memory means in RuVector

Memory classes are application semantics over vectors, metadata, and graphs. The core store is general purpose. RuVector currently exposes two typed layers:

  1. ruvllm::context::AgenticMemory combines working, episodic, semantic, and procedural memory behind one runtime API. It is implemented, but its unified manager is currently in memory and its cross type consolidation method is not complete.

  2. ruvector-core::AgenticDB persists Reflexion episodes, skills, causal edges, learning sessions, policy state, session turns, and a hash linked witness log. Its typed memory APIs support ONNX, Candle, and API embedding providers for semantic retrieval.

Memory classRepresentationRuVector surface
Working and sessionCurrent task, scratchpad, tool cache, turns, namespace, TTLWorkingMemory, SessionStateIndex
Episodic and ReflexionTrajectory, task, action, observation, critique, outcomeEpisodicMemory, ReflexionEpisode
SemanticFacts, confidence, source, tags, relations, collectionVectorDB, SemanticFact
ProceduralSkills, actions, triggers, examples, policies, Q valuesProceduralSkill, PolicyMemoryStore
Causal and relationalNodes, edges, hyperedges, Cypher pathsruvector-graph
LearningTrajectories, rewards, adapters, EWC stateSONA
SharedContributions, provenance, voting, transfermcp-brain
AuditableHash linked entries, snapshots, RVF witnessesWitnessLog, ruvector-snapshot, RVF

Capability map

Capture and encode

CapabilityWhat it enablesSurface
Local semantic embeddingsText memory without a per query API feeOnnxEmbedder
External embeddingsBring an existing embedding model or providerEmbeddingProvider
Embedding provenanceTrack model, dimension, normalization, and query or passage roleADR 210
Batch and parallel embeddingHigher throughput during memory ingestionONNX implementation

Persist and organize

CapabilityWhat it enablesSurface
Durable vector storageVectors, metadata, deletes, and restart recoveryruvector-core
Unified four type runtime memoryWorking, episodic, semantic, and procedural recallAgenticMemory
Typed persistent agent recordsReflexion episodes, skills, causal edges, policy state, sessions, and witness logsAgenticDB
HNSW and flat indexesApproximate or exact local similarity searchruvector-core
Collections and aliasesSeparate schemas and namespaces by workloadruvector-collections
Graph and hypergraph storageExplicit relationships and multi-hop memoryruvector-graph
High write ingestionMutable L0 memory plus background L1 and L2 compactionruvector-lsm-ann
Edge and embedded persistenceLightweight local vector storage through the RVF Core Profilervlite
PostgreSQL extensionKeep vector memory beside relational dataruvector-postgres

Recall and reconstruct

CapabilityBest useSurface
Dense similarityGeneral semantic recallVectorDB::search
Metadata filteringSimple structured narrowingSearchQuery
Sparse and dense fusionExact terms plus semantic meaningruvector-hybrid, ADR 256
Predicate aware ANNSelective filters without post filter recall collapseruvector-acorn
Temporal decayPrefer recent memories when the domain changesruvector-temporal-coherence, ADR 211
Coherence gatingPrefer memories supported by related observationsruvector-temporal-coherence
Graph reconstructionFollow Cue, Tag, and Content associations instead of retrieving one flat chunkMRAgent example, ADR 269
Multi-vector MaxSimLate interaction over token or passage vectorsruvector-maxsim, ADR 252
GNN rerankingRerank a noisy candidate graphruvector-gnn-rerank, ADR 194
Matryoshka funnelCoarse to fine search for truncatable embeddingsruvector-matryoshka
Disk backed ANNMove read heavy indexes toward SSD scaleruvector-diskann

Learn and adapt

CapabilityWhat changesTrigger
SONA MicroLoRASmall adapter weightsRecorded trajectory and reward
EWC++ consolidationProtects important learned weights from catastrophic forgettingExplicit consolidation
Outcome aware routingPolicy and routing preferencesSuccess, failure, or quality signal
GNN rerankingCandidate orderingTraining data or configured reranker
Self reconstructing graph memoryShortcut edges after successful reconstructionSuccessful graph traversal
Darwin optimizationRetrieval and reconstruction configurationExternal benchmark and promotion gate

Reading or searching memory does not, by itself, mutate learned weights or guarantee better future results.

Consolidate, compress, and recover

CapabilityWhat it controlsSurface
LRU, LFU, and coherence compactionWhich memories survive a capacity limitruvector-agent-memory, ADR 252
Temporal tensor codecsLow bit storage and temporal segment reuseruvector-temporal-tensor
Product quantizationCompressed candidate search with exact query vectorsruvector-pq-search
RaBitQDeterministic one bit candidate encoding and optional rerankingruvector-rabitq
Graph condensationSmaller graph memory while retaining original member provenanceruvector-graph-condense
Full snapshotsSerialized recovery data with compression and checksumsruvector-snapshot
Copy on write branchesIsolated memory experiments without full copiesRVF
Cache consistency modesFresh, eventual, or frozen reads across data sourcesruvector-rulake

The DbOptions.quantization field in ruvector-core is persisted but is not currently applied to core storage or indexes. Use a specialized compression crate when physical compression is required. See the source note in types.rs.

Govern and distribute

CapabilityWhat it providesSurface
Namespace isolationSeparate collections and schemasruvector-collections
Capability gated retrievalPer vector 64 bit read masks inside searchruvector-capgated, ADR 268
Tamper evident lineageHash linked records and witness verificationRVF
Replication primitivesVector clocks, local change propagation, and conflict strategiesruvector-replication
Raft primitivesElection, log, and metadata state machine componentsruvector-raft
Shared collective memoryRemote contributions, search, provenance, and votingmcp-brain

Choose a memory path

RequirementStart withAdd when needed
Local agent or coding memorynpx ruvector hooksONNX semantic mode, MCP
Embedded Node.js serviceruvector and VectorDBGraph, SONA, snapshots
Embedded Rust serviceruvector-coreSpecialized retrieval crates
Typed in-process agent memoryruvllm::context::AgenticMemoryExternal persistence and consolidation policy
High write event streamruvector-lsm-annSnapshot and compaction policy
Multi-hop enterprise knowledgeruvector-graphHybrid cue search and reconstruction harness
Recency sensitive memoryruvector-temporal-coherenceLearned half-life after domain evaluation
Memory constrained edge noderuvector-pq-search or ruvector-rabitqExact reranking for critical recalls
Existing lake or warehouseruvector-rulakeRVF witness bundles
PostgreSQL estateruvector-postgresBuild and operate with pgrx separately
Cross-agent shared memorymcp-brainExplicit hosted data policy and trust controls

Agent integration

For automated agent integration, install and pin the package locally:

npm install --save-exact ruvector
RUVECTOR_MCP_PROFILE=readonly ./node_modules/.bin/ruvector mcp start

List the currently available tools instead of relying on a hardcoded count:

./node_modules/.bin/ruvector mcp tools

Use RUVECTOR_MCP_ALLOW and RUVECTOR_MCP_DENY for an explicit tool policy. No policy preserves the broader compatibility surface, so production deployments should set one deliberately.

If you enable editor or coding hooks, inspect the generated configuration, keep the package local and pinned, and run ./node_modules/.bin/ruvector hooks verify. Do not depend on a fresh @latest download inside each hook invocation.

Deployment surfaces

SurfacePackage or crateData boundary
Node.js and TypeScriptruvectorLocal process and local files
Rustruvector-coreLocal process and local files
Browser@ruvector/wasmBrowser memory and browser storage
HTTP serviceruvector-serverYour service boundary
PostgreSQLruvector-postgresYour database boundary
RVF cognitive containercrates/rvfPortable signed artifact
Shared Brainmcp-brainOptional hosted service

Native npm binaries cover glibc Linux on x64 and arm64, macOS on x64 and arm64, and Windows on x64. Browser and other environments use separate packages. The root package's fallback mode is limited when neither the native core nor RVF can load; use @ruvector/wasm explicitly for browser vector operations. Validate the selected backend with:

npx ruvector info

Security and governance

  1. Treat embeddings as sensitive derivatives of source data. Apply the same classification, residency, access, and retention policy as the original content.

  2. Collections and metadata filters organize memory; they are not a complete authorization boundary. Enforce identity and authorization in the application. Capability gated ANN is currently a research component with a 64 capability mask and documented side channel and recall limitations.

  3. RVF witnesses and hash linked logs are tamper evident. They do not encrypt memory content or prevent an authorized process from reading it.

  4. A delete from the live store does not automatically remove copies in snapshots, branches, replicas, exports, or hosted memory. Define retention and erasure across every copy.

  5. Shared Brain is a hosted plane. Review its network, identity, provenance, poisoning, and data residency controls before sending enterprise memory.

  6. Pin and prepopulate embedding models for offline or regulated deployments. The default npm semantic path downloads its model on first use.

  7. Keep tool execution separate from memory retrieval. Retrieved context is untrusted input until policy checks and action authorization pass.

See SECURITY.md for reporting and project security guidance.

Known boundaries

  1. The repository is a monorepo. Installing ruvector does not activate every crate in this capability map.

  2. The unified four type ruvllm::AgenticMemory manager does not yet have native save and load support, and its episodic to semantic or procedural consolidation method currently returns no changes. Durable VectorDB storage and typed runtime memory are not yet one facade.

  3. Core metadata filtering currently narrows the retrieved candidate set. Highly selective filters may return fewer than k relevant results. Evaluate ACORN or an application level prefilter for selective workloads.

  4. Opening a persisted HNSW database currently enumerates stored vectors and rebuilds the index. Measure cold start time against the intended memory size.

  5. Temporal coherence currently builds an exact pairwise coherence graph and is a proof of concept for moderate memory sets. The planned production path is an approximate neighbor graph.

  6. Agent memory compaction is not yet wired into the default core, MCP, or RVF persistence path.

  7. Full snapshot serialization exists, but incremental snapshots, scheduling, cloud backends, and direct VectorDB restoration are not complete on the current main branch.

  8. Replication exposes local primitives and simulated transport behavior. Raft still has incomplete response transport and snapshot installation paths. These are not a complete production network replication plane.

  9. GNN reranking, MRAgent reconstruction, and Darwin optimization are implemented research surfaces, not automatic behavior in VectorDB::search.

  10. RVF and PostgreSQL are separate build surfaces and are excluded from the default workspace build because they require their own toolchains.

  11. Performance depends on vector dimension, index parameters, filter selectivity, recall target, hardware, and backend. Run the included benchmark for the component and workload you intend to deploy.

Reproduce the evidence

RuVector keeps benchmark code beside the implementation. These commands exercise memory relevant components without relying on unscoped cross product comparisons.

# Core vector search
cargo bench -p ruvector-core

# High write LSM memory
cargo run --release -p ruvector-lsm-ann --bin benchmark

# Temporal and coherence weighted recall
cargo run --release -p ruvector-temporal-coherence --bin tcd-benchmark

# Capability gated retrieval
cargo run --release -p ruvector-capgated --bin benchmark

# Matryoshka coarse to fine retrieval
cargo run --release -p ruvector-matryoshka --bin benchmark

Record dataset size, dimension, index configuration, hardware, latency percentiles, throughput, and recall together. A latency number without its recall target is not a useful retrieval benchmark. See the benchmarking guide.

Build from source

git clone https://github.com/ruvnet/RuVector.git
cd RuVector
cargo test --workspace

The workspace requires Rust 1.77 or newer. RVF and PostgreSQL have separate build instructions in their component documentation.

Documentation

TopicLink
Documentation indexdocs/INDEX.md
Node.js APIdocs/api/NODEJS_API.md
Rust APIdocs/api/RUST_API.md
Cypher referencedocs/api/CYPHER_REFERENCE.md
Architecture decisionsdocs/adr
Benchmarksdocs/benchmarks
Repository structuredocs/REPO_STRUCTURE.md

Contributing

Contributions are welcome. Start with the contribution guide. New capability claims should include an implementation link and reproducible evidence.

License

RuVector is available under the MIT License.

Built by rUv and powering Cognitum.