async-nodes 0.1.0

An asynchronous, type-safe node engine implementing the Bulk Synchronous Parallel (BSP) model: control-flow loops, recovery, suspension, and serializable graphs, with dataflow-once pipelines as a profile.
Documentation
//! `async-nodes` is a generic, type-safe execution engine implementing the Bulk
//! Synchronous Parallel (BSP) standard for **control-flow graphs with loops**, with the
//! classic dataflow-once pipelines expressed as a profile on the same core.
//!
//! # One core, two faces
//!
//! The engine core is control-flow with BSP superstep parallelism: nodes are
//! re-executable units over a consumer-owned state `S`, edges are *data* carrying
//! declarative [`Condition`]s, and activation is token-based (Kahn-style firing), which
//! makes loops first-class topology — a back-edge simply delivers another token.
//!
//! A **dataflow DAG is a control-flow graph in which each node fires exactly once, when
//! all its inputs are ready.** That profile (pins, links, `#[node]` macros, `BspSkip`
//! propagation, static inputs) keeps its guarantees — static analyzability, trivial
//! scheduling, no infinite loops by construction — without being a second engine.
//!
//! # The moving parts
//!
//! - [`BspGraph`] — the blueprint: nodes, [`graph::Edge`]s, static inputs, and the
//!   consumer's named-condition / merger registries. Author graphs with the fluent
//!   builder; exchange them as [`def::GraphDef`] JSON.
//! - [`BspEngine`] — the scheduler: frontier supersteps under `buffer_unordered`, bounded
//!   by `max_concurrency`; circuit breakers (`max_steps`, per-edge `max_iterations`,
//!   per-node `max_executions`, per-edge token caps); recovery policies; suspension.
//! - [`BspNode`] — the consumer's computation unit, generic over the consumer state `S`.
//! - [`NodeRegistry`] — node factories + named conditions + mergers, making graphs
//!   instantiable from JSON.
//! - [`BspInterceptor`] — the live event stream (supersteps, edges taken, loop
//!   iterations, retries, suspensions) a GUI subscribes to.
//!
//! # A loop, briefly
//!
//! ```text
//! entry ──▶ Generate ──[has_more]──▶ Tools ──[always]──▶ Generate   (back-edge, max_iterations = 30)
//!               │
//!               └──────[done]──────▶ next-node…
//! ```
//!
//! Joins inside loops are almost always [`Activation::Any`] or merger-joins: an
//! `All`-join on a cycle starves (one incoming edge fires once ever, the other once per
//! iteration) — see [`engine`] for the diagram, and expect a validation warning.

pub mod condition;
pub mod context;
pub mod def;
pub mod engine;
pub mod error;
pub mod events;
pub mod graph;
pub mod merge;
pub mod node;
pub mod recovery;
pub mod registry;
pub mod run;
pub mod value;

#[doc(inline)]
pub use condition::{Condition, ConditionEval, NamedConditionId};
#[doc(inline)]
pub use context::BspContext;
#[doc(inline)]
pub use def::{
    ActivationDef, ConditionDef, EdgeDef, GRAPH_DEF_VERSION, GraphDef, NodeDef, RecoveryDef,
    StaticInputDef,
};
#[doc(inline)]
pub use engine::{
    BranchTransform, BspEngine, DEFAULT_MAX_PENDING_TOKENS, DEFAULT_MAX_STEPS, ValidationReport,
};
#[doc(inline)]
pub use error::BspError;
#[cfg(feature = "tokio")]
#[doc(inline)]
pub use events::ChannelInterceptor;
#[doc(inline)]
pub use events::{BspEvent, BspInterceptor};
#[doc(inline)]
pub use graph::{
    BspGraph, ERROR_PORT, Edge, EdgeId, InputPin, NodeHandle, NodeId, OutputPin, PortIndex,
    TypedNodeHandle,
};
#[doc(inline)]
pub use merge::Merger;
#[doc(inline)]
pub use node::{Activation, BspNode, DataflowNode, NodeOutcome};
#[doc(inline)]
pub use recovery::{Recovery, RecoveryPolicy, RetryPolicy};
#[doc(inline)]
pub use registry::NodeRegistry;
#[doc(inline)]
pub use run::{
    EngineResult, PendingSuspension, RunContext, RunState, SuspendedExecution, ValueStore,
};
#[doc(inline)]
pub use value::{BspOutputMapExt, BspSkip, BspValue};

// Re-export proc-macros
pub use async_nodes_macros::{BspType, node, node_blocking};

// Hidden re-exports to provide macro hygiene in downstream projects
#[doc(hidden)]
pub use async_trait;
#[doc(hidden)]
pub use indexmap;

// Re-export typemap_rev to simplify implementation of TypeMapKey for users
pub use typemap_rev;

#[cfg(feature = "tokio-blocking")]
#[doc(hidden)]
pub use ::tokio;