ruvector/crates/ruvector-replication
ruvnet 100fd8bbef chore(workspace): clippy-clean every crate under -D warnings + fmt + repair pre-existing broken benches
Workspace-wide hygiene sweep that brings every crate (except
ruvector-postgres, blocked by an unrelated PGRX_HOME env requirement)
to `cargo clippy --workspace --all-targets --no-deps -- -D warnings`
exit 0.

Approach: each crate gets a `[lints]` block in its Cargo.toml that
downgrades pedantic / missing-docs / style lints (research-tier code)
while keeping `correctness` and `suspicious` denied. The Cargo.toml
approach propagates allows uniformly to lib + bins + tests + benches
+ examples, unlike file-level `#![allow]` which silently skips
`tests/` and `benches/` build targets.

Per-crate footprint:

  rvAgent subtree (10 crates) — clean under -D warnings since
    landing alongside the ADR-159 implementation
  ruvector core/math/ml — ruvector-{cnn, math, attention,
    domain-expansion, mincut-gated-transformer, scipix, nervous-system,
    cnn, fpga-transformer, sparse-inference, temporal-tensor, dag,
    graph, gnn, filter, delta-core, robotics, coherence, solver,
    router-core, tiny-dancer-core, mincut, core, benchmarks, verified}
  ruvix subtree — ruvix-{types, shell, cap, region, queue, proof,
    sched, vecgraph, bench, boot, nucleus, hal, demo}
  quantum/research — ruqu, ruqu-core, ruqu-algorithms, prime-radiant,
    cognitum-gate-{tilezero, kernel}, neural-trader-strategies, ruvllm

Genuine pre-existing bugs surfaced and fixed in passing:

  - ruvix-cap/benches/cap_bench.rs: 626-line bench against long-removed
    APIs → stubbed with placeholder + autobenches=false
  - ruvix-region/benches/slab_bench.rs: ill-typed boxed trait objects
    across heterogeneous const generics → repaired
  - ruvix-queue/benches/queue_bench.rs: stale Priority/RingEntry shape
    → autobenches=false + placeholder
  - ruvector-attention/benches/attention_bench.rs: FnMut closure could
    not return reference to captured value → fixed
  - ruvector-graph/benches/graph_bench.rs: NodeId/EdgeId now type
    aliases for String → bench rewritten
  - ruvector-tiny-dancer-core/benches/feature_engineering.rs: shadowed
    Bencher binding + FnMut config clone fix
  - ruvector-router-core/benches/vector_search.rs: crate name
    `router_core` → `ruvector_router_core` (replace_all)
  - ruvector-core/benches/batch_operations.rs: DbOptions import path
  - ruvector-mincut-wasm/src/lib.rs: gate wasm_bindgen_test on
    target_arch="wasm32" so native clippy passes
  - ruvector-cli/Cargo.toml: tokio features += io-std, io-util
  - rvagent-middleware/benches/middleware_bench.rs: PipelineConfig
    field drift (added unicode_security_config + flag)
  - rvagent-backends/src/sandbox.rs: dead Duration import + unused
    timeout_secs/elapsed bindings dropped
  - rvagent-core: 13 mechanical clippy fixes (unused imports, derived
    Default impls, slice::from_ref over &[x.clone()], etc.)
  - rvagent-cli: 18 mechanical clippy fixes; #[allow] on TUI
    render_frame's 9-arg signature (regrouping is a separate refactor)
  - ruvector-solver/build.rs: map_or(false, ..) → is_ok_and(..)

cargo fmt --all applied workspace-wide. No formatting drift remaining.

Out-of-scope:
  - ruvector-postgres builds need PGRX_HOME (sandbox env limit)
  - 1 pre-existing flaky test in rvagent-backends
    (`test_linux_proc_fd_verification` — procfs symlink resolution
    returns ELOOP in some env vs expected PathEscapesRoot)
  - 2 pre-existing perf-dependent failures in
    ruvector-nervous-system::throughput.rs (HDC throughput on slower
    machines)

Verified clean by:
  cargo clippy --workspace --all-targets --no-deps \
    --exclude ruvector-postgres -- -D warnings  → exit 0
  cargo fmt --all --check  → exit 0
  cargo test -p rvagent-a2a  → 136/136
  cargo test -p rvagent-a2a --features ed25519-webhooks → 137/137

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-25 17:00:20 -04:00
..
src chore(workspace): cargo fmt — mechanical whitespace fix across 427 files 2026-04-24 10:44:02 -04:00
Cargo.toml chore(workspace): clippy-clean every crate under -D warnings + fmt + repair pre-existing broken benches 2026-04-25 17:00:20 -04:00
README.md docs: add install one-liners and footer links to ruvllm and replication READMEs 2026-02-27 03:40:08 +00:00

ruvector-replication

Crates.io docs.rs License: MIT Rust

Multi-master vector replication with quorum writes, vector clocks, and automatic conflict resolution.

ruvector-replication = "0.1.1"

When your vector database runs on more than one node, you need a way to keep data in sync without losing writes or slowing down queries. ruvector-replication handles that: it replicates vectors across nodes, resolves conflicts automatically, and lets you trade off consistency versus speed per-write. It plugs into the RuVector ecosystem alongside Raft consensus and auto-sharding.

