Skip to main content

Crate distri_workflow

Crate distri_workflow 

Source
Expand description

distri-workflow — workflow engine for Distri.

Define multi-step workflows as data, execute them step by step, with support for sequential/parallel execution, conditions, agent runs, tool calls, and persistent state tracking.

§Architecture

Two layers, deliberately separated:

  • Definition — the workflow as a DAG of steps. Static template; no runtime state. (WorkflowDefinition, WorkflowStep).
  • Run — execution state for one invocation: status, shared context, per-step status / result / error / timestamps. (WorkflowRun, WorkflowStepRun).

Other key types:

  • StepRequirement — what a step needs to run (native skills, connections)
  • StepExecutor trait — executes a step (implement for your runtime)
  • WorkflowStateStore trait — persists WorkflowRuns (Redis, DB, in-memory)
  • WorkflowRunner — orchestrates execution with requirement checking

§Example

use distri_workflow::*;

let steps = vec![
    WorkflowStep::api_call("read", "Read document", "GET", "/api/docs/{id}")
        .with_requires(vec![
            StepRequirement::native("network"),
            StepRequirement::connection("google", "drive").with_permissions(vec!["drive.readonly"]),
        ]),
    WorkflowStep::tool_call("process", "Process data", "analyze_doc", serde_json::json!({"format": "markdown"})),
    WorkflowStep::script("test", "Run tests", "cargo test")
        .with_cwd("/project")
        .with_timeout(300),
];

let definition = WorkflowDefinition::new(steps);
let run = WorkflowRun::new(definition);

Re-exports§

pub use executor::EventSink;
pub use executor::NoopEventSink;
pub use executor::StepExecutor;
pub use executor::TracingEventSink;
pub use executor::WorkflowRunner;
pub use resolve::build_execution_context;
pub use resolve::evaluate_skip_condition;
pub use resolve::resolve_step_input;
pub use resolve::resolve_template;
pub use resolve::resolve_value;
pub use step_executions::InMemoryWorkflowStepExecutionStore;
pub use step_executions::WorkflowStepExecution;
pub use step_executions::WorkflowStepExecutionStore;
pub use step_executions::WorkflowStepExecutionUpdate;
pub use store::InMemoryStore;
pub use store::WorkflowStateStore;
pub use types::*;

Modules§

executor
Workflow executor — runs steps sequentially or in parallel.
resolve
Namespace resolution for workflow data flow.
step_executions
Per-step execution records — the storage sidecar to the cloud’s canonical Task system.
store
Workflow run storage trait.
types
Core types for the workflow engine.