Documentation
¶
Index ¶
- type Checkpoint
- type ExecutionResult
- type Manager
- func (m *Manager) CleanupCompleted(olderThan time.Duration) int
- func (m *Manager) CompleteCheckpoint(checkpoint *Checkpoint)
- func (m *Manager) DeleteCheckpoint(checkpointID string) error
- func (m *Manager) FindCheckpoint(taskDescription string) *Checkpoint
- func (m *Manager) GetProgress(checkpoint *Checkpoint) *Progress
- func (m *Manager) ListRecentCheckpoints(limit int) []*Checkpoint
- func (m *Manager) SetAutoResume(auto bool)
- func (m *Manager) SetValidationLevel(level ValidationLevel)
- func (m *Manager) StartCheckpoint(taskID string, plan *cognition.ExecutionPlan) *Checkpoint
- func (m *Manager) StoreError(checkpoint *Checkpoint, toolName string, err error)
- func (m *Manager) StoreToolResult(checkpoint *Checkpoint, toolName string, result interface{})
- func (m *Manager) SuggestRecoveryAction(checkpoint *Checkpoint, err error) RecoveryAction
- func (m *Manager) UpdateCheckpoint(checkpoint *Checkpoint, stepID int, stepName string)
- func (m *Manager) UpdateTurnCount(checkpoint *Checkpoint, turns int)
- func (m *Manager) ValidateResult(checkpoint *Checkpoint, toolName string, result interface{}) *ValidationResult
- type Progress
- type RecoveryAction
- type ResumeStrategy
- type ValidationLevel
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checkpoint ¶
type Checkpoint struct {
ID string `json:"id"` // Unique checkpoint ID
TaskID string `json:"task_id"` // Task this checkpoint belongs to
StepID int `json:"step_id"` // Current step being executed
StepName string `json:"step_name"` // Human-readable step name
TurnCount int `json:"turn_count"` // Turns used so far
State map[string]interface{} `json:"state"` // Arbitrary state data
ToolResults map[string]interface{} `json:"tool_results"` // Results from tools
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
IsFinal bool `json:"is_final"` // True if task completed
}
Checkpoint represents a saved execution state This is the core of the resumable execution pattern
type ExecutionResult ¶
type ExecutionResult struct {
ToolName string `json:"tool_name"`
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Duration time.Duration `json:"duration"`
Timestamp time.Time `json:"timestamp"`
}
ExecutionResult represents the result of a single tool execution
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles execution checkpointing, resumption, and validation This is Layer 3 of the Cortex three-layer architecture: Perception → Cognition → Execution
func NewManager ¶
NewManager creates a new execution manager
func (*Manager) CleanupCompleted ¶
CleanupCompleted removes completed checkpoints older than the threshold
func (*Manager) CompleteCheckpoint ¶
func (m *Manager) CompleteCheckpoint(checkpoint *Checkpoint)
CompleteCheckpoint marks a checkpoint as successfully completed
func (*Manager) DeleteCheckpoint ¶
DeleteCheckpoint removes a checkpoint
func (*Manager) FindCheckpoint ¶
func (m *Manager) FindCheckpoint(taskDescription string) *Checkpoint
FindCheckpoint finds a checkpoint to resume from Returns nil if no resumable checkpoint exists
func (*Manager) GetProgress ¶
func (m *Manager) GetProgress(checkpoint *Checkpoint) *Progress
GetProgress returns human-readable progress information
func (*Manager) ListRecentCheckpoints ¶
func (m *Manager) ListRecentCheckpoints(limit int) []*Checkpoint
ListRecentCheckpoints returns recently active checkpoints
func (*Manager) SetAutoResume ¶
SetAutoResume enables or disables auto-resume
func (*Manager) SetValidationLevel ¶
func (m *Manager) SetValidationLevel(level ValidationLevel)
SetValidationLevel sets the validation level
func (*Manager) StartCheckpoint ¶
func (m *Manager) StartCheckpoint(taskID string, plan *cognition.ExecutionPlan) *Checkpoint
StartCheckpoint begins a new checkpoint for a task
func (*Manager) StoreError ¶
func (m *Manager) StoreError(checkpoint *Checkpoint, toolName string, err error)
StoreError stores an execution error
func (*Manager) StoreToolResult ¶
func (m *Manager) StoreToolResult(checkpoint *Checkpoint, toolName string, result interface{})
StoreToolResult stores a tool execution result
func (*Manager) SuggestRecoveryAction ¶
func (m *Manager) SuggestRecoveryAction(checkpoint *Checkpoint, err error) RecoveryAction
SuggestRecoveryAction suggests what to do after a failure
func (*Manager) UpdateCheckpoint ¶
func (m *Manager) UpdateCheckpoint(checkpoint *Checkpoint, stepID int, stepName string)
UpdateCheckpoint updates the current checkpoint state
func (*Manager) UpdateTurnCount ¶
func (m *Manager) UpdateTurnCount(checkpoint *Checkpoint, turns int)
UpdateTurnCount updates the turn count in the checkpoint
func (*Manager) ValidateResult ¶
func (m *Manager) ValidateResult(checkpoint *Checkpoint, toolName string, result interface{}) *ValidationResult
ValidateResult validates an execution result against expectations
type Progress ¶
type Progress struct {
TaskID string `json:"task_id"`
CurrentStep int `json:"current_step"`
TotalSteps int `json:"total_steps"`
PercentComplete float64 `json:"percent_complete"`
CurrentAction string `json:"current_action"`
Message string `json:"message,omitempty"`
}
Progress represents task progress information for the user
type RecoveryAction ¶
type RecoveryAction string
RecoveryAction represents possible actions when execution fails
const ( RecoveryRetry RecoveryAction = "retry" // Retry the same step RecoveryAlternative RecoveryAction = "alternative" // Try a different approach RecoveryAskUser RecoveryAction = "ask_user" // Ask user what to do RecoveryAbort RecoveryAction = "abort" // Give up )
type ResumeStrategy ¶
type ResumeStrategy string
ResumeStrategy defines how to resume from a checkpoint
const ( ResumeAuto ResumeStrategy = "auto" // Resume automatically ResumeAskUser ResumeStrategy = "ask_user" // Ask user before resuming ResumeRestart ResumeStrategy = "restart" // Start over from beginning )
type ValidationLevel ¶
type ValidationLevel string
ValidationLevel defines how strictly to validate execution results
const ( ValidationNone ValidationLevel = "none" ValidationBasic ValidationLevel = "basic" // Check for obvious errors ValidationStrict ValidationLevel = "strict" // Verify expected outcomes ValidationFull ValidationLevel = "full" // LLM-based quality assessment )