ores.workflow.workflow_instance

Table of Contents

Tracks the lifecycle of a workflow execution, including its type, status, the serialised request that triggered it, and any result or error produced. Instances are append-mostly; status transitions are the primary mutation.

1. Flags

2. Natural keys

3. Columns

3.1. id

UUID primary key for the workflow instance.

3.2. type

Workflow type name, e.g. 'provision_parties_workflow'.

3.3. state_id

FK to the FSM state record (ores_workflow_fsm_states_tbl) for this instance.

3.4. request_json

Serialised JSON payload of the originating request.

3.5. result_json

Serialised JSON result, populated on successful completion.

3.6. error

Human-readable error message, populated on failure.

3.7. correlation_id

Distributed tracing correlation ID (Nats-Correlation-Id header value).

3.8. created_by

Username or service identity that initiated the workflow.

3.9. current_step_index

Zero-based index of the step currently being executed.

3.10. step_count

Total number of steps in this workflow definition.

3.11. materialised_steps_json

JSON snapshot of the step sequence built at instance start. Prevents a non-deterministic build_steps from reshaping an in-flight workflow after a service restart.

3.12. completed_at

Timestamp when the workflow reached a terminal state.

3.13. last_event_at

Timestamp of the most recent step-completed event processed.

4. SQL

4.1. Flags

5. Indexes

The list query filters by state and orders by type, and the engine's recovery pass reads every instance for a tenant, so the tenant index is the hot path.

5.1. tenant_id

5.2. state_id

5.3. tenant_type

6. C++

6.1. Flags

6.2. Repository

6.3. Domain includes

#include <chrono>
#include <optional>
#include <string>
#include <boost/uuid/uuid.hpp>

6.4. Conventions

6.5. Custom repository methods

7. See also

Emacs 29.3 (Org mode 9.6.15)