1#![forbid(unsafe_code)]
2#![warn(missing_docs)]
3#![cfg_attr(not(feature = "std"), no_std)]
4#![cfg_attr(feature = "std", doc = include_str!("../README.md"))]
5#![cfg_attr(
6 not(feature = "std"),
7 doc = "Core cognitive-kernel types and algorithms that can run without the Rust standard library. Enable the `std` feature for persistence, configuration files, and the product-facing `Kernel` API."
8)]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10
11extern crate alloc;
12
13use core::sync::atomic::{AtomicU32, Ordering};
14
15static UUID_SEQUENCE: AtomicU32 = AtomicU32::new(1);
16
17pub fn new_uuid() -> uuid::Uuid {
21 let sequence = UUID_SEQUENCE.fetch_add(1, Ordering::Relaxed) as u128;
22 uuid::Uuid::from_u128(0x4f4d_4547_412d_4b45_524e_454c_0000_0000u128 | sequence)
23}
24
25pub fn now_utc() -> crate::types::UtcTimestamp {
27 crate::types::UtcTimestamp::now()
28}
29
30#[cfg(feature = "std")]
32pub fn now_utc_string() -> alloc::string::String {
33 now_utc().to_rfc3339()
34}
35
36#[cfg(not(feature = "std"))]
37pub fn now_utc_string() -> alloc::string::String {
39 "1970-01-01T00:00:00+00:00".into()
40}
41
42#[doc(hidden)]
43pub mod prelude {
44 pub use alloc::{
45 boxed::Box,
46 format,
47 string::{String, ToString},
48 vec,
49 vec::Vec,
50 };
51}
52
53pub mod adaptive;
55#[cfg(feature = "std")]
56#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
57pub mod api;
58#[cfg(feature = "std")]
59#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
60pub mod audit;
61#[doc(hidden)]
62pub mod body;
63#[cfg(feature = "std")]
64#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
65pub mod checkpoint;
66#[cfg(feature = "std")]
67#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
68pub mod config;
69#[cfg(all(feature = "std", feature = "toml"))]
70#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "toml"))))]
71pub mod config_toml;
72#[doc(hidden)]
73pub mod critic;
74#[doc(hidden)]
75pub mod error;
76#[doc(hidden)]
77pub mod goals;
78#[doc(hidden)]
79pub mod introspect;
80pub mod l0;
82pub mod l1;
84pub mod l2;
86#[doc(hidden)]
87pub mod llm;
88pub mod memory;
90pub mod orchestrator;
92#[cfg(feature = "std")]
93#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
94pub mod persist;
95#[doc(hidden)]
96pub mod planning;
97#[cfg(feature = "std")]
98mod private_fs;
99#[doc(hidden)]
100pub mod reactor;
101pub mod safety;
103#[cfg(feature = "std")]
104#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
105pub mod task;
106pub mod types;
108
109pub use adaptive::{Bridge, Experience, Memory, Signal, SignalHandler, Training};
110#[cfg(feature = "std")]
111pub use api::{
112 replay_trajectory_file, Kernel, KernelMetricsSnapshot, KernelStatus, RunReport,
113 TrajectoryReplayRow, TrajectoryReplaySummary, DEFAULT_MAX_TRAJECTORY_BYTES,
114};
115#[cfg(feature = "std")]
116pub use audit::{AuditEvent, AuditLog, AuditRecord, AuditSummary, KernelEvent};
117#[cfg(feature = "std")]
118pub use config::{
119 InterventionLevel, InterventionMode, InterventionPolicy, KernelConfig, L2Config, PrivacyConfig,
120};
121pub use critic::{Critic, ReflectionReport, RewardSignal, TrialBudget};
122pub use error::{OmegaError, Result};
123pub use orchestrator::{OmegaOrchestrator, StepResult};
124#[cfg(all(feature = "std", feature = "async"))]
125#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "async"))))]
126pub use persist::AsyncStateStore;
127#[cfg(feature = "std")]
128pub use persist::{KernelSnapshot, CURRENT_SCHEMA_VERSION, DEFAULT_STATE_PATH};
129#[cfg(feature = "std")]
130pub use task::{
131 run_bandit_task, run_l1_l2_factorial_benchmark, run_l2_benchmark, run_l2_benchmark_scenario,
132 run_l2_benchmark_scenario_with_gate, run_l2_gain_matrix, BanditReport, FactorialArm,
133 FactorialBenchmarkReport, FactorialEffect, FactorialRun, L2BenchmarkAggregate,
134 L2BenchmarkReport, L2GainAssessment, L2GainMatrixReport, L2GainScenarioAssessment,
135 L2GainSeedSet, L2PairedRun, PairedMeanDifference, L2_GAIN_DEFAULT_EPISODES,
136 L2_GAIN_DEFAULT_RUNS, L2_GAIN_DEFAULT_STEPS, L2_GAIN_DISCOVERY_SEED, L2_GAIN_SCENARIOS,
137 L2_GAIN_VALIDATION_SEED,
138};
139pub use types::*;
140
141pub use body::{
143 BodyBus, BodyChannelInfo, BodyCommandProposal, BodyPacket, BodyPacketStatus, BodySummary,
144 ChannelKind,
145};
146pub use goals::{
147 GoalNode, GoalStatus, GoalTree, GoalTreeSummary, IntrinsicMotivation, IntrinsicSignal,
148};
149pub use introspect::{EntropyReport, EntropyWatchdog};
150pub use l0::bandit_decision::{BanditUcbDecisionMaker, BanditUcbSnapshot};
151pub use l0::decision::{ConstrainedDecisionMaker, DecisionMaker};
152#[cfg(feature = "async")]
153#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
154pub use l0::executor::{AsyncExecutor, AsyncExecutorAdapter, AsyncLoggingExecutor};
155pub use l0::executor::{Executor, SandboxedExecutor};
156#[cfg(feature = "std")]
157pub use l0::executor::{LoggingExecutor, ToolGateExecutor};
158pub use l0::hybrid_predictor::{HybridWorldModel, HybridWorldPredictor, TinyAttentionPredictor};
159#[cfg(feature = "async")]
160#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
161pub use l0::observer::{
162 AsyncDirSnapshotObserver, AsyncFileObserver, AsyncHttpObserver, AsyncObserver,
163 AsyncObserverAdapter,
164};
165#[cfg(feature = "std")]
166pub use l0::observer::{DirSnapshotObserver, FileObserver, HttpObserver};
167pub use l0::observer::{MultiModalObserver, Observer};
168pub use l0::predictor::{ModelBasedPredictor, Predictor};
169pub use l1::{L1SpectralReflector, SpectralBin, SpectralPatch};
170pub use l2::{
171 CognitiveRealm, KernelStepOutput, L2CognitiveGate, L2Decision, L2State, SpectralGateConfig,
172};
173pub use llm::{parse_suggestion_json, LlmBridge, LlmProposal, SchemaResult};
174pub use memory::{
175 export_weights, migrate_payload, squash_delta_history, verify_weights, WeightsPayload,
176 WEIGHTS_MAGIC, WEIGHTS_VERSION,
177};
178pub use planning::{Plan, PlanStep, ShortHorizonPlanner};
179pub use reactor::{PriorityReactor, ReactorTask};
180pub use safety::{ActionBoundary, AuthorizationToken, TokenBook};
181#[cfg(feature = "std")]
182pub use safety::{StorageLock, Vault};