From 0cf6f6a4c5c75c736e6fe3b1c726ef80c0a6c802 Mon Sep 17 00:00:00 2001 From: soryu Date: Sat, 24 Jan 2026 04:31:20 +0000 Subject: feat: implement dependency-ordered task execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add dependency tracking and validation for tasks to enforce execution order (schema changes → backend → UI) as specified in Section 1.3 of ralph-features-spec.md. Changes: - Add depends_on field to Task model (Vec) for explicit dependencies - Create database migration for depends_on column with GIN index - Add dependency_analysis.rs module with: - can_start_task() for checking if all dependencies are complete - Auto-detection of dependency patterns from file paths - Detection of schema/types/backend/UI categories - Warnings for potential dependency violations - Add DependencyOrderingConfig to daemon config with: - enabled: Enable/disable dependency checking - auto_detect: Auto-detect dependencies from file patterns - warn_on_violation: Warn on detected violations - Integrate dependency checks into task manager scheduling - Add depends_on to DaemonCommand::SpawnTask protocol The daemon performs dependency validation as a sanity check but defers to the server for authoritative scheduling decisions. Co-Authored-By: Claude Opus 4.5 --- makima/src/bin/makima.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'makima/src/bin/makima.rs') diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index 1a307d1..e2072da 100644 --- a/makima/src/bin/makima.rs +++ b/makima/src/bin/makima.rs @@ -165,7 +165,7 @@ async fn run_daemon( "[3/5] Opening local database: {}", config.local_db.path.display() ); - let _local_db = LocalDb::open(&config.local_db.path)?; + let local_db = Arc::new(std::sync::Mutex::new(LocalDb::open(&config.local_db.path)?)); eprintln!(" Database opened"); // Initialize worktree directories @@ -242,10 +242,17 @@ async fn run_daemon( api_key: config.server.api_key.clone(), heartbeat_commit_interval_secs: config.process.heartbeat_commit_interval_secs, checkpoint_patches: config.process.checkpoint_patches.clone(), + dependency_ordering: config.dependency_ordering.clone(), }; - // Create task manager - let task_manager = Arc::new(TaskManager::new(task_config, ws_tx.clone())); + // Create task manager with local database for crash recovery + let task_manager = Arc::new(TaskManager::new(task_config, ws_tx.clone(), local_db)); + + // Recover any orphaned tasks from previous daemon run + let recovered = task_manager.recover_orphaned_tasks().await; + if !recovered.is_empty() { + eprintln!(" Recovered {} orphaned tasks with intact worktrees", recovered.len()); + } // Spawn command handler let task_manager_clone = task_manager.clone(); @@ -260,6 +267,22 @@ async fn run_daemon( tracing::info!("Command handler stopped"); }); + // Spawn periodic worktree health check (every 60 seconds) + let health_check_manager = task_manager.clone(); + tokio::spawn(async move { + let mut interval = tokio::time::interval(std::time::Duration::from_secs(60)); + loop { + interval.tick().await; + let affected = health_check_manager.check_worktree_health().await; + if !affected.is_empty() { + tracing::info!( + count = affected.len(), + "Worktree health check detected missing worktrees - tasks marked for retry" + ); + } + } + }); + // Handle shutdown signals let shutdown_signal = async { tokio::signal::ctrl_c() -- cgit v1.2.3