Skip to content

Releases

v0.13.0

Choose a tag to compare

@github-actions github-actions released this 20 Nov 14:34
Immutable release. Only release title and notes can be modified.
a69596a

Added

  • Several initial steps. More than one step can set initial true. AshWorkflow.Transformers.AddStateMachine passes every initial step to the state machine's initial_states, and a create action starts a record in one with change transition_state(:step). A create that sets no state starts in the first initial step by declaration order. The reachability check in AshWorkflow.Verifiers.ValidateWorkflow starts from every initial step. A step reached only from a second initial step is no longer reported as unreachable. AshWorkflow.Info.initial_steps/1 and AshWorkflow.Entities.Step.find_initials/1 list the initial steps, and AshWorkflow.Info.workflow_graph/1, the charts and the Clarity overview mark each of them.
  • every can fire at a wall-clock time in the record's own time zone, instead of measuring an interval from its last fire. at ~T[09:00:00] names the local time, on [:mon, :tue, :wed, :thu, :fri] names the days, and time_zone :candidate_time_zone names the attribute holding the zone, or takes a literal such as "Australia/Sydney". A per-record zone is the case a global cron cannot express: two records in the same step fire at 09:00 in their own zones, at two different instants. AshWorkflow.Verifiers.ValidateEvery rejects an every declaring neither. Firing writes the same last_fired_field column, and until still bounds it against state_entered_at.
  • interval alongside at is a stride: how many local days must separate two fires. on says which days carry an occurrence and the stride says how many of them to skip, so interval {14, :days} with on [:mon] is 09:00 every second Monday. A stride must be given in :days, and counts local dates rather than elapsed duration — firing at 09:00 writes the last-fired column microseconds after 09:00, so a duration comparison would find the occurrence exactly one stride later ineligible by that margin and slip the fire a week.
  • AshWorkflow.WallClock computes the occurrences behind at. A local time daylight saving skipped still fires that day, at the instant the clock jumped to; a local time that happens twice fires on the first of the two. A missed occurrence fires late rather than being skipped. AshWorkflow.Scheduler.Precise arms its timers from it and AshWorkflow.Calculations.PendingDeadlines reports the next occurrence from it, so both run on any data layer. AshWorkflow.Scheduler.Oban asks the same question in SQL, with an AT TIME ZONE fragment reading the zone out of each row, so at under that scheduler needs a SQL data layer.
  • time_zone accepts an expression calculation as well as an attribute or a literal, which is how a record reads its zone off a related one: calculate :candidate_time_zone, :string, expr(candidate.time_zone). The calculation must be expression-based, since the zone is read from the trigger's filter — AshWorkflow.Verifiers.ValidateEvery rejects a module calculation, the same check AshWorkflow.Verifiers.ValidateTimeoutFields already applies to a timeout's field. AshWorkflow.Scheduler.Precise.Timeline and AshWorkflow.Calculations.PendingDeadlines load a calculated zone before reading it.
  • at needs a time zone database in the host application, such as config :elixir, :time_zone_database, Tz.TimeZoneDatabase. AshWorkflow.Verifiers.ValidateEvery checks a literal time_zone against it at compile time. A record holding a zone the database does not know arms nothing and reports no pending deadline, rather than raising.

Changed

  • The unreachable-step error names the initial step it searched from ("not reachable from the initial step :review") rather than "the first step".
  • AshWorkflow.Verifiers.ValidateWorkflow no longer raises "Only one step can have initial: true".
  • AshWorkflow.Verifiers.ValidateWorkflow rejects a create action whose transition_state names a step that is not initial. Before, the create failed at runtime.
  • AshWorkflow.Verifiers.ValidateWorkflow rejects an upserting create action that calls transition_state. ash_state_machine only lets an upsert move to a state that a transition declares for that action, and a workflow declares none for creates.
  • The unreachable-step error suggests initial true for an unreachable step that no other step leads into.

v0.12.0

Choose a tag to compare

@github-actions github-actions released this 06 Nov 14:51
Immutable release. Only release title and notes can be modified.
fafc3e3

