1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Workflow Module
//!
//! This module provides the core workflow/graph abstractions for MoFA.
//! Inspired by LangGraph, it provides a stateful graph-based workflow system
//! with support for:
//!
//! - **Reducer Pattern**: Configurable state update strategies (overwrite, append, merge, etc.)
//! - **Command Pattern**: Unified state updates and control flow
//! - **Send Pattern**: Dynamic edge creation for MapReduce scenarios
//! - **RemainingSteps**: Active recursion limit tracking
//!
//! # Architecture
//!
//! This module defines traits only (kernel layer). Concrete implementations
//! are provided in `mofa-foundation`.
//!
//! # Example
//!
//! ```rust,ignore
//! use mofa_kernel::workflow::{StateGraph, Command, RuntimeContext, START, END};
//!
//! // Define state
//! #[derive(Clone, Serialize, Deserialize)]
//! struct MyState {
//! messages: Vec<String>,
//! }
//!
//! impl GraphState for MyState {
//! // ... implementation
//! }
//!
//! // Build graph
//! let graph = StateGraphImpl::<MyState>::new("my_workflow")
//! .add_node("process", Box::new(ProcessNode))
//! .add_edge(START, "process")
//! .add_edge("process", END)
//! .compile()?;
//!
//! // Execute
//! let result = graph.invoke(initial_state, None).await?;
//! ```
// Re-export public API
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;