providers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package providers defines the pluggable backend contracts RunLore is built on.

Every backend the agent touches is an interface, so the investigation loop and the knowledge entries are written against engine-agnostic types (notably Change), never against Flux/ArgoCD/VictoriaMetrics/Prometheus directly.

Core providers are built-in (direct clients) so the binary is self-contained; MCP is the extension layer for additional, optional tools.

This file is the architecture contract. Method bodies live in sub-packages.

Index

Constants

This section is empty.

Variables

View Source
var Ops = map[string]OpSafety{
	"suspend":   {Reversible: true, Blast: 1},
	"resume":    {Reversible: true, Blast: 1},
	"reconcile": {Reversible: true, Blast: 1},
}

Ops is the canonical registry of executable remediation operations and their server-authoritative safety metadata. The action gate (internal/action) derives reversibility/blast from this — never from model output — and the executor (internal/executor/flux) runs only ops listed here. One entry per op is the single source of truth that keeps the gate and the executor from drifting.

Functions

func FingerprintMarker

func FingerprintMarker(fp string) string

FingerprintMarker renders a hidden PR-body marker carrying the dedup fingerprint, so an open PR's fingerprint is recoverable from the PR listing without fetching file contents. It returns "" for an empty fingerprint so callers may append it unconditionally.

func ParseFingerprintMarker

func ParseFingerprintMarker(body string) string

ParseFingerprintMarker extracts the fingerprint from a PR body, or "" if absent.

Types

type Action

type Action struct {
	Name        string
	Description string
	Op          string // executable operation: suspend | resume | reconcile (empty = suggestion only)
	Target      Workload
	Mutating    bool   // true for any cluster write
	Reversible  bool   // a rollback/suspend is reversible; a delete may not be
	BlastRadius int    // number of workloads affected
	ApprovalID  string // runtime: set when registered for approval; drives Slack approve/reject buttons
}

Action describes a remediation the agent can propose and (at the upper autonomy rungs, after approval) execute. Op names a concrete, reversible operation an Executor can run; an empty Op is a suggestion only.

type Change

type Change struct {
	Workload    Workload
	Engine      Engine
	Type        ChangeType
	When        time.Time
	FromRev     string
	ToRev       string
	Source      SourceRef
	ManagedBy   string     // the Kustomization/Application/ResourceSet that owns it
	BlastRadius []Workload // resources affected by the change
	DiffRef     string     // opaque handle resolvable via GitOpsProvider.Diff
}

Change is the engine-agnostic unit of "what changed". Flux and ArgoCD both reduce to: revision history + a Git diff between two deployed revisions.

type ChangeType

type ChangeType string

ChangeType classifies a detected change.

const (
	ChangeSync      ChangeType = "sync"       // a reconcile/sync applied a new revision
	ChangeChartBump ChangeType = "chart-bump" // a Helm chart version changed
	ChangeImageBump ChangeType = "image-bump" // a container image tag changed
	ChangeDrift     ChangeType = "drift"      // observed state diverged from desired
	ChangeCloudAPI  ChangeType = "cloud-api"  // a mutating cloud control-plane call (CloudTrail)
)

Change types detected on the cluster.

type CloudProvider

type CloudProvider interface {
	// CloudChanges returns recent mutating cloud control-plane events (AWS:
	// CloudTrail) in the window, normalized to the engine-agnostic Change model so
	// they join the same "what changed" timeline as GitOps diffs.
	CloudChanges(ctx context.Context, sel Selector, w TimeWindow) ([]Change, error)
	// ResourceHealth returns cloud-side state/health for resources backing the
	// selector (EC2 instance status, ASG capacity/activities, EKS nodegroup), as
	// normalized lines for the model.
	ResourceHealth(ctx context.Context, sel Selector, w TimeWindow) (LogResult, error)
}

CloudProvider abstracts read-only cloud-side context for an incident. It adds the AWS-layer "what changed" lens (mutating control-plane events) and cloud resource health (instances/ASGs/nodegroups) that the in-cluster signals can't see.

Implemented with native cloud SDKs (aws-sdk-go-v2) and in-cluster identity (EKS Pod Identity / IRSA) — not Steampipe and not a bundled CLI (both break the single-binary property). Steampipe / cloud MCP servers stay optional MCP extensions. Cloud is opt-in (config.cloud.provider).

type CompletionRequest

type CompletionRequest struct {
	System   string
	Messages []Message
	Tools    []ToolSpec
}

CompletionRequest / CompletionResponse are the minimal LLM exchange types.

type CompletionResponse

