A prepared unit of work ready for execution.
Contains everything needed to execute independently of the source workflow. After execute/2, contains result and events for reducing back into workflow.
Three-Phase Execution Model
- Prepare - Extract minimal context from workflow, build a Runnable
- Execute - Run the node's work function in isolation (potentially parallel)
- Apply - Fold events back into the workflow via
apply_event/2
The Runnable struct is the carrier between these phases, holding:
- The node to invoke
- The input fact triggering invocation
- Minimal causal context (no full workflow reference)
- After execution: result, status, and events for reducing into workflow
Summary
Functions
Marks a runnable as completed with result and events.
Marks a runnable as completed with events and hook apply_fns.
Marks a runnable as failed with an error.
Creates a new Runnable in pending state.
Creates a new Runnable with explicit id.
Generates a stable runnable id from node and fact hashes.
Marks a runnable as skipped with events.
Types
@type status() :: :pending | :completed | :failed | :skipped
@type t() :: %Runic.Workflow.Runnable{ context: Runic.Workflow.CausalContext.t() | nil, error: term() | nil, events: [struct()] | nil, hook_apply_fns: [function()] | nil, id: integer() | nil, input_fact: Runic.Workflow.Fact.t(), node: struct(), result: term() | nil, status: status() }
Functions
Marks a runnable as completed with result and events.
Events are the list of event structs produced by Invokable.execute/2.
They will be folded into the workflow via apply_event/2 during the apply phase.
Marks a runnable as completed with events and hook apply_fns.
Marks a runnable as failed with an error.
@spec new(struct(), Runic.Workflow.Fact.t(), Runic.Workflow.CausalContext.t()) :: t()
Creates a new Runnable in pending state.
The id is a hash of {node.hash, fact.hash} for idempotency tracking.
@spec new( integer(), struct(), Runic.Workflow.Fact.t(), Runic.Workflow.CausalContext.t() ) :: t()
Creates a new Runnable with explicit id.
@spec runnable_id( struct(), Runic.Workflow.Fact.t() ) :: integer()
Generates a stable runnable id from node and fact hashes.
Marks a runnable as skipped with events.
The events (typically just ActivationConsumed) are folded during apply,
and downstream nodes are marked as :upstream_failed.