//! `rag_with_retrieval` — RAG over a seeded local corpus. //! //! Seeds a tiny in-memory index, drives the `retrieve → enrich → //! rerank → read` pipeline at `JouleClawStack::rag`, and prints the //! extractive answer + per-stage joule trace. No model is invoked; //! the L1.5 reader extracts directly from passages — the *Apply* //! corner of Bloom's verifiable zone. //! //! Run with: //! cargo run -p jouleclaw-stack --example rag_with_retrieval use jouleclaw_local_index::{Document, InMemoryIndex, LocalIndexTier}; use jouleclaw_stack::{JouleClawStack, RagConfig}; fn main() { // Seed three short facts in the local index. let mut idx = InMemoryIndex::new(); idx.insert(Document::new("d1", "The capital of France is Paris.")); idx.insert(Document::new("d2", "The capital of Germany is Berlin.")); idx.insert(Document::new("d3", "The capital of Italy is Rome.")); let mut stack = JouleClawStack::with_defaults(); stack.local_index = LocalIndexTier::new(idx); // Local-only retrieval — federation's mock provider would add noise. let cfg = RagConfig { use_federation: false, use_graph_enrich: false, ..RagConfig::default() }; let outcome = stack.rag_with("What is the capital of France?", 100.0, &cfg); println!("RAG run:"); println!(" answer {:?}", outcome.answer); println!(" confidence {:.3}", outcome.confidence); println!(" total joules {:.6}", outcome.joules_spent); println!(" candidates {}", outcome.candidates); println!(" read {} passage(s)", outcome.passages_read); println!(); println!("per-stage trace:"); for s in &outcome.stages { println!( " {stage:<24} {joules:>10.6} J {note}", stage = s.stage, joules = s.joules, note = s.note ); } }