# `AshWorkflow.Transformers.AddActions`
[🔗](https://github.com/team-alembic/ash_workflow/blob/v0.12.0/lib/ash_workflow/transformers/add_actions.ex#L1)

Generates and modifies Ash actions based on workflow step declarations.

Adds or modifies the following actions on the resource:

- **Transition actions** (for manual steps) — one `:update` action per declared
  `transition` entity. Each includes:
  - `BuiltinChanges.transition_state(target)` to move the state
  - `AshWorkflow.Changes.RecordEvent` (`triggered_by: :manual`) to write through
    `state_entered_at` and append a log row if a `transition_log` is configured

- **Automatic step action injection** — for automatic steps, the user defines
  their own update action with business logic. This transformer finds that action
  by the step's `action` name and appends `transition_state` and
  `RecordEvent` (`triggered_by: :automatic`) changes to it. Raises at compile
  time if the action is not defined on the resource.

- **Timeout transition actions** — for timeouts with `transition_to`, generates
  a hidden update action named `__timeout_<step>_<name>` that transitions to the
  target state and records the event (`triggered_by: :timeout`).

- **`on_signal` handlers** — for each `on_signal`, a read action
  `:__signal_<step>_<signal>_read` that selects only records in the step, a
  transition action `:__signal_<step>_<signal>` (`triggered_by: :signal`) or `RecordEvent` on the
  handler's own `action`, and a `signals_in` listener joining them.

- **`every` action injection** — appends `AshWorkflow.Changes.RecordEvent`
  (`triggered_by: :timeout`, writing the `every`'s own last-fired column via
  `:every_field`, and its fire count via `:every_fires_field`) onto the
  action an `every` names, so each firing re-arms the interval and is logged
  the same way a timeout's firing is, without touching `state_entered_at`.

- **Stale-record refusal** — each transition action and the undo action
  also get `AshWorkflow.Changes.RefuseStaleTransition`, which filters the
  update on the values the transition decided from.

- **Undo action** — when the workflow declares an `undo` block, a single
  `:undo` update action that rewinds the record to the state before its most
  recent undoable state change. Not atomic: the target is only known after
  reading the transition log.

- **Primary read action** — if the workflow has automatic steps (which generate
  Oban triggers) and no primary read action is defined, generates one with
  keyset pagination enabled (required by ash_oban).

Also adds a resource-global `change RecordEvent, on: [:create]`
(`triggered_by: :initial`), since workflows are started through the user's
own create action rather than a generated one — there is no per-action call
site to inject into for that event.

# `after?`

# `after_compile?`

# `before?`

# `timeout_action_name`

Name of the hidden action a transition timeout performs.

Scoped by step so the same timeout name can be used on more than one step,
the way transition names can.

# `transform`

# `undo_action_name`

```elixir
@spec undo_action_name() :: atom()
```

Name of the generated undo action.

---

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