@ruvector/rvf 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -337,6 +337,198 @@ const results = await db.search([0.1, 0.2, ...], 5);
|
|
|
337
337
|
| `rvf-cli` | CLI binary |
|
|
338
338
|
| `rvf-import` | Import from external formats |
|
|
339
339
|
|
|
340
|
+
## Real-World Examples
|
|
341
|
+
|
|
342
|
+
### Self-Booting Microservice (Rust)
|
|
343
|
+
|
|
344
|
+
Create a single `.rvf` file that contains 50 vectors AND a bootable kernel — drop it on a VM and it boots:
|
|
345
|
+
|
|
346
|
+
```rust
|
|
347
|
+
use rvf_runtime::{RvfStore, RvfOptions, QueryOptions};
|
|
348
|
+
use rvf_runtime::options::DistanceMetric;
|
|
349
|
+
use rvf_types::kernel::{KernelArch, KernelType};
|
|
350
|
+
|
|
351
|
+
// 1. Create store with vectors
|
|
352
|
+
let mut store = RvfStore::create("bootable.rvf", RvfOptions {
|
|
353
|
+
dimension: 128, metric: DistanceMetric::L2, ..Default::default()
|
|
354
|
+
})?;
|
|
355
|
+
store.ingest_batch(&vectors, &ids, None)?;
|
|
356
|
+
|
|
357
|
+
// 2. Embed a kernel — file now boots as a microservice
|
|
358
|
+
store.embed_kernel(
|
|
359
|
+
KernelArch::X86_64 as u8,
|
|
360
|
+
KernelType::Hermit as u8,
|
|
361
|
+
0x0018, // HAS_QUERY_API | HAS_NETWORKING
|
|
362
|
+
&kernel_image,
|
|
363
|
+
8080,
|
|
364
|
+
Some("console=ttyS0 quiet"),
|
|
365
|
+
)?;
|
|
366
|
+
|
|
367
|
+
// 3. Verify everything is in one file
|
|
368
|
+
let (header, image) = store.extract_kernel()?.unwrap();
|
|
369
|
+
println!("Kernel: {} bytes, vectors: {}", image.len(), store.query(&q, 5, &QueryOptions::default())?.len());
|
|
370
|
+
store.close()?;
|
|
371
|
+
// Result: 31 KB file with vectors + kernel + witness chain
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Run: `cd examples/rvf && cargo run --example self_booting`
|
|
375
|
+
|
|
376
|
+
### Linux Microkernel Distribution
|
|
377
|
+
|
|
378
|
+
A single `.rvf` file as an immutable, bootable Linux distribution:
|
|
379
|
+
|
|
380
|
+
```rust
|
|
381
|
+
use rvf_runtime::{RvfStore, RvfOptions, MetadataEntry, MetadataValue, FilterExpr, QueryOptions};
|
|
382
|
+
use rvf_crypto::{create_witness_chain, sign_segment, verify_segment, shake256_256, WitnessEntry};
|
|
383
|
+
use ed25519_dalek::SigningKey;
|
|
384
|
+
|
|
385
|
+
// 1. Create system image with 20 packages as vector embeddings
|
|
386
|
+
let mut store = RvfStore::create("microkernel.rvf", options)?;
|
|
387
|
+
for pkg in packages {
|
|
388
|
+
store.ingest_batch(&[&pkg.embedding], &[pkg.id], Some(&[MetadataEntry {
|
|
389
|
+
key: "package".into(),
|
|
390
|
+
value: MetadataValue::String(format!("{}@{}", pkg.name, pkg.version)),
|
|
391
|
+
}]))?;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// 2. Embed kernel + SSH keys
|
|
395
|
+
store.embed_kernel(KernelArch::X86_64 as u8, KernelType::Linux as u8, 0x001F, &kernel, 8080, None)?;
|
|
396
|
+
|
|
397
|
+
// 3. Sign with Ed25519 — prevents unauthorized modifications
|
|
398
|
+
let signature = sign_segment(&segment_bytes, &signing_key);
|
|
399
|
+
verify_segment(&segment_bytes, &signature, &verifying_key)?;
|
|
400
|
+
|
|
401
|
+
// 4. Witness chain — every package install is audited
|
|
402
|
+
let chain = create_witness_chain(&witness_entries);
|
|
403
|
+
// Result: 14 KB file = bootable OS + packages + SSH + crypto + witness
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Run: `cd examples/rvf && cargo run --example linux_microkernel`
|
|
407
|
+
|
|
408
|
+
### Claude Code Appliance
|
|
409
|
+
|
|
410
|
+
Build an AI development environment as a single sealed file:
|
|
411
|
+
|
|
412
|
+
```rust
|
|
413
|
+
// Creates a .rvf file containing:
|
|
414
|
+
// - 20 development packages (rust, node, python, etc.)
|
|
415
|
+
// - Real Linux kernel with SSH on port 2222
|
|
416
|
+
// - eBPF XDP program for fast-path vector lookups
|
|
417
|
+
// - Vector store with development context embeddings
|
|
418
|
+
// - 6-entry witness chain for audit
|
|
419
|
+
// - Ed25519 + ML-DSA-65 signatures
|
|
420
|
+
let store = RvfStore::create("claude_code_appliance.rvf", options)?;
|
|
421
|
+
// ... embed packages, kernel, eBPF, witness chain, signatures ...
|
|
422
|
+
// Result: 17 KB sealed cognitive container
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Run: `cd examples/rvf && cargo run --example claude_code_appliance`
|
|
426
|
+
|
|
427
|
+
### CLI Proof-of-Operations
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Full lifecycle in one session:
|
|
431
|
+
|
|
432
|
+
# Create a vector store
|
|
433
|
+
rvf create demo.rvf --dimension 128
|
|
434
|
+
|
|
435
|
+
# Ingest 100 vectors from JSON
|
|
436
|
+
rvf ingest demo.rvf --input data.json --format json
|
|
437
|
+
|
|
438
|
+
# Query nearest neighbors
|
|
439
|
+
rvf query demo.rvf --vector "0.1,0.2,0.3,..." --k 5
|
|
440
|
+
|
|
441
|
+
# Derive a COW child (only stores differences)
|
|
442
|
+
rvf derive demo.rvf child.rvf --type filter
|
|
443
|
+
|
|
444
|
+
# Inspect all segments
|
|
445
|
+
rvf inspect demo.rvf
|
|
446
|
+
# Output: MANIFEST_SEG (4 KB), VEC_SEG (51 KB), INDEX_SEG (12 KB)
|
|
447
|
+
|
|
448
|
+
# Verify witness chain integrity
|
|
449
|
+
rvf verify-witness demo.rvf
|
|
450
|
+
|
|
451
|
+
# Embed a kernel — file becomes self-booting
|
|
452
|
+
rvf embed-kernel demo.rvf --image bzImage --arch x86_64
|
|
453
|
+
|
|
454
|
+
# Launch in QEMU microVM
|
|
455
|
+
rvf launch demo.rvf --port 8080
|
|
456
|
+
|
|
457
|
+
# Compact and reclaim space
|
|
458
|
+
rvf compact demo.rvf
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### Witness Chain Verification
|
|
462
|
+
|
|
463
|
+
```rust
|
|
464
|
+
use rvf_crypto::{create_witness_chain, verify_witness_chain, shake256_256, WitnessEntry};
|
|
465
|
+
|
|
466
|
+
// Every operation is recorded in a tamper-evident hash chain
|
|
467
|
+
let entries = vec![
|
|
468
|
+
WitnessEntry {
|
|
469
|
+
prev_hash: [0; 32],
|
|
470
|
+
action_hash: shake256_256(b"ingest: 1000 vectors, dim 384"),
|
|
471
|
+
timestamp_ns: 1_700_000_000_000_000_000,
|
|
472
|
+
witness_type: 0x01, // PROVENANCE
|
|
473
|
+
},
|
|
474
|
+
WitnessEntry {
|
|
475
|
+
prev_hash: [0; 32], // linked by create_witness_chain
|
|
476
|
+
action_hash: shake256_256(b"query: top-10, cosine"),
|
|
477
|
+
timestamp_ns: 1_700_000_001_000_000_000,
|
|
478
|
+
witness_type: 0x03, // SEARCH
|
|
479
|
+
},
|
|
480
|
+
WitnessEntry {
|
|
481
|
+
prev_hash: [0; 32],
|
|
482
|
+
action_hash: shake256_256(b"embed: kernel x86_64, 8080"),
|
|
483
|
+
timestamp_ns: 1_700_000_002_000_000_000,
|
|
484
|
+
witness_type: 0x02, // COMPUTATION
|
|
485
|
+
},
|
|
486
|
+
];
|
|
487
|
+
|
|
488
|
+
let chain_bytes = create_witness_chain(&entries);
|
|
489
|
+
let verified = verify_witness_chain(&chain_bytes)?;
|
|
490
|
+
assert_eq!(verified.len(), 3);
|
|
491
|
+
// Changing any byte in any entry breaks the entire chain
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### COW Branching (Git-like for Vectors)
|
|
495
|
+
|
|
496
|
+
```rust
|
|
497
|
+
use rvf_runtime::{RvfStore, RvfOptions};
|
|
498
|
+
use rvf_types::DerivationType;
|
|
499
|
+
|
|
500
|
+
// Parent: 1M vectors (~512 MB)
|
|
501
|
+
let parent = RvfStore::create("parent.rvf", options)?;
|
|
502
|
+
parent.ingest_batch(&million_vectors, &ids, None)?;
|
|
503
|
+
|
|
504
|
+
// Child: shares all parent data, only stores changes
|
|
505
|
+
let child = parent.derive("child.rvf", DerivationType::Filter, None)?;
|
|
506
|
+
assert_eq!(child.lineage_depth(), 1);
|
|
507
|
+
|
|
508
|
+
// Modify 100 vectors → only 10 clusters copied (~2.5 MB, not 512 MB)
|
|
509
|
+
child.ingest_batch(&updated_vectors, &updated_ids, None)?;
|
|
510
|
+
|
|
511
|
+
// Query child — transparent parent resolution
|
|
512
|
+
let results = child.query(&query, 10, &QueryOptions::default())?;
|
|
513
|
+
// Results come from both local (modified) and inherited (parent) clusters
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
### Generate All 45 Example Files
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
cd examples/rvf
|
|
520
|
+
cargo run --example generate_all
|
|
521
|
+
ls output/
|
|
522
|
+
# 45 .rvf files ready to inspect:
|
|
523
|
+
# basic_store.rvf (152 KB) — 1,000 vectors
|
|
524
|
+
# self_booting.rvf (31 KB) — vectors + kernel
|
|
525
|
+
# linux_microkernel.rvf (15 KB) — bootable OS image
|
|
526
|
+
# claude_code_appliance.rvf (17 KB) — AI dev environment
|
|
527
|
+
# sealed_engine.rvf (208 KB) — signed inference engine
|
|
528
|
+
# agent_memory.rvf (32 KB) — AI agent memory
|
|
529
|
+
# ... and 39 more
|
|
530
|
+
```
|
|
531
|
+
|
|
340
532
|
## License
|
|
341
533
|
|
|
342
534
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruvector/rvf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "RuVector Format — unified TypeScript SDK for vector intelligence",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -12,14 +12,24 @@
|
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/",
|
|
17
|
+
"package.json"
|
|
18
|
+
],
|
|
16
19
|
"scripts": {
|
|
17
20
|
"build": "tsc",
|
|
18
21
|
"test": "jest",
|
|
19
22
|
"bench": "tsx bench/index.ts",
|
|
20
23
|
"typecheck": "tsc --noEmit"
|
|
21
24
|
},
|
|
22
|
-
"keywords": [
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vector",
|
|
27
|
+
"database",
|
|
28
|
+
"binary-format",
|
|
29
|
+
"hnsw",
|
|
30
|
+
"simd",
|
|
31
|
+
"rvf"
|
|
32
|
+
],
|
|
23
33
|
"license": "MIT",
|
|
24
34
|
"repository": "https://github.com/ruvnet/ruvector",
|
|
25
35
|
"dependencies": {
|