Skip to content

v0.8.0

Choose a tag to compare

@github-actions github-actions released this 30 Sep 14:51
· 332 commits to main since this release
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.