diff options
| author | soryu <soryu@soryu.co> | 2026-05-18 01:21:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-18 01:21:30 +0100 |
| commit | f240675da99bc7705e473b8f70a2628812aa4c10 (patch) | |
| tree | 3ee2d24b431ccb8cd1a3013c86b34a5782a3e224 /makima/src/orchestration/directive.rs | |
| parent | 0d996cf7590e3e52f424859c7d6f0e68640f119e (diff) | |
| download | soryu-master.tar.gz soryu-master.zip | |
The contracts table, supervisor task type, and all their backing
machinery have been inert for several PRs. The directives system reads
its own active contract body for spec text, and PR #135 removed the
last LLM surface that spawned supervisors.
This PR wipes the dead surface in one shot — the user authorised a DB
wipe, so the migration drops every legacy table with CASCADE rather
than carrying forward stub rows. Net change: −12k LOC across handlers,
repository, state, models, the TUI, and the listen module.
What's gone:
- contracts, contract_chat_*, contract_events, contract_repositories,
contract_type_templates tables.
- supervisor_states, supervisor_heartbeats tables.
- mesh_chat_conversations, mesh_chat_messages tables.
- tasks.contract_id/is_supervisor/supervisor_task_id/supervisor_worktree_task_id columns.
- directive_steps.contract_id/contract_type columns.
- files.contract_id/contract_phase columns.
- history_events.contract_id/phase columns.
- The Contract/Supervisor/MeshChat handler + model + repository
surface, plus the daemon TUI views that read them.
- The standalone listen.rs websocket handler (orphaned with the LLM).
What stays:
- mesh_supervisor handler: trimmed to just the questions + orders
backchannel used by `makima directive ask` / `create-order` (kept
the URL prefix for CLI client compat).
- directive_documents (the user-facing "contracts" surface).
- pending_questions in-memory state for the directive Ask flow.
cargo check, cargo test --lib (68 passed), tsc, and vite build all
clean.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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, }; |
