qualia_core_db/inference/inference_agent/mod.rs
1// qualia-llm-agent: LLM Sub-Agent Layer for the Intentional Computing Ecosystem
2//
3// This crate implements the AgentRuntime trait and the Webizen-gated message
4// protocol that governs every LLM interaction under the Principal-Agent Duty of Care.
5//
6// Architecture:
7// Principal (Natural Person)
8// └── qualiaDB Webizen VM ← GATEKEEPER (validates all I/O)
9// └── LlmAgent (AgentRuntime impl)
10// ├── Backend::Local (llama.cpp / WebLLM / ONNX)
11// ├── Backend::Remote (Nym-tunnelled, ILP-metered, user-consented)
12// └── Backend::Hybrid (local first, remote fallback with consent)
13//
14// CRITICAL CONSTRAINT: All paths enforce:
15// - Zero outbound telemetry
16// - All outputs must be cited to a NQuin provenance chain
17// - Webizen validates I/O before touching the semantic graph
18// - Memory budget hard-capped; default 128MB within 512MB floor
19//
20// ─── Module layout (library-ized from the former `inference_agent.rs` monolith) ─
21// config — constants + the effective-timeout helper
22// types — AgentBackend / AgentIntent / WebizenVerdict / AgentOutput /
23// AgentError / the AgentRuntime trait / rule-ID constants
24// sticky_infer — the native sticky 1-thread infer pool (thread_local engine)
25// decode_helpers — embedding dispatch, topology-draft accept, sieve, prefix KV
26// local_agent — the LocalLlmAgent struct + constructors + LoRA / sieve wiring
27// decode — Phase-8 bifurcated-compute decode path (impl LocalLlmAgent)
28// validation — pre-flight intent validation (impl LocalLlmAgent)
29// runtime — the AgentRuntime impl for LocalLlmAgent
30// The full public surface is re-exported below, so every external path
31// (`crate::inference::inference_agent::*` and the `llm_agent` alias) resolves
32// exactly as before.
33
34// ─── AgentIntent (re-exported hot-path frame types) ──────────────────────────
35pub use crate::modalities::logic::n3_compiler::{
36 AgentIntentFrame, N3OutputMode, MAX_CONTEXT_NAMESPACE_SLOTS, MAX_INTENT_SCOPE_SLOTS,
37};
38
39#[cfg(not(target_arch = "wasm32"))]
40mod sticky_infer;
41
42mod config;
43mod decode;
44mod decode_helpers;
45mod local_agent;
46mod runtime;
47mod types;
48mod validation;
49
50pub use config::*;
51pub use local_agent::*;
52pub use types::*;
53
54#[cfg(test)]
55mod tests;