cgn_core/lib.rs
1//! Cognitora shared library.
2//!
3//! Lean cross-cutting concerns reused by every binary: configuration,
4//! errors, BLAKE3 prefix hashing, and the concurrent prefix index.
5//!
6//! Telemetry, TLS, and Kubernetes helpers live in dedicated `cgn-*`
7//! crates so this crate stays free of heavy transitive dependencies.
8
9#![forbid(unsafe_code)]
10
11pub mod config;
12pub mod error;
13pub mod hash;
14pub mod prefix;
15
16pub use error::{exit_code, Error, Result};
17
18/// Default UNIX domain socket directory used by the daemons.
19pub const DEFAULT_UDS_DIR: &str = "/run/cognitora";
20
21/// Default config search path.
22pub const DEFAULT_CONFIG_PATH: &str = "/etc/cognitora/cognitora.toml";
23
24/// Cluster state key prefixes (etcd) used by router/agent/operator.
25pub mod etcd_keys {
26 pub const NODES: &str = "/cognitora/nodes/";
27 pub const MODELS: &str = "/cognitora/models/";
28 pub const ROUTING: &str = "/cognitora/routing/policy";
29 pub const ROUTER_LEADER: &str = "/cognitora/router/leader";
30}
31
32/// Default ports.
33pub mod ports {
34 /// `cgn-router` OpenAI-compatible HTTP/SSE.
35 pub const ROUTER_HTTP: u16 = 8080;
36 /// `cgn-router` admin gRPC (metrics, control RPCs).
37 pub const ROUTER_GRPC: u16 = 9090;
38 /// `cgn-router` admin HTTP (Prometheus scrape).
39 pub const ROUTER_ADMIN: u16 = 9091;
40 /// `cgn-agent` gRPC (router → agent).
41 pub const AGENT_GRPC: u16 = 7070;
42 /// `cgn-kvcached` gRPC (cross-host KV ops).
43 pub const KV_GRPC: u16 = 7071;
44 /// `cgn-kvcached` QUIC transfer port.
45 pub const KV_QUIC: u16 = 7072;
46 /// `cgn-metrics` HTTP scrape.
47 pub const METRICS_HTTP: u16 = 9092;
48 /// vLLM HTTP (private to the agent).
49 pub const VLLM_HTTP: u16 = 8000;
50}
51
52/// Build / version metadata.
53pub mod build {
54 /// Crate version (from Cargo).
55 pub const VERSION: &str = env!("CARGO_PKG_VERSION");
56}