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
53#[cfg(feature = "std")]
54#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
55pub mod api;
56#[cfg(feature = "std")]
57#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
58pub mod audit;
59#[doc(hidden)]
60pub mod body;
61#[cfg(feature = "std")]
62#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
63pub mod checkpoint;
64#[cfg(feature = "std")]
65#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
66pub mod config;
67#[cfg(all(feature = "std", feature = "toml"))]
68#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "toml"))))]
69pub mod config_toml;
70#[doc(hidden)]
71pub mod critic;
72#[doc(hidden)]
73pub mod error;
74#[doc(hidden)]
75pub mod goals;
76#[doc(hidden)]
77pub mod introspect;
78pub mod l0;
80pub mod l1;
82pub mod l2;
84#[doc(hidden)]
85pub mod llm;
86pub mod memory;
88pub mod orchestrator;
90#[cfg(feature = "std")]
91#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
92pub mod persist;
93#[doc(hidden)]
94pub mod planning;
95#[cfg(feature = "std")]
96mod private_fs;
97#[doc(hidden)]
98pub mod reactor;
99pub mod safety;
101#[cfg(feature = "std")]
102#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
103pub mod task;
104pub mod types;
106
107#[cfg(feature = "std")]
108pub use api::{
109 replay_trajectory_file, Kernel, KernelMetricsSnapshot, KernelStatus, RunReport,
110 TrajectoryReplayRow, TrajectoryReplaySummary, DEFAULT_MAX_TRAJECTORY_BYTES,
111};
112#[cfg(feature = "std")]
113pub use audit::{AuditEvent, AuditLog, AuditRecord, AuditSummary, KernelEvent};
114#[cfg(feature = "std")]
115pub use config::{
116 InterventionLevel, InterventionMode, InterventionPolicy, KernelConfig, L2Config, PrivacyConfig,
117};
118pub use critic::{Critic, ReflectionReport, RewardSignal, TrialBudget};
119pub use error::{OmegaError, Result};
120pub use orchestrator::{OmegaOrchestrator, StepResult};
121#[cfg(all(feature = "std", feature = "async"))]
122#[cfg_attr(docsrs, doc(cfg(all(feature = "std", feature = "async"))))]
123pub use persist::AsyncStateStore;
124#[cfg(feature = "std")]
125pub use persist::{KernelSnapshot, CURRENT_SCHEMA_VERSION, DEFAULT_STATE_PATH};
126#[cfg(feature = "std")]
127pub use task::{
128 run_bandit_task, run_l1_l2_factorial_benchmark, run_l2_benchmark, run_l2_benchmark_scenario,
129 run_l2_benchmark_scenario_with_gate, run_l2_gain_matrix, BanditReport, FactorialArm,
130 FactorialBenchmarkReport, FactorialEffect, FactorialRun, L2BenchmarkAggregate,
131 L2BenchmarkReport, L2GainAssessment, L2GainMatrixReport, L2GainScenarioAssessment,
132 L2GainSeedSet, L2PairedRun, PairedMeanDifference, L2_GAIN_DEFAULT_EPISODES,
133 L2_GAIN_DEFAULT_RUNS, L2_GAIN_DEFAULT_STEPS, L2_GAIN_DISCOVERY_SEED, L2_GAIN_SCENARIOS,
134 L2_GAIN_VALIDATION_SEED,
135};
136pub use types::*;
137
138pub use body::{
140 BodyBus, BodyChannelInfo, BodyCommandProposal, BodyPacket, BodyPacketStatus, BodySummary,
141 ChannelKind,
142};
143pub use goals::{
144 GoalNode, GoalStatus, GoalTree, GoalTreeSummary, IntrinsicMotivation, IntrinsicSignal,
145};
146pub use introspect::{EntropyReport, EntropyWatchdog};
147pub use l0::bandit_decision::{BanditUcbDecisionMaker, BanditUcbSnapshot};
148pub use l0::decision::{ConstrainedDecisionMaker, DecisionMaker};
149#[cfg(feature = "async")]
150#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
151pub use l0::executor::{AsyncExecutor, AsyncExecutorAdapter, AsyncLoggingExecutor};
152pub use l0::executor::{Executor, SandboxedExecutor};
153#[cfg(feature = "std")]
154pub use l0::executor::{LoggingExecutor, ToolGateExecutor};
155pub use l0::hybrid_predictor::{HybridWorldModel, HybridWorldPredictor, TinyAttentionPredictor};
156#[cfg(feature = "async")]
157#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
158pub use l0::observer::{
159 AsyncDirSnapshotObserver, AsyncFileObserver, AsyncHttpObserver, AsyncObserver,
160 AsyncObserverAdapter,
161};
162#[cfg(feature = "std")]
163pub use l0::observer::{DirSnapshotObserver, FileObserver, HttpObserver};
164pub use l0::observer::{MultiModalObserver, Observer};
165pub use l0::predictor::{ModelBasedPredictor, Predictor};
166pub use l1::{L1SpectralReflector, SpectralBin, SpectralPatch};
167pub use l2::{
168 CognitiveRealm, KernelStepOutput, L2CognitiveGate, L2Decision, L2State, SpectralGateConfig,
169};
170pub use llm::{parse_suggestion_json, LlmBridge, LlmProposal, SchemaResult};
171pub use memory::{
172 export_weights, migrate_payload, squash_delta_history, verify_weights, WeightsPayload,
173 WEIGHTS_MAGIC, WEIGHTS_VERSION,
174};
175pub use planning::{Plan, PlanStep, ShortHorizonPlanner};
176pub use reactor::{PriorityReactor, ReactorTask};
177pub use safety::{ActionBoundary, AuthorizationToken, TokenBook};
178#[cfg(feature = "std")]
179pub use safety::{StorageLock, Vault};