Skip to main content

pureflow_core/
lib.rs

1//! Core traits and contracts for Pureflow.
2
3pub mod batch;
4pub mod capability;
5pub mod context;
6pub mod error;
7pub mod lifecycle;
8pub mod message;
9pub mod metadata;
10pub mod ports;
11
12use std::future::Future;
13
14pub use batch::{BatchExecutor, BatchInputs, BatchOutputs, WasmModule};
15use context::NodeContext;
16pub use context::{CancellationHandle, CancellationToken};
17pub use error::{
18    CancellationError, PureflowError, ErrorCode, ErrorVisibility, ExecutionError, LifecycleError,
19    MetadataError, RetryDisposition, ValidationError,
20};
21pub use message::PacketPayload;
22pub use metadata::{
23    DeadlockDiagnosticMetadata, ErrorDiagnosticMetadata, ErrorMetadataKind, ErrorMetadataRecord,
24    ExternalEffectMetadataKind, ExternalEffectMetadataRecord, JsonlMetadataSink,
25    MessageBoundaryKind, MessageBoundaryRecord, MetadataRecord, MetadataSink, MetadataTier,
26    NoopMetadataSink, TieredMetadataPolicy, TieredMetadataSink, metadata_record_to_json_value,
27};
28pub use ports::{
29    InputPortHandle, OutputPacketValidator, OutputPortHandle, PortPacket, PortRecvError,
30    PortSendError, PortSendPermit, PortsIn, PortsOut, bounded_edge_channel,
31};
32
33/// Shared result type for runtime-facing APIs.
34pub type Result<T> = std::result::Result<T, PureflowError>;
35
36/// Async node interface for the first runtime skeleton.
37///
38/// The trait matches the proposal's intended boundary shape early, but the
39/// `PortsIn` and `PortsOut` values remain Pureflow-owned adapters. Runtime
40/// beads can change the transport behind those handles without leaking raw
41/// async runtime primitives into every executor signature.
42pub trait NodeExecutor: Sync {
43    /// Future returned by one node execution attempt.
44    type RunFuture<'a>: Future<Output = Result<()>> + Send + 'a
45    where
46        Self: 'a;
47
48    /// Execute one runtime-managed node boundary.
49    ///
50    /// # Errors
51    ///
52    /// Returns an error if the node cannot complete the requested unit of
53    /// work.
54    fn run(&self, ctx: NodeContext, inputs: PortsIn, outputs: PortsOut) -> Self::RunFuture<'_>;
55}