cloacina::models::execution_event
Rust
Execution Event Model
This module defines domain structures and types for tracking execution events. Execution events provide a complete audit trail of task and workflow state transitions for debugging, compliance, and replay capability.
These are API-level types; backend-specific models handle database storage.
Structs
Section titled “Structs”struct ExecutionEvent
Section titled “struct ExecutionEvent”pub
Derives: Debug, Clone, Serialize, Deserialize
Represents an execution event record (domain type).
Execution events are append-only records tracking all state transitions for tasks and workflows. Each event captures the transition type, associated context, and ordering information for replay.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
id |
UniversalUuid |
Unique identifier for this event |
workflow_execution_id |
UniversalUuid |
The workflow execution this event belongs to |
task_execution_id |
Option<UniversalUuid> |
The task execution this event relates to (None for workflow-level events) |
event_type |
String |
The type of event (e.g., “task_created”, “task_completed”) |
event_data |
Option<String> |
JSON-encoded additional data for the event |
worker_id |
Option<String> |
Worker ID that generated this event (for distributed tracing) |
created_at |
UniversalTimestamp |
When this event was created |
sequence_num |
i64 |
Monotonically increasing sequence number for ordering |
request_id |
Option<UniversalUuid> |
CLOACI-T-0583: id of the originating request. Populated by server route handlers from the current tracing span; None for background scheduler emissions and the daemon path. |
runner_id |
Option<UniversalUuid> |
CLOACI-T-0583: id of the runner instance that emitted the event. Populated for per-tenant runner emissions; None for the daemon’s single direct runner. |
tenant_id |
Option<String> |
CLOACI-T-0583: tenant scope. None on the daemon and on emissions without a tenant context. |
struct NewExecutionEvent
Section titled “struct NewExecutionEvent”pub
Derives: Debug, Clone, Serialize, Deserialize
Structure for creating new execution event records (domain type).
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
workflow_execution_id |
UniversalUuid |
The workflow execution this event belongs to |
task_execution_id |
Option<UniversalUuid> |
The task execution this event relates to (None for workflow-level events) |
event_type |
String |
The type of event |
event_data |
Option<String> |
JSON-encoded additional data for the event |
worker_id |
Option<String> |
Worker ID that generated this event |
request_id |
Option<UniversalUuid> |
CLOACI-T-0583: originating request id (from the tracing span). |
runner_id |
Option<UniversalUuid> |
CLOACI-T-0583: runner instance id. |
tenant_id |
Option<String> |
CLOACI-T-0583: tenant scope. |
Methods
Section titled “Methods”workflow_event
Section titled “workflow_event”pub
fn workflow_event( workflow_execution_id: UniversalUuid, event_type: ExecutionEventType, event_data: Option<String>, worker_id: Option<String>,) -> SelfCreates a new execution event for a workflow-level transition.
CLOACI-T-0583 correlation fields default to None for backward
compatibility; use Self::with_context to populate them after
construction.
Source
pub fn workflow_event( workflow_execution_id: UniversalUuid, event_type: ExecutionEventType, event_data: Option<String>, worker_id: Option<String>, ) -> Self { Self { workflow_execution_id, task_execution_id: None, event_type: event_type.as_str().to_string(), event_data, worker_id, request_id: None, runner_id: None, tenant_id: None, } }task_event
Section titled “task_event”pub
fn task_event( workflow_execution_id: UniversalUuid, task_execution_id: UniversalUuid, event_type: ExecutionEventType, event_data: Option<String>, worker_id: Option<String>,) -> SelfCreates a new execution event for a task-level transition.
CLOACI-T-0583 correlation fields default to None; use
Self::with_context to populate them.
Source
pub fn task_event( workflow_execution_id: UniversalUuid, task_execution_id: UniversalUuid, event_type: ExecutionEventType, event_data: Option<String>, worker_id: Option<String>, ) -> Self { Self { workflow_execution_id, task_execution_id: Some(task_execution_id), event_type: event_type.as_str().to_string(), event_data, worker_id, request_id: None, runner_id: None, tenant_id: None, } }with_context
Section titled “with_context”pub
fn with_context( mut self, request_id: Option<UniversalUuid>, runner_id: Option<UniversalUuid>, tenant_id: Option<String>,) -> SelfBuilder-style: attach correlation context to an event before insert. Any Some value overrides whatever the constructor set; Nones pass through unchanged. CLOACI-T-0583.
Source
pub fn with_context( mut self, request_id: Option<UniversalUuid>, runner_id: Option<UniversalUuid>, tenant_id: Option<String>, ) -> Self { if request_id.is_some() { self.request_id = request_id; } if runner_id.is_some() { self.runner_id = runner_id; } if tenant_id.is_some() { self.tenant_id = tenant_id; } self }enum ExecutionEventType
Section titled “enum ExecutionEventType”pub
Enumeration of execution event types in the system.
These cover the full lifecycle of tasks and workflows, providing complete observability into execution state transitions.
Variants
Section titled “Variants”TaskCreated- A new task execution record was createdTaskMarkedReady- Task transitioned to Ready status (eligible for claiming)TaskClaimed- Task was claimed by a workerTaskStarted- Task execution startedTaskDeferred- Task was deferred (waiting for external condition)TaskResumed- Deferred task resumed executionTaskCompleted- Task completed successfullyTaskFailed- Task failed with an errorTaskRetryScheduled- Task scheduled for retry after failureTaskSkipped- Task was skipped (trigger rules not met)TaskAbandoned- Task was abandoned (exceeded max retries or manually cancelled)TaskReset- Task was reset by recovery processWorkflowStarted- Workflow execution startedWorkflowCompleted- Workflow execution completed successfullyWorkflowFailed- Workflow execution failedWorkflowPaused- Workflow was pausedWorkflowResumed- Paused workflow was resumed
Methods
Section titled “Methods”as_str
Section titled “as_str”pub
fn as_str(&self) -> &'static strReturns the string representation of the event type.
Source
pub fn as_str(&self) -> &'static str { match self { // Task events ExecutionEventType::TaskCreated => "task_created", ExecutionEventType::TaskMarkedReady => "task_marked_ready", ExecutionEventType::TaskClaimed => "task_claimed", ExecutionEventType::TaskStarted => "task_started", ExecutionEventType::TaskDeferred => "task_deferred", ExecutionEventType::TaskResumed => "task_resumed", ExecutionEventType::TaskCompleted => "task_completed", ExecutionEventType::TaskFailed => "task_failed", ExecutionEventType::TaskRetryScheduled => "task_retry_scheduled", ExecutionEventType::TaskSkipped => "task_skipped", ExecutionEventType::TaskAbandoned => "task_abandoned", ExecutionEventType::TaskReset => "task_reset", // Workflow events ExecutionEventType::WorkflowStarted => "workflow_started", ExecutionEventType::WorkflowCompleted => "workflow_completed", ExecutionEventType::WorkflowFailed => "workflow_failed", ExecutionEventType::WorkflowPaused => "workflow_paused", ExecutionEventType::WorkflowResumed => "workflow_resumed", } }from_str
Section titled “from_str”pub
fn from_str(s: &str) -> Option<Self>Parses an event type from its string representation.
Source
pub fn from_str(s: &str) -> Option<Self> { match s { "task_created" => Some(ExecutionEventType::TaskCreated), "task_marked_ready" => Some(ExecutionEventType::TaskMarkedReady), "task_claimed" => Some(ExecutionEventType::TaskClaimed), "task_started" => Some(ExecutionEventType::TaskStarted), "task_deferred" => Some(ExecutionEventType::TaskDeferred), "task_resumed" => Some(ExecutionEventType::TaskResumed), "task_completed" => Some(ExecutionEventType::TaskCompleted), "task_failed" => Some(ExecutionEventType::TaskFailed), "task_retry_scheduled" => Some(ExecutionEventType::TaskRetryScheduled), "task_skipped" => Some(ExecutionEventType::TaskSkipped), "task_abandoned" => Some(ExecutionEventType::TaskAbandoned), "task_reset" => Some(ExecutionEventType::TaskReset), "workflow_started" | "pipeline_started" => Some(ExecutionEventType::WorkflowStarted), "workflow_completed" | "pipeline_completed" => { Some(ExecutionEventType::WorkflowCompleted) } "workflow_failed" | "pipeline_failed" => Some(ExecutionEventType::WorkflowFailed), "workflow_paused" | "pipeline_paused" => Some(ExecutionEventType::WorkflowPaused), "workflow_resumed" | "pipeline_resumed" => Some(ExecutionEventType::WorkflowResumed), _ => None, } }is_task_event
Section titled “is_task_event”pub
fn is_task_event(&self) -> boolReturns true if this is a task-level event.
Source
pub fn is_task_event(&self) -> bool { matches!( self, ExecutionEventType::TaskCreated | ExecutionEventType::TaskMarkedReady | ExecutionEventType::TaskClaimed | ExecutionEventType::TaskStarted | ExecutionEventType::TaskDeferred | ExecutionEventType::TaskResumed | ExecutionEventType::TaskCompleted | ExecutionEventType::TaskFailed | ExecutionEventType::TaskRetryScheduled | ExecutionEventType::TaskSkipped | ExecutionEventType::TaskAbandoned | ExecutionEventType::TaskReset ) }is_workflow_event
Section titled “is_workflow_event”pub
fn is_workflow_event(&self) -> boolReturns true if this is a workflow-level event.
Source
pub fn is_workflow_event(&self) -> bool { matches!( self, ExecutionEventType::WorkflowStarted | ExecutionEventType::WorkflowCompleted | ExecutionEventType::WorkflowFailed | ExecutionEventType::WorkflowPaused | ExecutionEventType::WorkflowResumed ) }