xynthe 0.1.0

A unified orchestration framework for autonomous intelligence with temporal continuity
Documentation
//! Basic Xynthe usage example - demonstrates core primitives
//!
//! Run with: cargo run --example basic_usage

use xynthe::prelude::*;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<()> {
    println!("=== Xynthe Basic Usage Example ===\n");

    // 1. Initialize the identity system
    println!("1. Initializing Xynthe core components...");
    let _identity_fabric = Arc::new(ContextFabric::new());
    println!("   ✓ Context Fabric initialized\n");

    // 2. Create a thought stream for observations
    println!("2. Creating thought streams for cognitive events...");
    let observation_stream = ThoughtStream::new("observations");

    // Emit various types of cognitive events
    println!("   Emitting observation event...");
    let obs_event = ThoughtEvent::observation(
        StructuredContent::text("User requested weather forecast for San Francisco"),
        ProvenanceChain::new(),
    );
    observation_stream.emit(obs_event.clone())?;
    println!("   ✓ Observation event emitted\n");

    // Emit a hypothesis with confidence
    println!("3. Creating hypothesis with confidence...");
    let hypothesis = ThoughtEvent::hypothesis(
        StructuredContent::text("User is planning outdoor activity"),
        ProvenanceChain::new(),
        0.7, // 70% confidence
    );
    observation_stream.emit(hypothesis)?;
    println!("   ✓ Hypothesis event created with 70% confidence\n");

    // 4. Create context fabric for memory
    println!("4. Storing events in context fabric...");
    let context_fabric = Arc::new(ContextFabric::new());

    let context_event = ContextEvent {
        content: StructuredContent::text("Initial system state"),
        timestamp: Timestamp::now(),
        causal_chain: vec![],
        confidence: 1.0,
        layer: ContextLayer::Working,
    };

    context_fabric.store(context_event, ContextLayer::Working).await?;
    println!("   ✓ Event stored in working memory layer\n");

    // 5. Query the context fabric
    println!("5. Querying context fabric...");
    let time_window = TimeWindow::from_now(chrono::Duration::hours(1));
    let query = ContextQuery::recall("system", time_window)
        .with_limit(10);

    let results = context_fabric.query(query).await?;
    println!("   Retrieved {} events(s)", results.events.len());
    println!("   Execution time: {} ms\n", results.metadata.execution_time_ms);

    // 6. Demonstrate capability registry
    println!("6. Setting up capability registry...");
    let registry = Arc::new(CapabilityRegistry::new());

    // List capabilities (empty for now)
    let caps = registry.list().await;
    println!("   Registered capabilities: {:?}\n", caps);

    println!("=== Example completed successfully! ===\n");
    println!("Xynthe core components demonstrated:");
    println!("  • Thought streams with multiple event types");
    println!("  • Confidence-scored hypotheses");
    println!("  • Context fabric with temporal querying");
    println!("  • Capability registry structure");

    Ok(())
}