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/server/mod.rs | |
| parent | 0d996cf7590e3e52f424859c7d6f0e68640f119e (diff) | |
| download | soryu-f240675da99bc7705e473b8f70a2628812aa4c10.tar.gz soryu-f240675da99bc7705e473b8f70a2628812aa4c10.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/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(); |
