| Crates.io | omega-loops |
| lib.rs | omega-loops |
| version | 1.1.0 |
| created_at | 2025-12-05 18:03:52.319587+00 |
| updated_at | 2025-12-12 07:08:21.592182+00 |
| description | 7 temporal cognitive loops from Reflexive (1ms) to Transcendent (10y) for multi-scale processing |
| homepage | https://github.com/prancer-io/ExoGenesis-Omega |
| repository | https://github.com/prancer-io/ExoGenesis-Omega |
| max_upload_size | |
| id | 1968868 |
| size | 176,338 |
7 temporal cognitive loops from Reflexive (1ms) to Transcendent (10y) for multi-scale intelligence processing.
Part of the ExoGenesis-Omega cognitive architecture.
omega-loops implements a hierarchical system of 7 nested temporal loops that enable intelligence systems to operate coherently across vastly different timescales. From millisecond reflexes to decade-long transformations, each loop processes information at its natural temporal scale while coordinating with faster and slower loops.
Inspired by biological cognitive architectures (from reflexes to strategic planning) and extended to cosmic scales, this system enables AI to be simultaneously reactive, adaptive, deliberative, and transformative.
Add this to your Cargo.toml:
[dependencies]
omega-loops = "0.1.0"
use omega_loops::{LoopEngine, LoopType, CycleInput};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create and initialize the loop engine
let mut engine = LoopEngine::new();
engine.initialize().await?;
// Execute a cycle in the adaptive loop
let input = CycleInput {
data: HashMap::new(),
context: "learning_session".to_string(),
objectives: vec!["improve_accuracy".to_string()],
};
let output = engine.execute_cycle(LoopType::Adaptive, input).await?;
println!("Cycle completed: {}", output.cycle_id);
// Get statistics for all loops
let stats = engine.get_stats().await;
for (loop_type, stat) in stats {
println!("{:?}: {} cycles, {:.1}% success",
loop_type,
stat.cycles_completed,
stat.success_rate * 100.0
);
}
// Shutdown gracefully
engine.shutdown().await?;
Ok(())
}
Each loop operates at a specific timescale:
Reflexive (100ms)
Reactive (5 seconds)
Adaptive (30 minutes)
Deliberative (24 hours)
Evolutionary (7 days)
Transformative (1 year)
Transcendent (10 years)
Loops interact through:
Each cycle follows a standard flow:
use omega_loops::{LoopEngine, LoopType, CycleInput};
use std::collections::HashMap;
let mut engine = LoopEngine::new();
engine.initialize().await?;
// Reflexive loop handles immediate responses
tokio::spawn(async move {
loop {
let input = CycleInput {
data: get_sensor_data(),
context: "real_time_control".to_string(),
objectives: vec!["maintain_stability".to_string()],
};
engine.execute_cycle(LoopType::Reflexive, input).await.ok();
tokio::time::sleep(Duration::from_millis(100)).await;
}
});
// Adaptive loop runs every 30 minutes for learning
tokio::spawn(async move {
loop {
let input = CycleInput {
data: get_recent_performance(),
context: "learning_update".to_string(),
objectives: vec!["improve_model".to_string()],
};
engine.execute_cycle(LoopType::Adaptive, input).await.ok();
tokio::time::sleep(Duration::from_secs(1800)).await;
}
});
// Deliberative loop runs daily for strategic planning
tokio::spawn(async move {
loop {
let input = CycleInput {
data: get_daily_summary(),
context: "daily_planning".to_string(),
objectives: vec!["optimize_goals".to_string()],
};
engine.execute_cycle(LoopType::Deliberative, input).await.ok();
tokio::time::sleep(Duration::from_secs(86400)).await;
}
});
use omega_loops::{LoopEngine, LoopType};
let mut engine = LoopEngine::new();
engine.initialize().await?;
// Reactive loop: Immediate pattern recognition
let reactive_input = CycleInput {
data: get_current_patterns(),
context: "pattern_detection".to_string(),
objectives: vec!["recognize_patterns".to_string()],
};
engine.execute_cycle(LoopType::Reactive, reactive_input).await?;
// Adaptive loop: Consolidate patterns into rules
let adaptive_input = CycleInput {
data: get_detected_patterns(),
context: "rule_learning".to_string(),
objectives: vec!["form_rules".to_string()],
};
engine.execute_cycle(LoopType::Adaptive, adaptive_input).await?;
// Evolutionary loop: Refine and generalize rules
let evolutionary_input = CycleInput {
data: get_learned_rules(),
context: "rule_refinement".to_string(),
objectives: vec!["generalize_rules".to_string()],
};
engine.execute_cycle(LoopType::Evolutionary, evolutionary_input).await?;
use omega_loops::{LoopEngine, LoopType};
let mut engine = LoopEngine::new();
engine.initialize().await?;
// Evolutionary loop: Weekly performance review
let weekly_input = CycleInput {
data: get_weekly_metrics(),
context: "weekly_review".to_string(),
objectives: vec!["identify_weaknesses".to_string()],
};
engine.execute_cycle(LoopType::Evolutionary, weekly_input).await?;
// Transformative loop: Annual architecture evolution
let yearly_input = CycleInput {
data: get_annual_performance(),
context: "architecture_evolution".to_string(),
objectives: vec!["evolve_architecture".to_string()],
};
engine.execute_cycle(LoopType::Transformative, yearly_input).await?;
use omega_loops::{LoopEngine, LoopType};
// Each agent has its own loop engine
let mut agent1_engine = LoopEngine::new();
let mut agent2_engine = LoopEngine::new();
agent1_engine.initialize().await?;
agent2_engine.initialize().await?;
// Reactive coordination between agents
let coord_input = CycleInput {
data: get_agent_states(),
context: "agent_coordination".to_string(),
objectives: vec!["synchronize_actions".to_string()],
};
agent1_engine.execute_cycle(LoopType::Reactive, coord_input.clone()).await?;
agent2_engine.execute_cycle(LoopType::Reactive, coord_input).await?;
// Deliberative planning for collaborative tasks
let planning_input = CycleInput {
data: get_task_requirements(),
context: "collaborative_planning".to_string(),
objectives: vec!["divide_work".to_string()],
};
agent1_engine.execute_cycle(LoopType::Deliberative, planning_input.clone()).await?;
agent2_engine.execute_cycle(LoopType::Deliberative, planning_input).await?;
use omega_loops::{LoopEngine, LoopType};
let mut engine = LoopEngine::new();
engine.initialize().await?;
// Run some cycles...
// Check which loops are active
println!("Engine running: {}", engine.is_running().await);
// Get detailed statistics
let stats = engine.get_stats().await;
for (loop_type, stat) in stats {
println!("\n{:?} Loop:", loop_type);
println!(" Cycles: {}", stat.cycles_completed);
println!(" Success: {:.1}%", stat.success_rate * 100.0);
println!(" Avg time: {:?}", stat.average_cycle_time);
}
// Access coordinator for direct loop management
let coordinator = engine.coordinator();
let coord = coordinator.read().await;
for loop_type in LoopType::all_loops() {
if let Ok(Some(loop_info)) = coord.get_loop_by_type(loop_type).await {
println!("{:?} status: {:?}", loop_type, loop_info.status);
}
}
use omega_loops::{LoopExecutor, LoopType, CycleInput, CycleOutput};
// Create custom processor for specific loop type
struct CustomAdaptiveProcessor;
impl CustomAdaptiveProcessor {
async fn process(&self, input: CycleInput) -> Result<CycleOutput, Box<dyn std::error::Error>> {
// Custom processing logic
let mut output_data = HashMap::new();
output_data.insert(
"learned".to_string(),
serde_json::json!({"patterns": ["pattern1", "pattern2"]})
);
Ok(CycleOutput {
cycle_id: uuid::Uuid::new_v4().to_string(),
success: true,
data: output_data,
timestamp: chrono::Utc::now(),
})
}
}
use omega_loops::{LoopEngine, LoopCoordinator};
let mut engine = LoopEngine::new();
// Access coordinator to customize loop behavior
let coordinator = engine.coordinator();
let mut coord = coordinator.write().await;
// Create loops with custom configurations
for loop_type in LoopType::all_loops() {
coord.create_loop(
loop_type,
format!("Custom {:?}", loop_type),
format!("Customized {} loop", loop_type.description()),
).await?;
}
The loop system is structured hierarchically:
┌──────────────────────────────────────────┐
│ LoopEngine │
│ - Initialization & shutdown │
│ - Statistics aggregation │
└────────────┬─────────────────────────────┘
│
▼
┌──────────────────────────────────────────┐
│ LoopCoordinator │
│ - Loop creation & management │
│ - State tracking │
│ - Message bus coordination │
└────────────┬─────────────────────────────┘
│
▼
┌──────────────────────────────────────────┐
│ LoopExecutors (7) │
│ - Reflexive executor │
│ - Reactive executor │
│ - Adaptive executor │
│ - Deliberative executor │
│ - Evolutionary executor │
│ - Transformative executor │
│ - Transcendent executor │
└──────────────────────────────────────────┘
Loop system performance characteristics:
Memory usage: ~1KB per loop + cycle state
Licensed under the MIT License. See LICENSE for details.