summaryrefslogtreecommitdiff
path: root/makima/src/daemon/cli/supervisor.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-05-01 23:56:51 +0100
committerGitHub <noreply@github.com>2026-05-01 23:56:51 +0100
commite11759447b1ac00becfb1e979e488f7f9c9cf478 (patch)
treef8a58368de3f6dda3f2f5c1af34e869a0e714205 /makima/src/daemon/cli/supervisor.rs
parent80085c7cfa9d679ed3e3fd54a7d55fa8ab1addef (diff)
downloadsoryu-e11759447b1ac00becfb1e979e488f7f9c9cf478.tar.gz
soryu-e11759447b1ac00becfb1e979e488f7f9c9cf478.zip
chore(cleanup): Phase 5 contracts removal + tmp directive + 30-day expiry + scroll fix (#118)
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 `<main>`. 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) <noreply@anthropic.com>
Diffstat (limited to 'makima/src/daemon/cli/supervisor.rs')
-rw-r--r--makima/src/daemon/cli/supervisor.rs448
1 files changed, 0 insertions, 448 deletions
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
deleted file mode 100644
index 82d3900..0000000
--- a/makima/src/daemon/cli/supervisor.rs
+++ /dev/null
@@ -1,448 +0,0 @@
-//! Supervisor subcommand - contract orchestration commands.
-
-use clap::Args;
-use uuid::Uuid;
-
-/// Common arguments for supervisor commands.
-#[derive(Args, Debug, Clone)]
-pub struct SupervisorArgs {
- /// API URL
- #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")]
- pub api_url: String,
-
- /// API key for authentication
- #[arg(long, env = "MAKIMA_API_KEY")]
- pub api_key: String,
-
- /// Current task ID (optional) - the supervisor's own task ID
- #[arg(long, env = "MAKIMA_TASK_ID")]
- pub self_task_id: Option<Uuid>,
-
- /// Contract ID
- #[arg(long, env = "MAKIMA_CONTRACT_ID")]
- pub contract_id: Uuid,
-}
-
-/// Arguments for spawn command.
-#[derive(Args, Debug)]
-pub struct SpawnArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Name of the task
- #[arg(index = 1)]
- pub name: String,
-
- /// Plan/description for the task
- #[arg(index = 2)]
- pub plan: String,
-
- /// Parent task ID to branch from
- #[arg(long)]
- pub parent: Option<Uuid>,
-
- /// Checkpoint SHA to start from
- #[arg(long)]
- pub checkpoint: Option<String>,
-
- /// Repository URL (local path or remote URL). If not provided, will try to detect from current directory.
- #[arg(long)]
- pub repo: Option<String>,
-}
-
-/// Arguments for wait command.
-#[derive(Args, Debug)]
-pub struct WaitArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to wait for
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Timeout in seconds (total wait time)
- #[arg(index = 2, default_value = "300")]
- pub timeout: i32,
-
- /// Polling interval in seconds (how often to check task status via client-side polling)
- #[arg(long, default_value = "5")]
- pub poll_interval: u64,
-}
-
-/// Arguments for read-file command.
-#[derive(Args, Debug)]
-pub struct ReadFileArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to read from
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// File path to read
- #[arg(index = 2)]
- pub file_path: String,
-}
-
-/// Arguments for branch command.
-#[derive(Args, Debug)]
-pub struct BranchArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Branch name to create
- #[arg(index = 1)]
- pub name: String,
-
- /// Reference (task ID or SHA) to branch from
- #[arg(long)]
- pub from: Option<String>,
-}
-
-/// Arguments for merge command.
-#[derive(Args, Debug)]
-pub struct MergeArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to merge
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Target branch to merge into
- #[arg(long)]
- pub to: Option<String>,
-
- /// Squash commits on merge
- #[arg(long)]
- pub squash: bool,
-}
-
-/// Arguments for pr command.
-#[derive(Args, Debug)]
-pub struct PrArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Branch name to create PR from (e.g., "makima/feature-name")
- #[arg(index = 1)]
- pub branch: String,
-
- /// PR title
- #[arg(long)]
- pub title: String,
-
- /// PR body/description
- #[arg(long)]
- pub body: Option<String>,
-}
-
-/// Arguments for diff command.
-#[derive(Args, Debug)]
-pub struct DiffArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to get diff for
- #[arg(index = 1)]
- pub task_id: Uuid,
-}
-
-/// Arguments for checkpoint command.
-#[derive(Args, Debug)]
-pub struct CheckpointArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Checkpoint message
- #[arg(index = 1)]
- pub message: String,
-}
-
-/// Arguments for ask command (ask user a question).
-#[derive(Args, Debug)]
-pub struct AskArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// The question to ask
- #[arg(index = 1)]
- pub question: String,
-
- /// Optional choices (comma-separated)
- #[arg(long)]
- pub choices: Option<String>,
-
- /// Context about what this relates to
- #[arg(long)]
- pub context: Option<String>,
-
- /// Timeout in seconds (default: 3600 = 1 hour)
- #[arg(long, default_value = "3600")]
- pub timeout: i32,
-
- /// Block indefinitely until user responds (no timeout)
- #[arg(long, default_value = "false")]
- pub phaseguard: bool,
-
- /// Allow selecting multiple choices (response will be comma-separated)
- #[arg(long, default_value = "false")]
- pub multi_select: bool,
-
- /// Non-blocking mode - returns immediately without waiting for response
- #[arg(long, default_value = "false")]
- pub non_blocking: bool,
-
- /// Question type (general, phase_confirmation, contract_complete)
- #[arg(long, default_value = "general")]
- pub question_type: String,
-}
-
-/// Arguments for status command (get contract status including phase).
-#[derive(Args, Debug)]
-pub struct StatusArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-}
-
-/// Arguments for advance-phase command.
-#[derive(Args, Debug)]
-pub struct AdvancePhaseArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// The phase to advance to (specify, plan, execute, review)
- #[arg(index = 1)]
- pub phase: String,
-
- /// Confirm the phase transition (required when phase_guard is enabled).
- /// Without this flag, the command will return deliverables for review.
- #[arg(long, short = 'y')]
- pub confirmed: bool,
-}
-
-/// Arguments for mark-deliverable command.
-#[derive(Args, Debug)]
-pub struct MarkDeliverableArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// The deliverable ID to mark as complete (e.g., 'plan-document', 'pull-request', 'research-notes')
- #[arg(index = 1)]
- pub deliverable_id: String,
-
- /// Phase the deliverable belongs to. Defaults to current contract phase if not specified.
- #[arg(long)]
- pub phase: Option<String>,
-}
-
-/// Arguments for task command (get individual task details).
-#[derive(Args, Debug)]
-pub struct GetTaskArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to get details for
- #[arg(index = 1, id = "target_task_id")]
- pub target_task_id: Uuid,
-}
-
-/// Arguments for output command (get task output/claude log).
-#[derive(Args, Debug)]
-pub struct GetTaskOutputArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to get output for
- #[arg(index = 1, id = "target_task_id")]
- pub target_task_id: Uuid,
-}
-
-// ============================================================================
-// History Command Args
-// ============================================================================
-
-/// Arguments for task-history command.
-#[derive(Args, Debug)]
-pub struct TaskHistoryArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to view history for
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Include tool calls in output
- #[arg(long, default_value = "true")]
- pub tool_calls: bool,
-
- /// Maximum messages to return
- #[arg(long)]
- pub limit: Option<i32>,
-
- /// Output format (table, json, chat)
- #[arg(long, default_value = "chat")]
- pub format: String,
-}
-
-/// Arguments for task-checkpoints command (with optional diff).
-#[derive(Args, Debug)]
-pub struct TaskCheckpointsArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to list checkpoints for
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Include diff summary
- #[arg(long)]
- pub with_diff: bool,
-}
-
-// ============================================================================
-// Resume Command Args
-// ============================================================================
-
-/// Arguments for resume command.
-#[derive(Args, Debug)]
-pub struct ResumeArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Resume mode: continue, restart_phase, from_checkpoint
- #[arg(long, default_value = "continue")]
- pub mode: String,
-
- /// Checkpoint ID (required for from_checkpoint mode)
- #[arg(long)]
- pub checkpoint: Option<Uuid>,
-
- /// Additional context to inject
- #[arg(long)]
- pub context: Option<String>,
-}
-
-/// Arguments for task-resume-from command.
-#[derive(Args, Debug)]
-pub struct TaskResumeFromArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Source task ID
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Checkpoint number to resume from
- #[arg(long)]
- pub checkpoint: i32,
-
- /// Plan for the new task
- #[arg(long)]
- pub plan: String,
-
- /// Name for the new task
- #[arg(long)]
- pub name: Option<String>,
-}
-
-// ============================================================================
-// Rewind Command Args
-// ============================================================================
-
-/// Arguments for task-rewind command.
-#[derive(Args, Debug)]
-pub struct TaskRewindArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Task ID to rewind
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Checkpoint number to rewind to
- #[arg(long)]
- pub checkpoint: i32,
-
- /// Preserve mode: discard, create_branch, stash
- #[arg(long, default_value = "create_branch")]
- pub preserve: String,
-
- /// Branch name (for create_branch mode)
- #[arg(long)]
- pub branch_name: Option<String>,
-}
-
-/// Arguments for task-fork command.
-#[derive(Args, Debug)]
-pub struct TaskForkArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Source task ID
- #[arg(index = 1)]
- pub task_id: Uuid,
-
- /// Checkpoint number to fork from
- #[arg(long)]
- pub checkpoint: i32,
-
- /// Name for the new task
- #[arg(long)]
- pub name: String,
-
- /// Plan for the new task
- #[arg(long)]
- pub plan: String,
-
- /// Include conversation history
- #[arg(long, default_value = "true")]
- pub include_conversation: bool,
-}
-
-/// Arguments for rewind-conversation command.
-#[derive(Args, Debug)]
-pub struct ConversationRewindArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-
- /// Number of messages to rewind
- #[arg(long)]
- pub by_messages: Option<i32>,
-
- /// Message ID to rewind to
- #[arg(long)]
- pub to_message: Option<String>,
-
- /// Also rewind code to matching checkpoint
- #[arg(long)]
- pub rewind_code: bool,
-}
-
-/// Arguments for complete command (mark contract as complete).
-#[derive(Args, Debug)]
-pub struct CompleteArgs {
- #[command(flatten)]
- pub common: SupervisorArgs,
-}
-
-// ============================================================================
-// Resume Contract Command Args
-// ============================================================================
-
-/// Arguments for resume-contract command (reactivate a completed contract).
-#[derive(Args, Debug)]
-pub struct ResumeContractArgs {
- /// API URL
- #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")]
- pub api_url: String,
-
- /// API key for authentication
- #[arg(long, env = "MAKIMA_API_KEY")]
- pub api_key: String,
-
- /// Contract ID to resume
- #[arg(index = 1)]
- pub contract_id: Uuid,
-}
-