Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/build-verified.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: ruvector-verified CI

on:
push:
paths:
- "crates/ruvector-verified/**"
- "Cargo.lock"
pull_request:
paths:
- "crates/ruvector-verified/**"

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
feature-set:
- ""
- "--features hnsw-proofs"
- "--features rvf-proofs"
- "--features coherence-proofs"
- "--features all-proofs"
- "--features ultra"
- "--features serde"
- "--all-features"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check (${{ matrix.feature-set || 'default' }})
run: cargo check -p ruvector-verified ${{ matrix.feature-set }}

test:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests (all features)
run: cargo test -p ruvector-verified --all-features
- name: Run tests (default features)
run: cargo test -p ruvector-verified

bench:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run benchmarks (dry-run)
run: cargo bench -p ruvector-verified --all-features -- --test

clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy (all features)
run: cargo clippy -p ruvector-verified --all-features -- -D warnings
56 changes: 56 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ members = [
"crates/ruvector-profiler",
"crates/ruvector-attn-mincut",
"crates/ruvector-cognitive-container",
"crates/ruvector-verified",
"crates/ruvector-verified-wasm",
"examples/rvf-kernel-optimized",
"examples/verified-applications",
]
resolver = "2"

Expand Down Expand Up @@ -171,6 +175,9 @@ criterion = { version = "0.5", features = ["html_reports"] }
proptest = "1.5"
mockall = "0.13"

# Formal verification
lean-agentic = "=0.1.0"

# Performance
dashmap = "6.1"
parking_lot = "0.12"
Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ cargo add ruvector-raft ruvector-cluster ruvector-replication
| **Adaptive Routing** | Learn optimal routing strategies | Minimize latency, maximize accuracy |
| **SONA** | Two-tier LoRA + EWC++ + ReasoningBank | Runtime learning without retraining |
| **Local Embeddings** | 8+ ONNX models built-in | No external API needed |
| **[Verified Proofs](./crates/ruvector-verified)** | 82-byte proof attestations per vector op | Structural trust, not just assertions |

### Specialized Processing

Expand Down Expand Up @@ -1150,6 +1151,7 @@ await dag.execute();
| [ADR-013](./docs/adr/ADR-013-huggingface-publishing.md) | **New** | HuggingFace publishing |
| [ADR-030](./docs/adr/ADR-030-rvf-cognitive-container.md) | **Accepted** | RVF cognitive container architecture |
| [ADR-031](./docs/adr/ADR-031-rvcow-branching-and-real-cognitive-containers.md) | **Accepted** | RVCOW branching & real containers |
| [ADR-045](./docs/adr/ADR-045-lean-agentic-integration.md) | **Accepted** | Lean-agentic formal verification integration |

</details>

Expand Down Expand Up @@ -1482,6 +1484,54 @@ let syndrome = gate.assess_coherence(&quantum_state)?;

**RVF Features:** Single-file cognitive containers that boot as Linux microservices, COW branching at cluster granularity, eBPF acceleration, witness chains, post-quantum signatures, 24 segment types. [Full README](./crates/rvf/README.md)

### Formal Verification

