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 management - [
codegen]: AST code generation from execution graphs - [
compile]: Compilation orchestration and rustc invocation - [
dependency_analysis]: Dependency resolution for child scenarios - [
paths]: File path utilities for scenarios and data