Skip to main content

cbcl_core/
lib.rs

1//! cbcl-core: Pure core library for the CBCL language runtime.
2//!
3//! This crate contains all deterministic, effect-free modules that form the
4//! verified core of CBCL. Every module is `#![forbid(unsafe_code)]` and
5//! `no_std`-compatible (with `alloc`).
6//!
7//! # Modules
8//!
9//! - `sexpr` — S-expression data types (Atom, SExpr)
10//! - `blame` — Violation blame attribution (REQ-230, REQ-232, REQ-233, CON-205)
11//! - `message` — Message types and core performatives
12//! - `dialect` — Dialect definitions and resource bounds
13//! - `agent` — Agent with beliefs, dialect registry, message queue, threads
14//! - `evaluator` — Message evaluator: dispatch, template expansion, effect interpretation
15//! - `serializer` — Canonical S-expression serialization
16//! - `r1` — R1: No recursion safety constraint
17//! - `r2` — R2: Resource bounds safety constraint
18//! - `r3` — R3: Core preservation safety constraint
19//! - `r4` — R4: Integrity (Signer trait)
20//! - `r5` — R5: Shape well-formedness (REQ-222)
21//! - `template` — Template expansion
22//! - `pattern` — Pattern matching for message dispatch
23//! - `msg_tag` — Deterministic message tagging (DCFL)
24//! - `shape` — Structural shape constraints (REQ-220)
25//! - `gossip` — Epidemic gossip protocol for dialect propagation
26//! - `keyid` — Canonical suite-typed key identity (SPEC-015 REQ-708)
27//! - `attest` — R4 v2 attestation signing discipline (SPEC-015 REQ-701, ADR-700)
28//! - `envelope` — Redacted envelopes: payload-free evidence widening (SPEC-015 REQ-700..703)
29//! - `equivocation` — Equivocation accountability: predicate, proof object, lint (SPEC-015 REQ-705..707)
30//! - `state` — State layer: the `(state …)` clause, kernel, fold, values (SPEC-019 R.1–R.3)
31//! - `r7` — R7: state-clause installation checks and state shape (SPEC-019 R.4)
32//! - `intend` — The intent binder (SPEC-019 R.5)
33
34#![forbid(unsafe_code)]
35#![cfg_attr(not(feature = "std"), no_std)]
36
37extern crate alloc;
38
39/// Crate version, taken from `Cargo.toml` at compile time.
40///
41/// Re-exported by downstream bindings (e.g. `cbcl-erl`'s `versions/0` NIF —
42/// SPEC-009 OBS-001) so callers can identify the exact `cbcl-core` build the
43/// runtime was linked against without parsing the workspace manifest.
44pub const VERSION: &str = env!("CARGO_PKG_VERSION");
45
46pub mod admission;
47pub mod agent;
48pub mod attest;
49pub mod blame;
50pub mod canonical;
51mod causal_kernel;
52pub mod certification;
53pub mod clock;
54pub mod dialect;
55pub mod envelope;
56pub mod equivocation;
57pub mod escrow;
58pub mod evaluator;
59pub mod gossip;
60pub mod intend;
61pub mod keyid;
62pub mod lattice;
63pub mod message;
64pub mod msg_tag;
65pub mod multikey;
66pub mod pattern;
67pub mod policy;
68pub mod projection;
69pub mod protocol;
70pub mod r1;
71pub mod r2;
72pub mod r3;
73pub mod r4;
74pub mod r5;
75pub mod r6;
76pub mod r7;
77mod repeat;
78pub mod role;
79pub mod serializer;
80pub mod sexpr;
81pub mod shape;
82pub mod splice;
83pub mod state;
84pub mod store;
85pub mod template;
86pub mod typed_addr;
87
88/// Prelude re-exporting the most-used types.
89pub mod prelude {
90    pub use crate::admission::{
91        AdmissionError, AdmissionEvent, AdmissionGate, AdmissionMonitor, AdmissionState,
92    };
93    pub use crate::agent::{Agent, AgentOutcome, MergePolicy};
94    pub use crate::blame::{BlameEntry, BlameParty, ViolationError, ViolationKind};
95    #[cfg(feature = "std")]
96    pub use crate::clock::SystemClock;
97    pub use crate::clock::{Clock, NoClock};
98    pub use crate::dialect::{
99        Dialect, DialectInstallError, DialectRegistry, PerformativeDef, ResourceBounds,
100    };
101    pub use crate::envelope::{parse_envelope, redact, EnvelopeParseError, RedactedEnvelope};
102    pub use crate::evaluator::{Effect, EvalError, EvalResult};
103    pub use crate::gossip::{GossipConfig, GossipNetwork, GossipStats, PropagationState, Topology};
104    pub use crate::intend::{intend, may_send, roles_of, Instance, Reject};
105    pub use crate::message::{
106        CausedBy, CorePerformative, Message, MessageParseError, MessageType, Performative,
107        WrapperType,
108    };
109    pub use crate::policy::{
110        apply_policy, DropReason, PendingEntry, PendingQueue, PendingReason, PolicyOutcome,
111        UnknownPredecessorPolicy,
112    };
113    pub use crate::protocol::{
114        verify_causal, CausalProtocol, CausalViolation, NodeRef, ProtocolViolation, StepDecl,
115        VerificationResult, BEGIN_KEYWORD,
116    };
117    pub use crate::r4::{R4Result, Signer};
118    pub use crate::r7::{r7_violations, verify_state_shape, R7Violation};
119    pub use crate::sexpr::{Atom, SExpr};
120    pub use crate::shape::{ShapeConstraint, ShapeRule, ShapeViolation, TypeConstraint};
121    pub use crate::state::{
122        fold, frontier, render_json, state_schema, Act, Entry, Rule, StateBounds, StateClause,
123        Value,
124    };
125    pub use crate::store::{
126        BundleVerificationError, CausalClosureBundle, ClosureError, ContentHash, HashIndex,
127        MergeResult, MessageStore, ThreadId, ThreadedMessageStore,
128    };
129}
130
131/// Consensus-free quorum-budget runtime.
132pub mod quorum;
133
134pub mod context;
135pub mod finite;
136mod freeze;
137/// Pure host-supplied hybrid logical clock evidence (SPEC-035).
138pub mod hlc;
139
140pub mod multihash;
141
142pub mod numeric;
143
144pub mod contracts;