Expand description
Runtara Workflows - Workflow Compilation to Native Binaries
This crate compiles workflow definitions (DSL scenarios) into native Linux binaries. The compiled binaries are standalone executables that communicate with runtara-core via the SDK for durability, checkpointing, and signal handling.
§Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ Workflow Compilation Pipeline │
└─────────────────────────────────────────────────────────────────────────┘
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ DSL │ │ Rust │ │ Native │
│ Scenario │─────▶│ AST │─────▶│ Binary │
│ (JSON) │ │ (codegen) │ │ (rustc) │
└─────────────┘ └─────────────┘ └─────────────┘
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Dependency │ │ OCI Image │
│ Analysis │ │ (optional) │
└─────────────┘ └─────────────┘§Compilation Pipeline
- Parse: Load the DSL scenario from JSON
- Analyze Dependencies: Identify child scenarios and agent dependencies
- Generate AST: Convert the execution graph to Rust AST using
codegen - Write Source: Write generated Rust code to temp directory
- Invoke rustc: Compile with musl target for static linking
- Package: Optionally create OCI image for containerized execution
§Usage
ⓘ
use runtara_workflows::{compile_scenario, CompilationInput};
// Load scenario from JSON
let scenario: Scenario = serde_json::from_str(&json)?;
// Compile to native binary
let input = CompilationInput {
scenario: &scenario,
tenant_id: "tenant-1",
scenario_id: "scenario-1",
version: 1,
output_dir: PathBuf::from("./output"),
child_scenarios: vec![],
};
let result = compile_scenario(&input).await?;
println!("Binary at: {:?}", result.binary_path);§Important Notes
- This crate has NO database dependencies. Child workflows must be loaded by the caller and passed to compilation functions.
- Compilation requires
rustcandmusl-toolsto be installed. - The generated binary is statically linked for maximum portability.
§Modules
agents_library: Pre-compiled agents library managementcodegen: AST code generation from execution graphscompile: Compilation orchestration and rustc invocationdependency_analysis: Dependency resolution for child scenariospaths: File path utilities for scenarios and data
Re-exports§
pub use agents_library::NativeLibraryInfo;pub use agents_library::get_native_library;pub use agents_library::get_stdlib_name;pub use compile::ChildDependency;pub use compile::ChildScenarioInput;pub use compile::CompilationInput;pub use compile::NativeCompilationResult;pub use compile::compile_scenario;pub use compile::translate_scenario;pub use compile::workflow_has_side_effects;pub use dependency_analysis::DependencyGraph;pub use dependency_analysis::ScenarioReference;pub use validation::ValidationError;pub use validation::validate_workflow;
Modules§
- agents_
library - Pre-compiled agents library management. Native library management
- codegen
- AST code generation from execution graphs. Code generation modules for workflow compilation.
- compile
- Compilation orchestration and rustc invocation. Rustc-based scenario compilation to native binaries
- dependency_
analysis - Dependency analysis for child scenarios. Dependency analysis utilities for workflow compilation.
- paths
- File path utilities for scenarios and data.
- validation
- Workflow validation for security and correctness. Workflow validation for security and correctness.
Structs§
- Execution
Graph - The execution graph containing all steps and control flow
- Scenario
- Complete scenario definition
Functions§
- get_
data_ dir - Get the base data directory path from environment variable or default
- get_
scenario_ dir - Construct the scenario directory path
- get_
scenario_ json_ path - Construct the scenario JSON file path