Documentation
¶
Overview ¶
Package optimizer provides AI-driven plan optimization before execution. It reviews the full task list and suggests structural improvements: reordering for better dependency flow, splitting large tasks, merging small related tasks, and flagging contradictory or redundant work.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyReorder ¶
ApplyReorder updates the Priority field of each task in the plan to match the suggested order. Priority 1 = first in the reordered list. It does NOT save state — the caller is responsible for persisting changes.
Types ¶
type OptimizeResult ¶
type OptimizeResult struct {
// Suggestions is the ordered list of improvement recommendations.
Suggestions []Suggestion `json:"suggestions"`
// ReorderedIDs lists all task IDs in the AI-suggested execution order.
// Applying this reordering will update task Priority fields accordingly.
// An empty slice means no reordering is suggested.
ReorderedIDs []int `json:"reordered_ids,omitempty"`
// Splits are tasks the AI recommends breaking into smaller pieces.
Splits []SplitSpec `json:"splits,omitempty"`
// Merges are groups of tasks the AI recommends combining.
Merges []MergeSpec `json:"merges,omitempty"`
// Summary is a short human-readable overview of what was found.
Summary string `json:"summary"`
}
OptimizeResult is the full output of the optimization pass.
func Optimize ¶
func Optimize(ctx context.Context, prov provider.Provider, model string, timeout time.Duration, plan *pm.Plan) (*OptimizeResult, error)
Optimize performs an AI review of the plan and returns optimization suggestions. It does NOT modify the plan — callers decide whether to apply changes.
func (*OptimizeResult) HasActionable ¶
func (r *OptimizeResult) HasActionable() bool
HasActionable returns true if there are any reorders, splits, or merges to apply.
type SplitSpec ¶
type SplitSpec struct {
OriginalID int `json:"original_id"`
NewTasks []string `json:"new_tasks"` // titles of the replacement tasks
}
SplitSpec describes how one task should be broken into sub-tasks.
type Suggestion ¶
type Suggestion struct {
Type SuggestionType `json:"type"`
Description string `json:"description"`
TaskIDs []int `json:"task_ids,omitempty"` // affected task IDs
Severity Severity `json:"severity"`
}
Suggestion is a single optimization recommendation.
type SuggestionType ¶
type SuggestionType string
SuggestionType classifies what kind of improvement is suggested.
const ( SuggestionReorder SuggestionType = "reorder" // change execution order SuggestionSplit SuggestionType = "split" // break one task into multiple SuggestionMerge SuggestionType = "merge" // combine two or more tasks SuggestionFlag SuggestionType = "flag" // contradictory, redundant, or risky SuggestionDependency SuggestionType = "dependency" // missing or wrong dependency )