Added

  • max_fires and backoff on every. max_fires stops an every after a number of fires in the current step visit. backoff grows the gap after each fire, taking a duration tuple or :exponential like retry's backoff, and both schedulers compute it from AshWorkflow.Entities.Retry.delay_ms/2. Either option adds a <step>_<every>_fires integer column, so run mix ash.codegen on AshPostgres. An every without them is unchanged.
  • mix ash_workflow.gen.approval adds an approval workflow to a resource: a sibling approval resource with pending, approved, rejected, cancelled and an optional overdue step, a decision resource, quorum routing, and policies that stop a requester approving their own request. Who may open a request and who may approve live in generated Checks.CanRequest and Checks.CanApprove modules, which deny everyone until the application fills them in. See the approval recipe.
  • mix ash_workflow.gen.expiry adds an expiry workflow to a resource: a sibling expiry resource with active, expired and an optional expiring step, whose deadlines read expires_at and move when the expiry is renewed. The subject gains has_one :expiry, an expired? calculation and a :set_expiry update action, which creates the subject's expiry or renews the one it has. A subject with no expiry never expires. The generated Changes.SetExpiry change does the same work on any other subject action, taking an expires_in: option such as {365, :day} where the action has no :expires_at argument. --default-expiry 365d adds that change to the subject's changes block for every create, which then fails until Checks.CanCreate lets the creating actor through. Who may create an expiry and who may renew one live in generated Checks.CanCreate and Checks.CanRenew modules, which deny everyone until the application fills them in. See the expiry recipe.
  • mix ash_workflow.gen.dormancy adds a dormancy workflow to a resource: a sibling dormancy resource with active, dormant and an optional archived step, driven by a last_activity_at that a record_activity action moves and a reactivate action resets. The subject gains has_one :dormancy, a dormant? calculation, and a change on its create actions that runs the generated Changes.StartDormancy, so each new subject starts its own dormancy. The generated Changes.RecordActivity records activity from whichever subject actions the application adds it to. Who may create a dormancy directly and who may reactivate one live in generated Checks.CanCreate and Checks.CanReactivate modules, which deny everyone until the application fills them in. See the dormancy recipe.
  • mix ash_workflow.gen.sync adds a sync workflow to a resource: a sibling sync resource with syncing, synced and failed steps, whose :push action is retried with --max-attempts and --backoff and moves back to syncing on a resync. The subject gains has_one :sync, a synced? calculation, and two changes in its changes block. Changes.StartSync starts a sync on every subject create. Changes.RequestSync stamps resync_requested_at on every subject update, or only when a --fields field changes, and a fire_at timeout on synced and failed resyncs on that stamp, so a request made during a push runs once the push settles. Who may create a sync directly and who may resync one by hand live in generated Checks.CanCreate and Checks.CanResync modules, which deny everyone until the application fills them in. See the sync recipe.
  • mix ash_workflow.gen.transition_log accepts a workflow resource generated earlier in the same Igniter run, before it has compiled, by reading its source. A resource on disk that fails to compile is still reported as an issue.
  • mix ash_workflow.gen.publication adds a publication workflow to a resource: a sibling publication resource with draft, scheduled, published and unpublished steps, which goes live at publish_at and, with --with-unpublish-at, comes down at unpublish_at. The subject gains has_one :publication and a published? calculation. Who may create a publication and who may schedule, publish and unpublish one live in generated Checks.CanCreate and Checks.CanPublish modules, which deny everyone until the application fills them in. See the publication recipe.
  • mix ash_workflow.gen.review adds a review workflow to a resource: a sibling review resource with in_review, changes_requested, approved, rejected and an optional overdue step, a decision resource that records each round, and policies that stop a requester reviewing their own work. A subject has at most one open review. Who may open a review and who may review live in generated Checks.CanRequest and Checks.CanReview modules, which deny everyone until the application fills them in. See the review recipe.
  • mix ash_workflow.gen.invitation adds an invitation workflow to a resource: a sibling invitation resource with sent, accepted, declined, revoked and expired steps, whose deadline reads expires_at and moves when the invitation is resent. Who may invite and who may accept live in generated Checks.CanInvite and Checks.CanAccept modules, which deny everyone until the application fills them in. See the invitation recipe.
  • mix ash_workflow.gen.verification adds a verification workflow to a resource: a sibling verification resource with submitted, verifying, needs_review, verified and rejected steps, whose automatic :verify action retries up to --max-attempts times before the verification moves to review. The subject gains has_many :verifications, has_one :latest_verification and a verified? calculation. Who may submit a verification and who may decide one in review live in generated Checks.CanSubmit and Checks.CanReview modules, which deny everyone until the application fills them in. See the verification recipe.
  • mix ash_workflow.gen.deletion adds a deletion workflow to a resource: a sibling deletion resource with requested, purging, purge_failed, restored and deleted steps. A grace period after requested_at moves a request to purging, which runs a :purge action with retries and moves to purge_failed when they run out. The subject gains has_one :deletion and a pending_deletion? calculation. What a purge erases lives in a generated Changes.Purge change, which fails every purge until the application fills it in. Who may request and who may restore live in generated Checks.CanRequest and Checks.CanRestore modules, which deny everyone until the application fills them in. See the deletion recipe.
  • mix ash_workflow.gen.acknowledgement adds an acknowledgement workflow to a resource: a sibling acknowledgement resource with pending, acknowledged and an optional overdue step, holding one request per person per subject, which only that person may acknowledge. Who may open a request lives in a generated Checks.CanRequest module, which denies everyone until the application fills it in. See the acknowledgement recipe.

