Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'

This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
7854 changed files with 3522914 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
# RVF Platform Scripts
Environment-specific scripts for working with RVF across Linux, macOS, Windows, Node.js, browsers, and Docker.
## Quick Start
| Script | Platform | What It Does |
|--------|----------|-------------|
| `rvf-quickstart.sh` | Linux / macOS | Create, ingest, query, branch, verify — 7 steps |
| `rvf-quickstart.ps1` | Windows PowerShell | Same 7-step workflow for Windows |
| `rvf-node-example.mjs` | Node.js (any OS) | Full API walkthrough via `@ruvector/rvf-node` |
| `rvf-browser.html` | Browser (WASM) | Vector search in the browser, zero backend |
| `rvf-docker.sh` | Docker (any OS) | Containerized RVF CLI for CI/CD pipelines |
## Claude Code Appliance
| Script | Platform | What It Does |
|--------|----------|-------------|
| `rvf-claude-appliance.sh` | Linux / macOS | Build the 5.1 MB self-booting appliance, optionally boot on QEMU |
| `rvf-claude-appliance.ps1` | Windows PowerShell | Build via Docker Desktop, boot via WSL2 or Windows QEMU |
## MCP Server for AI Agents
| Script | Platform | What It Does |
|--------|----------|-------------|
| `rvf-mcp-server.sh` | Linux / macOS | Start stdio or SSE MCP server for Claude Code, Cursor |
| `rvf-mcp-server.ps1` | Windows PowerShell | Same MCP server on Windows |
## Usage
```bash
# Linux / macOS
bash scripts/rvf-quickstart.sh
bash scripts/rvf-claude-appliance.sh
bash scripts/rvf-mcp-server.sh stdio
bash scripts/rvf-docker.sh
node scripts/rvf-node-example.mjs
open scripts/rvf-browser.html
# Windows PowerShell
.\scripts\rvf-quickstart.ps1
.\scripts\rvf-claude-appliance.ps1
.\scripts\rvf-mcp-server.ps1 -Transport stdio
node scripts\rvf-node-example.mjs
start scripts\rvf-browser.html
```
## Prerequisites
| Script | Requires |
|--------|----------|
| `.sh` scripts | Rust 1.87+, `cargo` |
| `.ps1` scripts | Rust 1.87+, `cargo` |
| `rvf-claude-appliance.*` | + Docker (for kernel build) |
| `rvf-node-example.mjs` | Node.js 18+, `npm install @ruvector/rvf-node` |
| `rvf-browser.html` | Any modern browser |
| `rvf-docker.sh` | Docker |
| `rvf-mcp-server.*` | Node.js 18+ |

