1#![warn(missing_docs)]
48#![warn(clippy::all)]
49#![allow(clippy::module_name_repetitions, clippy::must_use_candidate)]
50
51#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
53use wasm_bindgen::prelude::*;
54
55
56#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
58#[wasm_bindgen]
59pub fn init_wasm() {
60 }
62
63#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
64#[wasm_bindgen]
65pub fn get_version() -> String {
66 crate::VERSION.to_string()
67}
68
69#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
70#[wasm_bindgen]
71pub fn create_nano_swarm(agent_count: usize) -> String {
72 format!("Created nano swarm with {} agents", agent_count)
73}
74
75#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
76#[wasm_bindgen]
77pub fn run_swarm_ticks(ticks: u32) -> u32 {
78 ticks * 1000 }
80
81#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
82#[wasm_bindgen]
83pub fn quantum_superposition(qubits: u32) -> String {
84 format!("Created superposition with {} qubits ({} states)", qubits, 2_u32.pow(qubits))
85}
86
87#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
88#[wasm_bindgen]
89pub fn evolve_consciousness(iterations: u32) -> f64 {
90 let base = 0.5;
91 let growth = 0.3 * (iterations as f64 / 1000.0);
92 (base + growth).min(1.0)
93}
94
95pub mod consciousness;
96pub mod error;
97pub mod types;
98pub mod vector3d;
99
100pub mod sublinear_solver;
102
103pub mod nano_agent;
105
106pub mod temporal_lead;
108pub mod strange_attractor;
109
110#[cfg(feature = "quantum")]
112pub mod quantum_container;
113#[cfg(feature = "consciousness")]
114pub mod temporal_consciousness;
115pub mod lipschitz_loop;
119pub mod retrocausal;
120pub mod self_modifying;
121
122pub use error::{LoopError, Result};
124pub use nano_agent::{NanoAgent, NanoScheduler, SchedulerConfig, SchedulerTopology, TickResult};
125pub use sublinear_solver::{SublinearNeumannSolver, SublinearConfig, SublinearNeumannResult, ComplexityBound, JLEmbedding};
126pub use temporal_lead::TemporalLeadPredictor;
127pub use types::{Context, LoopConfig, Policy, ScalarReasoner, SimpleCritic, SafeReflector, StrangeLoop};
128pub use vector3d::Vector3D;
129
130pub const VERSION: &str = env!("CARGO_PKG_VERSION");
132
133pub const BUILD_TIME: &str = "unknown";
135
136pub const GIT_SHA: &str = "unknown";
138
139pub const BUILD_INFO: &str = concat!(
141 "Strange Loop v", env!("CARGO_PKG_VERSION"),
142 " built for framework with thousands of tiny agents"
143);
144
145#[cfg(test)]
146mod tests {
147 use super::*;
148 use std::collections::HashMap;
149
150 #[test]
151 fn test_basic_strange_loop() {
152 let mut context = HashMap::from([("x".to_string(), 10.0)]);
153 let reasoner = ScalarReasoner::new(0.0, 0.1);
154 let critic = SimpleCritic::new();
155 let reflector = SafeReflector::new();
156
157 let config = LoopConfig {
158 max_iterations: 100,
159 max_duration_ns: 1_000_000, convergence_threshold: 1e-6,
161 lipschitz_constant: 0.8,
162 enable_consciousness: false,
163 enable_quantum: false,
164 enable_simd: false,
165 };
166
167 let mut loop_engine = StrangeLoop::new(reasoner, critic, reflector, config);
168 let result = loop_engine.run(&mut context);
169
170 assert!(result.is_ok());
171 let final_x = context.get("x").unwrap();
172 assert!(*final_x < 1.0); }
174
175 #[test]
176 fn test_nano_agent_system() {
177 let config = SchedulerConfig {
178 topology: SchedulerTopology::RoundRobin,
179 run_duration_ns: 1_000_000, tick_duration_ns: 100_000, max_agents: 5,
182 bus_capacity: 100,
183 enable_tracing: false,
184 };
185
186 let scheduler = NanoScheduler::new(config);
187 assert_eq!(scheduler.agent_count(), 0);
188 }
189
190 #[test]
191 fn test_temporal_prediction() {
192 let mut predictor = TemporalLeadPredictor::new(1_000_000, 100); let prediction = predictor.predict_future(vec![1.0, 2.0, 3.0]);
196 assert_eq!(prediction.len(), 3);
197
198 for &pred in &prediction {
200 assert!(pred.is_finite());
201 }
202 }
203
204 #[test]
205 fn test_version_info() {
206 assert!(!VERSION.is_empty());
207 assert!(!BUILD_TIME.is_empty());
208 assert!(!GIT_SHA.is_empty());
209 }
210}