ruvector/crates/ruvector-snapshot
rUv eafba64fa5
fix(security): RUSTSEC advisories + clippy hardening in RuVector (#504)
* 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>
2026-05-23 05:40:24 -04:00
..
src fix: Resolve CI build failures 2025-11-26 15:25:47 +00:00
Cargo.toml fix(security): RUSTSEC advisories + clippy hardening in RuVector (#504) 2026-05-23 05:40:24 -04:00
README.md docs: Add README files for all crates and update root README with crates table 2025-11-26 18:15:05 +00:00

Ruvector Snapshot

Crates.io Documentation License: MIT Rust

Point-in-time snapshots and backup for Ruvector vector databases.

ruvector-snapshot provides efficient snapshot creation, storage, and restoration for Ruvector databases. Supports incremental snapshots, compression, and integrity verification. Part of the Ruvector ecosystem.

Why Ruvector Snapshot?

  • Point-in-Time Recovery: Restore to any snapshot
  • Incremental Snapshots: Only store changed data
  • Compression: GZIP compression for storage efficiency
  • Integrity Verification: SHA-256 checksums
  • Async I/O: Non-blocking snapshot operations

Features

Core Capabilities

  • Full Snapshots: Complete database backup
  • Incremental Snapshots: Delta-based backups
  • Compression: GZIP compression support
  • Checksums: SHA-256 integrity verification
  • Async Operations: Tokio-based async I/O

Advanced Features

  • Snapshot Scheduling: Automated snapshot creation
  • Retention Policies: Automatic cleanup of old snapshots
  • Remote Storage: S3/GCS compatible storage (planned)
  • Streaming Restore: Progressive restoration
  • Parallel Processing: Multi-threaded snapshot creation

Installation

Add ruvector-snapshot to your Cargo.toml:

[dependencies]
ruvector-snapshot = "0.1.1"

Quick Start

Create Snapshot

use ruvector_snapshot::{SnapshotManager, SnapshotConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Configure snapshot manager
    let config = SnapshotConfig {
        snapshot_dir: "./snapshots".into(),
        compression: true,
        verify_checksum: true,
        ..Default::default()
    };

    let manager = SnapshotManager::new(config)?;

    // Create a full snapshot
    let snapshot = manager.create_snapshot(&db, "backup-2024-01").await?;
    println!("Created snapshot: {} ({} bytes)",
        snapshot.id,
        snapshot.size_bytes
    );

    Ok(())
}

Restore from Snapshot

use ruvector_snapshot::SnapshotManager;

// List available snapshots
let snapshots = manager.list_snapshots().await?;
for snapshot in &snapshots {
    println!("{}: {} ({})",
        snapshot.id,
        snapshot.created_at,
        snapshot.size_bytes
    );
}

// Restore from snapshot
let restored_db = manager.restore_snapshot(&snapshots[0].id).await?;
println!("Restored {} vectors", restored_db.len()?);

Incremental Snapshots

use ruvector_snapshot::{SnapshotManager, SnapshotType};

// Create base snapshot
let base = manager.create_snapshot(&db, "base").await?;

// ... database modifications ...

// Create incremental snapshot
let incremental = manager.create_incremental_snapshot(
    &db,
    "incremental-1",
    &base.id
).await?;

println!("Incremental snapshot: {} bytes (vs {} full)",
    incremental.size_bytes,
    base.size_bytes
);

API Overview

Core Types

// Snapshot configuration
pub struct SnapshotConfig {
    pub snapshot_dir: PathBuf,
    pub compression: bool,
    pub compression_level: u32,
    pub verify_checksum: bool,
    pub max_concurrent_io: usize,
}

// Snapshot metadata
pub struct Snapshot {
    pub id: String,
    pub created_at: DateTime<Utc>,
    pub size_bytes: u64,
    pub checksum: String,
    pub snapshot_type: SnapshotType,
    pub vector_count: usize,
    pub metadata: serde_json::Value,
}

// Snapshot types
pub enum SnapshotType {
    Full,
    Incremental { base_id: String },
}

Manager Operations

impl SnapshotManager {
    pub fn new(config: SnapshotConfig) -> Result<Self>;

    // Snapshot creation
    pub async fn create_snapshot(&self, db: &VectorDB, name: &str) -> Result<Snapshot>;
    pub async fn create_incremental_snapshot(
        &self,
        db: &VectorDB,
        name: &str,
        base_id: &str
    ) -> Result<Snapshot>;

    // Listing and info
    pub async fn list_snapshots(&self) -> Result<Vec<Snapshot>>;
    pub async fn get_snapshot(&self, id: &str) -> Result<Option<Snapshot>>;

    // Restoration
    pub async fn restore_snapshot(&self, id: &str) -> Result<VectorDB>;
    pub async fn verify_snapshot(&self, id: &str) -> Result<bool>;

    // Management
    pub async fn delete_snapshot(&self, id: &str) -> Result<()>;
    pub async fn cleanup_old_snapshots(&self, keep: usize) -> Result<usize>;
}

Snapshot Format

snapshot-{id}/
├── metadata.json       # Snapshot metadata
├── vectors.bin.gz      # Compressed vector data
├── index.bin.gz        # HNSW index data
├── metadata.bin.gz     # Vector metadata
└── checksum.sha256     # Integrity checksum

Documentation

License

MIT License - see LICENSE for details.


Part of Ruvector - Built by rUv

Star on GitHub

Documentation | Crates.io | GitHub