Runic.Runner.PromiseBuilder (Runic v0.1.0-alpha.7)

Copy Markdown View Source

Analyzes workflow graphs to construct Promises from linear chain patterns.

Given a set of prepared runnables, identifies structural chains by following :flow edges forward from each runnable. A chain is a sequence of nodes where each has exactly one successor and each successor has exactly one predecessor via :flow edges.

The Promise captures the full chain's node hashes but only contains the currently-prepared head runnable. The resolve loop inside the Worker executes each step, applies it to a local workflow copy, prepares the next runnable in the chain, and continues.

Chain Exclusions

The following nodes are excluded from chains:

  • Join/FanIn nodes — they synchronize external inputs
  • Nodes with :meta_ref edges — they read mutable workflow state

Usage

{promises, standalone} = PromiseBuilder.build_promises(workflow, runnables)

Summary

Functions

Given a set of prepared runnables, identifies structural linear chains that can be batched into Promises.

Functions

build_promises(workflow, runnables, opts \\ [])

Given a set of prepared runnables, identifies structural linear chains that can be batched into Promises.

Returns {[Promise.t()], [Runnable.t()]} — promises + standalone runnables that could not be chained.

Options

  • :min_chain_length — minimum chain length to form a Promise (default: 2)