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 ¶
- Variables
- func FingerprintMarker(fp string) string
- func ParseFingerprintMarker(body string) string
- type Action
- type Change
- type ChangeType
- type CloudProvider
- type CompletionRequest
- type CompletionResponse
- type CuratedIssue
- type CurationForge
- type DepNode
- type Diff
- type Engine
- type FailureEvent
- type FileDiff
- type GitOpsInspector
- type GitOpsProvider
- type Hypothesis
- type Investigation
- type KBEntry
- type KubeEvent
- type KubeReader
- type LogLine
- type LogReader
- type LogResult
- type LogsProvider
- type Matrix
- type Message
- type MetricsProvider
- type ModelProvider
- type NetworkProvider
- type Notifier
- type OpSafety
- type PodStatus
- type Point
- type Ref
- type ReinvestForge
- type ResourceStatus
- type Sample
- type Samples
- type Selector
- type Series
- type SourceRef
- type TimeWindow
- type ToolCall
- type ToolSpec
- type Usage
- type Workload
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 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 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 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 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 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 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 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 TimeWindow ¶
TimeWindow is a [Start, End] interval.
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 ¶
Workload identifies a Kubernetes object.
func (Workload) Ref ¶
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. |