summaryrefslogtreecommitdiff
path: root/makima/src/db
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-02-13 20:40:26 +0000
committerGitHub <noreply@github.com>2026-02-13 20:40:26 +0000
commitc2bad633593a8ec6ffa83d7ff10776560cf0f69f (patch)
tree44db52e4b818b9298d8b0af172a281cc2faa80c5 /makima/src/db
parentad5af0f7677c73fc159a3036b9479d1d847adf97 (diff)
downloadsoryu-c2bad633593a8ec6ffa83d7ff10776560cf0f69f.tar.gz
soryu-c2bad633593a8ec6ffa83d7ff10776560cf0f69f.zip
Rerun plan when directive goal is edited (#61)
When a directive's goal is updated, pending/ready/failed/skipped steps are now automatically cleared so that replanning generates fresh steps aligned with the new goal. The planning prompt is also improved to clearly categorize existing steps by status and provide explicit instructions for re-evaluation. Changes: - Add clear_pending_directive_steps() repository function to remove non-started steps when the goal changes - Call step cleanup in the update_goal HTTP handler - Restructure the planning prompt to categorize steps (completed, running, pending, failed, skipped) with clear instructions for each category Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/db')
-rw-r--r--makima/src/db/repository.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/makima/src/db/repository.rs b/makima/src/db/repository.rs
index e288eba..d8168f6 100644
--- a/makima/src/db/repository.rs
+++ b/makima/src/db/repository.rs
@@ -5465,6 +5465,25 @@ pub async fn delete_directive_step(
Ok(result.rows_affected() > 0)
}
+/// Delete all directive steps that have not started execution (pending, ready, failed, skipped).
+/// Completed and running steps are preserved.
+/// Returns the number of deleted steps.
+pub async fn clear_pending_directive_steps(
+ pool: &PgPool,
+ directive_id: Uuid,
+) -> Result<u64, sqlx::Error> {
+ let result = sqlx::query(
+ r#"DELETE FROM directive_steps
+ WHERE directive_id = $1
+ AND status IN ('pending', 'ready', 'failed', 'skipped')"#,
+ )
+ .bind(directive_id)
+ .execute(pool)
+ .await?;
+
+ Ok(result.rows_affected())
+}
+
// =============================================================================
// Directive DAG Progression
// =============================================================================