diff options
Diffstat (limited to 'makima/src/orchestration/directive.rs')
| -rw-r--r-- | makima/src/orchestration/directive.rs | 84 |
1 files changed, 1 insertions, 83 deletions
diff --git a/makima/src/orchestration/directive.rs b/makima/src/orchestration/directive.rs index 7f90bcd..3d00a8f 100644 --- a/makima/src/orchestration/directive.rs +++ b/makima/src/orchestration/directive.rs @@ -11,7 +11,7 @@ use uuid::Uuid; use base64::Engine; -use crate::db::models::{CreateContractRequest, CreateTaskRequest, UpdateContractRequest, UpdateTaskRequest}; +use crate::db::models::{CreateTaskRequest, UpdateTaskRequest}; use crate::db::repository; use crate::server::state::{DaemonCommand, SharedState}; @@ -276,70 +276,6 @@ impl DirectiveOrchestrator { /// Phase 3: Monitor running steps and orchestrator tasks. async fn phase_monitoring(&self) -> Result<(), anyhow::Error> { - // Check contract-backed running steps first - let contract_steps = repository::get_running_steps_with_contracts(&self.pool).await?; - - for step in contract_steps { - if let Err(e) = async { - match step.contract_status.as_str() { - "completed" | "archived" => { - tracing::info!( - step_id = %step.step_id, - directive_id = %step.directive_id, - contract_id = %step.contract_id, - contract_status = %step.contract_status, - "Contract-backed step contract completed — updating step to completed" - ); - let update = crate::db::models::UpdateDirectiveStepRequest { - status: Some("completed".to_string()), - ..Default::default() - }; - repository::update_directive_step(&self.pool, step.step_id, update).await?; - - // Mark linked orders as done - if let Ok(linked_orders) = repository::get_orders_by_step_id(&self.pool, step.step_id).await { - for order in linked_orders { - if order.status != "done" && order.status != "archived" { - let order_update = crate::db::models::UpdateOrderRequest { - status: Some("done".to_string()), - ..Default::default() - }; - let _ = repository::update_order(&self.pool, order.owner_id, order.id, order_update).await; - } - } - } - - repository::advance_directive_ready_steps(&self.pool, step.directive_id) - .await?; - repository::check_directive_idle(&self.pool, step.directive_id).await?; - } - "active" => { - // Contract still active — check if the supervisor has failed - // by looking at whether there are any failed tasks with no active tasks remaining - tracing::debug!( - step_id = %step.step_id, - contract_id = %step.contract_id, - contract_phase = %step.contract_phase, - "Contract-backed step still active — monitoring" - ); - } - _ => { - // Unknown status — log and skip - tracing::debug!( - step_id = %step.step_id, - contract_id = %step.contract_id, - contract_status = %step.contract_status, - "Contract-backed step in unexpected status" - ); - } - } - Ok::<(), anyhow::Error>(()) - }.await { - tracing::warn!(step_id = %step.step_id, error = %e, "Error processing contract-backed step — continuing"); - } - } - - // Check task-backed running steps (excludes contract-backed steps) let running = repository::get_running_steps_with_tasks(&self.pool).await?; for step in running { @@ -549,12 +485,10 @@ impl DirectiveOrchestrator { base_branch: Option<&str>, ) -> Result<(), anyhow::Error> { let req = CreateTaskRequest { - contract_id: None, name, description: Some("Directive planning task".to_string()), plan, parent_task_id: None, - is_supervisor: false, priority: 0, repository_url: repo_url.map(|s| s.to_string()), base_branch: base_branch.map(|s| s.to_string()), @@ -567,7 +501,6 @@ impl DirectiveOrchestrator { checkpoint_sha: None, branched_from_task_id: None, conversation_history: None, - supervisor_worktree_task_id: None, directive_id: Some(directive_id), directive_step_id: None, }; @@ -607,12 +540,10 @@ impl DirectiveOrchestrator { continue_from_task_id: Option<Uuid>, ) -> Result<(), anyhow::Error> { let req = CreateTaskRequest { - contract_id: None, name, description: Some("Directive step execution task".to_string()), plan, parent_task_id: None, - is_supervisor: false, priority: 0, repository_url: repo_url.map(|s| s.to_string()), base_branch: base_branch.map(|s| s.to_string()), @@ -625,7 +556,6 @@ impl DirectiveOrchestrator { checkpoint_sha: None, branched_from_task_id: None, conversation_history: None, - supervisor_worktree_task_id: None, directive_id: Some(directive_id), directive_step_id: Some(step_id), }; @@ -704,8 +634,6 @@ impl DirectiveOrchestrator { completion_action: updated_task.completion_action.clone(), continue_from_task_id: updated_task.continue_from_task_id, copy_files: None, - contract_id: None, - is_supervisor: false, autonomous_loop: false, resume_session: false, conversation_history: None, @@ -713,7 +641,6 @@ impl DirectiveOrchestrator { patch_base_sha, local_only: false, auto_merge_local: false, - supervisor_worktree_task_id: None, directive_id: updated_task.directive_id, }; @@ -1107,12 +1034,10 @@ impl DirectiveOrchestrator { base_branch: Option<&str>, ) -> Result<Uuid, anyhow::Error> { let req = CreateTaskRequest { - contract_id: None, name, description: Some("Directive PR completion task".to_string()), plan, parent_task_id: None, - is_supervisor: false, priority: 0, repository_url: repo_url.map(|s| s.to_string()), base_branch: base_branch.map(|s| s.to_string()), @@ -1125,7 +1050,6 @@ impl DirectiveOrchestrator { checkpoint_sha: None, branched_from_task_id: None, conversation_history: None, - supervisor_worktree_task_id: None, directive_id: Some(directive_id), directive_step_id: None, }; @@ -1374,12 +1298,10 @@ pub async fn trigger_completion_task( // Create the completion task FIRST so we have a real task ID for the FK let req = CreateTaskRequest { - contract_id: None, name: task_name, description: Some("Directive PR completion task".to_string()), plan: prompt, parent_task_id: None, - is_supervisor: false, priority: 0, repository_url: directive.repository_url.clone(), base_branch: directive.base_branch.clone(), @@ -1392,7 +1314,6 @@ pub async fn trigger_completion_task( checkpoint_sha: None, branched_from_task_id: None, conversation_history: None, - supervisor_worktree_task_id: None, directive_id: Some(directive_id), directive_step_id: None, }; @@ -1454,8 +1375,6 @@ pub async fn trigger_completion_task( completion_action: updated_task.completion_action.clone(), continue_from_task_id: updated_task.continue_from_task_id, copy_files: None, - contract_id: None, - is_supervisor: false, autonomous_loop: false, resume_session: false, conversation_history: None, @@ -1463,7 +1382,6 @@ pub async fn trigger_completion_task( patch_base_sha, local_only: false, auto_merge_local: false, - supervisor_worktree_task_id: None, directive_id: updated_task.directive_id, }; |
