post_cortex_daemon/lib.rs
1// Copyright (c) 2025, 2026 Julius ML
2// Licensed under the MIT License. See LICENSE at the workspace root.
3
4//! HTTP / gRPC / SSE / stdio daemon for post-cortex.
5//!
6//! Hosts:
7//!
8//! - the **rmcp Model Context Protocol** surface (streaming-HTTP +
9//! stdio transports) via [`daemon::rmcp_server`] and
10//! [`daemon::mcp_service`];
11//! - the **tonic gRPC API** (canonical post-cortex wire surface) via
12//! [`daemon::grpc_service`];
13//! - the **axum HTTP server** with REST endpoints for the `pcx` CLI
14//! client and the Server-Sent Events broadcast plumbing via
15//! [`daemon::server`] and [`daemon::sse`];
16//! - the **stdio bridge** that lets MCP hosts spawn the daemon as a
17//! child process via [`daemon::stdio_proxy`];
18//! - the unified **`pcx` CLI binary** (`[[bin]]`) under `src/bin/pcx`.
19//!
20//! The daemon owns no domain logic — every read / write / search /
21//! manage operation delegates downward into
22//! [`post_cortex_memory::ConversationMemorySystem`] (and, from Phase 7
23//! onwards, through the
24//! [`post_cortex_core::services::PostCortexService`] trait). Validation
25//! that was historically duplicated between the gRPC and MCP layers
26//! migrates to the trait impl in `post-cortex-memory::MemoryServiceImpl`.
27
28// rustdoc::broken_intra_doc_links is warned (not denied) for the daemon
29// because the migrated grpc_service / mcp_service files carry historical
30// `[private_item]` references; cleanup is Phase 12 follow-up after the
31// transport handlers migrate to call PostCortexService.
32#![warn(rustdoc::broken_intra_doc_links)]
33// The daemon's only unsafe is in two test cases that exercise env var
34// overrides for DaemonConfig (`set_var` / `remove_var` are `unsafe fn`
35// since Rust 1.85 because env mutation is racy in multi-threaded
36// programs). Both blocks are gated under #[cfg(test)] and serialised by
37// the test framework, so we relax `forbid` to `deny` and let those two
38// blocks opt in via `#[allow(unsafe_code)]`.
39#![deny(unsafe_code)]
40// CoercionError carries rich context (path, expected type, hint, source)
41// so consumers can render actionable validation messages. The lint
42// flags every Result<_, CoercionError> as "Err variant very large", but
43// boxing it would defeat the design — accept the warning at crate level.
44#![allow(clippy::result_large_err)]
45// Some daemon types (CoerceFn signatures, gRPC handler tuples) are
46// intentionally complex; refactoring them into separate type aliases
47// would obscure the call site without changing behaviour.
48#![allow(clippy::type_complexity)]
49// gRPC handler match arms include a wildcard branch even when the
50// variants are exhaustive — leaving it in keeps the handlers
51// forward-compatible if new request types land.
52#![allow(clippy::wildcard_in_or_patterns)]
53#![allow(clippy::match_wildcard_for_single_variants)]
54// Some pcx CLI handlers take many tuple-shaped command-line args.
55#![allow(clippy::too_many_arguments)]
56
57pub mod daemon;
58/// Error types for the daemon crate.
59pub mod error;
60
61pub use daemon::config::DaemonConfig;
62pub use error::{Error, Result};