Fixed

  • A create action that upserts onto an existing row no longer appends an :initial row to the transition log, emits the workflow's signals or calls AshWorkflow.Scheduler.notify_state_change/2. The row stays in the step it was in. AshWorkflow.Changes.RecordEvent skips all three when the returned record carries upsert_action: :update metadata, or upsert_skipped: true metadata from an upsert_condition that did not match. This covers Ash.create/2 and Ash.bulk_create/4. The [:ash_workflow, :transition] span still emits :stop, because its :start event fires before the data layer reports whether the row was inserted. Ash sets upsert_action on ETS and Mnesia from 3.29, which ash_workflow already requires. AshPostgres sets it from 2.10.0 on PostgreSQL 17 and later, and from 2.13.1 on every PostgreSQL version. With an older AshPostgres, an upsert onto an existing row is still logged.
  • Transition and timeout actions that AshWorkflow.Transformers.AddActions generates on a workflow resource with a pre_check_with identity now set require_atomic? false. Ash adds a before_action for such an identity, so the generated actions failed with MustBeAtomic. Those actions now run non-atomically on that resource.

v0.11.0

Choose a tag to compare

@github-actions github-actions released this 29 Oct 11:38
Immutable release. Only release title and notes can be modified.
63cfea4

Upgrading from 0.10.2

  • ash_workflow now depends on ash ~> 3.35, for Ash.Signals.

Added

  • Workflow signals. The new signals option on the workflow section names an Ash.Signals module, and emit declares a signal at four levels: the workflow (every state change), a step (on: :enter or on: :exit), a transition, and a timeout or every. AshWorkflow.Changes.RecordEvent emits each matching signal in its after_action hook, after the log row, with a payload of the workflow fields from_state, to_state, transition_name, triggered_by and occurred_at, the attributes that share a signal field's name, the emit's fields and its literal values. A failing listener fails the action and rolls it back. AshWorkflow.Transformers.AddActions declares each planned signal as a dynamic emit on the action, and AshWorkflow.Verifiers.ValidateSignals checks the names and phases. AshWorkflow.Info.signals/1, emits/1 and action_signals/2 read the configuration. A transition, timeout or every that contains an emit takes its options inside the do block. See the Signals guide.
  • Receiving signals with on_signal. A step can declare on_signal, which moves a record to transition_to, or runs an update action, when a signal from the workflow's signals module (or from) selects that record while it is in the step. filter selects records with ^signal(:field) templates, or read_action names a read action of the resource. AshWorkflow.Transformers.AddActions generates the :__signal_<step>_<signal>_read read action, the :__signal_<step>_<signal> transition action and a signals_in listener named :<step>_<signal>, and the log row records triggered_by: :signal. AshWorkflow.Transformers.AddPolicies authorizes the generated actions with signal_in/2. AshWorkflow.Verifiers.ValidateOnSignal checks the signal, its fields and the outcome, and a step whose only exits are on_signal handlers with transition_to is a wait state. Charts draw an on_signal edge with 📨. See the Signals guide.

v0.10.2

Choose a tag to compare

@github-actions github-actions released this 28 Oct 09:31
Immutable release. Only release title and notes can be modified.
c7b27e0

Upgrading from 0.10.1

  • Under AshWorkflow.Scheduler.Oban, an action that moves a record into an automatic step now inserts an Oban job. A test that runs such an action needs a repo connection checked out, even when the workflow resource uses the ETS data layer. With Oban's testing: :inline, the step's action now runs inside the action that moved the record.
  • A run_oban_trigger/1 change that queued an automatic step after a create or a transition is no longer needed. Leaving it in place queues no second job, because ash_oban's trigger worker is unique while a job is incomplete.

