zeta_shared/
lib.rs

1// Copyright 2025 ZETA RETICULA INC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Shared types and utilities for Zeta Reticula
16//! 
17//! This module consolidates common types from multiple crates
18
19use serde::{Serialize, Deserialize};
20use std::collections::HashMap;
21
22// Re-export core types
23pub use zeta_kv_cache::{KVCacheConfig, KVCacheError, PrecisionLevel as KVPrecisionLevel};
24pub use zeta_quantization::{QuantizationConfig, QuantizationError, PrecisionLevel, QuantizationResult};
25pub use zeta_salience::{SalienceConfig, SalienceError, SalienceResult, MesolimbicState};
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct ZetaConfig {
29    pub kv_cache: KVCacheConfig,
30    pub quantization: QuantizationConfig,
31    pub salience: SalienceConfig,
32    pub runtime: RuntimeConfig,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct RuntimeConfig {
37    pub max_memory_mb: usize,
38    pub worker_threads: usize,
39    pub enable_gpu: bool,
40    pub batch_size: usize,
41    pub timeout_seconds: u64,
42}
43
44impl Default for RuntimeConfig {
45    fn default() -> Self {
46        Self {
47            max_memory_mb: 4096,
48            worker_threads: 8,
49            enable_gpu: false,
50            batch_size: 32,
51            timeout_seconds: 300,
52        }
53    }
54}
55
56impl Default for ZetaConfig {
57    fn default() -> Self {
58        Self {
59            kv_cache: KVCacheConfig::default(),
60            quantization: QuantizationConfig::default(),
61            salience: SalienceConfig::default(),
62            runtime: RuntimeConfig::default(),
63        }
64    }
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct ProcessingStats {
69    pub tokens_processed: usize,
70    pub cache_hits: usize,
71    pub cache_misses: usize,
72    pub quantization_ratio: f32,
73    pub avg_salience: f32,
74    pub processing_time_ms: u64,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct ModelMetadata {
79    pub name: String,
80    pub version: String,
81    pub architecture: String,
82    pub parameters: u64,
83    pub precision: PrecisionLevel,
84    pub created_at: String,
85}
86
87pub type Result<T> = std::result::Result<T, ZetaError>;
88
89#[derive(Debug, thiserror::Error)]
90pub enum ZetaError {
91    #[error("KV Cache error: {0}")]
92    KVCache(#[from] KVCacheError),
93    #[error("Quantization error: {0}")]
94    Quantization(#[from] QuantizationError),
95    #[error("Salience error: {0}")]
96    Salience(#[from] SalienceError),
97    #[error("Configuration error: {0}")]
98    Config(String),
99    #[error("Runtime error: {0}")]
100    Runtime(String),
101}