Skip to main content

oris_execution_runtime/
models.rs

1//! Runtime domain models for Phase 1 skeleton.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6use oris_kernel::identity::{RunId, Seq};
7
8/// Runtime-level status of a run for control-plane orchestration.
9#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
10pub enum RunRuntimeStatus {
11    Queued,
12    Leased,
13    Running,
14    BlockedInterrupt,
15    RetryBackoff,
16    Completed,
17    Failed,
18    Cancelled,
19}
20
21/// Runtime-level status of an execution attempt.
22#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
23pub enum AttemptExecutionStatus {
24    Queued,
25    Leased,
26    Running,
27    RetryBackoff,
28    Completed,
29    Failed,
30    Cancelled,
31}
32
33/// Run metadata record for scheduler/control-plane usage.
34#[derive(Clone, Debug, Serialize, Deserialize)]
35pub struct RunRecord {
36    pub run_id: RunId,
37    pub workflow_name: String,
38    pub status: RunRuntimeStatus,
39    pub created_at: DateTime<Utc>,
40    pub updated_at: DateTime<Utc>,
41}
42
43/// Candidate attempt returned by repository for scheduler dispatch.
44#[derive(Clone, Debug, Serialize, Deserialize)]
45pub struct AttemptDispatchRecord {
46    pub attempt_id: String,
47    pub run_id: RunId,
48    pub attempt_no: u32,
49    pub status: AttemptExecutionStatus,
50    pub retry_at: Option<DateTime<Utc>>,
51}
52
53/// Lease metadata for worker ownership and failover.
54#[derive(Clone, Debug, Serialize, Deserialize)]
55pub struct LeaseRecord {
56    pub lease_id: String,
57    pub attempt_id: String,
58    pub worker_id: String,
59    pub lease_expires_at: DateTime<Utc>,
60    pub heartbeat_at: DateTime<Utc>,
61    pub version: u64,
62}
63
64/// Interrupt metadata record for operator resume flow.
65#[derive(Clone, Debug, Serialize, Deserialize)]
66pub struct InterruptRecord {
67    pub interrupt_id: String,
68    pub run_id: RunId,
69    pub attempt_id: String,
70    pub event_seq: Seq,
71    pub is_pending: bool,
72}