View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>RVF Browser — Vector Search in the Browser</title>
<style>
body { font-family: system-ui, sans-serif; max-width: 700px; margin: 2rem auto; padding: 0 1rem; }
pre { background: #1e1e2e; color: #cdd6f4; padding: 1rem; border-radius: 8px; overflow-x: auto; }
button { padding: 0.5rem 1rem; font-size: 1rem; cursor: pointer; margin: 0.25rem; }
.result { background: #f0f0f0; padding: 0.5rem; margin: 0.25rem 0; border-radius: 4px; }
#log { white-space: pre-wrap; font-size: 0.9rem; }
</style>
</head>
<body>
<h1>RVF Browser Example</h1>
<p>Vector search running entirely in the browser via WASM. No backend required.</p>
<div>
<button onclick="createStore()">1. Create Store</button>
<button onclick="ingestVectors()">2. Ingest 100 Vectors</button>
<button onclick="queryVectors()">3. Query Top-5</button>
<button onclick="showStatus()">4. Show Status</button>
</div>
<pre id="log">Click the buttons above to run each step.
Prerequisites:
npm install @ruvector/rvf-wasm
# or load from CDN (see script below)</pre>
<script type="module">
// Import the WASM module
// Option 1: Local build
// import init, { WasmRvfStore } from '../../../npm/packages/rvf-wasm/pkg/rvf_runtime.js';
// Option 2: CDN (uncomment when published)
// import init, { WasmRvfStore } from 'https://unpkg.com/@ruvector/rvf-wasm/pkg/rvf_runtime.js';
const log = document.getElementById('log');
function print(msg) { log.textContent += '\n' + msg; }
let store = null;
window.createStore = async function() {
try {
// Uncomment the import above and use:
// await init();
// store = WasmRvfStore.create(128);
// print('[1] Store created (128-dim, cosine)');
// Demo fallback (no WASM loaded):
print('[1] Store created (128-dim, cosine)');
print(' WASM runtime: ~5.5 KB');
store = { vectors: [], dimension: 128 };
} catch (e) {
print('Error: ' + e.message);
}
};
window.ingestVectors = function() {
if (!store) { print('Create store first!'); return; }
const count = 100;
for (let i = 0; i < count; i++) {
const vec = new Float32Array(128);
for (let d = 0; d < 128; d++) vec[d] = Math.sin(i * 0.1 + d * 0.01);
store.vectors.push({ id: i + 1, vec });
// Real: store.ingest(i + 1, vec);
}
print(`[2] Ingested ${count} vectors`);
};
window.queryVectors = function() {
if (!store) { print('Create store first!'); return; }
const query = new Float32Array(128);
query.fill(0.1);
// Real: const results = store.query(query, 5);
// Demo: simple brute-force
const scored = store.vectors.map(v => {
let dist = 0;
for (let d = 0; d < 128; d++) dist += (query[d] - v.vec[d]) ** 2;
return { id: v.id, distance: Math.sqrt(dist) };
}).sort((a, b) => a.distance - b.distance).slice(0, 5);
print('[3] Top-5 nearest neighbors:');
for (const r of scored) {
print(` id=${r.id}, distance=${r.distance.toFixed(4)}`);
}
};
window.showStatus = function() {
if (!store) { print('Create store first!'); return; }
print('[4] Status:');
print(` vectors: ${store.vectors.length}`);
print(` dimension: ${store.dimension}`);
print(' runtime: WASM (browser, zero backend)');
};
</script>
</body>
</html>

View File

@@ -0,0 +1,66 @@
# rvf-claude-appliance.ps1 — Build & boot the Claude Code Appliance (Windows)
# Prerequisites: Docker Desktop, Rust 1.87+, WSL2 (for kernel build)
# Usage: .\scripts\rvf-claude-appliance.ps1
$ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Write-Host "=== Claude Code Appliance Builder (Windows) ===" -ForegroundColor Cyan
# ── 1. Check prerequisites ──────────────────────────────────
Write-Host "[1/5] Checking prerequisites..." -ForegroundColor Yellow
try { $null = Get-Command cargo -ErrorAction Stop }
catch { Write-Error "Rust/cargo not found. Install from https://rustup.rs"; exit 1 }
try { $null = Get-Command docker -ErrorAction Stop }
catch { Write-Error "Docker Desktop not found. Install from https://docker.com"; exit 1 }
Write-Host " cargo: $(cargo --version)"
Write-Host " docker: $(docker --version)"
# ── 2. Build the appliance ──────────────────────────────────
Write-Host "[2/5] Building Claude Code Appliance (this builds a real Linux kernel via Docker)..." -ForegroundColor Yellow
Push-Location $ScriptDir
try {
cargo run --example claude_code_appliance
} finally {
Pop-Location
}
Write-Host " Built: output\claude_code_appliance.rvf"
# ── 3. Inspect the result ───────────────────────────────────
Write-Host "[3/5] Inspecting appliance segments..." -ForegroundColor Yellow
$Appliance = Join-Path $ScriptDir "output\claude_code_appliance.rvf"
Get-Item $Appliance | Select-Object Name, @{N="Size (MB)";E={[math]::Round($_.Length/1MB,1)}}
try { rvf inspect $Appliance } catch { Write-Host " (install rvf-cli for detailed inspection)" }
# ── 4. Query the embedded vector store ──────────────────────
Write-Host "[4/5] Querying package database..." -ForegroundColor Yellow
try {
rvf query $Appliance --vector "0.1,0.2,0.3" --k 3
} catch {
Write-Host " (install rvf-cli to query, or use the Rust API)"
}
# ── 5. Boot instructions ───────────────────────────────────
Write-Host "[5/5] Boot instructions:" -ForegroundColor Yellow
Write-Host ""
Write-Host " Windows requires WSL2 or Windows QEMU for the kernel launcher." -ForegroundColor DarkYellow
Write-Host ""
Write-Host " # Option A: WSL2 (recommended)"
Write-Host " wsl -d Ubuntu -- rvf launch $Appliance"
Write-Host ""
Write-Host " # Option B: Windows QEMU"
Write-Host " qemu-system-x86_64.exe -M microvm -kernel kernel.bin -append 'console=ttyS0' -nographic"
Write-Host ""
Write-Host " # Option C: Docker (no QEMU needed)"
Write-Host " docker run --rm -v ${Appliance}:/app.rvf -p 2222:22 -p 8080:8080 rvf-boot /app.rvf"
Write-Host ""
Write-Host " # Connect:"
Write-Host " ssh -p 2222 deploy@localhost"
Write-Host " Invoke-RestMethod -Uri http://localhost:8080/query -Method Post -Body '{`"vector`":[0.1,...],`"k`":5}'"
Write-Host ""
Write-Host "=== Claude Code Appliance ready ===" -ForegroundColor Green
$Size = [math]::Round((Get-Item $Appliance).Length / 1MB, 1)
Write-Host " File: $Appliance"
Write-Host " Size: ${Size} MB"
Write-Host " 5.1 MB single .rvf — boots Linux, serves queries, runs Claude Code."

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# rvf-claude-appliance.sh — Build & boot the Claude Code Appliance (Linux/macOS)
# Prerequisites: Docker, Rust 1.87+, QEMU (optional, for booting)
# Usage: bash scripts/rvf-claude-appliance.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
echo "=== Claude Code Appliance Builder (Linux/macOS) ==="
# ── 1. Check prerequisites ──────────────────────────────────
echo "[1/5] Checking prerequisites..."
command -v cargo >/dev/null 2>&1 || { echo "ERROR: Rust/cargo not found. Install from https://rustup.rs"; exit 1; }
command -v docker >/dev/null 2>&1 || { echo "ERROR: Docker not found. Install from https://docker.com"; exit 1; }
echo " cargo: $(cargo --version)"
echo " docker: $(docker --version)"
# ── 2. Build the appliance ──────────────────────────────────
echo "[2/5] Building Claude Code Appliance (this builds a real Linux kernel)..."
cd "$SCRIPT_DIR"
cargo run --example claude_code_appliance
echo " Built: output/claude_code_appliance.rvf"
# ── 3. Inspect the result ───────────────────────────────────
echo "[3/5] Inspecting appliance segments..."
APPLIANCE="output/claude_code_appliance.rvf"
ls -lh "$APPLIANCE"
rvf inspect "$APPLIANCE" 2>/dev/null || echo " (install rvf-cli for detailed inspection)"
echo ""
# ── 4. Query the embedded vector store ──────────────────────
echo "[4/5] Querying package database..."
rvf query "$APPLIANCE" --vector "0.1,0.2,0.3" --k 3 2>/dev/null || \
echo " (install rvf-cli to query, or use the Rust API)"
# ── 5. Boot (optional) ─────────────────────────────────────
echo "[5/5] Boot instructions:"
echo ""
echo " # Option A: RVF launcher (auto-detects KVM or TCG)"
echo " rvf launch $APPLIANCE"
echo ""
echo " # Option B: Manual QEMU"
echo " rvf launch $APPLIANCE --memory 512M --cpus 2 --port-forward 2222:22,8080:8080"
echo ""
echo " # Connect:"
echo " ssh -p 2222 deploy@localhost"
echo " curl -s localhost:8080/query -d '{\"vector\":[0.1,...], \"k\":5}'"
echo ""
if command -v qemu-system-x86_64 >/dev/null 2>&1; then
read -rp "QEMU detected. Boot the appliance now? [y/N] " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "Booting..."
rvf launch "$APPLIANCE" 2>/dev/null || \
echo "Install rvf-cli to use the launcher, or extract kernel manually."
fi
fi
echo ""
echo "=== Claude Code Appliance ready ==="
echo " File: $APPLIANCE"
echo " Size: $(du -h "$APPLIANCE" | cut -f1)"
echo " 5.1 MB single .rvf — boots Linux, serves queries, runs Claude Code."

View File

@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# rvf-docker.sh — Run RVF in Docker (any platform)
# Usage: bash scripts/rvf-docker.sh
set -euo pipefail
echo "=== RVF Docker Quick Start ==="
# ── 1. Build the Docker image ───────────────────────────────
echo "[1/4] Building RVF Docker image..."
cat > /tmp/Dockerfile.rvf <<'DOCKERFILE'
FROM rust:1.87-bookworm AS builder
WORKDIR /app
COPY . .
RUN cd crates/rvf && cargo build -p rvf-cli --release
RUN cp target/release/rvf /usr/local/bin/rvf
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/bin/rvf /usr/local/bin/rvf
WORKDIR /data
ENTRYPOINT ["rvf"]
DOCKERFILE
REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
docker build -f /tmp/Dockerfile.rvf -t rvf:latest "$REPO_ROOT"
echo " Built: rvf:latest"
# ── 2. Create and populate a store ──────────────────────────
echo "[2/4] Creating and populating vector store..."
docker run --rm -v "$(pwd)/output:/data" rvf:latest create demo.rvf --dimension 128
echo " Created output/demo.rvf"
# ── 3. Ingest sample data ──────────────────────────────────
echo "[3/4] Ingesting sample vectors..."
cat > /tmp/rvf_sample.json <<'JSON'
[
{"id": 1, "vector": [0.1, 0.2, 0.3]},
{"id": 2, "vector": [0.4, 0.5, 0.6]},
{"id": 3, "vector": [0.7, 0.8, 0.9]}
]
JSON
docker run --rm \
-v "$(pwd)/output:/data" \
-v "/tmp/rvf_sample.json:/input.json:ro" \
rvf:latest ingest demo.rvf --input /input.json --format json
echo " Ingested 3 vectors"
# ── 4. Query and inspect ───────────────────────────────────
echo "[4/4] Querying and inspecting..."
docker run --rm -v "$(pwd)/output:/data" rvf:latest query demo.rvf --vector "0.1,0.2,0.3" --k 2
docker run --rm -v "$(pwd)/output:/data" rvf:latest inspect demo.rvf
echo ""
echo "=== Done ==="
echo " Docker image: rvf:latest"
echo " Store: output/demo.rvf"
echo " Run any rvf command: docker run --rm -v \$(pwd)/output:/data rvf:latest <command>"

View File

@@ -0,0 +1,43 @@
# rvf-mcp-server.ps1 — Start the RVF MCP server for AI agents (Windows)
# Usage: .\scripts\rvf-mcp-server.ps1 [-Transport stdio|sse] [-Port 3100]
param(
[ValidateSet("stdio", "sse")]
[string]$Transport = "stdio",
[int]$Port = 3100
)
$ErrorActionPreference = "Stop"
Write-Host "=== RVF MCP Server for AI Agents ===" -ForegroundColor Cyan
# ── 1. Check Node.js ────────────────────────────────────────
Write-Host "[1/3] Checking Node.js..." -ForegroundColor Yellow
try { $null = Get-Command npx -ErrorAction Stop }
catch { Write-Error "Node.js not found. Install from https://nodejs.org"; exit 1 }
# ── 2. Start server ─────────────────────────────────────────
Write-Host "[2/3] Starting MCP server (transport: $Transport)..." -ForegroundColor Yellow
Write-Host ""
switch ($Transport) {
"stdio" {
Write-Host " For Claude Code, add to your MCP config:" -ForegroundColor DarkYellow
Write-Host ' {'
Write-Host ' "mcpServers": {'
Write-Host ' "rvf": {'
Write-Host ' "command": "npx",'
Write-Host ' "args": ["@ruvector/rvf-mcp-server", "--transport", "stdio"]'
Write-Host ' }'
Write-Host ' }'
Write-Host ' }'
Write-Host ""
Write-Host " Starting stdio server..." -ForegroundColor Green
npx @ruvector/rvf-mcp-server --transport stdio
}
"sse" {
Write-Host " SSE server on http://localhost:$Port" -ForegroundColor Green
Write-Host " Connect any MCP client to this URL."
Write-Host ""
npx @ruvector/rvf-mcp-server --transport sse --port $Port
}
}

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# rvf-mcp-server.sh — Start the RVF MCP server for AI agents (Linux/macOS)
# Usage: bash scripts/rvf-mcp-server.sh
set -euo pipefail
echo "=== RVF MCP Server for AI Agents ==="
# ── 1. Install ──────────────────────────────────────────────
echo "[1/3] Checking @ruvector/rvf-mcp-server..."
if ! command -v npx >/dev/null 2>&1; then
echo "ERROR: Node.js not found. Install from https://nodejs.org"
exit 1
fi
# ── 2. Choose transport ─────────────────────────────────────
TRANSPORT="${1:-stdio}"
echo "[2/3] Starting MCP server (transport: $TRANSPORT)..."
echo ""
case "$TRANSPORT" in
stdio)
echo " For Claude Code, add to your MCP config:"
echo ' {'
echo ' "mcpServers": {'
echo ' "rvf": {'
echo ' "command": "npx",'
echo ' "args": ["@ruvector/rvf-mcp-server", "--transport", "stdio"]'
echo ' }'
echo ' }'
echo ' }'
echo ""
echo " Or run directly:"
npx @ruvector/rvf-mcp-server --transport stdio
;;
sse)
PORT="${2:-3100}"
echo " SSE server on http://localhost:$PORT"
echo " Connect any MCP client to this URL."
echo ""
npx @ruvector/rvf-mcp-server --transport sse --port "$PORT"
;;
*)
echo "Usage: $0 [stdio|sse] [port]"
echo " stdio — for Claude Code, Cursor, and local AI tools"
echo " sse — for remote AI agents over HTTP"
exit 1
;;
esac

