cellstate_core/lib.rs
1// Copyright 2024-2026 CELLSTATE Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4//! CELLSTATE Core - Entity Types
5//!
6//! Core domain types and shared logic. All other crates depend on this.
7//! Contains domain types, scoring, decay, drift detection, and event-sourcing primitives.
8//!
9//! # Type Dictionary
10//!
11//! This crate serves as the "type dictionary" for CELLSTATE. All types visible
12//! here form the vocabulary of the system:
13//!
14//! - **Identity**: Type-safe ID newtypes (`TenantId`, `TrajectoryId`, etc.), `Timestamp`, `ContentHash`
15//! - **Enums**: Status types, entity types, categories. DB enum values use snake_case when
16//! writing; reading accepts legacy PascalCase/mixed-case via `from_db_str` (see `enums`).
17//! - **Entities**: Core domain entities (Trajectory, Scope, Artifact, Note, Turn)
18//! - **Typestate**: Compile-time safe Lock, Handoff, Delegation lifecycles
19//! - **Events**: Event DAG types (EventHeader, DagPosition, EventKind)
20//! - **Effects**: Error-as-effects pattern (Effect<T>, ErrorEffect)
21
22// Core modules
23mod agent;
24pub mod agent_state;
25mod battle_intel;
26mod config;
27pub mod decay;
28mod embedding;
29mod entities;
30mod enums;
31mod error;
32pub mod filter;
33mod health;
34mod identity;
35pub mod intent;
36mod llm;
37pub mod prompt_template;
38pub mod redaction;
39pub mod scoring;
40mod secret;
41
42// Typestate macros and modules (compile-time safety for critical paths)
43#[macro_use]
44mod typestate;
45mod delegation;
46mod handoff;
47mod lock;
48mod session;
49
50// Verifiable Credentials (agent identity)
51pub mod credentials;
52
53// Event DAG modules
54mod effect;
55mod event;
56pub mod event_payloads;
57
58// Event sourcing module
59pub mod event_sourcing;
60
61// PCP configuration, validation, lint, and context validator
62pub mod context_validator;
63pub mod lint;
64pub mod pcp;
65
66// Context assembly module
67mod context;
68
69// Drift detection module
70pub mod drift;
71
72// Synchronization pulse module
73pub mod sync_pulse;
74
75// Model discovery types
76pub mod models;
77
78// WebMCP types (browser-native agent tool discovery)
79pub mod web_mcp;
80
81// Re-export identity types
82pub use identity::*;
83
84// Re-export all enums
85pub use enums::*;
86
87// Re-export embedding types
88pub use embedding::*;
89
90// Re-export entity structs
91pub use entities::*;
92
93// Re-export Battle Intel types
94pub use battle_intel::*;
95
96// Re-export error types
97pub use error::*;
98
99// Re-export config types
100pub use config::*;
101
102// Re-export filter types
103pub use filter::*;
104
105// Re-export health types
106pub use health::*;
107
108// Re-export typestate types (Lock, Handoff, Delegation)
109pub use delegation::*;
110pub use handoff::*;
111pub use lock::*;
112pub use session::*;
113
114// Re-export event DAG types
115pub use event::*;
116
117// Re-export effect types
118pub use effect::*;
119
120// Re-export event sourcing trait
121pub use event_sourcing::EventSourced;
122
123// Re-export event payload types
124pub use event_payloads::*;
125
126// Re-export context assembly types
127pub use context::*;
128
129// Re-export drift detection types
130pub use drift::*;
131
132// Re-export sync pulse types
133pub use sync_pulse::*;
134
135// Re-export agent types (consolidated from cellstate-agents)
136pub use agent::*;
137
138// Re-export agent state types
139pub use agent_state::*;
140
141// Re-export WebMCP types
142pub use web_mcp::*;
143
144// Re-export scoring types
145pub use scoring::*;
146
147// Re-export decay types
148pub use decay::*;
149
150// Re-export intent engineering types
151pub use intent::*;
152// Re-export secret wrappers
153pub use secret::*;
154
155// Re-export LLM primitive types (consolidated from cellstate-llm)
156pub use llm::*;
157
158// Re-export PCP types (formerly in cellstate-server crate, now consolidated here)
159pub use context_validator::{ContextValidator, ContextValidator as PCPRuntime};
160pub use lint::lint_markdown_semantics;
161pub use pcp::*;
162
163// API request/response types (shared across server, CLI, and SDKs)
164pub mod api_types;