alert

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package alert provides ring buffer storage and delivery routing for process alerts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertEntry

type AlertEntry struct {
	PatternID   string    `json:"pattern_id"`
	Severity    string    `json:"severity"`
	Category    string    `json:"category"`
	Description string    `json:"description"`
	Line        string    `json:"line"`
	ScriptID    string    `json:"script_id"`
	ProjectPath string    `json:"project_path,omitempty"`
	Timestamp   time.Time `json:"timestamp"`
}

AlertEntry represents a single alert stored in the daemon.

type AlertHub

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

AlertHub routes formatted alert messages to available delivery mechanisms: PTY overlay (stdin injection) and/or MCP session notifications.

func NewAlertHub

func NewAlertHub() *AlertHub

NewAlertHub creates a new AlertHub.

func (*AlertHub) AddMCPSink

func (h *AlertHub) AddMCPSink(sink MCPAlertSink)

AddMCPSink registers an MCP session for alert delivery.

func (*AlertHub) Deliver

func (h *AlertHub) Deliver(severity string, formatted string)

Deliver sends a pre-formatted alert message to all available sinks. Checks the push config to determine which channels are enabled.

func (*AlertHub) RemoveMCPSink

func (h *AlertHub) RemoveMCPSink(sink MCPAlertSink)

RemoveMCPSink unregisters an MCP session sink.

func (*AlertHub) SetOverlaySink

func (h *AlertHub) SetOverlaySink(sink OverlayAlertSink)

SetOverlaySink sets the overlay (PTY stdin) delivery sink.

func (*AlertHub) SetPushConfig

func (h *AlertHub) SetPushConfig(pc *config.PushConfig)

SetPushConfig sets the push channel configuration. When set, Deliver checks each channel before dispatching. A nil config means all channels are enabled (universal default).

type AlertStoreFilter

type AlertStoreFilter struct {
	Since       time.Time
	ProcessID   string
	Severity    string
	ProjectPath string
	Limit       int
}

AlertStoreFilter is the daemon-side filter for querying alerts.

type MCPAlertSink

type MCPAlertSink interface {
	SendAlert(level string, message string) error
}

MCPAlertSink delivers alert messages via MCP session notifications.

type OverlayAlertSink

type OverlayAlertSink interface {
	TypeAlert(text string) error
	IsEnabled() bool
}

OverlayAlertSink delivers alert messages via PTY stdin injection.

type ProcessAlertStore

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

ProcessAlertStore is a ring buffer store for alert entries. head points to the oldest entry; new entries are written at (head+len) % maxSize.

func NewProcessAlertStore

func NewProcessAlertStore(maxSize int) *ProcessAlertStore

NewProcessAlertStore creates a new alert store with the given capacity.

func (*ProcessAlertStore) Add

func (s *ProcessAlertStore) Add(entry *AlertEntry)

Add inserts an alert entry into the ring buffer.

func (*ProcessAlertStore) Clear

func (s *ProcessAlertStore) Clear()

Clear resets the buffer.

func (*ProcessAlertStore) ClearForProcess

func (s *ProcessAlertStore) ClearForProcess(processID string) int

ClearForProcess removes all alert entries for the given process ID. Returns the number of entries removed.

func (*ProcessAlertStore) Len

func (s *ProcessAlertStore) Len() int

Len returns the current number of entries.

func (*ProcessAlertStore) Query

func (s *ProcessAlertStore) Query(filter AlertStoreFilter) []*AlertEntry

Query returns entries matching the filter, oldest-to-newest.

Jump to

Keyboard shortcuts

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