Skip to main content

macp_core/
lib.rs

1//! `macp-core` — the transport-free coordination vocabulary of MACP.
2//!
3//! This crate holds the stable types every other MACP crate (and external
4//! library consumers) build on, with no dependency on tonic, storage, or any
5//! async runtime:
6//!
7//! - [`error::MacpError`] — the canonical error enum and RFC error codes
8//! - [`session`] — the [`session::Session`] model and `SessionStart` validation
9//! - [`mode::ModeResponse`] — the result a mode hands back to the kernel
10//! - [`decision`] — the Decision mode's domain types (shared with policy)
11//! - [`policy`] — [`policy::PolicyDefinition`], [`policy::PolicyDecision`],
12//!   [`policy::PolicyError`], the shared [`policy::CommitmentRules`], and the
13//!   [`policy::PolicyEvaluator`] trait that modes call through
14//! - [`commitment_hash`] — the RFC-MACP-0013 canonical commitment hash
15
16/// The MACP protocol version this runtime implements and negotiates
17/// (`Envelope.macp_version`, `Initialize`'s `supported_protocol_versions`/
18/// `selected_protocol_version`). Real, kernel-enforced API — unlike the
19/// `#[doc(hidden)]` constants in [`session`], this one backs an actual
20/// wire-level check, so it is a plain, stable `pub const`.
21pub const MACP_VERSION: &str = "1.0";
22
23pub mod commitment_hash;
24pub mod decision;
25pub mod error;
26pub mod mode;
27pub mod policy;
28pub mod session;
29
30// Flat re-exports for the most commonly used types.
31pub use error::MacpError;
32pub use mode::ModeResponse;
33pub use policy::{PolicyDecision, PolicyDefinition, PolicyError, PolicyEvaluator};
34pub use session::{Session, SessionState};
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    #[test]
41    fn macp_version_value() {
42        assert_eq!(MACP_VERSION, "1.0");
43    }
44}