type CompletionResponse struct {
	Text      string
	ToolCalls []ToolCall
	// Usage is the provider-reported token count for this completion. Zero when
	// the provider omits it (older endpoints, or a provider that does not report
	// it) — callers treat the zero value as "unknown", not "zero tokens".
	Usage Usage
	// Truncated is true when the provider stopped because it hit the output-token
	// ceiling (Anthropic stop_reason "max_tokens", OpenAI finish_reason "length",
	// Gemini finishReason "MAX_TOKENS"). It distinguishes a cut-off answer from a
	// complete one, so the loop need not treat a truncated reply as final.
	Truncated bool
}

CompletionResponse is the model's reply (text and/or tool calls).

type CuratedIssue

type CuratedIssue struct {
	Number    int
	Title     string
	Body      string
	Labels    []string
	UpdatedAt time.Time // forge last-update time; used by the curate lifecycle sweep
}

CuratedIssue is a minimal view of a curated KB issue, used by the re-investigate loop to re-run and post results back.

type CurationForge

type CurationForge interface {
	OpenPR(ctx context.Context, entry KBEntry) (Ref, error)
	ListPRsByLabel(ctx context.Context, label string) ([]CuratedIssue, error)
	Comment(ctx context.Context, number int, body string) error
}

CurationForge is the forge surface the curator's file-time gate needs: open a drafted PR, list open KB PRs (dedup), and comment to coalesce duplicates.

type DepNode

type DepNode struct {
	Workload Workload
	NotFound bool
	Ready    string // Ready condition status
	Reason   string
	Children []DepNode
}

DepNode is a node in a GitOps dependency tree (dependsOn + sourceRef edges), used to find the ROOT failing resource behind a dependency cascade.

type Diff

type Diff struct {
	Files []FileDiff
}

Diff is a unified diff scoped to a workload's path.

type Engine

type Engine string

Engine identifies a GitOps engine.

const (
	EngineFlux   Engine = "flux"
	EngineArgoCD Engine = "argocd"
	EngineAWS    Engine = "aws"
)

Supported GitOps engines. EngineAWS marks a non-GitOps change from the cloud control plane (CloudTrail), so cloud events join the same "what changed" model.

type FailureEvent

type FailureEvent struct {
	Workload Workload
	Engine   Engine
	Reason   string
	Message  string
	When     time.Time
}

FailureEvent is a normalized GitOps failure signal used as a React trigger.

type FileDiff

type FileDiff struct {
	Path  string
	Patch string
}

FileDiff is the unified-diff patch for a single file.

type GitOpsInspector

type GitOpsInspector interface {
	// ResourceStatus returns conditions, key refs, and recent Events for one object.
	ResourceStatus(ctx context.Context, w Workload) (ResourceStatus, error)
	// DependencyTree walks dependsOn/sourceRef edges to surface the root failure.
	DependencyTree(ctx context.Context, w Workload) (DepNode, error)
}

GitOpsInspector is optional read-only deep introspection for an investigation: a resource's status/refs/events and its dependency tree. Not every engine implements it (Flux does); consumers type-assert for it.

type GitOpsProvider

type GitOpsProvider interface {
	// Changes returns the ranked change timeline in a window (the spine).
	Changes(ctx context.Context, w TimeWindow, sel Selector) ([]Change, error)
	// Diff returns the actual Git diff for a change, scoped to its source path.
	Diff(ctx context.Context, c Change) (Diff, error)
	// WatchFailures emits normalized GitOps failure events as a React trigger.
	WatchFailures(ctx context.Context) (<-chan FailureEvent, error)
}

GitOpsProvider abstracts Flux/ArgoCD: the "what changed" spine + failure triggers.

type Hypothesis

type Hypothesis struct {
	Summary         string
	Confidence      float64
	ChangeRef       string
	Evidence        []string
	SuggestedAction string // reversible-first
	Reversible      bool
}

Hypothesis is one ranked root-cause candidate with its evidence.

type Investigation

type Investigation struct {
	Title         string
	RootCauses    []Hypothesis
	Changes       []Change
	Unresolved    []string // honest: what the agent could not determine
	Confidence    float64
	Recalled      bool     // true when produced by instant recall (a KB cache hit); the curator skips re-curating it
	Resource      Workload // the workload the investigation identified as affected; defaults to the originating alert workload when none was named (stored on curated entries for structural recall)
	Actions       []Action // proposed remediations (autonomy ladder; never executed at rung "suggest")
	CuratedURL    string   // runtime: KB issue/PR the curator opened, linked in delivery (set after curation)
	Fingerprint   string   // originating alert fingerprint; for outcome-ledger attribution
	Fingerprints  []string // coalesced batch fingerprints; one outcome open is recorded per entry
	TriggerKey    string   // deterministic incident identity (alert fingerprint, or failing resource+condition) set at trigger time; curator.DupFingerprint prefers it so reworded re-investigations of one incident still dedupe (#137)
	RecalledEntry string   // when Recalled: the catalog entry Path that was matched
	Verified      bool     // true when the adversarial verify pass ran and a root cause survived it
}