Added

  • A Workflows lens for Clarity. With Clarity installed, AshWorkflow.Clarity.Lensmaker adds a Workflows lens that lists each workflow resource with its steps. AshWorkflow.Clarity.Introspector adds an AshWorkflow.Clarity.Vertex.Step for each step. A workflow resource gets Workflow Overview, Workflow Diagram and Workflow Timing tabs, and a step gets Step Overview, Step Diagram and Step Timeline tabs. The timing tabs place each automatic action, retry attempt, timeout, every firing and undo window at its offset from entering the step, and say how long a record can stay in each step. Clarity is an optional dependency, so a project without it compiles none of these modules.
  • An :actor option for AshWorkflow.Scheduler.Oban. The value becomes each generated trigger's default_actor. A cron-fired scheduler has no caller and read with a nil actor, so on a resource whose read policy needs an actor it matched no rows and the workflow never advanced. With scheduler {AshWorkflow.Scheduler.Oban, actor: ...} the scheduler reads as that actor, and the worker runs the step's or timeout's action as it when the job stored no actor. See issue #150.

Fixed

  • AshWorkflow.Scheduler.Oban runs an automatic step as soon as a record enters it, as AshWorkflow.Scheduler.Precise already did. Before, the record waited for the trigger's next check_interval, because AshWorkflow.Scheduler.notify_state_change/1 called only deadline_changed/2 and cancel/2, and the Oban scheduler implements neither. notify_state_change/2 now also calls the new optional AshWorkflow.Scheduler.step_entered/2 callback when AshWorkflow.Changes.RecordEvent reports that the record entered its step. AshWorkflow.Scheduler.Oban.step_entered/2 queues the step's trigger with AshOban.run_trigger/3. A step whose action routes the record back into the same step does not count as entering it, so that record still waits for the poll. An action timeout and an every do not count either. The queued job carries no actor, the same as a job the poll queues. A transition declared directly in the state_machine block does not run RecordEvent, so a record it moves into an automatic step still waits for the poll.
  • AshWorkflow.Scheduler.Precise arms a timeout whose fire_at or field names an expression calculation as soon as a record enters the step. AshWorkflow.Scheduler.notify_state_change/1 handed deadline_changed/2 the record without that calculation loaded, so AshWorkflow.Scheduler.due_at/2 returned nil, no timer was armed, and only the recovery sweep caught the deadline, up to look_ahead_ms late. notify_state_change/1 now loads the calculations returned by the new AshWorkflow.Scheduler.Work.deadline_loads/1 before calling deadline_changed/2. AshWorkflow.Scheduler.Oban was not affected, because its trigger evaluates the calculation in the where clause.

Security

  • The development lock now resolves ash 3.37.2, ash_postgres 2.15.2 and plug_crypto 2.2.1, which fix the advisories mix hex.audit reported against ash 3.34.6 (EEF-CVE-2026-96581, EEF-CVE-2026-114214), ash_postgres 2.13.1 (EEF-CVE-2026-115627, EEF-CVE-2026-115635) and plug_crypto 2.2.0 (EEF-CVE-2026-105963). The ash ~> 3.0 requirement in mix.exs is unchanged, so applications pick their own versions. Upgrade them in your own lock to get the fixes.

v0.10.1

Choose a tag to compare

@github-actions github-actions released this 19 Oct 08:09
Immutable release. Only release title and notes can be modified.
3225ff2

Upgrading from 0.10.0

  • A conditional route that reads a related field, a calculation or an aggregate now loads it when the transition runs. A route that relied on an unloaded relationship reading as nil, such as is_nil(sponsor.name), now sees the real value. A route on a relationship the caller had already loaded now reads the current value, not the loaded copy. AshWorkflow.Info.transition_target/3 still loads nothing.

Fixed

  • A transition whose action the resource declares without accept no longer crashes AshWorkflow.Transformers.AddActions with nil ++ []. The action keeps Ash's default_accept unless the transition accepts attributes of its own.
  • A conditional route that references a calculation, an aggregate or a related field now reads its current value. AshWorkflow.Changes.ConditionalTransition loads those fields before evaluating routes, as the :transition_targets calculation already did. The action used to read them off the record it was called on, so an unloaded field read as nil and no route matched. A route over a relationship the caller had already loaded now reads the current value rather than the loaded copy.

v0.10.0

Choose a tag to compare

