mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-07 00:37:36 +00:00
Create internal/ai/patterns package: 1. Pattern Detector (detector.go): - Records historical events (high memory, OOM, restarts, etc.) - Detects recurring failure patterns - Calculates average interval between occurrences - Computes confidence based on pattern consistency - Predicts when failures will occur again - Persists to ai_patterns.json 2. Event types tracked: - high_memory, high_cpu, disk_full - oom, restart, unresponsive - backup_failed 3. Integration: - Wire PatternDetector into router startup - Add to AI context in buildEnrichedContext - FormatForContext generates failure predictions Example AI context now includes: 'OOM events typically occurs every ~10 days (next expected in ~3 days)' This enables proactive alerts before problems recur. All tests passing.
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package ai
|
|
|
|
import (
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/ai/patterns"
|
|
)
|
|
|
|
// PatternDetector is an alias for patterns.Detector
|
|
type PatternDetector = patterns.Detector
|
|
|
|
// PatternDetectorConfig is an alias for patterns.DetectorConfig
|
|
type PatternDetectorConfig = patterns.DetectorConfig
|
|
|
|
// HistoricalEvent is an alias for patterns.HistoricalEvent
|
|
type HistoricalEvent = patterns.HistoricalEvent
|
|
|
|
// FailurePrediction is an alias for patterns.FailurePrediction
|
|
type FailurePrediction = patterns.FailurePrediction
|
|
|
|
// EventType is an alias for patterns.EventType
|
|
type EventType = patterns.EventType
|
|
|
|
// Pattern is an alias for patterns.Pattern
|
|
type Pattern = patterns.Pattern
|
|
|
|
// Event type constants
|
|
const (
|
|
EventHighMemory = patterns.EventHighMemory
|
|
EventHighCPU = patterns.EventHighCPU
|
|
EventDiskFull = patterns.EventDiskFull
|
|
EventOOM = patterns.EventOOM
|
|
EventRestart = patterns.EventRestart
|
|
EventUnresponsive = patterns.EventUnresponsive
|
|
EventBackupFailed = patterns.EventBackupFailed
|
|
)
|
|
|
|
// NewPatternDetector creates a new pattern detector
|
|
func NewPatternDetector(cfg PatternDetectorConfig) *PatternDetector {
|
|
return patterns.NewDetector(cfg)
|
|
}
|
|
|
|
// DefaultPatternConfig returns default pattern detector configuration
|
|
func DefaultPatternConfig() PatternDetectorConfig {
|
|
return patterns.DefaultConfig()
|
|
}
|