Skip to main content

vcp_core/
lib.rs

1//! # vcp-core
2//!
3//! Core types and parsing for the **Value Context Protocol (VCP)**.
4//!
5//! VCP is a protocol for expressing and transmitting human values,
6//! context, and personal state between Becoming Minds so they can
7//! adapt their behaviour accordingly.
8//!
9//! ## Modules
10//!
11//! | Module | Purpose |
12//! |--------|---------|
13//! | [`identity`] | VCP/I token parsing (`family.safe.guide@1.2.0`) |
14//! | [`csm1`] | CSM-1 compact codes and 8-line tokens |
15//! | [`personal`] | Personal state dimensions (cognitive, emotional, ...) |
16//! | [`situational`] | Situational context (time, space, company, ...) |
17//! | [`context`] | Full context wire format (situational + personal) |
18//! | [`transport`] | Content hashing, canonicalization, signing, bundle verification |
19//! | [`trust`] | Trust anchor management for issuers and auditors |
20//! | [`hooks`] | Hook system for the adaptation pipeline (6 hook types) |
21//! | [`revocation`] | Bundle revocation checking with SSRF protection |
22//! | [`error`] | Error types and verification codes |
23//!
24//! ## Quick Start
25//!
26//! ```rust
27//! use vcp_core::identity::VcpToken;
28//! use vcp_core::csm1::{Csm1Code, Persona};
29//! use vcp_core::context::FullContext;
30//! use vcp_core::transport::compute_content_hash;
31//!
32//! // Parse a VCP identity token.
33//! let token = VcpToken::parse("family.safe.guide@1.2.0").unwrap();
34//! assert_eq!(token.domain(), "family");
35//!
36//! // Parse a CSM-1 compact code.
37//! let code = Csm1Code::parse("N5+F+E").unwrap();
38//! assert_eq!(code.persona, Persona::Nanny);
39//! assert_eq!(code.encode(), "N5+E+F");
40//!
41//! // Hash constitution content.
42//! let hash = compute_content_hash("Be kind to everyone.").unwrap();
43//! assert!(hash.starts_with("sha256:"));
44//! ```
45
46#![warn(clippy::all, clippy::pedantic)]
47#![allow(clippy::module_name_repetitions)]
48#![allow(clippy::must_use_candidate)]
49
50pub mod agent;
51pub mod composer;
52pub mod context;
53pub mod csm1;
54pub mod error;
55pub mod hooks;
56pub mod identity;
57pub mod orchestrator;
58pub mod personal;
59pub mod revocation;
60pub mod situational;
61mod strict_json;
62pub mod transport;
63pub mod trust;
64
65// VCP v2.0 extensions
66pub mod extensions;
67pub mod negotiation;
68pub mod types;
69
70// Re-export commonly used types at crate root.
71pub use context::{ConformanceLevel, FullContext};
72pub use csm1::{Csm1Code, Csm1Token, Persona, Scope};
73pub use error::{VcpError, VcpResult};
74pub use hooks::{
75    ChainResult, Hook, HookAction, HookExecutor, HookHandler, HookInput, HookRegistry, HookResult,
76    HookScope, HookType,
77};
78pub use identity::VcpToken;
79pub use personal::{PersonalDimension, PersonalState};
80pub use revocation::{
81    Crl, CrlEntry, ReqwestRevocationTransport, RevocationChecker, RevocationDecision,
82    RevocationStatus, RevocationTransport,
83};
84pub use situational::{SituationalContext, SituationalDimension};
85pub use transport::{
86    compute_content_hash, sign_manifest, verify_content_hash, verify_manifest_signature,
87};
88pub use trust::{TrustAnchor, TrustConfig};
89
90// Orchestrator and composition engine.
91pub use composer::{Composer, CompositionMode, CompositionResult, Conflict, Constitution};
92pub use orchestrator::{Orchestrator, ReplayCache, VerificationContext};
93
94// VCP v2.0 type definitions.
95pub use types::{AdoptionStatus, EnforcementMode, TestimonyType, TokenType};