mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-29 11:13:33 +00:00
feat: add feature flags and scaffolding for WASM cognitive stack
Add canonical, spectral, cold-tier, and canonical-witness feature flags across ruvector-mincut, ruvector-coherence, ruvector-gnn, and cognitum-gate-kernel. Create ruvector-cognitive-container crate skeleton. Implementation agents are building the full modules in parallel. https://claude.ai/code/session_018QKTLyCUrMUQCRDqoiyEHY
This commit is contained in:
parent
3a94a0c2a1
commit
ecaa425bd2
7 changed files with 107 additions and 1 deletions
|
|
@ -35,6 +35,7 @@ harness = false
|
|||
[features]
|
||||
default = ["std"]
|
||||
std = ["ruvector-mincut"]
|
||||
canonical-witness = [] # Canonical pseudo-deterministic witness fragments
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z" # Optimize for size
|
||||
|
|
|
|||
25
crates/ruvector-cognitive-container/Cargo.toml
Normal file
25
crates/ruvector-cognitive-container/Cargo.toml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[package]
|
||||
name = "ruvector-cognitive-container"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Verifiable WASM cognitive container with canonical witness chains"
|
||||
keywords = ["wasm", "cognitive", "container", "witness-chain", "deterministic"]
|
||||
categories = ["algorithms", "wasm", "cryptography"]
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib"]
|
||||
64
crates/ruvector-cognitive-container/src/error.rs
Normal file
64
crates/ruvector-cognitive-container/src/error.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ContainerError {
|
||||
#[error("Memory allocation failed: requested {requested} bytes, available {available}")]
|
||||
AllocationFailed { requested: usize, available: usize },
|
||||
|
||||
#[error("Epoch budget exhausted: used {used} of {budget} ticks")]
|
||||
EpochExhausted { used: u64, budget: u64 },
|
||||
|
||||
#[error("Witness chain broken at epoch {epoch}")]
|
||||
BrokenChain { epoch: u64 },
|
||||
|
||||
#[error("Invalid configuration: {reason}")]
|
||||
InvalidConfig { reason: String },
|
||||
|
||||
#[error("Container not initialized")]
|
||||
NotInitialized,
|
||||
|
||||
#[error("Slab overflow: component {component} exceeded budget")]
|
||||
SlabOverflow { component: String },
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, ContainerError>;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_error_display() {
|
||||
let err = ContainerError::AllocationFailed {
|
||||
requested: 1024,
|
||||
available: 512,
|
||||
};
|
||||
assert!(err.to_string().contains("1024"));
|
||||
assert!(err.to_string().contains("512"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_variants() {
|
||||
let err = ContainerError::EpochExhausted {
|
||||
used: 100,
|
||||
budget: 50,
|
||||
};
|
||||
assert!(err.to_string().contains("100"));
|
||||
|
||||
let err = ContainerError::BrokenChain { epoch: 42 };
|
||||
assert!(err.to_string().contains("42"));
|
||||
|
||||
let err = ContainerError::InvalidConfig {
|
||||
reason: "bad value".to_string(),
|
||||
};
|
||||
assert!(err.to_string().contains("bad value"));
|
||||
|
||||
let err = ContainerError::NotInitialized;
|
||||
assert!(err.to_string().contains("not initialized"));
|
||||
|
||||
let err = ContainerError::SlabOverflow {
|
||||
component: "graph".to_string(),
|
||||
};
|
||||
assert!(err.to_string().contains("graph"));
|
||||
}
|
||||
}
|
||||
|
|
@ -11,3 +11,7 @@ description = "Coherence measurement proxies for comparing attention mechanisms"
|
|||
[dependencies]
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
spectral = [] # Spectral coherence scoring for graph index health
|
||||
|
|
|
|||
|
|
@ -9,9 +9,19 @@ pub mod comparison;
|
|||
pub mod metrics;
|
||||
pub mod quality;
|
||||
|
||||
#[cfg(feature = "spectral")]
|
||||
pub mod spectral;
|
||||
|
||||
pub use batch::{evaluate_batch, BatchResult};
|
||||
pub use comparison::{
|
||||
compare_attention_masks, edge_flip_count, jaccard_similarity, ComparisonResult,
|
||||
};
|
||||
pub use metrics::{contradiction_rate, delta_behavior, entailment_consistency, DeltaMetric};
|
||||
pub use quality::{cosine_similarity, l2_distance, quality_check, QualityResult};
|
||||
|
||||
#[cfg(feature = "spectral")]
|
||||
pub use spectral::{
|
||||
compute_degree_regularity, estimate_effective_resistance_sampled, estimate_fiedler,
|
||||
estimate_largest_eigenvalue, estimate_spectral_gap, CsrMatrixView, HealthAlert,
|
||||
HnswHealthMonitor, SpectralCoherenceScore, SpectralConfig, SpectralTracker,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ simd = []
|
|||
wasm = []
|
||||
napi = ["dep:napi", "dep:napi-derive"]
|
||||
mmap = ["dep:memmap2", "dep:page_size"]
|
||||
cold-tier = ["mmap"] # Hyperbatch training for graphs exceeding RAM
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ mockall = { workspace = true }
|
|||
|
||||
[features]
|
||||
default = ["exact", "approximate"]
|
||||
full = ["exact", "approximate", "integration", "monitoring", "simd", "agentic", "jtree", "tiered"]
|
||||
full = ["exact", "approximate", "integration", "monitoring", "simd", "agentic", "jtree", "tiered", "canonical"]
|
||||
exact = [] # Exact minimum cut algorithm
|
||||
approximate = [] # (1+ε)-approximate algorithm
|
||||
integration = ["ruvector-graph"] # GraphDB integration
|
||||
|
|
@ -52,6 +52,7 @@ wasm = [] # WASM compatibility mode
|
|||
agentic = [] # 256-core parallel agentic chip backend
|
||||
jtree = [] # j-Tree hierarchical decomposition (ADR-002)
|
||||
tiered = ["jtree", "exact"] # Two-tier coordinator (j-tree + exact)
|
||||
canonical = [] # Pseudo-deterministic canonical min-cut via cactus representation
|
||||
all-cut-queries = ["jtree"] # Sparsest cut, multiway, multicut queries
|
||||
|
||||
[lib]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue