engine

package
v0.0.0-...-0b35af4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionPlan

type ActionPlan struct {
	Type        string
	Description string
	RiskScore   float64
	ImpactScore float64
	EstSavings  float64
}

ActionPlan represents a proposed optimization action

type AnalysisVector

type AnalysisVector struct {
	Name       string
	Score      float64
	Weight     float64
	Findings   []string
	Confidence float64
}

AnalysisVector represents a dimension of analysis

type ArbitrageEngine

type ArbitrageEngine struct {
	Adapter cloud.CloudAdapter
}

ArbitrageEngine hunts for price discrepancies between Availability Zones

func NewArbitrageEngine

func NewArbitrageEngine(adapter cloud.CloudAdapter) *ArbitrageEngine

func (*ArbitrageEngine) FindArbitrageOpportunity

func (e *ArbitrageEngine) FindArbitrageOpportunity(currentZone string, instanceType string) (*ActionPlan, error)

FindArbitrageOpportunity checks if moving a workload can save > 20%

type EngineConfig

type EngineConfig struct {
	MaxConcurrentCycles   int           `yaml:"max_concurrent_cycles"`
	MaxConcurrentAnalysis int           `yaml:"max_concurrent_analysis"`
	CycleInterval         time.Duration `yaml:"cycle_interval"`
	RiskThreshold         float64       `yaml:"risk_threshold"`
	MinSavingsThreshold   float64       `yaml:"min_savings_threshold"`
	MaxAnalysisTime       time.Duration `yaml:"max_analysis_time"`
	EnableAutoExecution   bool          `yaml:"enable_auto_execution"`
	RequireHumanApproval  bool          `yaml:"require_human_approval"`
	DefaultSavingsRatio   float64       `yaml:"default_savings_ratio"`
}

EngineConfig holds configuration for the OODA engine

func DefaultEngineConfig

func DefaultEngineConfig() *EngineConfig

DefaultEngineConfig returns default engine configuration

func ProductionEngineConfig

func ProductionEngineConfig() *EngineConfig

ProductionEngineConfig returns production engine configuration

type Forecast

type Forecast struct {
	Timestamp time.Time
	Value     float64
	Low       float64 // Confidence interval lower bound
	High      float64 // Confidence interval upper bound
}

type OODAEngine

type OODAEngine struct {
	// contains filtered or unexported fields
}

OODAEngine implements the OODA loop for cloud optimization

func NewOODAEngine

func NewOODAEngine(
	aiOrchestrator *ai.UnifiedOrchestrator,
	cloudAdapter cloud.CloudAdapter,
	repository Repository,
	securityCtrl *security.SecurityController,
	logger *zap.Logger,
	tracer trace.Tracer,
	config *EngineConfig,
) *OODAEngine

NewOODAEngine creates a new OODA engine

func (*OODAEngine) RunCycle

func (e *OODAEngine) RunCycle(ctx context.Context) error

RunCycle executes a complete OODA cycle

type OODAState

type OODAState int

OODAState represents the state in the OODA loop

const (
	StateObserve OODAState = iota
	StateOrient
	StateDecide
	StateAct
	StateComplete
	StateFailed
)

func (OODAState) String

func (s OODAState) String() string

type Opportunity

type Opportunity struct {
	ID          string
	ResourceID  string
	Description string
	Savings     float64
	Confidence  float64
	ActionType  string // e.g., "resize", "stop", "switch_region"
}

Opportunity represents a detected optimization chance

func (*Opportunity) PredictSavings

func (o *Opportunity) PredictSavings() float64

PredictSavings returns an estimated dollar amount

type OptimizationOpportunity

type OptimizationOpportunity struct {
	Resource         *cloud.ResourceV2
	AnalysisVectors  []AnalysisVector
	RiskScore        float64
	Recommendations  []string
	EstimatedSavings float64
	Confidence       float64
}

OptimizationOpportunity represents a potential optimization

type Oracle

type Oracle struct {
	// contains filtered or unexported fields
}

Oracle is the predictive engine

func NewOracle

func NewOracle(db *sql.DB) *Oracle

func (*Oracle) ForecastMetric

func (o *Oracle) ForecastMetric(ctx context.Context, metricName string, horizon time.Duration) (*Forecast, error)

ForecastMetric predicts future values for a metric using simple linear regression (for now) In production, this would interface with a more complex model or external ML service via Python SDK

func (*Oracle) PredictResourceStress

func (o *Oracle) PredictResourceStress(ctx context.Context, resourceID string) (bool, error)

PredictResourceStress uses forecasts to predict if a resource will be stressed

type Repository

type Repository interface {
	CreateAction(ctx context.Context, action *database.Action) error
	UpdateActionStatus(ctx context.Context, id string, status string, startedAt *time.Time, completedAt *time.Time, errorMsg *string) error
	CreateSavingsEvent(ctx context.Context, event *database.SavingsEvent) error
}

Repository defines the interface for data persistence required by the engine

type ScalingEngine

type ScalingEngine struct {
	// contains filtered or unexported fields
}

ScalingEngine handles proactive scaling based on predictions

func NewScalingEngine

func NewScalingEngine(oracle *Oracle, mem *memory.MemoryStore) *ScalingEngine

func (*ScalingEngine) EvaluateScalingNeeds

func (e *ScalingEngine) EvaluateScalingNeeds(ctx context.Context, resourceID string) error

EvaluateScalingNeeds checks if resources need proactive scaling

type Scheduler

type Scheduler struct{}

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) GenerateSchedulePlan

func (s *Scheduler) GenerateSchedulePlan(res *cloud.ResourceV2) (*ActionPlan, error)

func (*Scheduler) IsIndieForceWindow

func (s *Scheduler) IsIndieForceWindow() bool

IsIndieForceWindow returns true during 12 AM - 6 AM (Deep Night)

func (*Scheduler) IsOffPeak

func (s *Scheduler) IsOffPeak() bool

IsOffPeak returns true if current time is night (10PM-6AM) or weekend

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL