ccf_core/lib.rs
1//! # ccf-core
2//!
3//! Contextual Coherence Fields — earned relational trust for autonomous systems.
4//!
5//! Patent pending: US Provisional Application 63/988,438 (priority date 23 Feb 2026).
6//!
7//! ---
8//!
9//! ## This is not a behaviour system. It is a mathematical architecture.
10//!
11//! Three primitives combine to produce emergent social behaviour without a single
12//! line of behavioural code.
13//!
14//! **Context-keyed accumulators** — trust is not a single global value. Every distinct
15//! sensory environment has its own independent trust history. Bright-and-quiet is not
16//! the same as dark-and-loud, and the two histories never share state. A robot that
17//! trusts the living room starts at zero in the basement.
18//!
19//! **The minimum gate** — effective coherence requires agreement between two signals:
20//! what the system has *learned* (accumulated context trust) and what it is
21//! *experiencing right now* (the instant sensor reading).
22//! > "Both must be true, or I stay reserved."
23//!
24//! Familiar contexts buffer noise — a single bad moment cannot erase earned trust.
25//! Unfamiliar contexts demand proof before any expressiveness is permitted.
26//!
27//! **Graph min-cut boundary** — as contexts accumulate trust histories, the system
28//! builds a trust-weighted graph. Stoer-Wagner global min-cut finds the cheapest
29//! place to divide it into two clusters.
30//! > "This room feels different from that room."
31//!
32//! The comfort zone *emerges* from the topology — you do not configure a threshold.
33//!
34//! None of these produces social behaviour alone. Together they produce shyness,
35//! warmth, protectiveness, and earned fluency — without programming any of it.
36//!
37//! ---
38//!
39//! ## The pipeline
40//!
41//! ```text
42//! Sensors → ContextKey → CoherenceField → SocialPhase → Outputs
43//! ↑ ↑ ↑
44//! SensorVocabulary Personality PhaseSpace
45//! ↓
46//! MinCutBoundary (comfort zone)
47//! SinkhornKnopp (trust mixing)
48//! ```
49//!
50//! ## Module overview
51//!
52//! | Module | Key types | What it does |
53//! |--------|-----------|--------------|
54//! | [`vocabulary`] | [`SensorVocabulary`], [`ContextKey`] | Define your sensor space; hash + cosine similarity |
55//! | [`accumulator`] | [`CoherenceAccumulator`], [`CoherenceField`] | Per-context trust with earned floor and minimum gate |
56//! | [`phase`] | [`SocialPhase`], [`Personality`], [`PhaseSpace`] | Four-quadrant phase classifier with Schmitt trigger hysteresis |
57//! | [`boundary`] | [`MinCutBoundary`] | Stoer-Wagner comfort-zone boundary discovery |
58//! | [`sinkhorn`] | [`SinkhornKnopp`] | Doubly stochastic trust mixing |
59//! | [`mbot`] | [`mbot::MbotSensors`] | Reference 6-dimensional vocabulary for mBot2 ($50 hardware) |
60//! | [`seg`] | [`seg::CcfSegSnapshot`] | Serialisable field snapshot for persistence (requires `serde` feature) |
61//!
62//! ## Patent claim map
63//!
64//! | Type | Patent Claims | Description |
65//! |------|--------------|-------------|
66//! | [`SensorVocabulary`] | 1, 8 | Composite sensor context key trait |
67//! | [`ContextKey`] | 1, 8 | Discrete context identifier from quantised sensor signals |
68//! | [`CoherenceAccumulator`] | 2–5 | Per-context trust state with earned floor and asymmetric decay |
69//! | [`CoherenceField`] | 6–7, 13 | Trust field: context-keyed accumulator map with min-gate |
70//! | [`SocialPhase`] | 14–18 | Four-quadrant phase classifier with Schmitt trigger hysteresis |
71//! | [`SinkhornKnopp`] | 19–23 | Birkhoff polytope projector — doubly stochastic mixing matrix |
72//! | [`MinCutBoundary`] | 9–12 | Stoer-Wagner comfort-zone boundary discovery |
73//! | [`Personality`] | 3 (modulators) | Dynamic modulators: curiosity, startle sensitivity, recovery |
74//!
75//! ## `no_std`
76//!
77//! This crate is `#![no_std]` by default with no heap required. Enable the `std` feature
78//! for persistence helpers. Enable the `serde` feature for serialisation support
79//! (required for [`seg::CcfSegSnapshot`] and RVF persistence).
80//!
81//! ## License
82//!
83//! Business Source License 1.1. Free for evaluation and non-production use.
84//! Change date: 23 February 2032 — Apache License 2.0.
85//! Commercial production use requires a license from Flout Labs (cbyrne@floutlabs.com).
86
87#![no_std]
88#![deny(unsafe_code)]
89#![deny(missing_docs)]
90#![cfg_attr(docsrs, feature(doc_cfg))]
91
92// Pull in std when the feature is enabled (for persistence helpers, etc.)
93#[cfg(feature = "std")]
94extern crate std;
95
96// Placeholder modules — populated by Phase 9 stories #48–#52
97pub mod vocabulary; // #48: SensorVocabulary trait + ContextKey
98pub mod accumulator; // #49: CoherenceAccumulator + CoherenceField
99pub mod phase; // #49: SocialPhase + Personality
100pub mod sinkhorn; // #50: SinkhornKnopp projector
101pub mod boundary; // #51: MinCutBoundary / Stoer-Wagner
102pub mod mbot; // mBot2 reference vocabulary (MbotSensors, 6-dim)
103#[cfg(feature = "serde")]
104pub mod seg; // #53: CCF_SEG snapshot format