summaryrefslogtreecommitdiff
path: root/makima/src/orchestration/directive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src/orchestration/directive.rs')
-rw-r--r--makima/src/orchestration/directive.rs77
1 files changed, 23 insertions, 54 deletions
diff --git a/makima/src/orchestration/directive.rs b/makima/src/orchestration/directive.rs
index 19077c9..b9ff3fe 100644
--- a/makima/src/orchestration/directive.rs
+++ b/makima/src/orchestration/directive.rs
@@ -448,6 +448,27 @@ impl DirectiveOrchestrator {
"Directive goal updated — spawning re-planning task"
);
+ // If directive already has a PR, remove completed steps that were included in it
+ if directive.pr_url.is_some() || directive.pr_branch.is_some() {
+ match remove_already_merged_steps(&self.pool, directive.id).await {
+ Ok(count) if count > 0 => {
+ tracing::info!(
+ directive_id = %directive.id,
+ removed = count,
+ "Auto-removed completed steps already included in PR before replanning"
+ );
+ }
+ Err(e) => {
+ tracing::warn!(
+ directive_id = %directive.id,
+ error = %e,
+ "Failed to auto-remove merged steps before replanning"
+ );
+ }
+ _ => {}
+ }
+ }
+
let existing_steps =
repository::list_directive_steps(&self.pool, directive.id).await?;
let generation =
@@ -471,61 +492,9 @@ impl DirectiveOrchestrator {
{
tracing::warn!(
directive_id = %directive.id,
- title = %directive.title,
- "Directive goal updated — spawning re-planning task"
+ error = %e,
+ "Failed to spawn re-planning task"
);
-
- // If directive already has a PR, remove completed steps that were included in it
- if directive.pr_url.is_some() || directive.pr_branch.is_some() {
- match remove_already_merged_steps(&self.pool, directive.id).await {
- Ok(count) if count > 0 => {
- tracing::info!(
- directive_id = %directive.id,
- removed = count,
- "Auto-removed completed steps already included in PR before replanning"
- );
- }
- Err(e) => {
- tracing::warn!(
- directive_id = %directive.id,
- error = %e,
- "Failed to auto-remove merged steps before replanning"
- );
- }
- _ => {}
- }
- }
-
- let existing_steps =
- repository::list_directive_steps(&self.pool, directive.id).await?;
- let generation =
- repository::get_directive_max_generation(&self.pool, directive.id).await? + 1;
- let goal_history =
- repository::get_directive_goal_history(&self.pool, directive.id, 3).await?;
-
- let plan =
- build_planning_prompt(&directive, &existing_steps, generation, &goal_history);
-
- if let Err(e) = self
- .spawn_orchestrator_task(
- directive.id,
- directive.owner_id,
- format!("Re-plan: {}", directive.title),
- plan,
- directive.repository_url.as_deref(),
- directive.base_branch.as_deref(),
- )
- .await
- {
- tracing::warn!(
- directive_id = %directive.id,
- error = %e,
- "Failed to spawn re-planning task"
- );
- }
- Ok::<(), anyhow::Error>(())
- }.await {
- tracing::warn!(directive_id = %directive.id, error = %e, "Error in re-planning directive — continuing");
}
}
Ok(())