All database access for workflow_nodes.
Centralizing node queries here keeps the engine modules (Check, Results,
Reschedule) free of Ecto and gives the library a single, testable data
layer. Every function resolves its repo at runtime via
Baton.Config.repo/0.
Results are stored wrapped as %{"value" => term} so that non-map results
(lists, scalars, strings) round-trip through the jsonb column. Callers always
receive the unwrapped value.
Summary
Functions
Step names in a workflow whose Oban job is currently completed.
Dependency states for the named steps in a workflow.
Load the node for a given Oban job id, or nil.
Bulk-insert node rows within an existing transaction.
The result this job stored on a previous attempt, for the idempotency guard.
The stored result of a specific step in a workflow.
Results for all of the given steps that have stored one, keyed by step name. Steps with no result yet are omitted.
The current Oban state of every step in a workflow.
Store (wrap) a step result on its node. Returns :ok or {:error, reason}.
Nodes that list completed_step as a dependency and whose job is currently
scheduled (i.e. snoozing). Returns %{id, deps} for the completion-triggered
reschedule to evaluate. Uses a native array membership test on deps.
Functions
Step names in a workflow whose Oban job is currently completed.
Dependency states for the named steps in a workflow.
LEFT JOINs to oban_jobs, so a dep whose job has been pruned comes back with
state: nil (detected as pruned by the caller) rather than vanishing.
Returns a list of %{name, state, attempted_at}.
@spec for_job(integer()) :: Baton.Node.t() | nil
Load the node for a given Oban job id, or nil.
@spec insert_all(module(), [map()]) :: {non_neg_integer(), nil}
Bulk-insert node rows within an existing transaction.
Takes the repo explicitly because this runs inside the same transaction as
the Oban job insert (see Baton.insert/2), where the repo is already
resolved.
The result this job stored on a previous attempt, for the idempotency guard.
Returns {:ok, value} or {:error, :no_result}. A missing node or a null
result both yield :no_result — both correctly mean "nothing cached".
The stored result of a specific step in a workflow.
Distinguishes a missing step (:not_found) from a step that exists but
hasn't stored a result yet (:no_result).
Results for all of the given steps that have stored one, keyed by step name. Steps with no result yet are omitted.
The current Oban state of every step in a workflow.
LEFT JOINs to oban_jobs, so a step whose job has been pruned comes back with
state: nil. Returns a list of %{name, state}. Used by
Baton.Completion to decide whether a workflow has fully settled.
Store (wrap) a step result on its node. Returns :ok or {:error, reason}.
Nodes that list completed_step as a dependency and whose job is currently
scheduled (i.e. snoozing). Returns %{id, deps} for the completion-triggered
reschedule to evaluate. Uses a native array membership test on deps.