summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-29 14:34:52 +0000
committersoryu <soryu@soryu.co>2026-01-29 14:34:52 +0000
commita7485a17157d2c066473de70d4dc630d18f3d294 (patch)
treeeb1a613bf2373fdda0374d7f5a82cff9a938fc0e
parent74e77be0ce3adae5889894e9a791fce96d7c82df (diff)
downloadsoryu-a7485a17157d2c066473de70d4dc630d18f3d294.tar.gz
soryu-a7485a17157d2c066473de70d4dc630d18f3d294.zip
Fix phase config in DB
-rw-r--r--makima/src/db/models.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs
index 2236ad5..91564c8 100644
--- a/makima/src/db/models.rs
+++ b/makima/src/db/models.rs
@@ -1457,11 +1457,11 @@ pub struct Contract {
/// when evaluating task outputs.
#[serde(skip_serializing_if = "Option::is_none")]
pub red_team_prompt: Option<String>,
- /// Phase configuration copied from template at contract creation.
+ /// Phase configuration copied from template at contract creation (raw JSON).
/// When present, this overrides the built-in contract type phases.
- #[sqlx(json, default)]
+ /// Use `get_phase_config()` to get the parsed PhaseConfig.
#[serde(skip_serializing_if = "Option::is_none")]
- pub phase_config: Option<PhaseConfig>,
+ pub phase_config: Option<serde_json::Value>,
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -1486,7 +1486,7 @@ impl Contract {
/// Get valid phase IDs for this contract (as strings)
pub fn valid_phase_ids(&self) -> Vec<String> {
// Check phase_config first (for custom templates)
- if let Some(ref config) = self.phase_config {
+ if let Some(config) = self.get_phase_config() {
let mut phases: Vec<_> = config.phases.iter().collect();
phases.sort_by_key(|p| p.order);
return phases.iter().map(|p| p.id.clone()).collect();
@@ -1520,7 +1520,7 @@ impl Contract {
/// Get the initial phase ID for this contract type (as string)
pub fn initial_phase_id(&self) -> String {
// Check phase_config first (for custom templates)
- if let Some(ref config) = self.phase_config {
+ if let Some(config) = self.get_phase_config() {
return config.default_phase.clone();
}
@@ -1542,7 +1542,7 @@ impl Contract {
/// Get the terminal phase ID for this contract type (as string)
pub fn terminal_phase_id(&self) -> String {
// Check phase_config first (for custom templates)
- if let Some(ref config) = self.phase_config {
+ if let Some(config) = self.get_phase_config() {
// Last phase in sorted order is the terminal phase
let mut phases: Vec<_> = config.phases.iter().collect();
phases.sort_by_key(|p| p.order);
@@ -1571,8 +1571,10 @@ impl Contract {
}
/// Get the phase configuration for custom templates
- pub fn get_phase_config(&self) -> Option<&PhaseConfig> {
- self.phase_config.as_ref()
+ pub fn get_phase_config(&self) -> Option<PhaseConfig> {
+ self.phase_config
+ .as_ref()
+ .and_then(|v| serde_json::from_value(v.clone()).ok())
}
/// Get completed deliverable IDs for a specific phase