1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! SONA Learning Integration for RuvLLM
//!
//! This module provides SONA (Self-Optimizing Neural Architecture) integration
//! for the RuvLLM inference runtime, including:
//!
//! - **Core Integration**: Three-tier learning loops (Instant, Background, Deep)
//! - **RuvLTRA Pretraining**: Optimized configurations for RuvLTRA-Small (0.5B)
//!
//! ## Architecture
//!
//! The SONA integration consists of two main components:
//!
//! 1. **SonaIntegration**: Runtime learning during inference
//! 2. **RuvLtraPretrainer**: Pretraining configuration for models
//!
//! ## Learning Loops
//!
//! ```text
//! +-------------------+ +-------------------+
//! | Request |---->| Instant Loop |
//! | (trajectory) | | - Ring buffer |
//! +-------------------+ | - MicroLoRA |
//! | - Edge weights |
//! +--------+----------+
//! |
//! v (async)
//! +--------+----------+
//! | Background Loop |
//! | - Router training |
//! | - EWC++ Fisher |
//! | - BaseLoRA update |
//! +--------+----------+
//! |
//! v (scheduled)
//! +--------+----------+
//! | Deep Loop |
//! | - Pattern bank |
//! | - Memory prune |
//! | - Knowledge xfer |
//! +-------------------+
//! ```
//!
//! ## RuvLTRA-Small Configuration
//!
//! The `ruvltra_pretrain` module provides optimized settings for 0.5B models:
//!
//! | Parameter | Value | Rationale |
//! |-----------|-------|-----------|
//! | hidden_dim | 128 | Smaller projection for efficiency |
//! | embedding_dim | 384 | Match model hidden/2 |
//! | micro_lora_rank | 1 | Minimal overhead (<0.1MB) |
//! | base_lora_rank | 4 | Conservative for small model |
//! | ewc_lambda | 500 | Lower regularization (less to protect) |
//! | quality_threshold | 0.6 | Higher threshold for quality |
//!
//! ## Example
//!
//! ```rust,ignore
//! use ruvllm::sona::{SonaIntegration, SonaConfig, RuvLtraPretrainConfig, RuvLtraPretrainer};
//!
//! // Runtime integration
//! let config = SonaConfig::default();
//! let sona = SonaIntegration::new(config);
//!
//! // Pretraining for RuvLTRA-Small
//! let pretrain_config = RuvLtraPretrainConfig::for_ruvltra_small();
//! let mut pretrainer = RuvLtraPretrainer::new(pretrain_config);
//!
//! // Seed initial patterns
//! let seeding_result = pretrainer.seed_reasoning_bank();
//! println!("Seeded {} patterns", seeding_result.patterns_seeded);
//!
//! // Export for deployment
//! let state = pretrainer.export_state();
//! let sona = state.into_sona_integration();
//! ```
// Core integration module
// Pretraining for RuvLTRA-Small
// Re-export integration types (primary API)
pub use ;
// Re-export pretraining types
pub use ;