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

Generates Ash policies from workflow step declarations.

Ensures workflow resources function by default when `Authorizer`
is present by injecting five layers of policies:

1. **AshOban bypass** — allows Oban-triggered actions (automatic steps,
   timeouts and `every` entities) to execute without an actor. Uses
   `AshOban.Checks.AshObanInteraction` which only matches when
   `context.private.ash_oban?` is true.

2. **Step-level policies** — for each manual step with a `policy` field,
   generates a policy scoped to that step's transition actions. For example:

       step :review do
         policy actor_attribute_equals(:role, :reviewer)
         transition :approve, to: :done
         transition :reject, to: :rejected
       end

   Generates:

       policy action([:approve, :reject]) do
         authorize_if {Ash.Policy.Check.ActorAttributeEquals, ...}
       end

3. **Signal policies** — for each `on_signal`, a policy scoped to its
   generated read and transition actions that authorizes
   `signal_in(signals_module, signal)`, since the listener runs as the
   emitting actor.

4. **Undo policy** — when the workflow declares `undo do policy ... end`, a
   policy scoped to the generated `:undo` action.

5. **Default allow** — a catch-all `authorize_if always()` scoped to workflow
   transition actions, automatic step actions, timeout actions, `every`
   actions, read actions, and user-defined create actions, so workflow
   initialization and background execution aren't blocked by other policies
   on the resource.

Skips all policy generation if `Authorizer` is not configured
on the resource.

# `after?`

# `after_compile?`

# `before?`

# `transform`

---

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