photonlayer_ruvector/lib.rs
1//! # photonlayer-ruvector
2//!
3//! Experiment memory and verification substrate for PhotonLayer optical
4//! simulations (ADR-260 §5, §11–§15).
5//!
6//! RuVector serves as the *experiment memory* layer — not a generic data
7//! store. Concretely, this crate provides:
8//!
9//! * **Embeddings** ([`embedding`]) — 32-dim L2-normalised experiment vectors
10//! built from mask phase-histograms and detector frame spectra.
11//! * **Memory** ([`memory`]) — in-memory store with cosine-similarity
12//! nearest-experiment recall.
13//! * **Boundary analysis** ([`boundary`]) — Fiedler spectral partitioning
14//! that identifies which `OpticalConfig` variable best separates pass/fail
15//! experiment outcomes.
16//! * **Coherence** ([`coherence`]) — spectral gap of the mask family similarity
17//! graph; families above the threshold qualify for demo promotion.
18//! * **Receipts** ([`receipts`]) — JSON persistence and binding-digest
19//! verification of RVF-style experiment receipts.
20//!
21//! ## Quick Start
22//! ```no_run
23//! use photonlayer_core::prelude::*;
24//! use photonlayer_ruvector::{
25//! embedding::experiment_embedding,
26//! memory::{ExperimentMemory, ExperimentRecord},
27//! receipts::ReceiptStore,
28//! };
29//!
30//! let n = 16;
31//! let pixels: Vec<f32> = (0..n * n).map(|i| (i % n) as f32 / n as f32).collect();
32//! let img = InputImage::from_norm_f32(n, n, pixels).unwrap();
33//! let mask = PhaseMask::random(n, n, 42);
34//! let cfg = OpticalConfig::demo(n, n);
35//! let frame = ScalarSimulator.simulate(&img, &mask, &cfg).unwrap();
36//! let metrics = MetricReport::default();
37//! let receipt = build_receipt("e1", &img, &mask, &cfg, &frame, &metrics, &Provenance::default());
38//!
39//! let embedding = experiment_embedding(&mask, &frame);
40//!
41//! let mut mem = ExperimentMemory::new();
42//! // ... store and recall experiments ...
43//!
44//! let mut store = ReceiptStore::new();
45//! store.insert(&receipt).unwrap();
46//! assert!(store.verify("e1"));
47//! ```
48
49pub mod boundary;
50pub mod coherence;
51pub mod embedding;
52pub mod memory;
53pub mod receipts;
54
55// Convenience re-exports for the most common types.
56pub use boundary::{explain_boundary, BoundaryReport};
57pub use coherence::{mask_family_coherence, FamilyCoherence};
58pub use embedding::{experiment_embedding, mask_embedding};
59pub use memory::{ExperimentMemory, ExperimentRecord, MaskSearchHit, NearestHit};
60pub use receipts::ReceiptStore;
61
62/// Crate version, driven from `Cargo.toml`.
63pub fn version() -> &'static str {
64 env!("CARGO_PKG_VERSION")
65}