mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-07-09 17:28:42 +00:00
* fix(security): RUSTSEC advisories + clippy hardening in RuVector - Replace all bare `partial_cmp().unwrap()` calls on f32/f64 with `.unwrap_or(Ordering::Equal)` to prevent panics on NaN values in sorting/max-by operations across ruvllm, ruvector-dag, prime-radiant, and rvagent-wasm (12 sites in production code). - Add input validation guards to the HTTP search endpoint: reject k=0, k > 10_000, empty vectors, and vectors exceeding 65_536 dimensions, preventing memory exhaustion via unbounded allocations. - Harden LocalFsBackend::execute in rvagent-cli with env_clear() + safe-env allowlist (SEC-005), deadline-based timeout enforcement, and 1 MB output truncation, matching the security posture of LocalShellBackend. - Remove 129 occurrences of the deprecated `unused_unit = "allow"` lint and 3 occurrences of the removed `clippy::match_on_vec_items` lint from Cargo.toml files workspace-wide; both are no-ops in current Rust/Clippy. - All 653+ tests across ruvector-core, ruvector-server, ruvector-dag, rvagent-cli, and prime-radiant pass with zero failures. Note: `bytes` is already at 1.11.1 (>= 1.10.0); `paste` 1.0.15 is a transitive dependency with no semver fix available upstream; `cargo audit` returns clean. Co-Authored-By: claude-flow <ruv@ruv.net> * fix(ci): cargo fmt + restore workspace unused_unit lint allow - Run cargo fmt --all across all 9 files that drifted from rustfmt style (prime-radiant/energy.rs, ruvector-dag/bottleneck.rs+reasoning_bank.rs, ruvector-server/points.rs, ruvllm/pretrain_pipeline.rs+report.rs+registry.rs, rvagent-cli/app.rs, rvagent-wasm/gallery.rs) - Add [workspace.lints.clippy] unused_unit = "allow" to root Cargo.toml; the per-crate entries removed in the security commit were still needed — moving to workspace-level is cleaner and restores -D warnings CI pass Co-Authored-By: claude-flow <ruv@ruv.net> * fix(ci): remove unneeded unit return type in ruvix bench Removes `-> ()` from the Fn bound in run_benchmark_with_kernel (crates/ruvix/benches/src/ruvix.rs:50) — triggers clippy::unused_unit under -D warnings. Clippy prefers `Fn(&mut Kernel)` without explicit unit return. Co-Authored-By: claude-flow <ruv@ruv.net> * fix(ci): resolve rustfmt and clippy unused_unit failures - Run cargo fmt --all to fix long closure formatting in 9 files (energy.rs, bottleneck.rs, reasoning_bank.rs, points.rs, pretrain_pipeline.rs, report.rs, registry.rs, app.rs, gallery.rs) - Add unused_unit = "allow" to [lints.clippy] in ruvix-bench and ruvector-mincut Cargo.toml files to suppress the unused_unit lint that was previously suppressed globally and now fires on two Fn(&mut T) -> () and FnMut() -> () function bounds Co-Authored-By: claude-flow <ruv@ruv.net> |
||
|---|---|---|
| .. | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| package.json | ||
| README.md | ||
Ruvector Cluster
Distributed clustering and sharding for Ruvector vector databases.
ruvector-cluster provides horizontal scaling capabilities with consistent hashing, shard management, and cluster coordination. Enables Ruvector to scale to billions of vectors across multiple nodes. Part of the Ruvector ecosystem.
Why Ruvector Cluster?
- Horizontal Scaling: Distribute data across multiple nodes
- Consistent Hashing: Minimal rebalancing on cluster changes
- Auto-Sharding: Automatic shard distribution and balancing
- Fault Tolerant: Handle node failures gracefully
- Async-First: Built on Tokio for high-performance networking
Features
Core Capabilities
- Cluster Membership: Node discovery and health monitoring
- Consistent Hashing: Ketama/Jump hash for shard placement
- Shard Management: Create, migrate, and balance shards
- Node Coordination: Leader election and consensus
- Failure Detection: Heartbeat-based failure detection
Advanced Features
- Dynamic Rebalancing: Auto-balance on node join/leave
- Rack Awareness: Place replicas across failure domains
- Hot Spot Detection: Identify and redistribute hot shards
- Gradual Migration: Zero-downtime shard migration
- Cluster Metrics: Prometheus-compatible metrics
Installation
Add ruvector-cluster to your Cargo.toml:
[dependencies]
ruvector-cluster = "0.1.1"
Quick Start
Initialize Cluster
use ruvector_cluster::{Cluster, ClusterConfig, Node};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure cluster
let config = ClusterConfig {
node_id: "node-1".to_string(),
listen_addr: "0.0.0.0:7000".parse()?,
seeds: vec!["10.0.0.1:7000".parse()?, "10.0.0.2:7000".parse()?],
replication_factor: 3,
num_shards: 64,
..Default::default()
};
// Create and start cluster
let cluster = Cluster::new(config).await?;
cluster.start().await?;
// Wait for cluster to stabilize
cluster.wait_for_stable().await?;
println!("Cluster ready with {} nodes", cluster.node_count().await);
Ok(())
}
Shard Operations
use ruvector_cluster::{Cluster, ShardId};
// Get shard for a vector ID
let shard_id = cluster.get_shard_for_key("vector-123")?;
// Get nodes hosting a shard
let nodes = cluster.get_shard_nodes(shard_id).await?;
println!("Shard {} hosted on: {:?}", shard_id, nodes);
// Manual shard migration
cluster.migrate_shard(shard_id, target_node).await?;
// Trigger rebalance
cluster.rebalance().await?;
Cluster Health
// Check cluster health
let health = cluster.health().await?;
println!("Status: {:?}", health.status);
println!("Healthy nodes: {}/{}", health.healthy_nodes, health.total_nodes);
// Get node status
for node in cluster.nodes().await? {
println!("{}: {:?} (last seen: {})",
node.id,
node.status,
node.last_heartbeat
);
}
API Overview
Core Types
// Cluster configuration
pub struct ClusterConfig {
pub node_id: String,
pub listen_addr: SocketAddr,
pub seeds: Vec<SocketAddr>,
pub replication_factor: usize,
pub num_shards: usize,
pub heartbeat_interval: Duration,
pub failure_timeout: Duration,
}
// Node information
pub struct Node {
pub id: String,
pub addr: SocketAddr,
pub status: NodeStatus,
pub shards: Vec<ShardId>,
pub last_heartbeat: DateTime<Utc>,
}
// Shard information
pub struct Shard {
pub id: ShardId,
pub primary: NodeId,
pub replicas: Vec<NodeId>,
pub status: ShardStatus,
pub size_bytes: u64,
}
Cluster Operations
impl Cluster {
pub async fn new(config: ClusterConfig) -> Result<Self>;
pub async fn start(&self) -> Result<()>;
pub async fn stop(&self) -> Result<()>;
// Membership
pub async fn nodes(&self) -> Result<Vec<Node>>;
pub async fn node_count(&self) -> usize;
pub async fn is_leader(&self) -> bool;
// Sharding
pub fn get_shard_for_key(&self, key: &str) -> Result<ShardId>;
pub async fn get_shard_nodes(&self, shard: ShardId) -> Result<Vec<Node>>;
pub async fn migrate_shard(&self, shard: ShardId, target: &NodeId) -> Result<()>;
// Health
pub async fn health(&self) -> Result<ClusterHealth>;
pub async fn rebalance(&self) -> Result<()>;
}
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Cluster │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Node 1 │ │ Node 2 │ │ Node 3 │ │ Node 4 │ │
│ │ Shards: │ │ Shards: │ │ Shards: │ │ Shards: │ │
│ │ 0,4,8 │ │ 1,5,9 │ │ 2,6,10 │ │ 3,7,11 │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │ │
│ └────────────┴────────────┴────────────┘ │
│ Gossip Protocol │
└─────────────────────────────────────────────────────────────┘
Related Crates
- ruvector-core - Core vector database engine
- ruvector-raft - RAFT consensus
- ruvector-replication - Data replication
Documentation
- Main README - Complete project overview
- API Documentation - Full API reference
- GitHub Repository - Source code
License
MIT License - see LICENSE for details.