Workflow and state machines for Rust applications
| Tier | operations |
| Role | unclassified (baselined) |
| Path | crates/operations/workflow |
| Edition | 2021 |
| Targets | operations_workflow, pg_transition |
| Public items | 116 across 1 module |
| Tests | 46 |
What it is for
Workflow and state machine library crates for Rust applications.
Provides state machines, approval workflows, and process automation.
Capabilities
Action
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct Action |
Action :: fn new(name : impl Into <String>) -> Self |
Action :: fn with_param(mut self, key : impl Into <String>, value : serde_json::Value) -> Self |
Approval
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct Approval |
ApprovalDecision
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum ApprovalDecision |
ApprovalRequest
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct ApprovalRequest |
ApprovalRequest :: fn new(workflow_instance_id : Uuid, transition_name : impl Into <String>, created_by : Uuid,) -> Self |
ApprovalRequest :: fn with_approvers(mut self, approvers : Vec <Uuid>) -> Self |
ApprovalRequest :: fn with_min_approvals(mut self, min : usize) -> Self |
ApprovalRequest :: fn with_expiration(mut self, expires_at : DateTime <Utc>) -> Self |
ApprovalRequest :: fn approve(& mut self, approver : Uuid, comment : Option <String>) -> Result <()> |
ApprovalRequest :: fn reject(& mut self, rejector : Uuid, comment : Option <String>) -> Result <()> |
ApprovalRequest :: fn cancel(& mut self) -> Result <()> |
ApprovalRequest :: fn is_expired(& self) -> bool |
ApprovalRequest :: fn is_approved(& self) -> bool |
ApprovalStatus
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum ApprovalStatus |
ApprovalStatus :: fn is_terminal(& self) -> bool |
EntityRef
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct EntityRef |
EntityRef :: fn new(entity_type : impl Into <String>, entity_id : Uuid) -> Self |
Guard
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct Guard |
Guard :: fn expression(expr : impl Into <String>) -> Self |
Guard :: fn service_call(service : impl Into <String>) -> Self |
GuardType
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum GuardType |
Result
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub type Result<T>: std::result::Result <T, WorkflowError> |
State
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct State |
State :: fn new(name : impl Into <String>) -> Self |
State :: fn initial(mut self) -> Self |
State :: fn final_state(mut self) -> Self |
State :: fn blocking(mut self) -> Self |
State :: fn waiting(mut self) -> Self |
State :: fn with_label(mut self, label : impl Into <String>) -> Self |
State :: fn with_description(mut self, description : impl Into <String>) -> Self |
State :: fn with_kanban_column(mut self, column : i32) -> Self |
State :: fn with_color(mut self, color : impl Into <String>) -> Self |
State :: fn with_metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self |
State :: fn display_name(& self) -> & str |
StateMachineDefinition:StateMachineDefinition
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct StateMachineDefinition |
StateMachineDefinition:available
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn available_transitions(& self, from_state : & str) -> Vec <& Transition> |
StateMachineDefinition :: fn available_transitions_for_role(& self, from_state : & str, role : & str) -> Vec <& Transition> |
StateMachineDefinition:find
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn find_transition(& self, from_state : & str, transition_name : & str) -> Option <& Transition> |
StateMachineDefinition:get
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn get_initial_state(& self) -> Option <& State> |
StateMachineDefinition:is
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn is_valid_transition(& self, from : & str, to : & str) -> bool |
StateMachineDefinition :: fn is_final_state(& self, state : & str) -> bool |
StateMachineDefinition :: fn is_blocking_state(& self, state : & str) -> bool |
StateMachineDefinition:new
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn new(name : impl Into <String>) -> Self |
StateMachineDefinition:states
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn states_by_kanban_order(& self) -> Vec <& State> |
StateMachineDefinition:with
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineDefinition :: fn with_description(mut self, description : impl Into <String>) -> Self |
StateMachineDefinition :: fn with_version(mut self, version : u32) -> Self |
StateMachineDefinition :: fn with_context_schema(mut self, schema : serde_json::Value) -> Self |
StateMachineDefinition :: fn with_state(mut self, state : State) -> Result <Self> |
StateMachineDefinition :: fn with_transition(mut self, transition : Transition) -> Result <Self> |
StateMachineInstance:StateMachineInstance
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct StateMachineInstance |
StateMachineInstance:cancel
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn cancel(& mut self, reason : Option <String>) |
StateMachineInstance:fail
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn fail(& mut self, error : String) |
StateMachineInstance:for
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn for_entity(mut self, entity_type : impl Into <String>, entity_id : Uuid) -> Self |
StateMachineInstance:force
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn force_state(& mut self, state : impl Into <String>, actor : Uuid, reason : String) |
StateMachineInstance:get
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn get_context(& self, key : & str) -> Option <& serde_json::Value> |
StateMachineInstance:initiated
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn initiated_by(mut self, actor : Uuid) -> Self |
StateMachineInstance:is
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn is_complete(& self) -> bool |
StateMachineInstance :: fn is_active(& self) -> bool |
StateMachineInstance:new
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn new(definition : & StateMachineDefinition) -> Self |
StateMachineInstance:resume
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn resume(& mut self) -> Result <()> |
StateMachineInstance:set
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn set_context(& mut self, key : impl Into <String>, value : serde_json::Value) |
StateMachineInstance:state
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn state(& self) -> & str |
StateMachineInstance:suspend
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn suspend(& mut self, reason : Option <String>) |
StateMachineInstance:transition
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn transition(& mut self, definition : & StateMachineDefinition, transition_name : & str, actor : Option <Uuid>, comment : Option <String>,) -> Result <()> |
StateMachineInstance :: fn transition_with_role(& mut self, definition : & StateMachineDefinition, transition_name : & str, actor : Uuid, role : & str, comment : Option <String>,) -> Result <()> |
StateMachineInstance:wait
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn wait(& mut self) |
StateMachineInstance:with
Workflow and state machine library crates for Rust applications.
| Item |
|---|
StateMachineInstance :: fn with_context(mut self, key : impl Into <String>, value : serde_json::Value) -> Self |
StateMachineInstance :: fn with_context_data(mut self, data : HashMap <String, serde_json::Value>) -> Self |
StateTransitionRecord
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct StateTransitionRecord |
StateType
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum StateType |
Transition:Transition
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct Transition |
Transition:can
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn can_trigger_from(& self, state : & str) -> bool |
Transition:from
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn from_many(name : impl Into <String>, from_states : Vec <String>, to : impl Into <String>,) -> Self |
Transition :: fn from(& self) -> & str |
Transition:is
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn is_role_allowed(& self, role : & str) -> bool |
Transition:new
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn new(name : impl Into <String>, from : impl Into <String>, to : impl Into <String>) -> Self |
Transition:requires
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn requires_approval(mut self) -> Self |
Transition:with
Workflow and state machine library crates for Rust applications.
| Item |
|---|
Transition :: fn with_label(mut self, label : impl Into <String>) -> Self |
Transition :: fn with_description(mut self, description : impl Into <String>) -> Self |
Transition :: fn with_guard(mut self, guard : Guard) -> Self |
Transition :: fn with_expression_guard(mut self, expr : impl Into <String>) -> Self |
Transition :: fn with_service_guard(mut self, service : impl Into <String>) -> Self |
Transition :: fn with_action(mut self, action : Action) -> Self |
Transition :: fn with_action_name(mut self, name : impl Into <String>) -> Self |
Transition :: fn with_roles(mut self, roles : Vec <String>) -> Self |
Transition :: fn with_role(mut self, role : impl Into <String>) -> Self |
Transition :: fn with_metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self |
WorkflowBuilder
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct WorkflowBuilder |
WorkflowBuilder :: fn new(name : impl Into <String>) -> Self |
WorkflowBuilder :: fn approval_workflow() -> Result <StateMachineDefinition> |
WorkflowBuilder :: fn multi_stage_approval(stages : & & str) -> Result <StateMachineDefinition> |
WorkflowBuilder :: fn linear_workflow(states : & & str) -> Result <StateMachineDefinition> |
WorkflowError
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum WorkflowError |
WorkflowInstanceStatus
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub enum WorkflowInstanceStatus |
WorkflowInstanceStatus :: fn is_terminal(& self) -> bool |
WorkflowInstanceStatus :: fn can_transition(& self) -> bool |
WorkflowInstanceStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
WorkflowTemplate
Workflow and state machine library crates for Rust applications.
| Item |
|---|
pub struct WorkflowTemplate |
WorkflowTemplate :: fn new(name : impl Into <String>, definition : StateMachineDefinition) -> Self |
WorkflowTemplate :: fn with_description(mut self, description : impl Into <String>) -> Self |
WorkflowTemplate :: fn create_instance(& self) -> StateMachineInstance |
WorkflowTemplate :: fn increment_version(& mut self) |
SqlIdent
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub struct SqlIdent |
SqlIdent :: const fn new(value : & 'static str) -> Self |
SqlIdent :: const fn as_str(& self) -> & 'static str |
StatefulEntity
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub trait StatefulEntity |
fn generate_transition_trigger_ddl <E : StatefulEntity>(allowed : & (& str, & str)) -> String |
TransitionOutcome
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub enum TransitionOutcome |
TransitionRecord
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub struct TransitionRecord |
WorkflowStore
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub struct WorkflowStore |
WorkflowStore :: fn new(pool : PgPool) -> Self |
WorkflowStore :: async fn transition_if <E : StatefulEntity>(& self, id : Uuid, expected : & str, next : & str, actor : Option <Uuid>,) -> Result <TransitionOutcome, WorkflowStoreError> |
WorkflowStore :: async fn transition_if_on <E : StatefulEntity>(tx : & mut sqlx::Transaction <'_, sqlx::Postgres>, id : Uuid, expected : & str, next : & str, actor : Option <Uuid>,) -> Result <(TransitionOutcome, Option <i64>), WorkflowStoreError> |
WorkflowStoreError
Postgres-backed atomic guarded state transition (compare-and-swap).
| Item |
|---|
pub enum WorkflowStoreError |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
operations_workflow
store
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum WorkflowError | Workflow errors. |
pub enum WorkflowInstanceStatus | Status of a workflow instance. |
WorkflowInstanceStatus :: fn is_terminal(& self) -> bool | Check if the workflow is in a terminal state. |
WorkflowInstanceStatus :: fn can_transition(& self) -> bool | Check if the workflow can accept transitions. |
WorkflowInstanceStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum GuardType | Type of guard for conditional transitions. |
pub struct Guard | A guard condition for a transition. |
Guard :: fn expression(expr : impl Into <String>) -> Self | Create a new expression guard. |
Guard :: fn service_call(service : impl Into <String>) -> Self | Create a new service call guard. |
pub struct Action | An action to execute on transition. |
Action :: fn new(name : impl Into <String>) -> Self | Create a new action. |
Action :: fn with_param(mut self, key : impl Into <String>, value : serde_json::Value) -> Self | Add a parameter to the action. |
pub type Result<T>: std::result::Result <T, WorkflowError> | Result type for workflow operations. |
pub enum StateType | Type of state for categorization. |
pub struct State | A state in a state machine. |
State :: fn new(name : impl Into <String>) -> Self | Create a new state. |
State :: fn initial(mut self) -> Self | Set as initial state. |
State :: fn final_state(mut self) -> Self | Set as final state. |
State :: fn blocking(mut self) -> Self | Set as blocking state (requires resolution before continuing). |
State :: fn waiting(mut self) -> Self | Set as waiting state (awaiting external input). |
State :: fn with_label(mut self, label : impl Into <String>) -> Self | Set display label. |
State :: fn with_description(mut self, description : impl Into <String>) -> Self | Set description. |
State :: fn with_kanban_column(mut self, column : i32) -> Self | Set kanban column position. |
State :: fn with_color(mut self, color : impl Into <String>) -> Self | Set display color. |
State :: fn with_metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self | Add metadata (accepts any JSON value). |
State :: fn display_name(& self) -> & str | Get the display name (label or name). |
pub struct Transition | A transition between states. |
Transition :: fn new(name : impl Into <String>, from : impl Into <String>, to : impl Into <String>) -> Self | Create a new transition from a single state. |
Transition :: fn from_many(name : impl Into <String>, from_states : Vec <String>, to : impl Into <String>,) -> Self | Create a new transition from multiple states. |
Transition :: fn with_label(mut self, label : impl Into <String>) -> Self | Set display label. |
Transition :: fn with_description(mut self, description : impl Into <String>) -> Self | Set description. |
Transition :: fn with_guard(mut self, guard : Guard) -> Self | Add a guard condition. |
Transition :: fn with_expression_guard(mut self, expr : impl Into <String>) -> Self | Add an expression guard. |
Transition :: fn with_service_guard(mut self, service : impl Into <String>) -> Self | Add a service call guard. |
Transition :: fn with_action(mut self, action : Action) -> Self | Add an action. |
Transition :: fn with_action_name(mut self, name : impl Into <String>) -> Self | Add a simple named action. |
Transition :: fn with_roles(mut self, roles : Vec <String>) -> Self | Set allowed roles for this transition. |
Transition :: fn with_role(mut self, role : impl Into <String>) -> Self | Add an allowed role. |
Transition :: fn requires_approval(mut self) -> Self | Require approval for this transition. |
Transition :: fn with_metadata(mut self, key : impl Into <String>, value : serde_json::Value) -> Self | Add metadata. |
Transition :: fn can_trigger_from(& self, state : & str) -> bool | Check if this transition can be triggered from a given state. |
Transition :: fn is_role_allowed(& self, role : & str) -> bool | Check if a role is allowed. |
Transition :: fn from(& self) -> & str | Get the first "from" state (for backwards compatibility). |
pub struct StateMachineDefinition | Definition of a state machine. |
StateMachineDefinition :: fn new(name : impl Into <String>) -> Self | Create a new state machine definition. |
StateMachineDefinition :: fn with_description(mut self, description : impl Into <String>) -> Self | Set description. |
StateMachineDefinition :: fn with_version(mut self, version : u32) -> Self | Set version. |
StateMachineDefinition :: fn with_context_schema(mut self, schema : serde_json::Value) -> Self | Set context schema for validation. |
StateMachineDefinition :: fn with_state(mut self, state : State) -> Result <Self> | Add a state. |
StateMachineDefinition :: fn with_transition(mut self, transition : Transition) -> Result <Self> | Add a transition. |
StateMachineDefinition :: fn available_transitions(& self, from_state : & str) -> Vec <& Transition> | Get available transitions from a state. |
StateMachineDefinition :: fn available_transitions_for_role(& self, from_state : & str, role : & str) -> Vec <& Transition> | Get available transitions from a state for a specific role. |
StateMachineDefinition :: fn is_valid_transition(& self, from : & str, to : & str) -> bool | Check if a transition is valid. |
StateMachineDefinition :: fn find_transition(& self, from_state : & str, transition_name : & str) -> Option <& Transition> | Find a transition by name from a given state. |
StateMachineDefinition :: fn get_initial_state(& self) -> Option <& State> | Get the initial state. |
StateMachineDefinition :: fn is_final_state(& self, state : & str) -> bool | Check if a state is final. |
StateMachineDefinition :: fn is_blocking_state(& self, state : & str) -> bool | Check if a state is blocking. |
StateMachineDefinition :: fn states_by_kanban_order(& self) -> Vec <& State> | Get states ordered by kanban column. |
pub struct EntityRef | Entity reference for workflow binding. |
EntityRef :: fn new(entity_type : impl Into <String>, entity_id : Uuid) -> Self | Create a new entity reference. |
pub struct StateMachineInstance | Instance of a state machine. |
StateMachineInstance :: fn new(definition : & StateMachineDefinition) -> Self | Create a new instance. |
StateMachineInstance :: fn for_entity(mut self, entity_type : impl Into <String>, entity_id : Uuid) -> Self | Bind to an entity. |
StateMachineInstance :: fn initiated_by(mut self, actor : Uuid) -> Self | Set who initiated the workflow. |
StateMachineInstance :: fn with_context(mut self, key : impl Into <String>, value : serde_json::Value) -> Self | Set context data. |
StateMachineInstance :: fn with_context_data(mut self, data : HashMap <String, serde_json::Value>) -> Self | Set multiple context values. |
StateMachineInstance :: fn transition(& mut self, definition : & StateMachineDefinition, transition_name : & str, actor : Option <Uuid>, comment : Option <String>,) -> Result <()> | Transition to a new state. |
StateMachineInstance :: fn transition_with_role(& mut self, definition : & StateMachineDefinition, transition_name : & str, actor : Uuid, role : & str, comment : Option <String>,) -> Result <()> | Transition with role check. |
StateMachineInstance :: fn force_state(& mut self, state : impl Into <String>, actor : Uuid, reason : String) | Force transition to a state (bypassing normal flow). |
StateMachineInstance :: fn suspend(& mut self, reason : Option <String>) | Suspend the workflow. |
StateMachineInstance :: fn resume(& mut self) -> Result <()> | Resume a suspended workflow. |
StateMachineInstance :: fn wait(& mut self) | Mark as waiting for external input. |
StateMachineInstance :: fn cancel(& mut self, reason : Option <String>) | Cancel the workflow. |
StateMachineInstance :: fn fail(& mut self, error : String) | Fail the workflow. |
StateMachineInstance :: fn state(& self) -> & str | Get the current state name. |
StateMachineInstance :: fn is_complete(& self) -> bool | Check if the workflow is complete (terminal state). |
StateMachineInstance :: fn is_active(& self) -> bool | Check if the workflow is active. |
StateMachineInstance :: fn get_context(& self, key : & str) -> Option <& serde_json::Value> | Get context value. |
StateMachineInstance :: fn set_context(& mut self, key : impl Into <String>, value : serde_json::Value) | Update context value. |
pub struct StateTransitionRecord | Record of a state transition. |
pub enum ApprovalStatus | Approval status. |
ApprovalStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
pub struct ApprovalRequest | An approval request in a workflow. |
ApprovalRequest :: fn new(workflow_instance_id : Uuid, transition_name : impl Into <String>, created_by : Uuid,) -> Self | Create a new approval request. |
ApprovalRequest :: fn with_approvers(mut self, approvers : Vec <Uuid>) -> Self | Set required approvers. |
ApprovalRequest :: fn with_min_approvals(mut self, min : usize) -> Self | Set minimum approvals needed. |
ApprovalRequest :: fn with_expiration(mut self, expires_at : DateTime <Utc>) -> Self | Set expiration. |
ApprovalRequest :: fn approve(& mut self, approver : Uuid, comment : Option <String>) -> Result <()> | Add an approval. |
ApprovalRequest :: fn reject(& mut self, rejector : Uuid, comment : Option <String>) -> Result <()> | Reject the request. |
ApprovalRequest :: fn cancel(& mut self) -> Result <()> | Cancel the request. |
ApprovalRequest :: fn is_expired(& self) -> bool | Check if the request has expired. |
ApprovalRequest :: fn is_approved(& self) -> bool | Check if the request is approved. |
pub struct Approval | A single approval decision. |
pub enum ApprovalDecision | Approval decision. |
pub struct WorkflowTemplate | Workflow template for reusable workflow definitions. |
WorkflowTemplate :: fn new(name : impl Into <String>, definition : StateMachineDefinition) -> Self | Create a new workflow template. |
WorkflowTemplate :: fn with_description(mut self, description : impl Into <String>) -> Self | Set description. |
WorkflowTemplate :: fn create_instance(& self) -> StateMachineInstance | Create an instance from this template. |
WorkflowTemplate :: fn increment_version(& mut self) | Increment version. |
pub struct WorkflowBuilder | Builder for common workflow patterns. |
WorkflowBuilder :: fn new(name : impl Into <String>) -> Self | Create a new workflow builder. |
WorkflowBuilder :: fn approval_workflow() -> Result <StateMachineDefinition> | Build a simple approval workflow. |
WorkflowBuilder :: fn multi_stage_approval(stages : & & str) -> Result <StateMachineDefinition> | Build a multi-stage approval workflow. |
WorkflowBuilder :: fn linear_workflow(states : & & str) -> Result <StateMachineDefinition> | Build a simple linear workflow. |
`store`
| Item | What it is |
|---|---|
pub struct SqlIdent | A table or column identifier, validated to a safe character set at construction |
SqlIdent :: const fn new(value : & 'static str) -> Self | Construct a validated identifier |
SqlIdent :: const fn as_str(& self) -> & 'static str | The validated identifier string. |
pub trait StatefulEntity | A domain entity whose status lives on its own table, transitioned via CAS |
pub struct TransitionRecord | One committed transition, recorded in workflow_transition_history. |
pub enum TransitionOutcome | The result of WorkflowStore::transition_if. |
pub enum WorkflowStoreError | Errors from the transition store. |
pub struct WorkflowStore | A Postgres-backed atomic guarded transition store. |
WorkflowStore :: fn new(pool : PgPool) -> Self | Wrap a connection pool. |
WorkflowStore :: async fn transition_if <E : StatefulEntity>(& self, id : Uuid, expected : & str, next : & str, actor : Option <Uuid>,) -> Result <TransitionOutcome, WorkflowStoreError> | Atomically transition id from expected to next, recording history in the SAME transaction |
WorkflowStore :: async fn transition_if_on <E : StatefulEntity>(tx : & mut sqlx::Transaction <'_, sqlx::Postgres>, id : Uuid, expected : & str, next : & str, actor : Option <Uuid>,) -> Result <(TransitionOutcome, Option <i64>), WorkflowStoreError> | The CAS + history insert on a CALLER-OWNED transaction, so a consumer can ride its own same-transaction effects (an extension-fact row, a dependent update) on the committed transition |
fn generate_transition_trigger_ddl <E : StatefulEntity>(allowed : & (& str, & str)) -> String | Generate the DB-enforcement trigger DDL for an entity FROM its allowed transitions (the app's one FSM graph) — the drift-proof defense-in-depth layer (Gate-1.5 consensus 2026-07-23, option d) |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier operations with 40 other crates: operations-approval-workflow, operations-assessments, operations-block-imaging, operations-boot-media, operations-browser-agent-worker, operations-camera-discovery, operations-camera-liveview, operations-camera-registry, … (40 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | operations |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/operations/workflow |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | yes | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
tokio | ^1 | full, macros, rt-multi-thread | no | always |
uuid | ^1 | v4, v7, serde, js, v4 | no | always |
Build. None.
Depended on by. 4 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_workflow["application-workflow"] -->|uses| SELF n_domain_legal_matter["domain-legal-matter"] -->|uses| SELF n_domain_legal_procedure["domain-legal-procedure"] -->|uses| SELF n_operations_control_plane["operations-control-plane"] -->|uses| SELF SELF["operations-workflow"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
postgres | dep:sqlx | no |
flowchart LR n_postgres["postgres"] --> n_dep_sqlx["dep:sqlx"]
Targets
| Kind | Name | Source |
|---|---|---|
| lib | operations_workflow | `src/lib.rs` |
| test | pg_transition | `tests/pg_transition.rs` |
Error model
| Error type | Named by |
|---|---|
WorkflowError | Result |
WorkflowStoreError | declared, no public signature returns it |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
4 workspace crates depend on this one: application-workflow, domain-legal-matter, domain-legal-procedure, operations-control-plane.
Verification
| Kind | Count |
|---|---|
| Unit tests | 43 |
| Integration tests | 3 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 19 | 0 | 9 |
store | 7 | 0 | 6 |
What the tests establish, by name:
db_trigger_rejects_illegal_transition_bypassing_the_app—tests/pg_transition.rsmissing_entity_is_not_found—tests/pg_transition.rsstale_expected_transition_conflicts_never_applies—tests/pg_transition.rstest_action_creation—src/lib.rstest_approval_request_approve—src/lib.rstest_approval_request_cancel—src/lib.rstest_approval_request_cannot_approve_after_rejection—src/lib.rstest_approval_request_creation—src/lib.rstest_approval_request_multiple_approvals—src/lib.rstest_approval_request_reject—src/lib.rstest_approval_status_is_terminal—src/lib.rstest_approval_workflow_builder—src/lib.rstest_available_transitions—src/lib.rstest_context_operations—src/lib.rstest_force_state—src/lib.rstest_guard_types—src/lib.rstest_instance_cancel_and_fail—src/lib.rstest_instance_entity_binding—src/lib.rstest_instance_suspend_and_resume—src/lib.rstest_instance_with_context—src/lib.rstest_invalid_transition_attempt—src/lib.rstest_is_valid_transition—src/lib.rstest_linear_workflow_builder—src/lib.rstest_linear_workflow_too_few_states—src/lib.rstest_multi_stage_approval_builder—src/lib.rstest_previous_state_tracking—src/lib.rstest_state_blocking—src/lib.rstest_state_creation—src/lib.rstest_state_final—src/lib.rstest_state_machine_definition—src/lib.rs- _… 16 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 115 | 116 |
Public modules with a //! block | 1 | 1 |
pie showData
title Public items with rustdoc
"Documented" : 115
"No rustdoc detected" : 1
Metrics
| Metric | Value |
|---|---|
| Rust source files | 2 |
| Source lines | 2132 |
| Code lines | 1595 |
| Public API items | 116 |
| Public modules | 1 |
| Tests | 46 |
| Examples | 0 |
| Cargo features | 1 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 4 |
pie showData
title Public API by kind
"enum" : 8
"function" : 1
"method" : 90
"struct" : 15
"trait" : 1
"type alias" : 1
pie showData
title Rust source composition
"Code" : 1595
"Blank or comment" : 537
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.