ruvector_sona/lib.rs
1//! SONA (Self-Optimizing Neural Architecture)
2//!
3//! A lightweight adaptive learning system with ReasoningBank integration.
4//!
5//! ## Features
6//!
7//! - **Micro-LoRA**: Ultra-low rank (1-2) LoRA for instant learning
8//! - **Base-LoRA**: Standard LoRA for background learning
9//! - **EWC++**: Elastic Weight Consolidation to prevent catastrophic forgetting
10//! - **ReasoningBank**: Pattern extraction and similarity search
11//! - **Three Learning Loops**: Instant, Background, and Coordination loops
12//! - **WASM Support**: Run in browsers and edge devices (enable `wasm` feature)
13//!
14//! ## Example
15//!
16//! ```rust,ignore
17//! use sona::{SonaEngine, SonaConfig};
18//!
19//! // Create engine
20//! let engine = SonaEngine::new(SonaConfig {
21//! hidden_dim: 256,
22//! embedding_dim: 256,
23//! ..Default::default()
24//! });
25//!
26//! // Begin trajectory
27//! let mut builder = engine.begin_trajectory(vec![0.1; 256]);
28//! builder.add_step(vec![0.5; 256], vec![], 0.8);
29//!
30//! // End trajectory
31//! engine.end_trajectory(builder, 0.85);
32//!
33//! // Apply learned transformations
34//! let input = vec![1.0; 256];
35//! let mut output = vec![0.0; 256];
36//! engine.apply_micro_lora(&input, &mut output);
37//! ```
38//!
39//! ## WASM Usage
40//!
41//! Enable the `wasm` feature and build with:
42//! ```bash
43//! wasm-pack build --target web --features wasm
44//! ```
45
46#![warn(missing_docs)]
47
48pub mod types;
49pub mod lora;
50pub mod trajectory;
51pub mod ewc;
52pub mod reasoning_bank;
53pub mod loops;
54pub mod engine;
55
56#[cfg(feature = "serde-support")]
57pub mod export;
58
59#[cfg(feature = "wasm")]
60pub mod wasm;
61
62#[cfg(feature = "napi")]
63pub mod napi_simple;
64
65// Re-export main types
66pub use types::{
67 LearningSignal, QueryTrajectory, TrajectoryStep,
68 LearnedPattern, PatternType, SignalMetadata, SonaConfig,
69};
70pub use lora::{MicroLoRA, BaseLoRA, LoRAEngine, LoRALayer};
71pub use trajectory::{TrajectoryBuffer, TrajectoryBuilder, TrajectoryIdGen};
72pub use ewc::{EwcConfig, EwcPlusPlus, TaskFisher};
73pub use reasoning_bank::{ReasoningBank, PatternConfig};
74pub use loops::{InstantLoop, BackgroundLoop, LoopCoordinator};
75pub use engine::SonaEngine;
76
77#[cfg(feature = "serde-support")]
78pub use export::{
79 HuggingFaceExporter, ExportConfig, ExportResult, ExportError, ExportType,
80 SafeTensorsExporter, DatasetExporter, HuggingFaceHub,
81 PretrainConfig, PretrainPipeline,
82};
83
84#[cfg(feature = "wasm")]
85pub use wasm::WasmSonaEngine;