rvcsi_ruvector/lib.rs
1//! # rvCSI RuVector bridge
2//!
3//! Exports temporal RF embeddings + event metadata as a queryable RF-memory
4//! store (ADR-095 FR8, D8).
5//!
6//! This crate is a **standin** for the production RuVector vector-database
7//! binding (which gets wired in later). It provides:
8//!
9//! * deterministic, dependency-free embedding functions —
10//! [`window_embedding`] / [`event_embedding`] / [`cosine_similarity`];
11//! * the [`RfMemoryStore`] trait plus value objects ([`EmbeddingId`],
12//! [`RecordKind`], [`SimilarHit`], [`DriftReport`]);
13//! * two implementations: the in-process [`InMemoryRfMemory`] and the
14//! file-backed [`JsonlRfMemory`] (JSONL append log, identical query semantics).
15//!
16//! Everything here is pure and deterministic given the same sequence of
17//! operations — no clocks, randomness, or order-dependent reductions — so
18//! captures replayed twice yield byte-identical stores and query results.
19//!
20//! ```
21//! use rvcsi_ruvector::{InMemoryRfMemory, RfMemoryStore, window_embedding};
22//! use rvcsi_core::{CsiWindow, SessionId, SourceId, WindowId};
23//!
24//! let w = CsiWindow {
25//! window_id: WindowId(0),
26//! session_id: SessionId(1),
27//! source_id: SourceId::from("esp32"),
28//! start_ns: 1_000,
29//! end_ns: 2_000,
30//! frame_count: 10,
31//! mean_amplitude: vec![1.0, 2.0, 3.0],
32//! phase_variance: vec![0.1, 0.2, 0.1],
33//! motion_energy: 0.3,
34//! presence_score: 0.7,
35//! quality_score: 0.9,
36//! };
37//! let mut mem = InMemoryRfMemory::new();
38//! let id = mem.store_window(&w).unwrap();
39//! let hits = mem.query_similar(&window_embedding(&w), 1).unwrap();
40//! assert_eq!(hits[0].id, id);
41//! assert!((hits[0].score - 1.0).abs() < 1e-5);
42//! ```
43
44#![forbid(unsafe_code)]
45#![warn(missing_docs)]
46
47mod embedding;
48mod jsonl;
49mod memory;
50mod store;
51
52pub use embedding::{
53 cosine_similarity, event_embedding, window_embedding, EVENT_EMBEDDING_DIM,
54 WINDOW_EMBEDDING_DIM,
55};
56pub use jsonl::JsonlRfMemory;
57pub use memory::InMemoryRfMemory;
58pub use store::{DriftReport, EmbeddingId, RecordKind, RfMemoryStore, SimilarHit};