diff options
Diffstat (limited to 'makima/src/server/handlers')
| -rw-r--r-- | makima/src/server/handlers/chains.rs | 136 |
1 files changed, 4 insertions, 132 deletions
diff --git a/makima/src/server/handlers/chains.rs b/makima/src/server/handlers/chains.rs index ae19ca0..6cef72c 100644 --- a/makima/src/server/handlers/chains.rs +++ b/makima/src/server/handlers/chains.rs @@ -15,8 +15,8 @@ use uuid::Uuid; use crate::db::models::{ AddContractDefinitionRequest, ChainContractDefinition, ChainContractDetail, ChainDefinitionGraphResponse, ChainEditorData, ChainEvent, ChainGraphResponse, ChainSummary, - ChainWithContracts, CreateChainRequest, CreateTaskRequest, StartChainRequest, - StartChainResponse, UpdateChainRequest, UpdateContractDefinitionRequest, + ChainWithContracts, CreateChainRequest, StartChainRequest, StartChainResponse, + UpdateChainRequest, UpdateContractDefinitionRequest, }; use crate::db::repository::{self, RepositoryError}; use crate::server::auth::Authenticated; @@ -1067,7 +1067,7 @@ pub async fn start_chain( State(state): State<SharedState>, Authenticated(auth): Authenticated, Path(chain_id): Path<Uuid>, - body: Option<Json<StartChainRequest>>, + _body: Option<Json<StartChainRequest>>, ) -> impl IntoResponse { let Some(ref pool) = state.db_pool else { return ( @@ -1077,11 +1077,6 @@ pub async fn start_chain( .into_response(); }; - let req = body.map(|b| b.0).unwrap_or(StartChainRequest { - with_supervisor: false, - repository_url: None, - }); - // Verify ownership and get chain let chain = match repository::get_chain_for_owner(pool, chain_id, auth.owner_id).await { Ok(Some(c)) => c, @@ -1152,114 +1147,6 @@ pub async fn start_chain( } } - // Create supervisor task if requested - let mut supervisor_task_id: Option<Uuid> = None; - if req.with_supervisor { - let supervisor_name = format!("Chain Supervisor: {}", chain.name); - let supervisor_plan = format!( - r#"You are the supervisor for chain "{}". - -## Environment Variables -- MAKIMA_CHAIN_ID={} -- MAKIMA_API_URL (configured) -- MAKIMA_API_KEY (configured) - -## Your Responsibilities -1. Monitor chain progress by periodically checking chain status -2. Validate that contracts are completing successfully -3. Identify and report any issues or blockers -4. Track the overall chain progress through the DAG - -## Available Commands -Use these makima CLI commands to monitor the chain: - -```bash -# Check chain status -makima chain status {} - -# List contracts in the chain -makima chain contracts {} - -# View the chain DAG with current status -makima chain graph {} --with-status -``` - -## Monitoring Loop -1. Check chain status every few minutes -2. If a contract fails, investigate the issue -3. Report progress to the user when milestones are reached -4. Mark the chain as complete when all contracts finish - -## Current Chain Info -- Chain ID: {} -- Chain Name: {} -- Total definitions: {} - -Begin monitoring the chain. Check the initial status and report what you find."#, - chain.name, - chain_id, - chain_id, - chain_id, - chain_id, - chain_id, - chain.name, - definitions.len() - ); - - let supervisor_req = CreateTaskRequest { - name: supervisor_name, - description: Some(format!("Supervisor task for chain: {}", chain.name)), - plan: supervisor_plan, - repository_url: req.repository_url.clone(), - base_branch: None, - target_branch: None, - parent_task_id: None, - contract_id: None, // Chain supervisor is not tied to a specific contract - target_repo_path: None, - completion_action: None, - continue_from_task_id: None, - copy_files: None, - is_supervisor: true, - checkpoint_sha: None, - priority: 0, - merge_mode: None, - branched_from_task_id: None, - conversation_history: None, - supervisor_worktree_task_id: None, - }; - - match repository::create_task_for_owner(pool, auth.owner_id, supervisor_req).await { - Ok(supervisor_task) => { - tracing::info!( - chain_id = %chain_id, - supervisor_task_id = %supervisor_task.id, - "Created supervisor task for chain" - ); - - // Update chain with supervisor_task_id - if let Err(e) = - repository::set_chain_supervisor_task(pool, chain_id, Some(supervisor_task.id)) - .await - { - tracing::warn!( - chain_id = %chain_id, - error = %e, - "Failed to link supervisor task to chain" - ); - } - - supervisor_task_id = Some(supervisor_task.id); - } - Err(e) => { - tracing::warn!( - chain_id = %chain_id, - error = %e, - "Failed to create supervisor task for chain" - ); - } - } - } - // Progress the chain - this creates root contracts (definitions with no dependencies) let progression = match repository::progress_chain(pool, chain_id, auth.owner_id).await { Ok(p) => p, @@ -1268,7 +1155,6 @@ Begin monitoring the chain. Check the initial status and report what you find."# // Chain is active but no contracts created - return partial success return Json(StartChainResponse { chain_id, - supervisor_task_id, contracts_created: vec![], status: "active".to_string(), }) @@ -1278,7 +1164,6 @@ Begin monitoring the chain. Check the initial status and report what you find."# Json(StartChainResponse { chain_id, - supervisor_task_id, contracts_created: progression.contracts_created, status: if progression.chain_completed { "completed".to_string() @@ -1357,20 +1242,7 @@ pub async fn stop_chain( .into_response(); } - // TODO: Kill the supervisor task if running - // Clear supervisor task ID and set status to archived - match repository::set_chain_supervisor_task(pool, chain_id, None).await { - Ok(_) => {} - Err(e) => { - tracing::error!("Failed to clear chain supervisor: {}", e); - return ( - StatusCode::INTERNAL_SERVER_ERROR, - Json(ApiError::new("DB_ERROR", e.to_string())), - ) - .into_response(); - } - } - + // Archive the chain match repository::update_chain_status(pool, chain_id, "archived").await { Ok(_) => Json(serde_json::json!({"stopped": true, "status": "archived"})).into_response(), Err(e) => { |
