summaryrefslogtreecommitdiff
path: root/makima/src/server/handlers/contracts.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-05 01:42:59 +0000
committersoryu <soryu@soryu.co>2026-02-05 01:42:59 +0000
commit6a0c912a3fbd8e9b3e87ef40e960803d819d966d (patch)
treeb2c50c490811286d163e40f8d624ee8d43c0ce43 /makima/src/server/handlers/contracts.rs
parent0302b4596e14210884df5d645df9a179d8f0c1c6 (diff)
downloadsoryu-6a0c912a3fbd8e9b3e87ef40e960803d819d966d.tar.gz
soryu-6a0c912a3fbd8e9b3e87ef40e960803d819d966d.zip
Add makima directives
Diffstat (limited to 'makima/src/server/handlers/contracts.rs')
-rw-r--r--makima/src/server/handlers/contracts.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/makima/src/server/handlers/contracts.rs b/makima/src/server/handlers/contracts.rs
index 54bae71..2b2fc26 100644
--- a/makima/src/server/handlers/contracts.rs
+++ b/makima/src/server/handlers/contracts.rs
@@ -575,11 +575,55 @@ pub async fn update_contract(
}),
).await;
- // If contract is part of a chain, progress the chain
+ // If contract is part of a chain, check evaluation requirements
if let Some(chain_id) = contract.chain_id {
let pool_clone = pool.clone();
let owner_id = auth.owner_id;
+ let contract_id = contract.id;
tokio::spawn(async move {
+ // Check if chain has evaluation enabled
+ let chain = match repository::get_chain_for_owner(&pool_clone, chain_id, owner_id).await {
+ Ok(Some(c)) => c,
+ Ok(None) => {
+ tracing::warn!(chain_id = %chain_id, "Chain not found for progression");
+ return;
+ }
+ Err(e) => {
+ tracing::error!(chain_id = %chain_id, error = %e, "Failed to get chain");
+ return;
+ }
+ };
+
+ // If evaluation is enabled, mark contract for evaluation
+ if chain.evaluation_enabled {
+ // Mark the chain_contract as pending evaluation
+ if let Ok(Some(chain_contract)) = repository::get_chain_contract_by_contract_id(&pool_clone, contract_id).await {
+ if let Err(e) = repository::update_chain_contract_evaluation_status(
+ &pool_clone,
+ chain_contract.id,
+ "pending_evaluation",
+ None,
+ None,
+ ).await {
+ tracing::error!(
+ chain_id = %chain_id,
+ contract_id = %contract_id,
+ error = %e,
+ "Failed to mark contract for evaluation"
+ );
+ } else {
+ tracing::info!(
+ chain_id = %chain_id,
+ contract_id = %contract_id,
+ "Contract marked for evaluation - waiting for directive contract to evaluate"
+ );
+ }
+ }
+ // Don't progress chain - directive contract will evaluate and progress
+ return;
+ }
+
+ // If evaluation is disabled, progress chain directly
match repository::progress_chain(&pool_clone, chain_id, owner_id).await {
Ok(result) => {
if !result.contracts_created.is_empty() {