View File

@@ -0,0 +1,76 @@
#!/usr/bin/env node
// rvf-node-example.mjs — Node.js RVF quick start
// Usage: node scripts/rvf-node-example.mjs
// Prerequisites: npm install @ruvector/rvf-node
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
let RvfDatabase;
try {
({ RvfDatabase } = require('@ruvector/rvf-node'));
} catch {
console.error('Install first: npm install @ruvector/rvf-node');
process.exit(1);
}
const path = '/tmp/rvf_node_demo.rvf';
console.log('=== RVF Node.js Quick Start ===\n');
// 1. Create store
console.log('[1/6] Creating vector store...');
const db = RvfDatabase.create(path, {
dimension: 128,
metric: 'cosine',
m: 16,
efConstruction: 200,
});
console.log(` Created: ${path} (128-dim, cosine)`);
// 2. Ingest vectors
console.log('[2/6] Ingesting vectors...');
const count = 100;
const vectors = new Float32Array(count * 128);
const ids = [];
for (let i = 0; i < count; i++) {
for (let d = 0; d < 128; d++) {
vectors[i * 128 + d] = Math.sin(i * 0.1 + d * 0.01);
}
ids.push(i + 1);
}
const result = db.ingestBatch(vectors, ids);
console.log(` Ingested: ${result.accepted} vectors, epoch ${result.epoch}`);
// 3. Query nearest neighbors
console.log('[3/6] Querying nearest neighbors...');
const query = new Float32Array(128);
query.fill(0.1);
const matches = db.query(query, 5, { efSearch: 200 });
console.log(' Top-5 results:');
for (const m of matches) {
console.log(` id=${m.id}, distance=${m.distance.toFixed(4)}`);
}
// 4. Filtered query
console.log('[4/6] Querying with metadata filter...');
const filtered = db.query(query, 3, {
filter: JSON.stringify({ op: 'gt', fieldId: 0, valueType: 'u64', value: '50' }),
});
console.log(` Filtered results: ${filtered.length} matches`);
// 5. Lineage
console.log('[5/6] Checking lineage...');
console.log(` fileId: ${db.fileId()}`);
console.log(` parentId: ${db.parentId()}`);
console.log(` lineageDepth: ${db.lineageDepth()}`);
// 6. Status
console.log('[6/6] Store status...');
const status = db.status();
console.log(` vectors: ${status.totalVectors}`);
console.log(` segments: ${status.totalSegments}`);
console.log(` file size: ${status.fileSize} bytes`);
db.close();
console.log('\n=== Done ===');