Investigation is the structured output contract of an investigation.

type KBEntry

type KBEntry struct {
	Type        string // OKF type, one of the validator vocabulary: Incident | Playbook | Concept
	Title       string
	Description string
	Resource    string
	Tags        []string
	Body        string // markdown
	Fingerprint string // deterministic dedup fingerprint (see curator.DupFingerprint)
}

KBEntry is an OKF knowledge entry the curator drafts from an investigation.

type KubeEvent

type KubeEvent struct {
	Type    string // Normal | Warning
	Reason  string
	Object  string // Kind/Name
	Message string
	Count   int32
}

KubeEvent is a normalized Kubernetes Event — surfaces causes that live in the event stream, not logs or status (FailedScheduling, FailedMount, …).

type KubeReader

type KubeReader interface {
	// PodStatuses returns pod health in a namespace, optionally narrowed by a label
	// selector (empty = all pods).
	PodStatuses(ctx context.Context, namespace, labelSelector string) ([]PodStatus, error)
	// Events returns recent Events in a namespace; objectName "" = all objects;
	// warnOnly restricts to Warning events.
	Events(ctx context.Context, namespace, objectName string, warnOnly bool) ([]KubeEvent, error)
}

KubeReader reads read-only pod status and Kubernetes Events for incident triage, backing the pod_status / kube_events tools. Implemented with client-go CoreV1.

type LogLine

type LogLine struct {
	Time    time.Time
	Message string
	Fields  map[string]string
}

LogLine is one normalized log entry (engine-agnostic).

type LogReader

type LogReader interface {
	// PodLogs returns recent log lines from pods matching labelSelector in
	// namespace, bounded to the last sinceMinutes (0 = no lower bound).
	PodLogs(ctx context.Context, namespace, labelSelector string, sinceMinutes int) (LogResult, error)
}

LogReader reads recent pod logs from the cluster (read-only), backing the controller_logs investigation tool. Implemented with client-go CoreV1 GetLogs.

type LogResult

type LogResult []LogLine

LogResult is a logs/network query result.

type LogsProvider

type LogsProvider interface {
	Query(ctx context.Context, query string, w TimeWindow) (LogResult, error)
}

LogsProvider abstracts the logs backend (VictoriaLogs now; Loki etc. later).

type Matrix

type Matrix []Series

Matrix is a range-query result.

type Message

type Message struct {
	Role       string // system | user | assistant | tool
	Content    string
	ToolCalls  []ToolCall // assistant turn requesting tools
	ToolCallID string     // tool turn: the call this answers
}

Message is one turn in an LLM exchange.

type MetricsProvider

type MetricsProvider interface {
	Query(ctx context.Context, promql string, at time.Time) (Samples, error)
	QueryRange(ctx context.Context, promql string, w TimeWindow, step time.Duration) (Matrix, error)
}

MetricsProvider abstracts VictoriaMetrics/Prometheus (both speak PromQL).

type ModelProvider

type ModelProvider interface {
	Complete(ctx context.Context, req CompletionRequest) (CompletionResponse, error)
}

ModelProvider abstracts the LLM (Anthropic | OpenAI-compatible: vLLM/Ollama).

type NetworkProvider

type NetworkProvider interface {
	Drops(ctx context.Context, sel Selector, w TimeWindow) (LogResult, error)
}

NetworkProvider abstracts network observability (Hubble now).

type Notifier

type Notifier interface {
	Deliver(ctx context.Context, inv Investigation) error
}

Notifier delivers an investigation to a destination. Pluggable: Slack and Matrix first; PagerDuty and incident.io later. Several notifiers can be wired at once (e.g. chat for humans + an incident platform for the on-call record).

type OpSafety

type OpSafety struct {
	Reversible bool
	Blast      int
}

OpSafety is the server-derived safety metadata for an executable action op.

type PodStatus

type PodStatus struct {
	Name    string
	Phase   string
	Ready   string   // "1/2"
	Healthy bool     // Running/Succeeded with all containers ready and no waiting reasons
	Reasons []string // e.g. "registry: CreateContainerConfigError: couldn't find key username in Secret …"
}

PodStatus is a pod's high-level health: phase, ready count, and per-container waiting/terminated reasons — the pod-level signals (CreateContainerConfigError, ImagePullBackOff, CrashLoopBackOff, …) that never reach logs because the container never started.

type Point

