lib.rs
1 //! # Abzu Mesh Inference 2 //! 3 //! Privacy-preserving LLM inference via token sharding. 4 //! 5 //! ## Architecture 6 //! 7 //! This crate implements *token-sharded inference* to ensure no single mesh node 8 //! sees the full context of an inference request. The key insight: by splitting 9 //! hidden state across multiple independent nodes, we achieve: 10 //! 11 //! - **Context privacy**: No node can reconstruct the full prompt 12 //! - **Collusion resistance**: Requires majority coalition to break privacy 13 //! - **Plausible deniability**: Each shard is meaningless in isolation 14 //! 15 //! ## Protocol 16 //! 17 //! ```text 18 //! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ 19 //! │ Requester │ │ Node A │ │ Node B │ 20 //! │ (Agent) │ │ (Shard 1) │ │ (Shard 2) │ 21 //! └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ 22 //! │ │ │ 23 //! │ InferenceRequest │ │ 24 //! │ (sharded) │ │ 25 //! ├──────────────────►│ │ 26 //! ├────────────────────────────────────► │ 27 //! │ │ │ 28 //! │ PartialResult │ │ 29 //! │◄──────────────────┤ │ 30 //! │◄──────────────────────────────────── │ 31 //! │ │ │ 32 //! │ [Aggregate] │ │ 33 //! ▼ ▼ ▼ 34 //! ``` 35 //! 36 //! ## Usage 37 //! 38 //! ```ignore 39 //! use abzu_inference::{MeshInference, InferenceConfig}; 40 //! 41 //! // Configure with 3 shards for strong privacy 42 //! let config = InferenceConfig::new() 43 //! .with_shard_count(3) 44 //! .with_threshold(2); // 2-of-3 needed 45 //! 46 //! let mesh = MeshInference::new(config); 47 //! 48 //! // Sharded inference - no single node sees full context 49 //! let response = mesh.infer("What is the meaning of life?").await?; 50 //! ``` 51 52 mod error; 53 mod shard; 54 pub mod protocol; 55 mod coordinator; 56 pub mod agent_circles; 57 pub mod discovery; 58 pub mod dht_executor; 59 pub mod mesh; 60 pub mod reputation; 61 pub mod proof_of_inference; 62 pub mod service; 63 64 pub use error::InferenceError; 65 pub use shard::{TokenShard, ShardConfig}; 66 pub use protocol::{InferenceRequest, InferenceResponse, PartialResult}; 67 pub use coordinator::MeshInference; 68 pub use service::InferenceService; 69 70 // Agent Circles re-exports 71 pub use agent_circles::{ 72 AgentCircle, AgentProfile, AgentStatus, 73 Capability, CircleInvite, 74 }; 75 76 // Mesh re-exports 77 pub use mesh::{ 78 CircleAnnouncement, Task, TaskResult, RoutingStrategy, TaskRouter, 79 MeshDiscoveryRouter, MeshDiscoveryResult, RoutingTarget, MeshStats, 80 }; 81 82 // Discovery re-exports 83 pub use discovery::{ 84 CircleCache, DiscoveryQuery, DiscoveryResult, DhtOp, 85 PublishedCircle, plan_publish, plan_discovery, 86 }; 87 88 // DHT Executor re-exports 89 pub use dht_executor::{ 90 DhtExecutor, ExecutorConfig, DhtAction, ExecutorEvent, 91 }; 92 93 #[cfg(test)] 94 mod tests { 95 use super::*; 96 97 #[test] 98 fn test_module_exports() { 99 // Verify all public types are accessible 100 let _ = ShardConfig::default(); 101 } 102 }