Baton.Flow.Compiler (Baton v0.27.4)

Copy Markdown View Source

Compiles a portable definition into an executable Baton workflow.

Summary

Functions

Validate, load context, and compile a portable definition.

Functions

compile(definition, opts \\ [])

@spec compile(
  Baton.Flow.Definition.t(),
  keyword()
) :: {:ok, Baton.Flow.Compiled.t()} | {:error, term()}

Validate, load context, and compile a portable definition.

Options

  • :input — the run's input map, resolvable as $input bindings.
  • :definition_ref — an opaque host reference recorded in the snapshot.
  • :name — overrides the workflow name.
  • :context — a preloaded context map (skips the context provider).
  • :transport"live" or "batch": the default transport for every llm node that doesn't declare one, so a single definition serves an interactive run (no override) and a bulk overnight run ("batch") without a second copy. A node's own explicit "transport" always wins — that is how a flow pins, say, a cheap synthesis step live even in a batch run.
  • :poll_interval, :batch_deadline — seconds; defaults for nodes that end up batched and don't set their own. Tuning belongs to the run — a bulk runner that queues into a coalescer knows how much headroom the deadline needs; the definition doesn't.
  • :seed_steps%{step_name => result}: results supplied up front instead of computed by jobs. A dep naming a seeded step is satisfied at compile time, so a definition containing a single node — or only the suffix of a larger graph — compiles and runs with everything upstream seeded. Each seed is materialized as a real workflow_nodes row (seeded_at set, no Oban job) in the insert transaction, visible to $steps bindings, Baton.Results scans, and dependency gating exactly like a completed step. For a fanned-out upstream node, either seed the fan-in — the ordered list of expansion envelopes under the logical id, which is the shape dependents' bindings consume — or seed each expansion under its own name and group them with :seed_fan_in below.
  • :seed_fan_in%{logical_id => [seeded expansion name, ...]}: which seeded steps stand in for one fanned-out upstream node. Dependents declare a dep on the logical id and get both halves of what a real fan-out gives them — $steps.<logical_id> as the ordered fan-in list, and one result per expansion under its own step name, which is what a result-scanning consumer (Baton.Results.get_all_results/1) reads. Seed the fan-in list under the logical id instead when only the bindings matter; use this when something downstream scans results by step name.
  • :debug — force per-workflow debug capture (workflow_debug_logs), independent of the global Baton.Debug setting. What Baton.new/1's debug: true does, exposed at the compile boundary.

The override is merged before validation, so everything the validator rejects about a transport — including "batch" on a sequential fan-out — still fails the compile. Both the flow snapshot and each job's args carry the merged config: what ran is what is recorded.