Repository navigation
v0.8.0
·
332 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
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.StaleRecordinstead of a silent, wrong write. Reload the record first, or use the struct the previous transition returned, and handleStaleRecordwherever 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 asAsh.DataLayer.Simple, nothing changes. entered_current_state_atis gone. Readstate_entered_atinstead, or filterhistory/1for rows wherefrom_state != to_state.- New:
skip_other_actors?onbelongs_to_actor, for anyone who hand-rolled actor capture around a non-Ash-resource actor. - New:
AshWorkflow.Info.transition_target/3and the generated:transition_targetscalculation, 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.StaleRecordinstead 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 andundofilter their update on the state attribute and on each attribute of the resource that a route of the loaded step reads, withis_nil/1for anilvalue. 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 throughacceptis 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 asAsh.DataLayer.Simple, nothing is pinned and transitions behave as before.AshWorkflow.Changes.RefuseStaleTransitiondoes the filtering. It shares the route reference collection of:transition_targetsthroughAshWorkflow.Routing.references/2. - Removed the
entered_current_state_atcalculation andAshWorkflow.Calculations.EnteredCurrentStateAt. The calculation existed because a repeating timeout resetstate_entered_aton each firing. Since 0.7.0 eacheverywrites its own<step>_<every>_last_fired_atcolumn, sostate_entered_atis 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 updatesstate_entered_atbut logs afrom_state == to_staterow, which the calculation skipped. It also readhistory/1once per record and could not be used as a timeoutfield. Readstate_entered_atinstead. To get the entry time the log attests to, filterhistory/1for rows wherefrom_state != to_state.
Added
skip_other_actors?onbelongs_to_actor.belongs_to_actor :user, MyApp.Accounts.User, skip_other_actors?: truerecordsnilfor an actor that is not aMyApp.Accounts.Userstruct, as it does for anilactor. 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, raisesAsh.Error.UnknownwhenAshWorkflow.Changes.RecordEventwrites its log row, and an actor of another resource has its primary key written to the actor foreign key. Both stay the default. Withundo same_actor? true,AshWorkflow.Undorefuses a skipped caller with:no_actor.AshWorkflow.Entities.TransitionLog.recorded_actor/2returns the actor a log row records.- A workflow resource with a
transition_lognow gets a publichas_many :transitionsrelationship to the log resource, added byAshWorkflow.Transformers.AddRelationships. Itsdestination_attributeis the log'sbelongs_toforeign key back to the workflow. A user-defined:transitionsrelationship takes precedence. AshWorkflow.Info.transition_target/3returns 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'swhenfails to evaluate. It raisesArgumentErrorfor 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 asAshWorkflow.Changes.ConditionalTransition, which now shares its route matching and input merge with it, so a preview and the transition cannot disagree.- A generated
:transition_targetscalculation 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 tonilwhen 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.AddCalculationsadds it withadd_new_calculation, so a user-defined:transition_targetstakes precedence.
Security
- Updated the locked
ashfrom 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.0constraint 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 setsconfig :ash, default_string_length_count:, so each demo now sets:codepoints, as this library's own config does.