type Point struct {
	Time  time.Time
	Value float64
}

Point is a single (time, value) in a range series.

type Ref

type Ref struct{ URL string }

Ref is a URL handle to a created issue or PR.

type ReinvestForge

type ReinvestForge interface {
	// ListIssuesByLabel returns open issues carrying the given label.
	ListIssuesByLabel(ctx context.Context, label string) ([]CuratedIssue, error)
	// Comment posts a comment on an issue.
	Comment(ctx context.Context, number int, body string) error
	// ReplaceLabel removes one label and adds another (lifecycle transition);
	// either side may be empty to only add or only remove.
	ReplaceLabel(ctx context.Context, number int, remove, add string) error
}

ReinvestForge lists curated issues flagged for re-investigation and posts results back to them. RunLore polls the forge (outbound) — it receives no inbound GitHub webhooks — so a human checking the "reinvestigate" label triggers a fresh run.

type ResourceStatus

type ResourceStatus struct {
	Workload Workload
	NotFound bool              // the object does not exist (often the cascade root)
	Ready    string            // Ready condition status: "True"/"False"/"Unknown"/""
	Reason   string            // Ready condition reason
	Message  string            // Ready condition message
	Refs     map[string]string // key spec references (e.g. sourceRef, dependsOn)
	Events   []string          // recent Event lines (type/reason/message)
}

ResourceStatus is a read-only snapshot of a GitOps/Kubernetes object's health, used to investigate WHY a resource is failing (not just that it is).

type Sample

type Sample struct {
	Metric map[string]string
	Value  float64
	Time   time.Time
}

Sample is one instant metric value with its labels.

type Samples

type Samples []Sample

Samples is an instant-vector result.

type Selector

type Selector struct {
	Namespace string
	Kind      string
	Name      string
}

Selector narrows a query to a subset of workloads.

type Series

type Series struct {
	Metric map[string]string
	Points []Point
}

Series is a labeled time series (range query).

type SourceRef

type SourceRef struct {
	RepoURL string
	Path    string
}

SourceRef points at the Git source + path backing a change.

type TimeWindow

type TimeWindow struct {
	Start time.Time
	End   time.Time
}

TimeWindow is a [Start, End] interval.

type ToolCall

type ToolCall struct {
	ID   string
	Name string
	Args string // JSON
}

ToolCall is a model request to invoke a tool.

type ToolSpec

type ToolSpec struct {
	Name        string
	Description string
	Schema      string // JSON Schema
}

ToolSpec describes a tool offered to the model.

type Usage

type Usage struct {
	InputTokens  int // prompt/input tokens billed for the request
	OutputTokens int // generated/output tokens in the reply
}

Usage is the provider-reported token accounting for one completion.

type Workload

type Workload struct {
	Kind      string
	Name      string
	Namespace string
}

Workload identifies a Kubernetes object.

func (Workload) Ref

func (w Workload) Ref() string

Ref renders the workload as "namespace/name", or just "namespace" when the name is unknown (common for alert-triggered investigations), or "" when the namespace is unknown too. It is the canonical form used for structural recall matching, curated-entry resources, and outcome-ledger attribution.

Directories

Path Synopsis
cloud
aws
Package aws implements providers.CloudProvider against AWS using aws-sdk-go-v2 and in-cluster identity (EKS Pod Identity / IRSA, resolved by the SDK's default credential chain).
Package aws implements providers.CloudProvider against AWS using aws-sdk-go-v2 and in-cluster identity (EKS Pod Identity / IRSA, resolved by the SDK's default credential chain).
Package cluster reads Kubernetes pod logs for investigation (read-only) via the client-go CoreV1 GetLogs API.
Package cluster reads Kubernetes pod logs for investigation (read-only) via the client-go CoreV1 GetLogs API.
gitops
argocd
Package argocd implements providers.GitOpsProvider for Argo CD: it reads Argo CD Applications from the cluster and emits engine-agnostic Changes (diffable via whatchanged.Differ) and failure events — the same contract as the flux package.
Package argocd implements providers.GitOpsProvider for Argo CD: it reads Argo CD Applications from the cluster and emits engine-agnostic Changes (diffable via whatchanged.Differ) and failure events — the same contract as the flux package.
flux
Package flux implements providers.GitOpsProvider for Flux: it reads Flux Kustomizations and their GitRepository sources from the cluster and emits engine-agnostic Changes, each diffable through whatchanged.Differ.
Package flux implements providers.GitOpsProvider for Flux: it reads Flux Kustomizations and their GitRepository sources from the cluster and emits engine-agnostic Changes, each diffable through whatchanged.Differ.

Jump to

Keyboard shortcuts

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