keelrun_core/lib.rs
1//! keel-core: the real Keel kernel, Tier 1 scope (architecture spec §4).
2//!
3//! One [`Engine`] per process runs every intercepted call through its
4//! target's layer chain — cache → rate → breaker → timeout → retry — driven
5//! by the shared typed policy model ([`keel_core_api::policy`]). Waits are
6//! real `tokio::time` sleeps: production sleeps wall-clock time, and the
7//! conformance harness runs under `start_paused` where the same sleeps
8//! advance virtual time deterministically. The engine passes the identical
9//! scenario corpus as `keel-core-stub` — that equivalence is the whole point
10//! of the conformance suite.
11//!
12//! Beyond the stub, the real engine:
13//! - enforces `timeout` with `tokio::time::timeout` around each attempt
14//! (a policy-layer timeout terminates as `KEEL-E011`)
15//! - applies schedule `jitter` (equal jitter: uniform in `[w/2, w]`)
16//! - is `&self`-concurrent: interior state behind a mutex, never held
17//! across an await
18//!
19//! Every call and attempt is also emitted as a `tracing` span
20//! (`keel.call` / `keel.attempt`, architecture spec §4.5), with breaker
21//! transitions and cache hits as debug events. Spans cost effectively
22//! nothing when no subscriber is active. Enabling the optional `otel`
23//! feature adds [`otel::init_otlp`] to export those spans over OTLP.
24//! Independently of tracing, the [`events`] sink streams a live NDJSON
25//! feed of attempts/backoffs/breaker transitions to `.keel/events/` (for
26//! `keel tail`), and mints the trace refs Tier 1 failure messages carry.
27//!
28//! Tier 2 durable flows ([`FlowManager`]) build on the Tier 1 engine and the
29//! [`keel_journal`] persistence layer; the FFI facade wraps this async surface
30//! (later slices) for the PyO3/napi bridges.
31
32mod engine;
33pub mod events;
34pub mod flow;
35mod journal_backend;
36mod metrics;
37#[cfg(feature = "otel")]
38pub mod otel;
39
40pub use engine::{DiscoveryRecorder, Engine};
41pub use flow::{FlowConfig, FlowDescriptor, FlowHandle, FlowManager};