# Baton v0.27.4 - Table of Contents

> DAG-based job workflows for Oban: dependency ordering, fan-out/fan-in (over a fixed collection or one computed mid-run), result passing, retry idempotency, and per-step LLM cost tracking — without Oban Pro.

## Pages

- [README](readme.md)
- [Changelog](changelog.md)

- Guides
  - [Getting Started](getting_started.md)
  - [Building a Workflow](building_a_workflow.md)
  - [Multi-Model Workflows](multi_model.md)
  - [Batch Mode](batch_mode.md)
  - [Running on Multiple Nodes](multi_node.md)
  - [The Flow Compiler](flow_compiler.md)

## Modules

- [Baton.Application](Baton.Application.md): Starts when the `:baton` dependency starts and attaches Baton's telemetry
handlers, so they are active whether or not the host installs `Baton.Plugin`.
- [Baton.Artifact](Baton.Artifact.md): A large step result spilled out of `workflow_nodes`.
- [Baton.Backoff](Baton.Backoff.md): A snooze-free view of a job's retry counters.
- [Baton.CompletionReporter](Baton.CompletionReporter.md): Event-driven backstop for the terminal `{:workflow_finished, _}` notification.
- [Baton.DebugLog](Baton.DebugLog.md): Schema for capturing full LLM request/response payloads per workflow step.
- [Baton.Dispatch](Baton.Dispatch.md): Wakes Oban producers immediately for queues that have newly-available jobs.
- [Baton.Expansion](Baton.Expansion.md): Mid-run fan-out: one running step turns a list it could not know at build
time into one job per item, then waits for them.
- [Baton.Flow.GuardRunner](Baton.Flow.GuardRunner.md): The host-side contract for a node's `guards` (see `Baton.Flow.NodeSpec`).
- [Baton.Flow.RequestAssembly](Baton.Flow.RequestAssembly.md): Assemble a generic llm node's provider request from its config and a runtime
environment — as a pure function, shared by execution and preview.
- [Baton.Flow.Workers.Expander](Baton.Flow.Workers.Expander.md): Runs a flow node whose fan-out collection is only knowable at run time.
- [Baton.Pricing.Default](Baton.Pricing.Default.md): A reference `Baton.Pricing` implementation with a small built-in price
table (USD per million tokens).
- [Baton.RateLimiter.Noop](Baton.RateLimiter.Noop.md): The default `Baton.RateLimiter`: reserves nothing, snoozes never. Wired
unless a host configures `config :baton, rate_limiter: MyModule`.

- [Baton.RescheduleReporter](Baton.RescheduleReporter.md): Wakes downstream steps the instant a step completes, instead of waiting for the
Stager.
- [Baton.ResultCache](Baton.ResultCache.md): Optional, node-local read cache for resolved (decoded) large step results.
- [Baton.ResultStore](Baton.ResultStore.md): Tiered storage for step results, with a pluggable large-payload backend.
- [Baton.ResultStore.Postgres](Baton.ResultStore.Postgres.md): Built-in `Baton.ResultStore` backend — stores large step results in the
`workflow_artifacts` table.
- [Baton.StepStat](Baton.StepStat.md): Ecto schema for per-step LLM usage stats.
- [Baton.WorkflowRun](Baton.WorkflowRun.md): Immutable authored and compiled flow snapshots for one Baton workflow execution.
- [Baton.WorkflowRuns](Baton.WorkflowRuns.md): Persistence and retrieval of portable-flow execution snapshots.

- Building Workflows
  - [Baton](Baton.md): Build and insert DAG-based Oban job workflows.
  - [Baton.MultiModel](Baton.MultiModel.md): Multi-model fan-out pattern for workflow steps.

- Portable Flows
  - [Baton.Flow](Baton.Flow.md): Declarative flows: describe a DAG once as a list of `Baton.Flow.Step`s, then
either **build** it into an executable Baton workflow or **project** it into a
node/edge graph for display. Single-sourcing the two means they can't drift.
  - [Baton.Flow.Action](Baton.Flow.Action.md): A host-owned, allow-listed domain operation invoked by an action flow node.
  - [Baton.Flow.Binding](Baton.Flow.Binding.md): Resolves portable flow bindings against a JSON-compatible runtime environment.
  - [Baton.Flow.Compiled](Baton.Flow.Compiled.md): The validated, context-loaded result of compiling a portable flow definition.
  - [Baton.Flow.Compiler](Baton.Flow.Compiler.md): Compiles a portable definition into an executable Baton workflow.
  - [Baton.Flow.ContextProvider](Baton.Flow.ContextProvider.md): Host contract for loading a flow's domain context from its portable input.
  - [Baton.Flow.Definition](Baton.Flow.Definition.md): The portable, versioned source representation of a Baton flow.
  - [Baton.Flow.FanOut](Baton.Flow.FanOut.md): Declares that one logical `Baton.Flow.Step` expands to one Baton node per item
