From 88a4f15ce1310f8ee8693835be14aa5280233f17 Mon Sep 17 00:00:00 2001 From: soryu Date: Thu, 5 Feb 2026 23:42:48 +0000 Subject: Add directive-first chain system redesign Redesigns the chain system with a directive-first architecture where Directive is the top-level entity (the "why/what") and Chains are generated execution plans (the "how") that can be dynamically modified. Backend: - Add database migration for directive system tables - Add Directive, DirectiveChain, ChainStep, DirectiveEvent models - Add DirectiveVerifier and DirectiveApproval models - Add orchestration module with engine, planner, and verifier - Add comprehensive API handlers for directives - Add daemon CLI commands for directive management - Add directive skill documentation - Integrate contract completion with directive engine - Add SSE endpoint for real-time directive events Frontend: - Add directives route with split-view layout - Add 6-tab detail view (Overview, Chain, Events, Evaluations, Approvals, Verifiers) - Add React Flow DAG visualization for chain steps - Add SSE subscription hook for real-time event updates - Add useDirectives and useDirectiveEventSubscription hooks - Add directive types and API functions Fixes: - Fix test failures in ws/protocol, task_output, completion_gate, patch - Fix word boundary matching in looks_like_task() - Fix parse_last() to find actual last completion gate - Fix create_export_patch when merge-base equals HEAD - Clean up clippy warnings in new code Co-Authored-By: Claude Opus 4.5 --- makima/src/daemon/storage/patch.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'makima/src/daemon/storage') diff --git a/makima/src/daemon/storage/patch.rs b/makima/src/daemon/storage/patch.rs index 0da4eda..b374d15 100644 --- a/makima/src/daemon/storage/patch.rs +++ b/makima/src/daemon/storage/patch.rs @@ -227,6 +227,16 @@ pub async fn create_export_patch( None }; + // Get current HEAD SHA for comparison + let head_sha = Command::new("git") + .current_dir(worktree_path) + .args(["rev-parse", "HEAD"]) + .output() + .await + .ok() + .filter(|o| o.status.success()) + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()); + // If we couldn't find upstream, try common default branches let base = if base.is_none() { let default_branches = ["origin/main", "origin/master", "main", "master"]; @@ -241,14 +251,23 @@ pub async fn create_export_patch( if let Ok(output) = merge_base { if output.status.success() { - found_base = Some(String::from_utf8_lossy(&output.stdout).trim().to_string()); - break; + let mb_sha = String::from_utf8_lossy(&output.stdout).trim().to_string(); + // Skip if merge-base equals HEAD (would result in empty diff) + if head_sha.as_ref() != Some(&mb_sha) { + found_base = Some(mb_sha); + break; + } } } } found_base } else { - base + // Also check upstream base + if base.as_ref() == head_sha.as_ref() { + None + } else { + base + } }; // If still nothing, get the first commit or use HEAD~1 -- cgit v1.2.3