@github-actions github-actions released this 18 Oct 11:18
Immutable release. Only release title and notes can be modified.
77728b9

Upgrading from 0.9.x

  • Generate a migration. Each action timeout (a timeout with action and no transition_to) adds a nilable <step>_<timeout>_fired_at column. On AshPostgres, run mix ash.codegen after upgrading.
  • A record whose action timeout already fired before the upgrade has a nil column, so that timeout fires once more for it after the upgrade.

Added

  • A generated :workflow_terminated_at calculation returns state_entered_at while a record is in a terminal step, and nil while the workflow is still running. A terminal step has no outgoing transitions, so the time the record entered it is the time the workflow ended, and no new attribute or migration is needed. The calculation is an expression, so it filters and sorts in the data layer: Ash.Query.filter(workflow_terminated_at > ago(7, :day)). The new terminated_at_calculation option on the workflow section renames it, for a resource that already has a field by that name. AshWorkflow.Transformers.AddCalculations adds it with add_new_calculation, so a user-defined calculation with the configured name takes precedence. (#120)

Fixed

  • An action timeout fires once for each deadline under both schedulers. AshWorkflow.Scheduler.Precise fired a due action timeout in a loop: firing left the record matching, AshWorkflow.Changes.RecordEvent rearmed it, and run_due/2 never returned 0. AshWorkflow.Scheduler.Oban relied on trigger_once?, so the completed job row was the only record of a firing. Pruning the row fired the timeout again, keeping it stopped a second visit to the step from firing, and a fire_at timeout whose action moved its own field later never fired a second time. Each action timeout now writes its own <step>_<timeout>_fired_at column (AshWorkflow.Entities.Timeout.fired_field/2) when it fires, and AshWorkflow.Scheduler.Work.not_fired/1 adds is_nil(fired_at) or fired_at < deadline to the timeout's match. The timeout fires again once its deadline moves past the column. A new visit to the step and a later fire_at value both do that. AshWorkflow.Scheduler.Work replaces once? with fired_field, the generated Oban trigger no longer sets trigger_once?, and pending_deadlines omits an action timeout that has fired for its current deadline. AshWorkflow.Verifiers.ValidateTimeoutFiredFields rejects a fired column that names an existing non-datetime attribute, and two timeouts, or a timeout and an every, that resolve to the same column. (#106)
  • The exported locals_without_parens now includes last_fired_field. A project with import_deps: [:ash_workflow] in its .formatter.exs had mix format rewrite last_fired_field :reminder_fired_at as last_fired_field(:reminder_fired_at). (#120)

v0.9.0

Choose a tag to compare

@github-actions github-actions released this 17 Oct 19:47
Immutable release. Only release title and notes can be modified.
5ac4d33

Upgrading from 0.8.x

  • ash_workflow now depends on jason ~> 1.4, for the :json chart backend.

Added

  • Workflow diagrams. AshWorkflow.Charts draws a workflow from its DSL. AshWorkflow.Charts.mermaid_state_diagram/2 returns a Mermaid stateDiagram-v2 that marks each step as automatic, manual, wait state or terminal. It labels a timeout with its name and its deadline (⏱ auto_escalate after 4 hours, ⏱ go_live at publish_at) and gives each conditional route its when expression. It notes a step's policy through the check's own describe/1, its retry, the timeouts that run an action and its every entries. It draws each undo move that AshWorkflow.Info.undoable_edges/1 allows, with the undo window when within is set (↶ undo within 1 hour). AshWorkflow.Charts.render/3 takes :mermaid, :json or any module that implements AshWorkflow.Charts.Backend. Every format draws from one AshWorkflow.Charts.Graph, so all formats show the same workflow. :json gives that graph as plain data, for a client that draws the workflow itself. mix ash_workflow.diagram prints a diagram, or with --output writes one file for each workflow resource in the project's domains. The Diagrams guide shows four small workflows from examples/basic with their charts, and both the definitions and the charts are generated from the code: bin/update-chart-examples rewrites them, and test/documentation_charts_test.exs fails when one is stale. (#16)
  • Graphviz DOT diagrams. AshWorkflow.Charts.render(resource, :dot) and mix ash_workflow.diagram --format dot give a Graphviz DOT chart of a workflow. It shows the same steps, edges and labels as the Mermaid chart, with colour and line styles. It takes its colours from AshWorkflow.Charts.Palette.
    • svg: true, or --svg, runs dot from the PATH and returns the SVG. You install Graphviz. :path under config :ash_workflow, :dot selects another dot, for example in a release. Without a dot, svg: true raises an ArgumentError that says to install Graphviz.
    • Colour follows the graph: blue automatic steps, amber manual steps and lavender wait states. A terminal step is green, red, amber or grey by the kinds of edges that reach it. on_success is a thick line, a timeout is dashed, and undo is dotted with a hollow arrowhead.
    • theme: :dark, or --theme dark, gives a dark chart. With --output, a dark chart goes to a file such as MyApp.Candidate-dark.svg, beside the light file.
    • classes: changes the colours and line styles of the step kinds, the terminal steps, and the on_success, on_error, timeout and undo edges. Transitions, the start circle and the background have no class. A key is a Graphviz attribute name, such as fillcolor or penwidth: a node attribute for a step class, and an edge attribute for an edge class. classes: [light: [...], dark: [...]] gives each theme its own colours. classes: and theme: can also go under config :ash_workflow, :dot.
    • The chart puts a step's notes inside the step. direction: :right turns the chart on its side.

v0.8.0

Choose a tag to compare

@github-actions github-actions released this 30 Sep 14:51
Immutable release. Only release title and notes can be modified.
fd1dce1

Upgrading from 0.7.x

  • A stale transition now fails. Code that transitions a struct it loaded before the record changed — a second transition on the struct the first was called on, or a record held in a LiveView assign since mount — gets Ash.Error.Changes.StaleRecord instead of a silent, wrong write. Reload the record first, or use the struct the previous transition returned, and handle StaleRecord wherever a user can act on a page that has gone stale (show "this changed, refresh"). There is no option to turn it off. On a data layer that cannot filter an update, such as Ash.DataLayer.Simple, nothing changes.
  • entered_current_state_at is gone. Read state_entered_at instead, or filter history/1 for rows where from_state != to_state.
  • New: skip_other_actors? on belongs_to_actor, for anyone who hand-rolled actor capture around a non-Ash-resource actor.
  • New: AshWorkflow.Info.transition_target/3 and the generated :transition_targets calculation, for anyone who copied route matching to preview where a transition goes.

Breaking

  • A transition built from a stale record now fails with Ash.Error.Changes.StaleRecord instead of writing. A transition decides from the record it is called on whether it is legal and where it goes, then writes by primary key. Before this, a transition from a stale copy ran from a step the record had left, routed on values that had since changed, or overwrote a concurrent transition, all silently. Now every manual transition and undo filter their update on the state attribute and on each attribute of the resource that a route of the loaded step reads, with is_nil/1 for a nil value. The row is left as it was, on the atomic and non-atomic update paths. There is no option to turn this off. Code that transitions a struct it loaded before the record changed, such as a second transition on the struct the first was called on, must reload it first. An attribute the call supplies through accept is not pinned, and neither are references through a relationship, calculations or aggregates. A change to an attribute no route reads does not make a copy stale. Automatic step actions, timeouts and error paths are not covered, since the scheduler reads the record just before it runs them. On a data layer that cannot filter an update, such as Ash.DataLayer.Simple, nothing is pinned and transitions behave as before. AshWorkflow.Changes.RefuseStaleTransition does the filtering. It shares the route reference collection of :transition_targets through AshWorkflow.Routing.references/2.
  • Removed the entered_current_state_at calculation and AshWorkflow.Calculations.EnteredCurrentStateAt. The calculation existed because a repeating timeout reset state_entered_at on each firing. Since 0.7.0 each every writes its own <step>_<every>_last_fired_at column, so state_entered_at is written only on a genuine step entry and the two agree. Where they still differed, the calculation was wrong: a transition into the step the record is already in updates state_entered_at but logs a from_state == to_state row, which the calculation skipped. It also read history/1 once per record and could not be used as a timeout field. Read state_entered_at instead. To get the entry time the log attests to, filter history/1 for rows where from_state != to_state.

Added

  • skip_other_actors? on belongs_to_actor. belongs_to_actor :user, MyApp.Accounts.User, skip_other_actors?: true records nil for an actor that is not a MyApp.Accounts.User struct, as it does for a nil actor. Without it, an action run as a plain-struct actor that is not an Ash resource, such as a system actor for an AshOban run or an internal side effect, raises Ash.Error.Unknown when AshWorkflow.Changes.RecordEvent writes its log row, and an actor of another resource has its primary key written to the actor foreign key. Both stay the default. With undo same_actor? true, AshWorkflow.Undo refuses a skipped caller with :no_actor. AshWorkflow.Entities.TransitionLog.recorded_actor/2 returns the actor a log row records.
  • A workflow resource with a transition_log now gets a public has_many :transitions relationship to the log resource, added by AshWorkflow.Transformers.AddRelationships. Its destination_attribute is the log's belongs_to foreign key back to the workflow. A user-defined :transitions relationship takes precedence.
  • AshWorkflow.Info.transition_target/3 returns the step a transition would move a record to, without running it. It returns {:ok, step}, {:ok, nil} when the record's current step does not declare the transition or no route matches, and {:error, error} when a route's when fails to evaluate. It raises ArgumentError for a name no step declares. A route that reads accepted input sees it only when the transition runs, so the function takes an optional input map and applies the keys the transition accepts. It resolves routes through the same code as AshWorkflow.Changes.ConditionalTransition, which now shares its route matching and input merge with it, so a preview and the transition cannot disagree.
  • A generated :transition_targets calculation maps each transition of a record's current step to the step it would land in, such as %{advance: :compliance, reject: :rejected}. A transition maps to nil when no route matches or a route fails to evaluate, and a record at an automatic or terminal step gets an empty map. The map is not filtered by authorization. The calculation loads every field its routes reference, including fields on related resources. AshWorkflow.Transformers.AddCalculations adds it with add_new_calculation, so a user-defined :transition_targets takes precedence.

Security

  • Updated the locked ash from 3.33.5 to 3.33.11, which fixes EEF-CVE-2026-93477 (MEDIUM): private action arguments can be set by user input on the bulk update and bulk destroy paths. Introduced in 2.17.15 and fixed in 3.33.11. The ~> 3.0 constraint already allowed the fix; only the lockfile held the affected version. The demo lockfiles moved from 3.32.3 to the same version, with the packages ash requires. Ash 3.33.11 also refuses to compile a resource until the application sets config :ash, default_string_length_count:, so each demo now sets :codepoints, as this library's own config does.

v0.7.1

Choose a tag to compare

@github-actions github-actions released this 23 Sep 13:58
Immutable release. Only release title and notes can be modified.
72aa871

Fixed

  • AshWorkflow.Scheduler.Precise.Timeline's sweep now reads the attribute a workflow named with state_attribute. It built its step predicate as state == ^step, so a workflow keeping its state anywhere other than state matched no records: a deadline nothing had armed was never recovered, and one inside the horizon was never armed. Timeline.deadline_changed/2 was unaffected, since it arms from AshWorkflow.Scheduler.Work.match, which AshWorkflow.Transformers.AddScheduler has always built through the named attribute. The sweep rebuilds that predicate rather than reusing match so the horizon's bound reaches the data layer as a bind parameter, and it now builds it from AshWorkflow.Info.state_attribute/1.

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 22 Sep 16:42
Immutable release. Only release title and notes can be modified.
f6bac53

Upgrading from 0.6.x

  • Rewrite every repeating timeout as an every. timeout :nudge, fire_after: {1, :day}, action: :send_nudge, repeat: true becomes every :nudge, {1, :day}, action: :send_nudge. The repeat option no longer compiles.
  • Run mix ash.codegen add_every_last_fired_columns and migrate. AshWorkflow.Transformers.AddAttributes now adds one column per every, and AshWorkflow.Transformers.AddIndexes a (state, column) index for each, so a resource that declares an every fails on insert until the migration runs.
  • Drop state_entered_at from any action's accept list. It is writable?: false, and a caller that genuinely needs to set it uses Ash.Changeset.force_change_attribute/3.

Added

  • every, a sibling entity to timeout. Declares a recurring action that runs on an interval for as long as a record sits in its step: every :nudge, {1, :day}, action: :send_reminder or the block form with interval, action, check_interval, self_scheduled?, last_fired_field and a nested retry. Unlike timeout, every always requires action, has no transition_to and no field. It measures interval against its own nilable :utc_datetime_usec attribute, one per every, named <step>_<every>_last_fired_at by default or explicitly with last_fired_field — not state_entered_at, and not field, which names an anchor AshWorkflow reads and never writes. AshWorkflow.Changes.RecordEvent writes that column on every fire via its :every_field option, so two every entities on the same step, or an every and a timeout, no longer share (and reset) one anchor. A record whose column is still nil (never fired) measures its interval from state_entered_at instead, so the first firing lands one whole interval after the record entered the step and an existing table needs no backfill. Both the generated Oban trigger and AshWorkflow.Scheduler.Precise.Timeline apply that fallback, as does AshWorkflow.Calculations.PendingDeadlines. AshWorkflow.Info.everys/2 reads the entities off a step. AshWorkflow.Info.recommended_indexes/1 covers each every's column with the same (state, field) composite index it gives a timeout.

  • fire_at on a timeout. Names a datetime attribute or expression calculation that already holds the deadline instant, rather than an anchor to measure an offset from: timeout :dormant do fire_at :next_check_at; transition_to :dormant_review end fires once next_check_at has passed, at whatever resolution the selected scheduler polls with. fire_at and fire_after are mutually exclusive and exactly one of them is required, and fire_at cannot be combined with field, which is the anchor fire_after measures from. AshWorkflow.Verifiers.ValidateTimeoutPrecision skips a fire_at timeout: it promises no duration, so there is no precision for the scheduler to miss. That replaces the fire_after: {1, :seconds} sentinel the verifier used to coach people towards, which handed it a number that meant nothing. AshWorkflow.Scheduler.Work's deadline map expresses both shapes, with a nil fire_after meaning the field holds the instant, and AshWorkflow.Scheduler.due_at/2 resolves either to a DateTime. AshWorkflow.Info.workflow_graph/1 carries fire_at, and AshWorkflow.Info.recommended_indexes/1 covers a fire_at field with the same (state, field) composite index it gives a field.

  • A bound on every with until. every fires forever by default; until stops it after a fixed amount of wall-clock time:

    every :reminder do
      interval {2, :days}
      action :send_review_reminder
      until {8, :days}
    end
    

    until is measured against state_entered_at directly, which an every's own firing no longer touches (see above). AshWorkflow.Verifiers.ValidateEvery rejects an until that is not strictly longer than interval, since anything shorter or equal leaves no room to fire even once. Both AshWorkflow.Scheduler.Oban and AshWorkflow.Scheduler.Precise honour the bound through the same Work.match expression every other check already goes through, and AshWorkflow.Scheduler.Precise.Timeline's recovery sweep filters on it too. Reaching the bound only stops the firing; compose a second, ordinary timeout with a fire_after equal to the bound for "give up and move on".

Changed

  • Breaking: state_entered_at is no longer writable through an action. AshWorkflow.Transformers.AddAttributes declares it writable?: false, so it cannot appear in an action's accept list and is rejected as action input. Every deadline on a step measures from this attribute, so a write from outside moved all of them at once, and a fire_after timeout could be pushed out of reach by an unrelated update. AshWorkflow.Changes.RecordEvent is unaffected: it writes the attribute with Ash.Changeset.force_change_attribute/3 and, on the atomic path, through the map atomic/3 returns, and neither goes through writable?. A caller that genuinely needs to set it, such as one backfilling imported records, uses force_change_attribute/3 or the data layer directly. A resource that defines its own state_entered_at keeps whatever it declared, since the transformer is a no-op there.

  • Breaking: timeout's repeat option is gone. Use every instead. repeat: true let a timeout re-fire on its own interval, but it also compiled two combinations that were meaningless: repeat: true with transition_to (firing leaves the step, so the repeat never comes round) and repeat: true with a custom field (rejected at compile time, since the repeat mechanism resets state_entered_at, not the custom field). every requiring action and offering neither transition_to nor field stops both from being representable at all. Change timeout :name, fire_after: ..., action: ..., repeat: true to every :name, interval: ..., action: .... AshWorkflow.Verifiers.ValidateTimeoutFields.validate_no_repeat_with_custom_field/2 and its tests are gone along with the option.

  • Breaking: AshWorkflow.Info.workflow_graph/1's :timeouts entries drop :repeat, and each step's map gains an :everys list of %{name:, interval:, action:, until:, retry:} maps, mirroring :timeouts.

Fixed

  • AshWorkflow.Scheduler.due_at/2 returns nil for a deadline field that is an unloaded calculation, rather than raising on the %Ash.NotLoaded{} struct it read. AshWorkflow.Scheduler.Precise.Timeline loads a calculation deadline field with the records it sweeps and re-reads before firing, so it arms the timer from a value rather than from nothing. That is the #70 failure mode under the Precise scheduler; a caller computing due_at/2 from a record of its own still has to load the calculation first.