in a collection drawn from the build subject.
  - [Baton.Flow.FanOutSpec](Baton.Flow.FanOutSpec.md): A JSON-compatible fan-out declaration.
  - [Baton.Flow.LLMAdapter](Baton.Flow.LLMAdapter.md): Host extension contract for portable LLM nodes that need domain preparation.
  - [Baton.Flow.NodeSpec](Baton.Flow.NodeSpec.md): A portable node in a serialized `Baton.Flow.Definition`.
  - [Baton.Flow.PromptResolver](Baton.Flow.PromptResolver.md): Host contract for resolving and rendering a portable prompt specification.
  - [Baton.Flow.Registry](Baton.Flow.Registry.md): Host allow-list for portable action and LLM-adapter keys.
  - [Baton.Flow.Step](Baton.Flow.Step.md): One declarative step in a `Baton.Flow`: the worker that runs it, its logical
dependencies, an optional `Baton.Flow.FanOut`, and an opaque `meta` bag.
  - [Baton.Flow.Validator](Baton.Flow.Validator.md): Validates portable flow definitions before compilation or execution.
  - [Baton.Flow.Workers.Action](Baton.Flow.Workers.Action.md): Generic worker that invokes an allow-listed host action.
  - [Baton.Flow.Workers.LLM](Baton.Flow.Workers.LLM.md): Generic LLM worker driven by a portable flow node specification.

- Execution
  - [Baton.Check](Baton.Check.md): Runtime dependency resolution for workflow jobs.
  - [Baton.LLMWorker](Baton.LLMWorker.md): Base module for workflow steps that call an LLM API.
  - [Baton.Results](Baton.Results.md): Pass structured results between workflow steps.
  - [Baton.Worker](Baton.Worker.md): Drop-in replacement for `Oban.Worker` with DAG dependency gating,
result passing, PubSub broadcasting, and retry idempotency.

- LLM Steps
  - [Baton.LLMClient](Baton.LLMClient.md): The contract between Baton and whatever actually talks to a model provider.
  - [Baton.LLMStep](Baton.LLMStep.md): A structured contract for LLM workflow steps: you describe the **request**
and how to **handle the decoded response** — the engine owns everything in
between.
  - [Baton.RateLimiter](Baton.RateLimiter.md): A pluggable pre-call gate for token throughput.

- Observability
  - [Baton.Debug](Baton.Debug.md): Capture and inspect full LLM context windows at each workflow step.
  - [Baton.Events](Baton.Events.md): PubSub broadcasting for workflow step lifecycle events.
  - [Baton.Query](Baton.Query.md): Read queries powering the Workflow LiveView dashboard.
  - [Baton.Stats](Baton.Stats.md): Record and query LLM usage statistics per workflow step.
  - [Baton.Telemetry](Baton.Telemetry.md): Telemetry is Baton's primary integration surface. The PubSub events and
LiveView dashboard are optional layers on top; everything observable is also
emitted as telemetry, so you can integrate without Phoenix.

- Infrastructure
  - [Baton.Config](Baton.Config.md): Runtime configuration and repo resolution.
  - [Baton.Migration](Baton.Migration.md): Installs and updates Baton's database schema.
  - [Baton.Plugin](Baton.Plugin.md): Oban plugin that keeps workflows healthy.
  - [Baton.Pricing](Baton.Pricing.md): Behaviour for computing the cost of an LLM call.
  - [Baton.Retention](Baton.Retention.md): Deletes Baton's own rows once the Oban job they belong to is gone.

- Internals
  - [Baton.Completion](Baton.Completion.md): Detects when a whole workflow has finished and announces it exactly once.
  - [Baton.DAG](Baton.DAG.md): Directed Acyclic Graph validation for workflow step definitions.
  - [Baton.Node](Baton.Node.md): A single step within a workflow DAG.
  - [Baton.Nodes](Baton.Nodes.md): All database access for `workflow_nodes`.
  - [Baton.Reschedule](Baton.Reschedule.md): Completion-triggered rescheduling of downstream workflow jobs.

