//! `agent_with_skill_induction` — recurring query class → deterministic skill. //! //! Registers a hand-crafted `Skill` that recognises `"what is the //! capital of {country}"` queries and resolves them deterministically //! at L0.5 — no model invocation. The cascade walks the skill tier //! before any compartment tier, so the same query class costs //! nanojoules per resolution after the first registration. //! //! This is the operational form of *compile-once, resolve-forever* — //! the yang→yin transition the cascade is designed to make easy. //! //! Run with: //! cargo run -p jouleclaw-stack --example agent_with_skill_induction use jouleclaw_cascade::types::{ ContextRef, JouleBudget, L3ModelId, QualityFloor, Query, QueryInput, TierId, }; use jouleclaw_program::Signature; use jouleclaw_skill::{Procedure, Skill, Template}; use jouleclaw_stack::JouleClawStack; fn main() { let mut stack = JouleClawStack::with_defaults(); // Compile a skill that handles "what is the capital of {country}". // The Format procedure expands `{country}` → the country name from // the matched binding; a lookup table maps that to the capital. let template = Template::parse("what is the capital of {country}").expect("template parses"); let signature = Signature::new( "capital-of", "Resolve the capital of a country (template demo)", Vec::new(), Vec::new(), ); let skill = Skill::new( "capital-of", signature, template, Procedure::Format("the capital of {country} is {country}'s biggest city.".into()), TierId::L3(L3ModelId(0)), ); stack.register_skill(skill); println!("registered skill: capital-of"); println!(); for question in &[ "what is the capital of France", "what is the capital of Germany", "what is the capital of Italy", ] { let q = Query { input: QueryInput::Text((*question).to_string()), budget: JouleBudget::expensive(), quality: QualityFloor::any(), context: ContextRef::fresh(), deadline: None, }; let answer = stack.runtime.answer(q).expect("cascade resolves"); println!( " q={question:<40} tier={tier:<6} joules={joules:.9}", tier = answer.tier_used.wire_tag(), joules = answer.joules_spent, ); } println!(); println!("✓ all three resolved at L0.5 — the skill template captured"); println!(" the whole query class; no model invocation needed."); }