From e11759447b1ac00becfb1e979e488f7f9c9cf478 Mon Sep 17 00:00:00 2001 From: soryu Date: Fri, 1 May 2026 23:56:51 +0100 Subject: chore(cleanup): Phase 5 contracts removal + tmp directive + 30-day expiry + scroll fix (#118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sweeping cleanup across the surface and the wire. Net: -14k LOC of legacy contracts code, plus the tmp/scroll/UX fixes the user asked for. ## Sidebar/editor independent scroll Replace `height: calc(100vh - 80px)` (which assumed an 80px masthead and quietly clipped or pushed the whole page below the fold when the masthead was taller) with `h-screen + overflow-hidden` on the page root and proper `flex-1 min-h-0` sizing on `
`. Sidebar and editor pane now manage their own scroll independently; the page itself never scrolls. Same fix in /tmp/:taskId. ## tmp directive — real backing for orphans/ephemerals New migration `20260501100000_tmp_directive_and_clear_orphans.sql`: * Adds `directives.is_tmp` BOOLEAN NOT NULL DEFAULT false. * Partial unique index `(owner_id) WHERE is_tmp` — at most ONE tmp directive per owner. * Hard-deletes every existing orphan task (`directive_id IS NULL`). Per the user spec: "ALSO there are TOO MANY old tasks in tmp, we need to remove all of them as well." New repository helpers: * `get_or_create_tmp_directive(pool, owner_id) -> Directive` INSERT ON CONFLICT DO NOTHING + fallback SELECT, race-safe. * `list_all_tmp_directives` — drives the expiry sweep. * `delete_expired_tmp_tasks(tmp_directive_id) -> u64`. * `list_tmp_tasks_for_owner` (replaces `list_orphan_tasks_for_owner`). `mesh::create_task`: every top-level task must have a directive. If a caller doesn't supply `directive_id` and isn't a subtask, attach to the caller's tmp directive (auto-creating it on first use). `list_directives_for_owner` filters out `is_tmp=true` so the scratchpad directive doesn't pollute the contract list — surfaced via the sidebar's `tmp/` folder instead. ## 30-day expiry on tmp tasks New `phase_tmp_expiry` in the directive reconciler. Throttled to once per hour: enumerates every tmp directive, calls `delete_expired_tmp_tasks`, logs the count. The actual delete is `WHERE created_at < NOW() - INTERVAL '30 days'` and is fast on the existing index. Subtasks die via FK cascade. ## Phase 5 — contracts removed ### Frontend Deleted entire `/contracts` surface: * routes: `contracts.tsx`, `contract-file.tsx` * components/contracts: ContractList, ContractDetail, ContractCliInput, ContractContextMenu, CommandModePanel, PhaseBadge, PhaseHint, PhaseDeliverablesPanel, PhaseProgressBar, QuickActionButtons, RepositoryPanel, TaskDerivationPreview * (Kept `PhaseConfirmationModal` — used outside the contracts surface by `TaskOutput` and `PhaseConfirmationNotification`.) * Routes deregistered from `main.tsx`; nav entry removed from `NavStrip`. ### Backend handlers Deleted: `contracts.rs` (2.4k LOC), `contract_chat.rs` (3.2k LOC), `contract_daemon.rs` (~940 LOC), `contract_discuss.rs` (~590 LOC), `transcript_analysis.rs` (~690 LOC). All `/api/v1/contracts/*` routes deregistered. OpenAPI entries dropped. Module declarations removed from `server/handlers/mod.rs`. ### CLI Removed `makima contract` and `makima supervisor` subcommands. Deleted `daemon/cli/contract.rs` and `daemon/cli/supervisor.rs`. Bin dispatch trimmed (~377 LOC). ### Orchestrator Removed the contract-spawn path from `phase_execution` (`spawn_step_contract` and its caller). `directive_steps.contract_type` now logs a warning and falls through to standalone-task spawn. Column itself stays — old data still reads, just no longer triggers a contract+supervisor spawn. ### TUI `Action::PerformCreateContract` is now a no-op that surfaces a status message: "Contracts have been removed. Use directives instead." The TUI form is dead code pending a wider refresh. ## Out of scope (deliberately left) * Contracts DB tables (`contracts`, `contract_repositories`, `contract_chat_history`, `contract_events`, `contract_templates`) are retained for historical data + because some peripheral code still joins to them in TaskSummary queries. * `mesh_supervisor` handlers are retained — they aren't only used by contracts (some mesh-level supervisor behaviour persists), and the cross-cutting cleanup is bigger than this PR. * `directive_steps.contract_type` column itself isn't dropped; just no longer functional. Co-authored-by: Claude Opus 4.7 (1M context) --- makima/src/server/mod.rs | 73 ++++-------------------------------------------- 1 file changed, 6 insertions(+), 67 deletions(-) (limited to 'makima/src/server/mod.rs') diff --git a/makima/src/server/mod.rs b/makima/src/server/mod.rs index efae901..59eff2e 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, chat, contract_chat, contract_daemon, contract_discuss, contracts, daemon_download, directives, file_ws, files, history, listen, mesh, mesh_chat, mesh_daemon, mesh_merge, mesh_supervisor, mesh_ws, orders, repository_history, speak, templates, transcript_analysis, users, versions}; +use crate::server::handlers::{api_keys, chat, daemon_download, directives, file_ws, files, history, listen, mesh, mesh_chat, mesh_daemon, mesh_merge, mesh_supervisor, mesh_ws, orders, repository_history, speak, templates, users, versions}; use crate::server::openapi::ApiDoc; use crate::server::state::SharedState; @@ -45,10 +45,8 @@ pub fn make_router(state: SharedState) -> Router { let api_v1 = Router::new() .route("/listen", get(listen::websocket_handler)) .route("/speak", get(speak::websocket_handler)) - // Listen/transcript analysis endpoints - .route("/listen/analyze", post(transcript_analysis::analyze_transcript)) - .route("/listen/create-contract", post(transcript_analysis::create_contract_from_analysis)) - .route("/listen/update-contract", post(transcript_analysis::update_contract_from_analysis)) + // Listen/transcript-analysis endpoints removed in Phase 5 with the + // contracts subsystem. .route("/files/subscribe", get(file_ws::file_subscription_handler)) .route("/files", get(files::list_files).post(files::create_file)) .route( @@ -167,68 +165,9 @@ pub fn make_router(state: SharedState) -> Router { get(users::get_user_settings_handler) .put(users::update_user_settings_handler), ) - // Contract endpoints - .route("/contracts/discuss", post(contract_discuss::discuss_contract_handler)) - .route( - "/contracts", - get(contracts::list_contracts).post(contracts::create_contract), - ) - .route( - "/contracts/{id}", - get(contracts::get_contract) - .put(contracts::update_contract) - .delete(contracts::delete_contract), - ) - .route("/contracts/{id}/phase", post(contracts::change_phase)) - .route("/contracts/{id}/deliverables/complete", post(contracts::mark_deliverable_complete)) - .route("/contracts/{id}/events", get(contracts::get_events)) - .route("/contracts/{id}/chat", post(contract_chat::contract_chat_handler)) - .route( - "/contracts/{id}/chat/history", - get(contract_chat::get_contract_chat_history).delete(contract_chat::clear_contract_chat_history), - ) - // Contract supervisor resume endpoints - .route("/contracts/{id}/supervisor/resume", post(mesh_supervisor::resume_supervisor)) - .route("/contracts/{id}/supervisor/conversation/rewind", post(mesh_supervisor::rewind_conversation)) - // Contract supervisor status endpoints - .route("/contracts/{id}/supervisor/status", get(contracts::get_supervisor_status)) - .route("/contracts/{id}/supervisor/heartbeats", get(contracts::get_supervisor_heartbeats)) - .route("/contracts/{id}/supervisor/sync", post(contracts::sync_supervisor)) - // History endpoints - .route("/contracts/{id}/history", get(history::get_contract_history)) - .route("/contracts/{id}/supervisor/conversation", get(history::get_supervisor_conversation)) - // Contract daemon endpoints (for tasks to interact with contracts) - .route("/contracts/{id}/daemon/status", get(contract_daemon::get_contract_status)) - .route("/contracts/{id}/daemon/checklist", get(contract_daemon::get_contract_checklist)) - .route("/contracts/{id}/daemon/goals", get(contract_daemon::get_contract_goals)) - .route("/contracts/{id}/daemon/report", post(contract_daemon::post_progress_report)) - .route("/contracts/{id}/daemon/suggest-action", post(contract_daemon::get_suggest_action)) - .route("/contracts/{id}/daemon/completion-action", post(contract_daemon::get_completion_action)) - .route( - "/contracts/{id}/daemon/files", - get(contract_daemon::list_contract_files).post(contract_daemon::create_contract_file), - ) - .route( - "/contracts/{id}/daemon/files/{file_id}", - get(contract_daemon::get_contract_file).put(contract_daemon::update_contract_file), - ) - // Contract repository endpoints - .route("/contracts/{id}/repositories/remote", post(contracts::add_remote_repository)) - .route("/contracts/{id}/repositories/local", post(contracts::add_local_repository)) - .route("/contracts/{id}/repositories/managed", post(contracts::create_managed_repository)) - .route( - "/contracts/{id}/repositories/{repo_id}", - axum::routing::delete(contracts::delete_repository), - ) - .route( - "/contracts/{id}/repositories/{repo_id}/primary", - axum::routing::put(contracts::set_repository_primary), - ) - // Contract task association endpoints - .route( - "/contracts/{id}/tasks/{task_id}", - post(contracts::add_task_to_contract).delete(contracts::remove_task_from_contract), - ) + // Contract endpoints removed in Phase 5. The contracts subsystem + // has been folded into directives — see Phase 5 in the unified + // surface plan. Routes are gone; handler files were deleted. // Directive endpoints .route( "/directives", -- cgit v1.2.3