diff options
Diffstat (limited to 'makima/src/server/mod.rs')
| -rw-r--r-- | makima/src/server/mod.rs | 88 |
1 files changed, 9 insertions, 79 deletions
diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs index bd48a8f..62ad1c7 100644 --- a/makima/src/server/mod.rs +++ b/makima/src/server/mod.rs @@ -18,7 +18,7 @@ use tower_http::trace::TraceLayer; use utoipa::OpenApi; use utoipa_swagger_ui::SwaggerUi; -use crate::server::handlers::{api_keys, daemon_download, directive_documents, directives, file_ws, files, history, listen, mesh, mesh_daemon, mesh_merge, mesh_supervisor, mesh_ws, orders, repository_history, speak, users, versions}; +use crate::server::handlers::{api_keys, daemon_download, directive_documents, directives, file_ws, files, history, mesh, mesh_daemon, mesh_merge, mesh_supervisor, mesh_ws, orders, repository_history, speak, users, versions}; use crate::server::openapi::ApiDoc; use crate::server::state::SharedState; @@ -43,7 +43,6 @@ async fn health_check() -> impl IntoResponse { pub fn make_router(state: SharedState) -> Router { // API v1 routes let api_v1 = Router::new() - .route("/listen", get(listen::websocket_handler)) .route("/speak", get(speak::websocket_handler)) // Listen/transcript-analysis endpoints removed in Phase 5 with the // contracts subsystem. @@ -55,7 +54,6 @@ pub fn make_router(state: SharedState) -> Router { .put(files::update_file) .delete(files::delete_file), ) - .route("/files/{id}/sync-from-repo", post(files::sync_file_from_repo)) // Version history endpoints .route("/files/{id}/versions", get(versions::list_versions)) .route("/files/{id}/versions/{version}", get(versions::get_version)) @@ -103,9 +101,7 @@ pub fn make_router(state: SharedState) -> Router { .route("/mesh/tasks/{id}/merge/abort", post(mesh_merge::merge_abort)) .route("/mesh/tasks/{id}/merge/skip", post(mesh_merge::merge_skip)) .route("/mesh/tasks/{id}/merge/check", get(mesh_merge::merge_check)) - // Checkpoint endpoints - .route("/mesh/tasks/{id}/checkpoint", post(mesh_supervisor::create_checkpoint)) - .route("/mesh/tasks/{id}/checkpoints", get(mesh_supervisor::list_checkpoints)) + // Task conversation history. .route("/mesh/tasks/{id}/conversation", get(history::get_task_conversation)) // Resume and rewind endpoints .route("/mesh/tasks/{id}/rewind", post(mesh::rewind_task)) @@ -114,20 +110,11 @@ pub fn make_router(state: SharedState) -> Router { .route("/mesh/tasks/{id}/checkpoints/{cid}/branch", post(mesh::branch_from_checkpoint)) // Task branching endpoint .route("/mesh/tasks/{id}/branch", post(mesh::branch_task)) - // Supervisor endpoints (for supervisor.sh) - .route("/mesh/supervisor/contracts/{contract_id}/tasks", get(mesh_supervisor::list_contract_tasks)) - .route("/mesh/supervisor/contracts/{contract_id}/tree", get(mesh_supervisor::get_contract_tree)) - .route("/mesh/supervisor/tasks", post(mesh_supervisor::spawn_task)) - .route("/mesh/supervisor/tasks/{task_id}/wait", post(mesh_supervisor::wait_for_task)) - .route("/mesh/supervisor/tasks/{task_id}/read-file", post(mesh_supervisor::read_worktree_file)) - // Supervisor git operations - .route("/mesh/supervisor/branches", post(mesh_supervisor::create_branch)) - .route("/mesh/supervisor/tasks/{task_id}/merge", post(mesh_supervisor::merge_task)) - .route("/mesh/supervisor/tasks/{task_id}/diff", get(mesh_supervisor::get_task_diff)) - .route("/mesh/supervisor/pr", post(mesh_supervisor::create_pr)) - // Supervisor order creation endpoint + // Directive backchannel — used by `makima directive ask` and + // `makima directive create-order`. The /supervisor/ path is + // kept for CLI client backwards compat (see mesh_supervisor.rs + // module docstring). .route("/mesh/supervisor/orders", post(mesh_supervisor::create_order_for_task)) - // Supervisor question endpoints .route("/mesh/supervisor/questions", post(mesh_supervisor::ask_question)) .route("/mesh/supervisor/questions/{question_id}/poll", get(mesh_supervisor::poll_question)) .route("/mesh/questions", get(mesh_supervisor::list_pending_questions)) @@ -315,9 +302,6 @@ const ANONYMOUS_TASK_MAX_AGE_DAYS: i32 = 7; /// Interval for checkpoint patch cleanup (hourly) const CHECKPOINT_PATCH_CLEANUP_INTERVAL_SECS: u64 = 3600; -// Retry orchestrator checks for pending tasks every 30 seconds -const RETRY_ORCHESTRATOR_INTERVAL_SECS: u64 = 30; - /// Run the HTTP server with graceful shutdown support. /// /// # Arguments @@ -455,63 +439,9 @@ pub async fn run_server(state: SharedState, addr: &str) -> anyhow::Result<()> { } }); - // Clone state and pool for retry orchestrator - let retry_pool = pool.clone(); - let retry_state = state.clone(); - - // Spawn retry orchestrator - periodically retries pending tasks on available daemons - tokio::spawn(async move { - let mut interval = tokio::time::interval( - std::time::Duration::from_secs(RETRY_ORCHESTRATOR_INTERVAL_SECS) - ); - loop { - interval.tick().await; - - // Get all contracts with pending tasks awaiting retry - match crate::db::repository::get_all_pending_task_contracts(&retry_pool).await { - Ok(contract_owners) => { - for (contract_id, owner_id) in contract_owners { - // Try to start a pending task for this contract - match handlers::mesh_supervisor::try_start_pending_task( - &retry_state, - contract_id, - owner_id, - ).await { - Ok(Some(task)) => { - tracing::info!( - task_id = %task.id, - contract_id = %contract_id, - retry_count = task.retry_count, - "Retry orchestrator started pending task" - ); - } - Ok(None) => { - // No tasks could be started (no available daemons, etc.) - } - Err(e) => { - tracing::warn!( - contract_id = %contract_id, - error = %e, - "Retry orchestrator failed to start pending task" - ); - } - } - } - } - Err(e) => { - tracing::warn!( - error = %e, - "Retry orchestrator failed to query pending task contracts" - ); - } - } - } - }); - - tracing::info!( - "Retry orchestrator started (interval: {}s)", - RETRY_ORCHESTRATOR_INTERVAL_SECS - ); + // Retry orchestrator (contract-keyed) removed alongside legacy + // contracts — the directive system has its own reconciler that + // handles pending directive tasks. // Spawn directive orchestrator - automates directive lifecycle let directive_pool = pool.clone(); |
