Skip to main content

agentics_domain/models/challenge/
lifecycle.rs

1//! Published challenge lifecycle values.
2
3use std::fmt;
4
5use serde::{Deserialize, Serialize};
6
7/// Persistent lifecycle state for a challenge shell or published benchmark.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
9#[serde(rename_all = "snake_case")]
10pub enum ChallengeLifecycleStatus {
11    PendingReview,
12    Active,
13    Archived,
14}
15
16impl ChallengeLifecycleStatus {
17    /// Stable database string for a challenge lifecycle state.
18    pub fn as_str(self) -> &'static str {
19        match self {
20            Self::PendingReview => "pending_review",
21            Self::Active => "active",
22            Self::Archived => "archived",
23        }
24    }
25
26    /// Parse a stable database string for a challenge lifecycle state.
27    pub fn from_storage_value(value: &str) -> Option<Self> {
28        match value {
29            "pending_review" => Some(Self::PendingReview),
30            "active" => Some(Self::Active),
31            "archived" => Some(Self::Archived),
32            _ => None,
33        }
34    }
35}
36
37impl fmt::Display for ChallengeLifecycleStatus {
38    /// Format the challenge status as its stable persisted and wire value.
39    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40        f.write_str(self.as_str())
41    }
42}