Documentation
¶
Index ¶
- type CPUThreshold
- type Context
- func (c *Context) WithCurrentState(state *monitor.SystemState) *Context
- func (c *Context) WithPendingTasks(tasks []PendingTask) *Context
- func (c *Context) WithPrediction(prediction *ResourceImpact) *Context
- func (c *Context) WithResources(resources *ResourceEstimate) *Context
- func (c *Context) WithSafetyBuffer(buffer float64) *Context
- func (c *Context) WithThresholds(thresholds *ThresholdsConfig) *Context
- type FutureState
- type GPUThreshold
- type Manager
- func (m *Manager) AddPendingTask(task PendingTask)
- func (m *Manager) Decide(task string, complexity int, resources *ResourceEstimate) *Result
- func (m *Manager) Model() PredictionModel
- func (m *Manager) PendingCount() int
- func (m *Manager) RemovePendingTask(taskID string)
- func (m *Manager) Strategy() Strategy
- func (m *Manager) UpdateThresholds(thresholds *ThresholdsConfig)
- type ManagerConfig
- type MemoryThreshold
- type PendingTask
- type PredictionModel
- type Reason
- type ResourceEstimate
- type ResourceImpact
- type Result
- type StorageThreshold
- type Strategy
- type ThresholdsConfig
- type VRAMThreshold
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUThreshold ¶
type CPUThreshold struct {
MaxPercent float64
}
CPUThreshold defines CPU threshold.
type Context ¶
type Context struct {
// Request data
Task string
Complexity int
Resources *ResourceEstimate // optional, from client
// Current system state
CurrentState *monitor.SystemState
// Model prediction (may be nil if no data)
Prediction *ResourceImpact
// Configuration
Thresholds *ThresholdsConfig
SafetyBuffer float64 // for conservative strategy (e.g., 0.10 = 10%)
// Pending tasks (for queue_aware strategy)
PendingTasks []PendingTask
}
Context contains all information needed for making a decision.
func NewContext ¶
NewContext creates a new decision context.
func (*Context) WithCurrentState ¶
func (c *Context) WithCurrentState(state *monitor.SystemState) *Context
WithCurrentState sets the current system state.
func (*Context) WithPendingTasks ¶
func (c *Context) WithPendingTasks(tasks []PendingTask) *Context
WithPendingTasks sets the pending tasks for queue_aware strategy.
func (*Context) WithPrediction ¶
func (c *Context) WithPrediction(prediction *ResourceImpact) *Context
WithPrediction sets the model prediction.
func (*Context) WithResources ¶
func (c *Context) WithResources(resources *ResourceEstimate) *Context
WithResources sets the client's resource estimate.
func (*Context) WithSafetyBuffer ¶
WithSafetyBuffer sets the safety buffer for conservative strategy.
func (*Context) WithThresholds ¶
func (c *Context) WithThresholds(thresholds *ThresholdsConfig) *Context
WithThresholds sets the threshold configuration.
type FutureState ¶
type FutureState struct {
CPUPercent float64 `json:"cpu_percent"`
MemoryPercent float64 `json:"memory_percent"`
GPUPercent float64 `json:"gpu_percent,omitempty"`
VRAMPercent float64 `json:"vram_percent,omitempty"`
}
FutureState represents predicted system state after task execution.
type GPUThreshold ¶
type GPUThreshold struct {
MaxPercent float64
}
GPUThreshold defines GPU threshold.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager coordinates decision making.
func NewManager ¶
func NewManager( strategy Strategy, model PredictionModel, aggregator *monitor.Aggregator, cfg ManagerConfig, ) *Manager
NewManager creates a new decision manager.
func (*Manager) AddPendingTask ¶
func (m *Manager) AddPendingTask(task PendingTask)
AddPendingTask adds a task to the pending list.
func (*Manager) Decide ¶
func (m *Manager) Decide(task string, complexity int, resources *ResourceEstimate) *Result
Decide makes a decision about whether a task can run.
func (*Manager) PendingCount ¶
PendingCount returns the number of pending tasks.
func (*Manager) RemovePendingTask ¶
RemovePendingTask removes a task from the pending list.
func (*Manager) UpdateThresholds ¶
func (m *Manager) UpdateThresholds(thresholds *ThresholdsConfig)
UpdateThresholds updates the threshold configuration.
type ManagerConfig ¶
type ManagerConfig struct {
Thresholds *ThresholdsConfig
SafetyBuffer float64
}
ManagerConfig holds manager configuration.
type MemoryThreshold ¶
type MemoryThreshold struct {
MaxPercent float64
}
MemoryThreshold defines memory threshold.
type PendingTask ¶
type PendingTask struct {
Task string
Complexity int
StartedAt time.Time
Predicted *ResourceImpact
}
PendingTask represents a task awaiting observation.
type PredictionModel ¶
type PredictionModel interface {
Name() string
Predict(task string, complexity int) *ResourceImpact
Observe(task string, complexity int, impact *ResourceImpact)
Confidence(task string) float64
}
PredictionModel defines the interface for resource impact prediction. This is duplicated here to avoid import cycles. The actual implementation is in decision/model package.
type ResourceEstimate ¶
type ResourceEstimate struct {
CPU int `json:"cpu,omitempty"`
GPU int `json:"gpu,omitempty"`
Memory int `json:"memory,omitempty"`
}
ResourceEstimate represents client's estimate of resource requirements.
type ResourceImpact ¶
type ResourceImpact struct {
CPUDelta float64 `json:"cpu_delta"`
MemoryDelta float64 `json:"memory_delta"`
GPUDelta float64 `json:"gpu_delta,omitempty"`
VRAMDelta float64 `json:"vram_delta,omitempty"`
}
ResourceImpact represents the predicted or observed impact on resources.
type Result ¶
type Result struct {
// Main result
Allowed bool `json:"allowed"`
Reasons []Reason `json:"reasons,omitempty"`
// Predicted state after task execution
PredictedState *FutureState `json:"predicted,omitempty"`
// Confidence in the decision (0-1)
Confidence float64 `json:"confidence"`
// Metadata
Strategy string `json:"strategy"`
Model string `json:"model"`
}
Result contains the decision outcome.
type StorageThreshold ¶
type StorageThreshold struct {
MinFreeGB float64
}
StorageThreshold defines storage threshold.
type Strategy ¶
Strategy defines the interface for decision-making strategies. This is duplicated here to avoid import cycles. The actual implementation is in decision/strategy package.
type ThresholdsConfig ¶
type ThresholdsConfig struct {
CPU CPUThreshold
Memory MemoryThreshold
GPU GPUThreshold
VRAM VRAMThreshold
Storage StorageThreshold
}
ThresholdsConfig holds threshold configuration for decisions.
type VRAMThreshold ¶
type VRAMThreshold struct {
MaxPercent float64
}
VRAMThreshold defines VRAM threshold.