Skip to main content

cognee_core/
lib.rs

1//! Core runtime primitives for the cognee pipeline.
2//!
3//! This crate provides:
4//!
5//! - [`AsyncRuntime`] — a thin wrapper around a Tokio [`tokio::runtime::Runtime`].
6//! - [`RayonThreadPool`] / [`CpuPool`] / [`CpuPoolExt`] — a Rayon-backed CPU thread pool
7//!   with an async interface for offloading CPU-intensive work from Tokio workers.
8//! - [`CancellationHandle`] / [`CancellationToken`] — cooperative task cancellation via
9//!   a `tokio::sync::watch` channel pair.
10//! - [`ProgressToken`] — a lock-free, clone-able progress counter.
11//! - [`TaskContext`] / [`TaskContextBuilder`] — a bundle of all runtime services
12//!   (thread pool, databases, cancellation, progress) passed into pipeline tasks.
13//! - [`Task`] / [`Pipeline`] — composable unit of work and ordered executor with
14//!   fan-out batching and retry support.
15
16pub mod cancellation;
17pub mod error;
18pub mod exec_status;
19pub mod pipeline;
20pub mod progress;
21pub mod provenance;
22pub mod rate_limiter;
23pub mod runtime;
24pub mod sentinels;
25pub mod task;
26pub mod task_context;
27pub mod thread_pool;
28
29#[cfg(feature = "pipeline-run-registry")]
30pub mod pipeline_run_registry;
31
32pub use cancellation::{CancellationHandle, CancellationToken, cancellation_pair};
33pub use error::CoreError;
34pub use exec_status::{ExecStatusManager, NoopExecStatusManager};
35pub use pipeline::{
36    DataIdFn, ExecutionError, NoopWatcher, Pipeline, PipelineBuilder, PipelineRunHandle,
37    PipelineRunInfo, PipelineRunResult, PipelineRunStatus, PipelineStatus, PipelineWatcher,
38    RetryDelay, RetryPolicy, TaskStatus, execute, execute_blocking, execute_in_background,
39};
40pub use progress::ProgressToken;
41pub use provenance::{
42    HasDataPoint, ProvenanceContext, extract_content_hash_from_value, extract_node_set_from_value,
43    stamp_tree, stamp_tree_dyn,
44};
45pub use rate_limiter::{RateLimiter, SemaphoreLimiter, TokenBucketLimiter};
46pub use runtime::AsyncRuntime;
47pub use sentinels::{DroppedSentinel, PassthroughSentinel, is_dropped, is_passthrough};
48pub use task::{
49    AsyncBatchFn, AsyncFn, AsyncStreamBatchFn, AsyncStreamFn, SyncBatchFn, SyncFn, SyncIterBatchFn,
50    SyncIterFn, Tagged, TaggedMeta, Task, TaskCall, TaskError, TaskInfo, TypedTask, Value,
51    ValueIter, ValueStream, downcast_value, extract_node_set,
52};
53pub use task_context::{PipelineContext, TaskContext, TaskContextBuilder};
54pub use thread_pool::{CpuPool, CpuPoolExt, RayonThreadPool};
55
56#[cfg(feature = "pipeline-run-registry")]
57pub use pipeline_run_registry::{
58    DbPipelineWatcher, DefaultPipelineRunRegistry, PipelineFuture, PipelineRunRegistry,
59    RegistryConfig, RegistryError, RunEvent, RunEventKind, RunHandle, RunOutcome, RunPhase,
60    RunSpec, ScopedRunWatcher,
61};
62
63// Re-export the repository trait from cognee-database for ergonomics.
64// This is unconditional — the trait costs nothing if unused.
65pub use cognee_database::PipelineRunRepository;