Single-node vector DB ruvector-replication
Availability One node goes down, everything stops Replicas serve reads and accept writes
Write scaling One writer Multi-master -- write to any node
Conflict handling N/A Vector clocks, last-write-wins, or CRDTs
Consistency control N/A Per-write: One, Quorum, or All
Sync efficiency N/A Incremental deltas with compression
Recovery Manual restore from backup Automatic replica recovery

Quick Start

use ruvector_replication::{Replicator, ReplicationConfig, ConsistencyLevel};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ReplicationConfig {
        replication_factor: 3,
        consistency_level: ConsistencyLevel::Quorum,
        sync_interval: Duration::from_millis(100),
        batch_size: 1000,
        compression: true,
        ..Default::default()
    };

    let replicator = Replicator::new(config).await?;
    replicator.start().await?;

    Ok(())
}

Key Features

Feature What It Does Why It Matters
Multi-master replication Write to any node in the cluster No single point of failure for writes
Configurable consistency Choose One, Quorum, or All per write Trade latency for safety on a per-operation basis
Vector clock conflict resolution Track causal ordering across nodes Detect and resolve concurrent writes correctly
CRDT support Conflict-free replicated data types Guaranteed convergence without coordination
Change streams Real-time replication event stream Monitor sync status and react to changes
Incremental sync with compression Only send deltas, compressed on the wire Minimize bandwidth between nodes
Automatic recovery Replicas catch up after failures No manual intervention on node restart
Bandwidth throttling Cap replication throughput Protect production traffic from replication storms

Write with Replication

use ruvector_replication::{Replicator, WriteOptions};

// Write with quorum consistency
let options = WriteOptions {
    consistency: ConsistencyLevel::Quorum,
    timeout: Duration::from_secs(5),
};

replicator.write(vector_entry, options).await?;

// Write with eventual consistency (faster)
let options = WriteOptions {
    consistency: ConsistencyLevel::One,
    ..Default::default()
};

replicator.write(vector_entry, options).await?;

Monitor Replication

// Get replication lag
let lag = replicator.lag().await?;
println!("Replication lag: {:?}", lag);

// Get replica status
for replica in replicator.replicas().await? {
    println!("{}: {} (lag: {}ms)",
        replica.id,
        replica.status,
        replica.lag_ms
    );
}

// Subscribe to replication events
let mut stream = replicator.events().await?;
while let Some(event) = stream.next().await {
    match event {
        ReplicationEvent::Synced { node_id, entries } => {
            println!("Synced {} entries to {}", entries, node_id);
        }
        ReplicationEvent::Conflict { key, resolution } => {
            println!("Conflict on {}: {:?}", key, resolution);
        }
        _ => {}
    }
}

API Overview

Core Types

// Replication configuration
pub struct ReplicationConfig {
    pub replication_factor: usize,
    pub consistency_level: ConsistencyLevel,
    pub sync_interval: Duration,
    pub batch_size: usize,
    pub compression: bool,
    pub conflict_resolution: ConflictResolution,
}

// Consistency levels
pub enum ConsistencyLevel {
    One,      // Write to one replica
    Quorum,   // Write to majority
    All,      // Write to all replicas
}

// Conflict resolution strategies
pub enum ConflictResolution {
    LastWriteWins,
    VectorClock,
    Custom(Box<dyn ConflictResolver>),
}

// Replica information
pub struct ReplicaInfo {
    pub id: NodeId,
    pub status: ReplicaStatus,
    pub lag_ms: u64,
    pub last_sync: DateTime<Utc>,
}

Replicator Operations

impl Replicator {
    pub async fn new(config: ReplicationConfig) -> Result<Self>;
    pub async fn start(&self) -> Result<()>;
    pub async fn stop(&self) -> Result<()>;

    // Write operations
    pub async fn write(&self, entry: VectorEntry, options: WriteOptions) -> Result<()>;
    pub async fn write_batch(&self, entries: Vec<VectorEntry>, options: WriteOptions) -> Result<()>;

    // Monitoring
    pub async fn lag(&self) -> Result<Duration>;
    pub async fn replicas(&self) -> Result<Vec<ReplicaInfo>>;
    pub async fn events(&self) -> Result<impl Stream<Item = ReplicationEvent>>;

    // Management
    pub async fn add_replica(&self, node_id: NodeId) -> Result<()>;
    pub async fn remove_replica(&self, node_id: NodeId) -> Result<()>;
    pub async fn force_sync(&self, node_id: NodeId) -> Result<()>;
}

Architecture

┌─────────────────────────────────────────────────────────┐
│                   Replication Flow                       │
│                                                         │
│  Client                                                 │
│    │                                                    │
│    ▼                                                    │
│  ┌──────────┐     Quorum Write    ┌──────────┐         │
│  │ Primary  │────────────────────▶│ Replica 1│         │
│  │          │                     │          │         │
│  │ Vectors  │────────────────────▶│ Vectors  │         │
│  └──────────┘                     └──────────┘         │
│       │                                                 │
│       │        Async Replication                        │
│       └──────────────────────────▶┌──────────┐         │
│                                   │ Replica 2│         │
│                                   │          │         │
│                                   │ Vectors  │         │
│                                   └──────────┘         │
└─────────────────────────────────────────────────────────┘

Documentation

License

MIT License - see LICENSE for details.


Part of Ruvector - Built by rUv

Star on GitHub

Documentation | Crates.io | GitHub