core

package
v1.4.0-beta Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateOnCallProvider func(cfg *config.Config, awsClient *ssmincidents.Client) (OnCallProvider, error)

Function that will be implemented in the common package to avoid circular imports

Functions

func InitOnCallWorkflow

func InitOnCallWorkflow(awsClient *ssmincidents.Client, redisClient *redis.Client)

InitOnCallWorkflow initializes the global singleton instance This is called once from main.go with the Redis client and AWS client

Types

type AICallResult added in v1.4.0

type AICallResult struct {
	Finding     *AIFinding
	UserPrompt  string
	RawResponse string
	DurationMs  int64
	Model       string
}

AICallResult bundles the parsed finding with the inputs and outputs of the underlying model call. The trace fields (UserPrompt, RawResponse, DurationMs, Model) are persisted into the detect log so operators can audit what was sent to the model and what came back.

SystemPrompt is intentionally omitted — it is a constant per build and would bloat every record. Operators can fetch the current assembled system prompt via the agent admin API.

type AIFinding added in v1.3.9

type AIFinding struct {
	Title       string
	Summary     string
	Severity    string  // critical|high|medium|low
	Category    string  // e.g. "database", "auth", "deploy"
	Confidence  float64 // 0..1
	Suggestions []string
	SampleIDs   []string // signal IDs / pattern IDs for traceability
}

AIFinding is the structured response returned by an AISRE for an unknown / spiking pattern. Used by detect mode.

type AISRE added in v1.4.0

type AISRE interface {
	Name() string
	Analyze(ctx context.Context, result AgentResult) (*AICallResult, error)
}

AISRE turns an AgentResult into an AICallResult. Concrete implementations (OpenAI-compatible chat/completions, etc.) live under pkg/agent/ai.

type AgentResult added in v1.3.9

type AgentResult struct {
	Verdict       AgentVerdict
	PatternID     string   // empty when VerdictUnknown and pattern not yet stored
	Template      string   // human-readable pattern template ("Failed to ... at <*>:<*>")
	SampleSignals []Signal // representative signals (capped, post-redaction)
	Frequency     int      // matches in the current tick / window
	Baseline      float64  // EWMA baseline for the pattern (0 when unknown)
}

AgentResult is the output of a Detector for one batch of signals that share the same fingerprint.

type AgentVerdict added in v1.3.9

type AgentVerdict int

AgentVerdict is the classification a Detector pipeline assigns to a batch of signals that share a fingerprint.

const (
	// VerdictKnownPattern means the pattern is in the catalog and current
	// frequency is within baseline — suppress (no AI, no incident).
	VerdictKnownPattern AgentVerdict = iota
	// VerdictUnknown means the pattern was never seen during training —
	// forward to AI for analysis.
	VerdictUnknown
	// VerdictSpike means the pattern is known but frequency exceeds the
	// baseline by more than the configured threshold — forward to AI.
	VerdictSpike
)

func (AgentVerdict) String added in v1.3.9

func (v AgentVerdict) String() string

String renders an AgentVerdict for logging.

type Alert

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

func NewAlert

func NewAlert(providers ...AlertProvider) *Alert

func (*Alert) SendAlert

func (a *Alert) SendAlert(incident *m.Incident) error

type AlertProvider

type AlertProvider interface {
	SendAlert(incident *m.Incident) error
}

AlertProvider interface remains the same

type Detector added in v1.3.9

type Detector interface {
	Name() string
	Process(ctx context.Context, batch []Signal) ([]AgentResult, error)
}

Detector consumes signals and emits AgentResults.

type OnCallProvider added in v1.3.0

type OnCallProvider interface {
	TriggerOnCall(ctx context.Context, incidentID string, cfg *config.OnCallConfig) error
}

OnCallProvider defines the interface for on-call notification providers

type OnCallWorkflow

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

OnCallWorkflow coordinates on-call escalation with a single provider

func GetOnCallWorkflow

func GetOnCallWorkflow() *OnCallWorkflow

GetOnCallWorkflow returns the global singleton instance This maintains compatibility with existing code

func NewOnCallWorkflow added in v1.3.0

func NewOnCallWorkflow(redisClient *redis.Client, provider OnCallProvider) *OnCallWorkflow

NewOnCallWorkflow creates a new on-call workflow with the given provider

func (*OnCallWorkflow) Ack

func (w *OnCallWorkflow) Ack(incidentID string) error

Ack acknowledges an incident to prevent escalation

func (*OnCallWorkflow) Start

func (w *OnCallWorkflow) Start(incidentID string, oc config.OnCallConfig) error

Start initiates the on-call workflow for an incident

type QueueListener

type QueueListener interface {
	StartListening(handler func(content *map[string]interface{}) error) error
}

type Signal added in v1.3.9

type Signal struct {
	Source    string // e.g. "elasticsearch:prod-app"
	Timestamp time.Time
	Severity  string                 // raw severity from source, best-effort
	Message   string                 // primary text payload
	Fields    map[string]interface{} // structured fields
	Raw       map[string]interface{} // original document (capped size)
}

Signal is one normalized observation pulled from a SignalSource.

Fields holds best-effort structured fields; Raw is the original source document (capped to AgentConfig.SignalMaxBytes by the SignalSource so the pipeline cannot OOM on large documents).

type SignalSource added in v1.3.9

type SignalSource interface {
	// Name uniquely identifies the configured source instance. It is used as
	// part of Redis cursor keys, so it must be stable across restarts.
	Name() string

	// Pull returns all signals strictly newer than `since`, plus the new
	// cursor (== max timestamp seen, or `since` if no signals were returned).
	Pull(ctx context.Context, since time.Time) ([]Signal, time.Time, error)
}

SignalSource is a puller for one external observability backend (Elasticsearch, Loki, CloudWatch, ...).

Jump to

Keyboard shortcuts

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