From 04e1e8f0dd85d19917ac5ba0b73cba65ebac8976 Mon Sep 17 00:00:00 2001 From: soryu Date: Mon, 26 Jan 2026 20:19:30 +0000 Subject: Add completion phases --- makima/src/db/models.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'makima/src/db/models.rs') diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs index 0c1d9f2..95517a1 100644 --- a/makima/src/db/models.rs +++ b/makima/src/db/models.rs @@ -1321,6 +1321,11 @@ pub struct Contract { /// phase outputs (like plans, requirements, etc.) before continuing. #[serde(default)] pub phase_guard: bool, + /// Completed deliverables per phase. + /// Structure: { "plan": ["plan-document"], "execute": ["pull-request"] } + #[sqlx(json)] + #[serde(default)] + pub completed_deliverables: serde_json::Value, pub version: i32, pub created_at: DateTime, pub updated_at: DateTime, @@ -1374,6 +1379,25 @@ impl Contract { _ => ContractPhase::Execute, // simple and execute both end at execute } } + + /// Get completed deliverable IDs for a specific phase + pub fn get_completed_deliverables(&self, phase: &str) -> Vec { + self.completed_deliverables + .get(phase) + .and_then(|v| v.as_array()) + .map(|arr| { + arr.iter() + .filter_map(|v| v.as_str().map(String::from)) + .collect() + }) + .unwrap_or_default() + } + + /// Check if a specific deliverable is marked as complete for a phase + pub fn is_deliverable_complete(&self, phase: &str, deliverable_id: &str) -> bool { + self.get_completed_deliverables(phase) + .contains(&deliverable_id.to_string()) + } } /// Contract repository record from the database -- cgit v1.2.3