1use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6use oris_kernel::identity::{RunId, Seq};
7
8#[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#[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#[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#[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#[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#[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}
73
74#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
76pub enum BountyStatus {
77 Open,
78 Accepted,
79 Closed,
80}
81
82impl BountyStatus {
83 pub fn as_str(&self) -> &str {
84 match self {
85 BountyStatus::Open => "open",
86 BountyStatus::Accepted => "accepted",
87 BountyStatus::Closed => "closed",
88 }
89 }
90
91 pub fn from_str(s: &str) -> Self {
92 match s {
93 "accepted" => BountyStatus::Accepted,
94 "closed" => BountyStatus::Closed,
95 _ => BountyStatus::Open,
96 }
97 }
98}
99
100#[derive(Clone, Debug, Serialize, Deserialize)]
102pub struct BountyRecord {
103 pub bounty_id: String,
104 pub title: String,
105 pub description: Option<String>,
106 pub reward: i64,
107 pub status: BountyStatus,
108 pub created_by: String,
109 pub created_at_ms: i64,
110 pub closed_at_ms: Option<i64>,
111 pub accepted_by: Option<String>,
112 pub accepted_at_ms: Option<i64>,
113}
114
115#[derive(Clone, Debug, Serialize, Deserialize)]
117pub struct SwarmTaskRecord {
118 pub parent_task_id: String,
119 pub decomposition_json: String,
120 pub proposer_id: String,
121 pub proposer_reward_pct: i32,
122 pub solver_reward_pct: i32,
123 pub aggregator_reward_pct: i32,
124 pub status: String,
125 pub created_at_ms: i64,
126 pub completed_at_ms: Option<i64>,
127}
128
129#[derive(Clone, Debug, Serialize, Deserialize)]
131pub struct WorkerRecord {
132 pub worker_id: String,
133 pub domains: String,
134 pub max_load: i32,
135 pub metadata_json: Option<String>,
136 pub registered_at_ms: i64,
137 pub last_heartbeat_ms: Option<i64>,
138 pub status: String,
139}
140
141#[derive(Clone, Debug, Serialize, Deserialize)]
143pub struct RecipeRecord {
144 pub recipe_id: String,
145 pub name: String,
146 pub description: Option<String>,
147 pub gene_sequence_json: String,
148 pub author_id: String,
149 pub forked_from: Option<String>,
150 pub created_at_ms: i64,
151 pub updated_at_ms: i64,
152 pub is_public: bool,
153}
154
155#[derive(Clone, Debug, Serialize, Deserialize)]
157pub struct OrganismRecord {
158 pub organism_id: String,
159 pub recipe_id: String,
160 pub status: String,
161 pub current_step: i32,
162 pub total_steps: i32,
163 pub created_at_ms: i64,
164 pub completed_at_ms: Option<i64>,
165}
166
167#[derive(Clone, Debug, Serialize, Deserialize)]
169pub struct SessionRecord {
170 pub session_id: String,
171 pub session_type: String,
172 pub creator_id: String,
173 pub status: String,
174 pub created_at_ms: i64,
175 pub ended_at_ms: Option<i64>,
176}
177
178#[derive(Clone, Debug, Serialize, Deserialize)]
180pub struct SessionMessageRecord {
181 pub message_id: String,
182 pub session_id: String,
183 pub sender_id: String,
184 pub content: String,
185 pub message_type: String,
186 pub sent_at_ms: i64,
187}
188
189#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
191pub enum DisputeStatus {
192 Open,
193 Resolved,
194}
195
196impl DisputeStatus {
197 pub fn as_str(&self) -> &str {
198 match self {
199 DisputeStatus::Open => "open",
200 DisputeStatus::Resolved => "resolved",
201 }
202 }
203
204 pub fn from_str(s: &str) -> Self {
205 match s {
206 "resolved" => DisputeStatus::Resolved,
207 _ => DisputeStatus::Open,
208 }
209 }
210}
211
212#[derive(Clone, Debug, Serialize, Deserialize)]
214pub struct DisputeRecord {
215 pub dispute_id: String,
216 pub bounty_id: String,
217 pub opened_by: String,
218 pub status: DisputeStatus,
219 pub evidence_json: Option<String>,
220 pub resolution: Option<String>,
221 pub resolved_by: Option<String>,
222 pub resolved_at_ms: Option<i64>,
223 pub created_at_ms: i64,
224}