use chaotic_semantic_memory::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
println!("⏱️ Streaming Temporal Processing\n");
let framework = ChaoticSemanticFramework::builder()
.without_persistence()
.with_reservoir_size(10240)
.with_reservoir_input_size(64)
.with_chaos_strength(0.05)
.build()
.await?;
let sequences: Vec<(&str, Vec<Vec<f32>>)> = vec![
(
"sine-wave",
(0..5)
.map(|t| {
(0..64)
.map(|i| ((t as f32 + i as f32) * 0.1).sin())
.collect()
})
.collect(),
),
(
"cosine-wave",
(0..5)
.map(|t| {
(0..64)
.map(|i| ((t as f32 + i as f32) * 0.1).cos())
.collect()
})
.collect(),
),
(
"sawtooth",
(0..5)
.map(|t| {
(0..64)
.map(|i| ((t as f32 + i as f32) * 0.05) % 1.0)
.collect()
})
.collect(),
),
];
for (name, sequence) in &sequences {
let hvec = framework.process_sequence(sequence).await?;
framework.inject_concept(*name, hvec).await?;
println!(
" ✅ Processed '{name}' ({} steps × {} dims)",
sequence.len(),
sequence[0].len()
);
}
let query_sequence: Vec<Vec<f32>> = (0..5)
.map(|t| {
(0..64)
.map(|i| ((t as f32 + i as f32) * 0.1 + 0.01).sin())
.collect()
})
.collect();
let query_hvec = framework.process_sequence(&query_sequence).await?;
println!("\n🔍 Query: slightly shifted sine wave");
let hits = framework.probe(query_hvec, 3).await?;
println!("\n📊 Temporal similarity results:");
for (id, score) in &hits {
println!(" {id}: {score:.4}");
}
let snapshot = framework.metrics_snapshot().await;
println!("\n📈 Metrics:");
println!(" Concepts injected: {}", snapshot.concepts_injected_total);
println!(" Reservoir steps: {}", snapshot.reservoir_steps_total);
println!(" Probes executed: {}", snapshot.probes_total);
println!("\n✅ Temporal processing demo complete!");
Ok(())
}