diff --git a/Cargo.lock b/Cargo.lock
index a8d52a1b0..196c10b23 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2603,6 +2603,16 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "page_size"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
[[package]]
name = "papergrid"
version = "0.12.0"
@@ -3673,6 +3683,57 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "ruvector-gnn"
+version = "0.1.1"
+dependencies = [
+ "anyhow",
+ "criterion",
+ "dashmap",
+ "libc",
+ "memmap2",
+ "napi",
+ "napi-derive",
+ "ndarray 0.16.1",
+ "page_size",
+ "parking_lot 0.12.5",
+ "proptest",
+ "rand 0.8.5",
+ "rand_distr",
+ "rayon",
+ "ruvector-core",
+ "serde",
+ "serde_json",
+ "tempfile",
+ "thiserror 2.0.17",
+]
+
+[[package]]
+name = "ruvector-gnn-node"
+version = "0.1.1"
+dependencies = [
+ "napi",
+ "napi-build",
+ "napi-derive",
+ "ruvector-gnn",
+ "serde_json",
+]
+
+[[package]]
+name = "ruvector-gnn-wasm"
+version = "0.1.1"
+dependencies = [
+ "console_error_panic_hook",
+ "getrandom 0.2.16",
+ "getrandom 0.3.4",
+ "js-sys",
+ "ruvector-gnn",
+ "serde",
+ "serde-wasm-bindgen",
+ "wasm-bindgen",
+ "wasm-bindgen-test",
+]
+
[[package]]
name = "ruvector-graph"
version = "0.1.1"
@@ -3764,6 +3825,7 @@ dependencies = [
"parking_lot 0.12.5",
"regex",
"ruvector-core",
+ "ruvector-graph",
"serde",
"serde-wasm-bindgen",
"serde_json",
diff --git a/Cargo.toml b/Cargo.toml
index 5599a123e..fe6a99c84 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,9 @@ members = [
"crates/ruvector-graph",
"crates/ruvector-graph-node",
"crates/ruvector-graph-wasm",
+ "crates/ruvector-gnn",
+ "crates/ruvector-gnn-node",
+ "crates/ruvector-gnn-wasm",
]
resolver = "2"
diff --git a/README.md b/README.md
index 2e858c188..cd5faa252 100644
--- a/README.md
+++ b/README.md
@@ -1,468 +1,277 @@
-# Ruvector
+# RuVector
[](https://opensource.org/licenses/MIT)
[](https://www.rust-lang.org)
[](https://github.com/ruvnet/ruvector)
-[](./docs/TECHNICAL_PLAN.md)
-[](./docs/TECHNICAL_PLAN.md)
-[](./docs/IMPLEMENTATION_SUMMARY.md)
-[](https://github.com/ruvnet/ruvector)
-[](https://github.com/ruvnet/ruvector)
-[](https://www.npmjs.com/package/ruvector)
-[](https://discord.gg/ruvnet)
-[](https://twitter.com/ruvnet)
-**Next-generation vector database built in Rust for extreme performance and universal deployment.**
+**The index is the neural network.** A high-performance vector database with built-in Graph Neural Networks, Neo4j-compatible hypergraph storage, and adaptive tensor compression.
-> Transform your AI applications with **sub-millisecond vector search** that scales from edge devices to **500M+ concurrent global streams**. Built by [rUv](https://ruv.io) and the open-source community at [GitHub/ruvnet](https://github.com/ruvnet).
+## What is RuVector?
-## π Why Ruvector?
+RuVector combines three powerful concepts into one unified system:
-In the age of AI, **vector similarity search is the foundation** of modern applicationsβfrom RAG systems to recommendation engines. But existing solutions force you to choose between **performance**, **scale**, or **portability**.
-
-**Ruvector eliminates that compromise.**
-
-### The rUv Advantage
-
-Developed by **[rUv](https://ruv.io)**βpioneers in agentic AI systems and high-performance distributed computingβRuvector brings enterprise-grade vector search to everyone. Whether you're building the next AI startup or scaling to billions of users, Ruvector adapts to your needs.
-
-π **Learn more**: [ruv.io](https://ruv.io) | [GitHub](https://github.com/ruvnet/ruvector)
-
-### Built for the Modern AI Stack
-
-- β‘ **Blazing Fast**: <0.5ms p50 latency with HNSW indexing and SIMD optimizations
-- π **Globally Scalable**: Deploy to 500M+ concurrent streams across 15 regions with auto-scaling
-- π― **Universal Deployment**: Run anywhereβNative Rust, Node.js, WebAssembly, browsers, edge devices
-- π° **Cost Optimized**: 60% cost reduction through intelligent caching and batching strategies
-- π§ **AI-Native**: Built specifically for embeddings, RAG, semantic search, and agent memory
-- π **Open Source**: MIT licensed, community-driven, production-ready
-
-## π Features
-
-### Core Capabilities
-
-- **Sub-Millisecond Queries**: <0.5ms p50 local latency with state-of-the-art HNSW indexing
-- **Memory Efficient**: 4-32x compression with advanced quantization techniques
-- **High Recall**: 95%+ accuracy with HNSW + Product Quantization
-- **Zero Dependencies**: Pure Rust implementation with minimal external dependencies
-- **Production Ready**: Battle-tested algorithms with comprehensive benchmarks
-- **AgenticDB Compatible**: Drop-in replacement with familiar API patterns
-
-### Global Cloud Scale β¨
-
-- **500M+ Concurrent Streams**: Baseline capacity with burst to 25B for major events
-- **15 Global Regions**: Multi-region deployment with automatic failover
-- **<10ms Global Latency**: p50 worldwide with multi-level caching
-- **99.99% Availability**: Enterprise SLA with redundancy and health monitoring
-- **Adaptive Auto-Scaling**: Predictive + reactive scaling for traffic spikes
-- **60% Cost Savings**: Optimized infrastructure reducing costs from $2.75M to $1.74M/month
-
-### Universal Platform Support
-
-| Platform | Status | Package | Use Case |
-|----------|--------|---------|----------|
-| **Rust Native** | β
Ready | `cargo add ruvector-core` | Servers, microservices, CLI tools |
-| **Node.js** | β
Ready | `npm install ruvector` | APIs, serverless, backend apps |
-| **WebAssembly** | β
Ready | `npm install ruvector-wasm` | Browsers, edge computing, offline |
-| **Cloud Run** | β
Ready | Docker + Terraform | Global scale, 500M+ streams |
-
-## π Performance Benchmarks
-
-### Local Performance (Single Instance)
+1. **Vector Database** β Sub-millisecond HNSW search with 95%+ recall
+2. **Graph Neural Network** β The HNSW topology becomes a trainable GNN
+3. **Hypergraph Storage** β Neo4j-compatible Cypher queries with N-ary relationships
```
-Metric Ruvector Pinecone Qdrant ChromaDB
-ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-Query Latency (p50) <0.5ms ~2ms ~1ms ~50ms
-Throughput (QPS) 50K+ ~10K ~20K ~1K
-Memory (1M vectors) ~800MB ~2GB ~1.5GB ~3GB
-Recall @ k=10 95%+ 93% 94% 85%
-Browser Support β
β β β
-Offline Capable β
β β
β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
+β RuVector Stack β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
+β Query API β Cypher Parser β Differentiable Search β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
+β GNN Layers β Message Passing β Multi-Head Attention β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
+β HNSW Index β Vector Storage β Tensor Compression (2-32x) β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
+β Rust Core β WASM Bindings β Node.js (napi-rs) β
+βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
-### Global Cloud Performance (500M Streams)
+## Features
-```
-Metric Value Details
-ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-Concurrent Streams 500M baseline Burst to 25B (50x)
-Global Latency (p50) <10ms Multi-region + CDN
-Availability 99.99% SLA 15 regions, auto-failover
-Cost per Stream/Month $0.0035 60% optimized ($1.74M total)
-Regions 15 global Americas, EMEA, APAC
-Throughput per Region 100K+ QPS Adaptive batching
-```
+| Feature | Description |
+|---------|-------------|
+| **GNN on HNSW** | Graph neural network layers that treat the index topology as a trainable graph |
+| **Cypher Queries** | Neo4j-compatible query language with `MATCH`, `WHERE`, `RETURN`, `CREATE` |
+| **Hyperedges** | N-ary relationships connecting multiple nodes (not just pairs) |
+| **Adaptive Compression** | 5-tier tensor compression: f32 β f16 β PQ8 β PQ4 β Binary (2-32x) |
+| **Differentiable Search** | Soft attention over candidates with gradient flow for end-to-end training |
+| **WASM Support** | Full browser support with WebAssembly bindings |
+| **Memory-Mapped Training** | Efficient gradient accumulation on memory-mapped embeddings |
-## β‘ Quick Start
+## Quick Start
### Installation
-**Rust:**
```bash
-cargo add ruvector-core
+# Rust
+cargo add ruvector-graph
+
+# Node.js
+npm install ruvector-gnn-node
+
+# Browser (WASM)
+npm install ruvector-gnn-wasm
```
-**Node.js:**
-```bash
-npm install ruvector
-```
+### Basic Usage
-**WebAssembly:**
-```bash
-npm install ruvector-wasm
-```
-
-### Usage Examples
-
-**Rust:**
+**Cypher Queries (Neo4j-compatible):**
```rust
-use ruvector_core::{VectorDB, Config};
+use ruvector_graph::{GraphDB, cypher::CypherExecutor};
-// Create database
-let db = VectorDB::new(Config::default())?;
+let db = GraphDB::new();
+let executor = CypherExecutor::new(&db);
-// Insert vectors
-db.insert("doc1", vec![0.1, 0.2, 0.3])?;
-db.insert("doc2", vec![0.4, 0.5, 0.6])?;
+// Create nodes and relationships
+executor.execute("CREATE (a:Person {name: 'Alice'})-[:KNOWS]->(b:Person {name: 'Bob'})")?;
-// Search similar vectors
-let results = db.search(vec![0.1, 0.2, 0.3], 10)?;
-for (id, score) in results {
- println!("{}: {}", id, score);
-}
+// Query with pattern matching
+let results = executor.execute("MATCH (p:Person)-[:KNOWS]->(friend) RETURN p.name, friend.name")?;
```
-**Node.js:**
-```javascript
-const { VectorDB } = require('ruvector');
+**GNN Forward Pass:**
+```rust
+use ruvector_gnn::{RuvectorLayer, differentiable_search};
-// Create database
-const db = new VectorDB();
+// Create GNN layer
+let layer = RuvectorLayer::new(128, 256, 4, 0.1); // input, hidden, heads, dropout
-// Insert vectors
-await db.insert('doc1', [0.1, 0.2, 0.3]);
-await db.insert('doc2', [0.4, 0.5, 0.6]);
+// Forward pass with neighbor aggregation
+let output = layer.forward(&node_embedding, &neighbor_embeddings, &edge_weights);
-// Search similar vectors
-const results = await db.search([0.1, 0.2, 0.3], 10);
-results.forEach(({ id, score }) => {
- console.log(`${id}: ${score}`);
-});
+// Differentiable search (soft k-NN)
+let (indices, weights) = differentiable_search(&query, &candidates, 10, 0.07);
```
-**WebAssembly (Browser):**
-```javascript
-import init, { VectorDB } from 'ruvector-wasm';
+**Tensor Compression:**
+```rust
+use ruvector_gnn::TensorCompress;
+
+let compressor = TensorCompress::new();
+
+// Adaptive compression based on access frequency
+let compressed = compressor.compress(&embedding, 0.5)?; // Warm data β f16
+let restored = compressor.decompress(&compressed)?;
+```
+
+### Browser Usage (WASM)
+
+```javascript
+import init, { JsRuvectorLayer, JsTensorCompress, differentiableSearch } from 'ruvector-gnn-wasm';
-// Initialize WASM module
await init();
-// Create database (runs entirely in browser!)
-const db = new VectorDB();
+// GNN layer
+const layer = new JsRuvectorLayer(128, 256, 4, 0.1);
+const output = layer.forward(nodeEmbedding, neighbors, weights);
-// Insert and search
-db.insert('doc1', new Float32Array([0.1, 0.2, 0.3]));
-const results = db.search(new Float32Array([0.1, 0.2, 0.3]), 10);
+// Compression
+const compressor = new JsTensorCompress();
+const compressed = compressor.compress(embedding, 0.5);
```
-### Global Cloud Deployment
+## Architecture
-Deploy Ruvector to handle 500M+ concurrent streams worldwide:
+### Crate Structure
+
+```
+crates/
+βββ ruvector-core/ # Vector database core (HNSW, storage)
+βββ ruvector-graph/ # Neo4j-compatible hypergraph + Cypher
+βββ ruvector-gnn/ # GNN layers, compression, training
+βββ ruvector-gnn-wasm/ # WebAssembly bindings
+βββ ruvector-gnn-node/ # Node.js bindings (napi-rs)
+βββ ruvector-graph-wasm/ # Graph WASM bindings
+βββ ruvector-graph-node/ # Graph Node.js bindings
+```
+
+### Compression Tiers
+
+| Tier | Access Freq | Format | Compression | Use Case |
+|------|------------|--------|-------------|----------|
+| Hot | >80% | f32 | 1x | Active queries |
+| Warm | 40-80% | f16 | 2x | Recent data |
+| Cool | 10-40% | PQ8 | ~8x | Older data |
+| Cold | 1-10% | PQ4 | ~16x | Archived |
+| Archive | <1% | Binary | ~32x | Rarely accessed |
+
+### GNN Message Passing
+
+The RuvectorLayer implements attention-based message passing on the HNSW graph:
+
+```
+h_new = LayerNorm(h + GRU(h, Attention(W_msg(neighbors), edge_weights)))
+```
+
+1. **Message**: Transform neighbor embeddings with learned weights
+2. **Aggregate**: Multi-head attention over messages, weighted by edge similarity
+3. **Update**: GRU cell combines current state with aggregated messages
+4. **Normalize**: Layer normalization with residual connection
+
+## Tutorial
+
+### 1. Creating a Knowledge Graph
+
+```rust
+use ruvector_graph::{GraphDB, NodeBuilder, EdgeBuilder};
+
+let db = GraphDB::new();
+
+// Create nodes
+let alice = NodeBuilder::new("alice")
+ .label("Person")
+ .property("name", "Alice")
+ .property("age", 30)
+ .build();
+
+let knows_rust = NodeBuilder::new("rust")
+ .label("Skill")
+ .property("name", "Rust")
+ .build();
+
+db.create_node(alice)?;
+db.create_node(knows_rust)?;
+
+// Create relationship
+let edge = EdgeBuilder::new("e1", "alice", "rust")
+ .edge_type("KNOWS")
+ .property("level", "expert")
+ .build();
+
+db.create_edge(edge)?;
+```
+
+### 2. Semantic Search with GNN Enhancement
+
+```rust
+use ruvector_gnn::{RuvectorLayer, RuvectorQuery, QueryMode};
+
+// Initialize GNN layer
+let gnn = RuvectorLayer::new(384, 512, 8, 0.1);
+
+// Build query
+let query = RuvectorQuery::neural_search(query_embedding, 10, 2)
+ .with_temperature(0.07);
+
+// Search with GNN-enhanced representations
+let enhanced = gnn.forward(&query.vector.unwrap(), &neighbor_embs, &weights);
+```
+
+### 3. Training with InfoNCE Loss
+
+```rust
+use ruvector_gnn::training::{info_nce_loss, sgd_step, TrainConfig};
+
+let config = TrainConfig::default();
+
+// Compute contrastive loss
+let loss = info_nce_loss(
+ &anchor_embedding,
+ &positive_embeddings,
+ &negative_embeddings,
+ config.temperature
+);
+
+// Update embeddings
+sgd_step(&mut embedding, &gradient, config.learning_rate);
+```
+
+## Documentation
+
+| Topic | Link |
+|-------|------|
+| **Getting Started** | [docs/guide/GETTING_STARTED.md](./docs/guide/GETTING_STARTED.md) |
+| **Cypher Query Language** | [docs/api/CYPHER_REFERENCE.md](./docs/api/CYPHER_REFERENCE.md) |
+| **GNN Architecture** | [docs/gnn-layer-implementation.md](./docs/gnn-layer-implementation.md) |
+| **Compression Guide** | [docs/optimization/COMPRESSION.md](./docs/optimization/COMPRESSION.md) |
+| **WASM Bindings** | [crates/ruvector-gnn-wasm/README.md](./crates/ruvector-gnn-wasm/README.md) |
+| **Node.js Bindings** | [crates/ruvector-gnn-node/README.md](./crates/ruvector-gnn-node/README.md) |
+| **API Reference** | [docs/api/](./docs/api/) |
+| **Performance Tuning** | [docs/optimization/PERFORMANCE_TUNING_GUIDE.md](./docs/optimization/PERFORMANCE_TUNING_GUIDE.md) |
+
+## Performance
+
+```
+Query Latency (p50) <0.5ms HNSW with SIMD
+GNN Forward Pass ~1ms Per-node with neighbors
+Compression (PQ8) ~8x Memory reduction
+Recall @ k=10 95%+ High accuracy search
+Browser (WASM) ~2ms Full functionality
+```
+
+## Building from Source
```bash
-# 1. Clone repository
+# Clone
git clone https://github.com/ruvnet/ruvector.git
cd ruvector
-# 2. Deploy infrastructure (Terraform)
-cd src/burst-scaling/terraform
-terraform init && terraform apply
-
-# 3. Deploy Cloud Run services (multi-region)
-cd ../cloud-run
-gcloud builds submit --config=cloudbuild.yaml
-
-# 4. Initialize agentic coordination
-cd ../agentic-integration
-npm install && npm run swarm:init
-
-# 5. Run validation tests
-cd ../../benchmarks
-npm run test:quick
-```
-
-**Deployment Time**: 4-6 hours for full global infrastructure
-**Cost**: $1.74M/month (500M streams, optimized)
-
-See [Deployment Guide](./docs/cloud-architecture/DEPLOYMENT_GUIDE.md) for complete instructions.
-
-## π― Use Cases
-
-### Local & Edge Computing
-
-- **RAG Systems**: Fast vector retrieval for Large Language Models with <0.5ms latency
-- **Semantic Search**: AI-powered similarity search for documents, images, and code
-- **Recommender Systems**: Real-time personalized recommendations on edge devices
-- **Agent Memory**: Reflexion memory and skill libraries for autonomous AI agents
-- **Code Search**: Find similar code patterns across repositories instantly
-- **Offline AI**: Run powerful vector search entirely in the browser (WebAssembly)
-
-### Global Cloud Scale
-
-- **Streaming Platforms**: 500M+ concurrent learners with real-time recommendations
-- **Live Events**: Handle 50x traffic spikes (World Cup: 25B concurrent streams)
-- **Multi-Region AI**: Global vector search with <10ms latency anywhere
-- **Enterprise RAG**: Planet-scale retrieval for distributed AI applications
-- **Real-Time Analytics**: Process billions of similarity queries per day
-- **E-Commerce**: Product recommendations at massive scale with auto-scaling
-
-## ποΈ Architecture
-
-### Project Structure
-
-Ruvector is organized as a Rust workspace with specialized crates:
-
-```
-ruvector/
-βββ crates/
-β βββ ruvector-core/ # Core vector database engine (Rust)
-β βββ ruvector-node/ # Node.js bindings via NAPI-RS
-β βββ ruvector-wasm/ # WebAssembly bindings (browser)
-β βββ ruvector-cli/ # Command-line interface
-β βββ ruvector-bench/ # Performance benchmarks
-β βββ router-core/ # Neural routing and inference
-β βββ router-cli/ # Router command-line tools
-β βββ router-ffi/ # Foreign function interface
-β βββ router-wasm/ # Router WebAssembly bindings
-βββ src/
-β βββ burst-scaling/ # Auto-scaling for traffic spikes
-β βββ cloud-run/ # Google Cloud Run deployment
-β βββ agentic-integration/ # AI agent coordination
-βββ benchmarks/ # Load testing and scenarios
-βββ docs/ # Comprehensive documentation
-```
-
-### Core Technologies
-
-- **HNSW Indexing**: Hierarchical Navigable Small World for fast approximate nearest neighbor search
-- **Product Quantization**: Memory-efficient vector compression (4-32x reduction)
-- **SIMD Optimizations**: Hardware-accelerated vector operations via simsimd
-- **Zero-Copy I/O**: Memory-mapped files for efficient data access
-- **Google Cloud Run**: Multi-region serverless deployment with auto-scaling
-- **Adaptive Batching**: Intelligent request batching for 70% latency reduction
-
-## π Documentation
-
-### Getting Started
-
-- **[Quick Start Guide](./docs/guide/GETTING_STARTED.md)** - Get up and running in 5 minutes
-- **[Installation Guide](./docs/guide/INSTALLATION.md)** - Detailed setup for all platforms
-- **[Basic Tutorial](./docs/guide/BASIC_TUTORIAL.md)** - Step-by-step vector search tutorial
-- **[AgenticDB Quick Start](./docs/getting-started/AGENTICDB_QUICKSTART.md)** - Migration from AgenticDB
-
-### API Documentation
-
-- **[Rust API Reference](./docs/api/RUST_API.md)** - Complete Rust API documentation
-- **[Node.js API Reference](./docs/api/NODEJS_API.md)** - JavaScript/TypeScript API
-- **[WebAssembly API](./docs/getting-started/wasm-api.md)** - Browser and edge usage
-- **[AgenticDB API](./docs/getting-started/AGENTICDB_API.md)** - AgenticDB compatibility layer
-
-### Advanced Topics
-
-- **[Advanced Features](./docs/guide/ADVANCED_FEATURES.md)** - Quantization, indexing, optimization
-- **[Performance Tuning](./docs/optimization/PERFORMANCE_TUNING_GUIDE.md)** - Optimize for your workload
-- **[Optimization Guide](./docs/getting-started/OPTIMIZATION_QUICK_START.md)** - Best practices
-- **[Build Optimization](./docs/optimization/BUILD_OPTIMIZATION.md)** - Compile-time optimizations
-
-### Cloud Deployment
-
-- **[Implementation Summary](./docs/IMPLEMENTATION_SUMMARY.md)** - Complete overview of global deployment
-- **[Architecture Overview](./docs/cloud-architecture/architecture-overview.md)** - 15-region global design
-- **[Deployment Guide](./docs/cloud-architecture/DEPLOYMENT_GUIDE.md)** - Step-by-step setup (4-6 hours)
-- **[Scaling Strategy](./docs/cloud-architecture/scaling-strategy.md)** - Auto-scaling & burst handling
-- **[Performance Optimization](./docs/cloud-architecture/PERFORMANCE_OPTIMIZATION_GUIDE.md)** - 70% latency reduction
-- **[Cost Optimization](./src/cloud-run/COST_OPTIMIZATIONS.md)** - 60% cost savings ($3.66M/year)
-- **[Load Testing](./benchmarks/LOAD_TEST_SCENARIOS.md)** - World Cup and burst scenarios
-
-### Development
-
-- **[Contributing Guidelines](./docs/development/CONTRIBUTING.md)** - How to contribute
-- **[Development Guide](./docs/development/MIGRATION.md)** - Development setup
-- **[Benchmarking Guide](./docs/benchmarks/BENCHMARKING_GUIDE.md)** - Run performance tests
-- **[Technical Plan](./docs/TECHNICAL_PLAN.md)** - Architecture and design decisions
-
-### Complete Index
-
-- **[Documentation Index](./docs/README.md)** - Complete documentation organization
-- **[Changelog](./CHANGELOG.md)** - Version history and updates
-
-## π¨ Building from Source
-
-### Prerequisites
-
-- **Rust**: 1.77 or higher
-- **Node.js**: 18.0 or higher (for Node.js/WASM builds)
-- **wasm-pack**: For WebAssembly builds
-
-### Build Commands
-
-```bash
-# Build all Rust crates (release mode)
+# Build all crates
cargo build --release
# Run tests
cargo test --workspace
-# Run benchmarks
-cargo bench --workspace
-
-# Build Node.js bindings
-cd crates/ruvector-node
-npm install && npm run build
-
-# Build WebAssembly
-cd crates/ruvector-wasm
-wasm-pack build --target web
-
-# Run CLI
-cargo run -p ruvector-cli -- --help
+# Build WASM
+cargo build --package ruvector-gnn-wasm --target wasm32-unknown-unknown
```
-### Development Workflow
+## Contributing
-```bash
-# Format code
-cargo fmt --all
+We welcome contributions! See [CONTRIBUTING.md](./docs/development/CONTRIBUTING.md).
-# Lint code
-cargo clippy --workspace -- -D warnings
+## License
-# Type check
-cargo check --workspace
-
-# Run specific tests
-cargo test -p ruvector-core
-
-# Run benchmarks with specific features
-cargo bench -p ruvector-bench --features simd
-```
-
-## π€ Contributing
-
-We welcome contributions from the community! Ruvector is built by developers, for developers.
-
-### How to Contribute
-
-1. **Fork** the repository at [github.com/ruvnet/ruvector](https://github.com/ruvnet/ruvector)
-2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
-3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
-4. **Push** to the branch (`git push origin feature/amazing-feature`)
-5. **Open** a Pull Request
-
-### Contribution Areas
-
-- π **Bug Fixes**: Help us squash bugs and improve stability
-- β¨ **New Features**: Add new capabilities and integrations
-- π **Documentation**: Improve guides, tutorials, and API docs
-- π§ͺ **Testing**: Add test coverage and benchmarks
-- π **Translations**: Translate documentation to other languages
-- π‘ **Ideas**: Propose new features and improvements
-
-See [Contributing Guidelines](./docs/development/CONTRIBUTING.md) for detailed instructions.
-
-## π Community & Support
-
-### Connect with Us
-
-- **GitHub**: [github.com/ruvnet/ruvector](https://github.com/ruvnet/ruvector) - Star β and follow for updates
-- **Discord**: [Join our community](https://discord.gg/ruvnet) - Chat with developers and users
-- **Twitter**: [@ruvnet](https://twitter.com/ruvnet) - Follow for announcements and tips
-- **Website**: [ruv.io](https://ruv.io) - Learn about rUv's AI platform and tools
-- **Issues**: [GitHub Issues](https://github.com/ruvnet/ruvector/issues) - Report bugs and request features
-- **Discussions**: [GitHub Discussions](https://github.com/ruvnet/ruvector/discussions) - Ask questions and share ideas
-
-### Enterprise Support
-
-Need enterprise support, custom development, or consulting services?
-
-π§ Contact us at [enterprise@ruv.io](mailto:enterprise@ruv.io)
-
-## π Comparison with Alternatives
-
-| Feature | Ruvector | Pinecone | Qdrant | ChromaDB | Milvus |
-|---------|----------|----------|--------|----------|--------|
-| **Language** | Rust | ? | Rust | Python | C++/Go |
-| **Local Latency (p50)** | <0.5ms | ~2ms | ~1ms | ~50ms | ~5ms |
-| **Global Scale** | 500M+ β¨ | Limited | Limited | No | Limited |
-| **Browser Support** | β
WASM | β | β | β | β |
-| **Offline Capable** | β
| β | β
| β
| β
|
-| **NPM Package** | β
| β
| β | β
| β |
-| **Native Binary** | β
| β | β
| β | β
|
-| **Burst Capacity** | 50x β¨ | Unknown | Unknown | No | Unknown |
-| **Open Source** | β
MIT | β | β
Apache | β
Apache | β
Apache |
-| **Cost (500M)** | $1.74M/mo | $$$$ | $$$ | Self-host | Self-host |
-| **Edge Deployment** | β
| β | Partial | Partial | β |
-
-## π― Latest Updates
-
-### v0.1.0 - Global Streaming Optimization β¨
-
-Complete implementation for massive-scale deployment:
-
-- β
**Architecture**: 15-region global topology with 99.99% SLA
-- β
**Cloud Run Service**: HTTP/2 + WebSocket with adaptive batching (70% latency improvement)
-- β
**Agentic Coordination**: Distributed agent swarm with auto-scaling (6 files, 3,550 lines)
-- β
**Burst Scaling**: Predictive + reactive scaling for 50x spikes (11 files, 4,844 lines)
-- β
**Benchmarking**: Comprehensive test suite supporting 25B concurrent (13 files, 4,582 lines)
-- β
**Cost Optimization**: 60% reduction through caching/batching ($3.66M/year savings)
-- β
**Query Optimization**: 5x throughput increase, 70% latency reduction
-- β
**Production-Ready**: 45+ files, 28,000+ lines of tested code
-
-**Deployment Time**: 4-6 hours for full global infrastructure
-**Cost**: $2.75M/month baseline β **$1.74M with optimizations (60% savings)**
-**Capacity**: 500M concurrent β 25B burst (50x for major events)
-
-See [Implementation Summary](./docs/IMPLEMENTATION_SUMMARY.md) for complete details.
-
-## π License
-
-**MIT License** - see [LICENSE](./LICENSE) for details.
-
-Free to use for commercial and personal projects. We believe in open source.
-
-## π Acknowledgments
-
-Built with battle-tested algorithms and technologies:
-
-- **HNSW**: Hierarchical Navigable Small World graphs
-- **Product Quantization**: Efficient vector compression
-- **simsimd**: SIMD-accelerated similarity computations
-- **Google Cloud Run**: Serverless multi-region deployment
-- **Advanced Caching**: Multi-level caching strategies
-- **Community Contributors**: Thank you to all our contributors! π
-
-### Special Thanks
-
-- The Rust community for incredible tooling and ecosystem
-- Contributors to HNSW, quantization research, and SIMD libraries
-- Our users and beta testers for valuable feedback
-- The [rUv](https://ruv.io) team for making this possible
+MIT License - see [LICENSE](./LICENSE).
---
-**Built by [rUv](https://ruv.io) β’ Open Source on [GitHub](https://github.com/ruvnet/ruvector) β’ Production Ready**
+**Built by [rUv](https://ruv.io)** β’ [GitHub](https://github.com/ruvnet/ruvector) β’ [Documentation](./docs/)
-[](https://github.com/ruvnet/ruvector)
-[](https://twitter.com/ruvnet)
-[](https://discord.gg/ruvnet)
-
-**Status**: Production Ready | **Version**: 0.1.0 | **Scale**: Local to 500M+ concurrent
-
-**Ready for**: World Cup (25B concurrent) β’ Olympics β’ Product Launches β’ Streaming Platforms
-
-[Get Started](./docs/guide/GETTING_STARTED.md) β’ [Documentation](./docs/README.md) β’ [API Reference](./docs/api/RUST_API.md) β’ [Contributing](./docs/development/CONTRIBUTING.md)
+*"The index is a sparse neural network whose topology encodes learned similarity."*
diff --git a/crates/ruvector-core/Cargo.toml b/crates/ruvector-core/Cargo.toml
index 945ebe7c5..89b2c2bc2 100644
--- a/crates/ruvector-core/Cargo.toml
+++ b/crates/ruvector-core/Cargo.toml
@@ -40,7 +40,7 @@ once_cell = { workspace = true }
# Time and UUID
chrono = { workspace = true }
-uuid = { workspace = true, optional = true }
+uuid = { workspace = true, features = ["v4"] }
[dev-dependencies]
criterion = { workspace = true }
@@ -70,12 +70,12 @@ name = "comprehensive_bench"
harness = false
[features]
-default = ["simd", "uuid-support", "storage", "hnsw"]
-uuid-support = ["uuid"]
+default = ["simd", "storage", "hnsw"]
simd = []
storage = ["redb", "memmap2"] # File-based storage (not available in WASM)
hnsw = ["hnsw_rs"] # HNSW indexing (not available in WASM due to mmap dependency)
memory-only = [] # Pure in-memory storage for WASM
+uuid-support = [] # Deprecated: uuid is now always included
[lib]
crate-type = ["rlib"]
diff --git a/crates/ruvector-core/src/error.rs b/crates/ruvector-core/src/error.rs
index 079ea2362..f317a187e 100644
--- a/crates/ruvector-core/src/error.rs
+++ b/crates/ruvector-core/src/error.rs
@@ -54,36 +54,42 @@ pub enum RuvectorError {
Internal(String),
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::Error) -> Self {
RuvectorError::DatabaseError(err.to_string())
}
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::DatabaseError) -> Self {
RuvectorError::DatabaseError(err.to_string())
}
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::StorageError) -> Self {
RuvectorError::DatabaseError(err.to_string())
}
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::TableError) -> Self {
RuvectorError::DatabaseError(err.to_string())
}
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::TransactionError) -> Self {
RuvectorError::DatabaseError(err.to_string())
}
}
+#[cfg(feature = "storage")]
impl From for RuvectorError {
fn from(err: redb::CommitError) -> Self {
RuvectorError::DatabaseError(err.to_string())
diff --git a/crates/ruvector-core/src/index.rs b/crates/ruvector-core/src/index.rs
index a3c1ec8a9..34374e39d 100644
--- a/crates/ruvector-core/src/index.rs
+++ b/crates/ruvector-core/src/index.rs
@@ -1,5 +1,6 @@
//! Index structures for efficient vector search
+#[cfg(feature = "hnsw")]
pub mod hnsw;
pub mod flat;
diff --git a/crates/ruvector-core/src/storage_memory.rs b/crates/ruvector-core/src/storage_memory.rs
index 1faaef782..63a9a72f0 100644
--- a/crates/ruvector-core/src/storage_memory.rs
+++ b/crates/ruvector-core/src/storage_memory.rs
@@ -50,7 +50,9 @@ impl MemoryStorage {
// Insert metadata if present
if let Some(metadata) = &entry.metadata {
- self.metadata.insert(id.clone(), metadata.clone());
+ self.metadata.insert(id.clone(), serde_json::Value::Object(
+ metadata.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
+ ));
}
Ok(id)
@@ -73,7 +75,9 @@ impl MemoryStorage {
self.vectors.insert(id.clone(), entry.vector.clone());
if let Some(metadata) = &entry.metadata {
- self.metadata.insert(id.clone(), metadata.clone());
+ self.metadata.insert(id.clone(), serde_json::Value::Object(
+ metadata.iter().map(|(k, v)| (k.clone(), v.clone())).collect()
+ ));
}
ids.push(id);
@@ -86,7 +90,13 @@ impl MemoryStorage {
pub fn get(&self, id: &str) -> Result