post_cortex_core/lib.rs
1// Copyright (c) 2025, 2026 Julius ML
2// Licensed under the MIT License. See LICENSE at the workspace root.
3
4//! Core domain library for post-cortex — types, error, and lightweight
5//! domain modules.
6//!
7//! This crate is the **dependency root** of the workspace. It contains
8//! only the types and helpers needed to describe a post-cortex
9//! conversation: session, graph, workspace, summary, and the
10//! cross-cutting primitives under [`core`]. Heavy infrastructure lives
11//! in dedicated sibling crates:
12//!
13//! | Concern | Crate |
14//! |--------|-------|
15//! | gRPC wire types | [`post_cortex_proto`] |
16//! | Storage backends (RocksDB, SurrealDB) | `post-cortex-storage` |
17//! | Embeddings + HNSW | `post-cortex-embeddings` |
18//! | Conversation memory orchestrator | `post-cortex-memory` |
19//! | MCP tool library | `post-cortex-mcp` |
20//! | rmcp + axum + tonic daemon | `post-cortex-daemon` |
21//!
22//! Library users embedding post-cortex into their own Rust applications
23//! depend on `post-cortex-core` if they want the type system only, or
24//! on `post-cortex-memory` (which transitively pulls core + storage +
25//! embeddings) if they want a ready-to-use memory system.
26//!
27//! See `/Users/julius/.claude/plans/stateful-hugging-hopper.md` for the
28//! migration plan that produced this layout.
29
30// candle's `from_mmaped_safetensors` requires `unsafe` at a single call
31// site in post-cortex-embeddings; this crate is otherwise unsafe-free.
32#![deny(unsafe_code)]
33// Cosmetic clippy suggestions silenced workspace-wide — see other
34// crates' lib.rs for the same rationale.
35#![allow(clippy::result_large_err)]
36#![allow(clippy::type_complexity)]
37#![allow(clippy::field_reassign_with_default)]
38#![allow(clippy::manual_div_ceil)]
39// `sort_by` with .cmp() is sometimes clearer than the suggested
40// `sort_by_key(|x| x.field)` when the key involves multiple fields.
41#![allow(clippy::unnecessary_sort_by)]
42// Doc lists with indentation drift in legacy code; cleanup is Phase 12
43// follow-up.
44#![allow(clippy::doc_lazy_continuation)]
45
46/// Cross-cutting primitives shared by every post-cortex crate.
47///
48/// Hosts the [`cache`][core::cache] LRU helpers, the
49/// [`context_update`][core::context_update] data model, the
50/// [`error`][core::error] hierarchy ([`SystemError`] + [`Result`]),
51/// the [`structured_context`][core::structured_context] projection
52/// types, and the [`timeout_utils`][core::timeout_utils] retry helpers.
53pub mod core;
54
55/// Entity graph + GraphRAG types — `petgraph`-backed knowledge graph
56/// used to enrich semantic search with relationship traversal.
57pub mod graph;
58
59/// Canonical [`services::PostCortexService`] trait. Every transport
60/// (gRPC, MCP, REST) delegates to the same single implementation in
61/// `post-cortex-memory`.
62pub mod services;
63
64/// `ActiveSession` and session-component types — the hot-context cache
65/// + change-history layer that backs the lock-free session manager.
66pub mod session;
67
68/// Read-only summary projection types (decisions, entities,
69/// timeline) consumed by MCP `get_structured_summary` and the gRPC
70/// equivalent.
71pub mod summary;
72
73/// Workspace types — `WorkspaceManager`, `SessionRole`, the entities
74/// that group multiple sessions for cross-session search.
75pub mod workspace;
76
77pub use crate::core::error::{Result, SystemError};
78
79/// Re-export of the gRPC wire-types crate so consumers can reach freshness /
80/// source-reference types as `post_cortex_core::proto::FreshnessEntry` —
81/// matches the convenience export of the legacy single-crate layout.
82pub use post_cortex_proto as proto;