| Crate | Description | crates.io |
|-------|-------------|-----------|
| [ruvector-verified](./crates/ruvector-verified) | Proof-carrying vector operations with lean-agentic dependent types (~500ns proofs) | [![crates.io](https://img.shields.io/crates/v/ruvector-verified.svg)](https://crates.io/crates/ruvector-verified) |
| [ruvector-verified-wasm](./crates/ruvector-verified-wasm) | WASM bindings for browser/edge formal verification | [![crates.io](https://img.shields.io/crates/v/ruvector-verified-wasm.svg)](https://crates.io/crates/ruvector-verified-wasm) |

**Verification Features:** 82-byte proof attestations, 3-tier gated proof routing (Reflex <10ns / Standard <1us / Deep <100us), FastTermArena with O(1) dedup, batch dimension verification (~11ns/vector), type-safe pipeline composition. [Full README](./crates/ruvector-verified/README.md)

<details>
<summary>Formal Verification Details</summary>

**How it works:** Every vector operation produces a machine-checked proof term using lean-agentic dependent types. Proofs are constructed at compile-time semantics but execute at runtime with sub-microsecond overhead, then serialized into 82-byte attestations that can be embedded in RVF witness chains.

| Operation | Latency | Description |
|-----------|---------|-------------|
| `ProofEnvironment::new()` | ~470ns | Initialize proof context with type declarations |
| `prove_dim_eq(a, b)` | ~496ns | Dimension equality proof with FxHash caching |
| `verify_batch_dimensions()` | ~11ns/vec | Batch verification for N vectors |
| `compose_chain()` | ~1.2us | Type-safe pipeline composition |
| `create_attestation()` | ~180ns | 82-byte formal proof witness |
| `FastTermArena::intern()` | ~1.6ns hit | O(1) dedup with 4-wide linear probe |
| `gated::route_proof()` | <10ns | 3-tier routing: Reflex / Standard / Deep |

**10 Exotic Application Domains** ([examples/verified-applications](./examples/verified-applications)):

1. **Autonomous Weapons Filter** — certified targeting pipeline blocks tampered sensors
2. **Medical Diagnostics** — proof-carrying ECG analysis with patient-keyed attestations
3. **Financial Order Routing** — verified trade execution with proof-hash audit trail
4. **Multi-Agent Contracts** — dimension + metric + depth contracts enforced by proof
5. **Distributed Sensor Swarm** — coherence verification across heterogeneous nodes
6. **Quantization Proof** — certify quantization error within formal tolerance bounds
7. **Verifiable Synthetic Memory** — AGI memory with per-embedding proof attestations
8. **Cryptographic Vector Signatures** — model-keyed signatures with contract matching
9. **Simulation Integrity** — proof receipt per step for reproducible physics
10. **Legal Forensics** — court-admissible replay bundles with structural invariants

```rust
use ruvector_verified::{ProofEnvironment, vector_types, proof_store};

let mut env = ProofEnvironment::new();
let proof = vector_types::prove_dim_eq(&mut env, 384, 384).unwrap();
let att = proof_store::create_attestation(&env, proof);
assert_eq!(att.to_bytes().len(), 82); // 82-byte formal witness
```

</details>

**Self-booting example** — the `claude_code_appliance` builds a complete AI dev environment as one file:

```bash
Expand Down Expand Up @@ -3974,6 +4024,7 @@ console.log(`Similarity: ${cosineSimilarity(vecA, vecB)}`); // 1.0
| `@ruvector/exotic-wasm` | <150KB | NAO, Morphogenetic, Time Crystal |
| `@ruvector/nervous-system-wasm` | <100KB | BTSP, HDC (10K-bit), WTA, Global Workspace |
| `@ruvector/attention-unified-wasm` | <200KB | 18+ attention mechanisms, unified API |
| `@ruvnet/ruvector-verified-wasm` | <80KB | Formal proof verification in browser/edge |

**Common Patterns:**

Expand Down Expand Up @@ -4502,6 +4553,8 @@ curl -X POST http://localhost:8080/search \
| [prime-radiant](./examples/prime-radiant) | Prime-Radiant coherence engine examples and usage demos | Rust |
| [benchmarks](./examples/benchmarks) | Comprehensive benchmarks for temporal reasoning and vector operations | Rust |
| [vwm-viewer](./examples/vwm-viewer) | Visual vector world model viewer (HTML Canvas) | HTML |
| [**verified-applications**](./examples/verified-applications) | **10 exotic domains: weapons filter, medical diagnostics, financial routing, agent contracts, sensor swarm, quantization proof, AGI memory, vector signatures, simulation integrity, legal forensics** | Rust |
| [rvf-kernel-optimized](./examples/rvf-kernel-optimized) | Verified + hyper-optimized Linux kernel RVF with proof-carrying ingest | Rust |

</details>

Expand Down
35 changes: 35 additions & 0 deletions crates/ruvector-verified-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[package]
name = "ruvector-verified-wasm"
version = "0.1.1"
edition = "2021"
rust-version = "1.77"
license = "MIT OR Apache-2.0"
description = "WASM bindings for ruvector-verified: proof-carrying vector operations in the browser"
repository = "https://github.com/ruvnet/ruvector"
homepage = "https://github.com/ruvnet/ruvector"
documentation = "https://docs.rs/ruvector-verified-wasm"
readme = "README.md"
keywords = ["wasm", "verification", "vector-database", "dependent-types", "webassembly"]
categories = ["wasm", "science", "mathematics"]

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
ruvector-verified = { version = "0.1.1", path = "../ruvector-verified", features = ["ultra"] }
wasm-bindgen = "0.2"
serde-wasm-bindgen = "0.6"
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
js-sys = "0.3"
web-sys = { version = "0.3", features = ["console"] }

[dev-dependencies]
wasm-bindgen-test = "0.3"

[profile.release]
opt-level = "s"
lto = true
66 changes: 66 additions & 0 deletions crates/ruvector-verified-wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# ruvector-verified-wasm

[![Crates.io](https://img.shields.io/crates/v/ruvector-verified-wasm.svg)](https://crates.io/crates/ruvector-verified-wasm)
[![npm](https://img.shields.io/npm/v/ruvector-verified-wasm.svg)](https://www.npmjs.com/package/ruvector-verified-wasm)
[![License](https://img.shields.io/crates/l/ruvector-verified-wasm.svg)](https://github.com/ruvnet/ruvector)

WebAssembly bindings for [ruvector-verified](https://crates.io/crates/ruvector-verified) — proof-carrying vector operations in the browser. Verify vector dimensions, build typed HNSW indices, and create 82-byte proof attestations entirely client-side with sub-microsecond overhead.

## Quick Start

```js
import init, { JsProofEnv } from "ruvector-verified-wasm";

await init();
const env = new JsProofEnv();

// Prove dimension equality (~500ns)
const proofId = env.prove_dim_eq(384, 384);

// Verify a batch of vectors (flat f32 array)
const flat = new Float32Array(384 * 100); // 100 vectors
const count = env.verify_batch_flat(384, flat);
console.log(`Verified ${count} vectors`);

// Create 82-byte proof attestation
const att = env.create_attestation(proofId);
console.log(att.bytes.length); // 82

// Route proof to cheapest tier
const routing = env.route_proof("dimension");
console.log(routing); // { tier: "reflex", reason: "...", estimated_steps: 1 }

// Get statistics
console.log(env.stats());
```

## API

| Method | Returns | Description |
|--------|---------|-------------|
| `new JsProofEnv()` | `JsProofEnv` | Create environment with all ultra optimizations |
| `.prove_dim_eq(a, b)` | `number` | Prove dimensions equal, returns proof ID |
| `.mk_vector_type(dim)` | `number` | Build `RuVec n` type term |
| `.mk_distance_metric(m)` | `number` | Build metric type: `"L2"`, `"Cosine"`, `"Dot"` |
| `.verify_dim_check(dim, vec)` | `number` | Verify single vector dimension |
| `.verify_batch_flat(dim, flat)` | `number` | Verify N vectors (flat f32 array) |
| `.arena_intern(hi, lo)` | `[id, cached]` | Intern into FastTermArena |
| `.route_proof(kind)` | `object` | Route to Reflex/Standard/Deep tier |
| `.create_attestation(id)` | `object` | Create 82-byte proof witness |
| `.stats()` | `object` | Get verification statistics |
| `.reset()` | `void` | Reset environment |
| `.terms_allocated()` | `number` | Count of allocated proof terms |

## Building

```bash
# With wasm-pack
wasm-pack build crates/ruvector-verified-wasm --target web

# With cargo (for crates.io)
cargo build -p ruvector-verified-wasm --target wasm32-unknown-unknown
```

## License

MIT OR Apache-2.0
Loading
Loading