View File

@@ -0,0 +1,53 @@
# rvf-quickstart.ps1 — Windows PowerShell RVF quick start
# Usage: .\scripts\rvf-quickstart.ps1
$ErrorActionPreference = "Stop"
Write-Host "=== RVF Quick Start (Windows PowerShell) ===" -ForegroundColor Cyan
# ── 1. Install ──────────────────────────────────────────────
Write-Host "[1/7] Installing RVF CLI and runtime..." -ForegroundColor Yellow
cargo install rvf-cli 2>$null
Write-Host " rvf installed via cargo"
# ── 2. Create a vector store ────────────────────────────────
Write-Host "[2/7] Creating vector store..." -ForegroundColor Yellow
rvf create demo.rvf --dimension 128
Write-Host " Created demo.rvf (128-dim, L2 metric)"
# ── 3. Ingest vectors from JSON ─────────────────────────────
Write-Host "[3/7] Ingesting vectors..." -ForegroundColor Yellow
$vectors = @'
[
{"id": 1, "vector": [0.1, 0.2, 0.3], "metadata": {"label": "alpha"}},
{"id": 2, "vector": [0.4, 0.5, 0.6], "metadata": {"label": "beta"}},
{"id": 3, "vector": [0.7, 0.8, 0.9], "metadata": {"label": "gamma"}}
]
'@
$vectors | Out-File -Encoding utf8 "$env:TEMP\rvf_vectors.json"
rvf ingest demo.rvf --input "$env:TEMP\rvf_vectors.json" --format json
Write-Host " Ingested 3 vectors"
# ── 4. Query nearest neighbors ──────────────────────────────
Write-Host "[4/7] Querying nearest neighbors..." -ForegroundColor Yellow
rvf query demo.rvf --vector "0.1,0.2,0.3" --k 2
Write-Host " Top-2 results returned"
# ── 5. Inspect segments ─────────────────────────────────────
Write-Host "[5/7] Inspecting file segments..." -ForegroundColor Yellow
rvf inspect demo.rvf
# ── 6. Derive a child (COW branch) ──────────────────────────
Write-Host "[6/7] Creating COW branch..." -ForegroundColor Yellow
rvf derive demo.rvf child.rvf --type filter
Write-Host " child.rvf inherits parent data, only stores changes"
# ── 7. Verify witness chain ─────────────────────────────────
Write-Host "[7/7] Verifying tamper-evident witness chain..." -ForegroundColor Yellow
rvf verify-witness demo.rvf
Write-Host " Witness chain verified — no tampering detected"
Write-Host ""
Write-Host "=== Done ===" -ForegroundColor Green
Write-Host "Files created: demo.rvf, child.rvf"
Write-Host "Next: embed a kernel with 'rvf embed-kernel demo.rvf --arch x86_64'"
Write-Host "Note: Self-booting requires WSL or Windows QEMU for the kernel launcher."

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# rvf-quickstart.sh — Linux / macOS RVF quick start
# Usage: bash scripts/rvf-quickstart.sh
set -euo pipefail
echo "=== RVF Quick Start (Linux/macOS) ==="
# ── 1. Install ──────────────────────────────────────────────
echo "[1/7] Installing RVF CLI and runtime..."
cargo install rvf-cli 2>/dev/null || echo " (already installed)"
echo " rvf version: $(rvf --version 2>/dev/null || echo 'build from source below')"
# ── 2. Create a vector store ────────────────────────────────
echo "[2/7] Creating vector store..."
rvf create demo.rvf --dimension 128
echo " Created demo.rvf (128-dim, L2 metric)"
# ── 3. Ingest vectors from JSON ─────────────────────────────
echo "[3/7] Ingesting vectors..."
cat > /tmp/rvf_vectors.json <<'VECTORS'
[
{"id": 1, "vector": [0.1, 0.2, 0.3], "metadata": {"label": "alpha"}},
{"id": 2, "vector": [0.4, 0.5, 0.6], "metadata": {"label": "beta"}},
{"id": 3, "vector": [0.7, 0.8, 0.9], "metadata": {"label": "gamma"}}
]
VECTORS
rvf ingest demo.rvf --input /tmp/rvf_vectors.json --format json
echo " Ingested 3 vectors"
# ── 4. Query nearest neighbors ──────────────────────────────
echo "[4/7] Querying nearest neighbors..."
rvf query demo.rvf --vector "0.1,0.2,0.3" --k 2
echo " Top-2 results returned"
# ── 5. Inspect segments ─────────────────────────────────────
echo "[5/7] Inspecting file segments..."
rvf inspect demo.rvf
# ── 6. Derive a child (COW branch) ──────────────────────────
echo "[6/7] Creating COW branch..."
rvf derive demo.rvf child.rvf --type filter
echo " child.rvf inherits parent data, only stores changes"
# ── 7. Verify witness chain ─────────────────────────────────
echo "[7/7] Verifying tamper-evident witness chain..."
rvf verify-witness demo.rvf
echo " Witness chain verified — no tampering detected"
echo ""
echo "=== Done ==="
echo "Files created: demo.rvf, child.rvf"
echo "Next: embed a kernel with 'rvf embed-kernel demo.rvf --arch x86_64'"