Pure business logic for workflow transition decisions.
All functions are pure — no I/O, no side effects. Guards and side-effect dispatch rely on data maps, not concrete impls.
Pure business logic for workflow transition decisions. All functions are pure — no I/O, no side effects. Guards and side-effect dispatch rely on data maps, not concrete impls.
(allowed-transition-names definition current-state)Return the names of all transitions reachable from the current state.
Args: definition - WorkflowDefinition map current-state - keyword
Returns: Vector of keywords (transition :name or :to when :name absent)
Return the names of all transitions reachable from the current state. Args: definition - WorkflowDefinition map current-state - keyword Returns: Vector of keywords (transition :name or :to when :name absent)
(allowed-transitions definition current-state)Return all transition definitions reachable from the current state.
Args: definition - WorkflowDefinition map current-state - keyword
Returns: Vector of TransitionDef maps
Return all transition definitions reachable from the current state. Args: definition - WorkflowDefinition map current-state - keyword Returns: Vector of TransitionDef maps
(available-transitions-with-status definition
current-state
actor-roles
guard-registry
context)Return all transitions reachable from current-state, each annotated with :enabled? and, when disabled, a :reason keyword.
Runs the full can-transition? check (existence ✓, permissions, guard) for every reachable transition and returns a summary vector suitable for driving UI buttons or API responses.
Args: definition - WorkflowDefinition map current-state - keyword actor-roles - Collection of keywords (may be nil) guard-registry - Map of guard-key -> (fn [ctx] bool?) (may be nil) context - Context map (may be nil)
Returns: Vector of maps: {:id keyword ; transition identifier (name or :to) :to keyword ; target state :label string? ; optional, from :label on the transition def :enabled? boolean :reason keyword?} ; only present when :enabled? is false
Return all transitions reachable from current-state, each annotated with
:enabled? and, when disabled, a :reason keyword.
Runs the full can-transition? check (existence ✓, permissions, guard) for
every reachable transition and returns a summary vector suitable for driving
UI buttons or API responses.
Args:
definition - WorkflowDefinition map
current-state - keyword
actor-roles - Collection of keywords (may be nil)
guard-registry - Map of guard-key -> (fn [ctx] bool?) (may be nil)
context - Context map (may be nil)
Returns:
Vector of maps:
{:id keyword ; transition identifier (name or :to)
:to keyword ; target state
:label string? ; optional, from :label on the transition def
:enabled? boolean
:reason keyword?} ; only present when :enabled? is false(can-transition? definition
current-state
transition
actor-roles
guard-registry
context)Full pre-flight check for a transition request.
Runs, in order:
Args: definition - WorkflowDefinition map current-state - keyword transition - keyword actor-roles - Collection of keywords (may be nil) guard-registry - Map of guard-key -> (fn [ctx] bool?) (may be nil) context - Arbitrary context map (may be nil)
Returns: {:allowed? true :transition-def <TransitionDef>} or {:allowed? false :reason <keyword> ...}
Full pre-flight check for a transition request.
Runs, in order:
1. Existence — is the transition defined from the current state?
2. Permissions — does the actor have a required role?
3. Guard — does the guard function approve the context?
Args:
definition - WorkflowDefinition map
current-state - keyword
transition - keyword
actor-roles - Collection of keywords (may be nil)
guard-registry - Map of guard-key -> (fn [ctx] bool?) (may be nil)
context - Arbitrary context map (may be nil)
Returns:
{:allowed? true :transition-def <TransitionDef>}
or
{:allowed? false :reason <keyword> ...}(check-permissions transition-def actor-roles)Verify that the actor has at least one of the required roles.
Args: transition-def - TransitionDef map actor-roles - Collection of keywords the actor holds (may be nil/empty)
Returns: {:allowed? true} or {:allowed? false :reason :insufficient-permissions :required [:finance :admin] :provided [...]}
Verify that the actor has at least one of the required roles.
Args:
transition-def - TransitionDef map
actor-roles - Collection of keywords the actor holds (may be nil/empty)
Returns:
{:allowed? true}
or
{:allowed? false
:reason :insufficient-permissions
:required [:finance :admin]
:provided [...]}(destination-state transition-def)Return the target state for a transition definition.
Args: transition-def - TransitionDef map
Returns: keyword (:to value)
Return the target state for a transition definition. Args: transition-def - TransitionDef map Returns: keyword (:to value)
(evaluate-guard transition-def guard-registry context)Evaluate a named guard function against the transition context.
The guard registry is a plain map of keyword -> (fn [context] boolean?). Guards are optional; absence means the transition is always allowed.
Args: transition-def - TransitionDef map guard-registry - Map of guard-key -> guard-fn (may be nil/empty) context - Arbitrary context map passed through the transition
Returns: {:allowed? true} or {:allowed? false :reason :guard-rejected :guard :guard-key}
Evaluate a named guard function against the transition context.
The guard registry is a plain map of keyword -> (fn [context] boolean?).
Guards are optional; absence means the transition is always allowed.
Args:
transition-def - TransitionDef map
guard-registry - Map of guard-key -> guard-fn (may be nil/empty)
context - Arbitrary context map passed through the transition
Returns:
{:allowed? true}
or
{:allowed? false
:reason :guard-rejected
:guard :guard-key}(find-transition-def definition from-state transition)Find the transition definition matching a from-state and transition name.
Args: definition - WorkflowDefinition map from-state - keyword (current state) transition - keyword (transition name, derived from :to when :name absent)
Returns: TransitionDef map or nil
Find the transition definition matching a from-state and transition name. Args: definition - WorkflowDefinition map from-state - keyword (current state) transition - keyword (transition name, derived from :to when :name absent) Returns: TransitionDef map or nil
(side-effects transition-def)Return the list of side-effect keys for a transition definition.
Args: transition-def - TransitionDef map
Returns: Vector of keywords (may be empty)
Return the list of side-effect keys for a transition definition. Args: transition-def - TransitionDef map Returns: Vector of keywords (may be empty)
(transition-exists? definition current-state transition)Check whether the given transition is defined from the current state.
Args: definition - WorkflowDefinition map current-state - keyword transition - keyword
Returns: true / false
Check whether the given transition is defined from the current state. Args: definition - WorkflowDefinition map current-state - keyword transition - keyword Returns: true / false
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |