Skip to main content

omega_cognitive_kernel/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4
5use core::sync::atomic::{AtomicU32, Ordering};
6
7static UUID_SEQUENCE: AtomicU32 = AtomicU32::new(1);
8
9/// Generates process-local identifiers without requiring an OS random source.
10/// Host applications can replace this with an external identity source when
11/// globally unique IDs are required; the core only needs stable instance IDs.
12pub fn new_uuid() -> uuid::Uuid {
13    let sequence = UUID_SEQUENCE.fetch_add(1, Ordering::Relaxed) as u128;
14    uuid::Uuid::from_u128(0x4f4d_4547_412d_4b45_524e_454c_0000_0000u128 | sequence)
15}
16
17#[cfg(feature = "std")]
18pub fn now_utc() -> chrono::DateTime<chrono::Utc> {
19    chrono::Utc::now()
20}
21
22#[cfg(not(feature = "std"))]
23pub fn now_utc() -> chrono::DateTime<chrono::Utc> {
24    chrono::DateTime::<chrono::Utc>::UNIX_EPOCH
25}
26
27#[cfg(feature = "std")]
28pub fn now_utc_string() -> alloc::string::String {
29    now_utc().to_rfc3339()
30}
31
32#[cfg(not(feature = "std"))]
33pub fn now_utc_string() -> alloc::string::String {
34    "1970-01-01T00:00:00+00:00".into()
35}
36
37#[doc(hidden)]
38pub mod prelude {
39    pub use alloc::{
40        boxed::Box,
41        format,
42        string::{String, ToString},
43        vec,
44        vec::Vec,
45    };
46}
47
48#[cfg(feature = "std")]
49pub mod api;
50#[cfg(feature = "std")]
51pub mod audit;
52#[cfg(feature = "std")]
53pub mod checkpoint;
54#[cfg(feature = "std")]
55pub mod config;
56pub mod error;
57pub mod l0;
58pub mod l1;
59pub mod l2;
60pub mod memory;
61pub mod orchestrator;
62#[cfg(feature = "std")]
63pub mod persist;
64pub mod safety;
65#[cfg(feature = "std")]
66pub mod task;
67pub mod types;
68
69#[cfg(feature = "std")]
70pub use api::{
71    replay_trajectory_file, Kernel, KernelStatus, RunReport, TrajectoryReplayRow,
72    TrajectoryReplaySummary,
73};
74#[cfg(feature = "std")]
75pub use audit::{AuditEvent, AuditLog, AuditRecord, AuditSummary, KernelEvent};
76#[cfg(feature = "std")]
77pub use config::{InterventionLevel, InterventionMode, InterventionPolicy, KernelConfig};
78pub use error::{OmegaError, Result};
79pub use orchestrator::{OmegaOrchestrator, StepResult};
80#[cfg(feature = "std")]
81pub use persist::{KernelSnapshot, CURRENT_SCHEMA_VERSION, DEFAULT_STATE_PATH};
82#[cfg(feature = "std")]
83pub use task::{
84    run_bandit_task, run_l2_benchmark, run_l2_benchmark_scenario,
85    run_l2_benchmark_scenario_with_gate, BanditReport, L2BenchmarkAggregate, L2BenchmarkReport,
86};
87pub use types::*;
88
89// Public adapter surface — implement these to plug real world I/O into the kernel.
90pub use l0::decision::{ConstrainedDecisionMaker, DecisionMaker};
91pub use l0::executor::{Executor, SandboxedExecutor};
92#[cfg(feature = "std")]
93pub use l0::executor::{LoggingExecutor, ToolGateExecutor};
94#[cfg(feature = "std")]
95pub use l0::observer::{DirSnapshotObserver, FileObserver, HttpObserver};
96pub use l0::observer::{MultiModalObserver, Observer};
97pub use l0::predictor::{ModelBasedPredictor, Predictor};