# `Runic.Runner.PromiseBuilder`
[🔗](https://github.com/zblanco/runic/blob/main/lib/runic/runner/promise_builder.ex#L1)

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)

# `build_promises`

```elixir
@spec build_promises(Runic.Workflow.t(), [Runic.Workflow.Runnable.t()], keyword()) ::
  {[Runic.Runner.Promise.t()], [Runic.Workflow.Runnable.t()]}
```

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)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
