diagnose

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package diagnose is a deterministic, pure-Go pattern matcher over diagnostic signals the platform already collects: deploy attempt status/error, reconcile condition reason strings, crashloop alert state, and recent log lines. It is the "read-and-suggest layer on top of the platform API" section 4.11 of the project's CLAUDE.md describes: it never calls an external model, never writes to any resource, and never influences the reconciler. Every explanation this package returns is backed by a literal signal it read; when nothing matches, Diagnose returns the fallback response rather than a guess.

Index

Constants

View Source
const (
	ConfidenceHigh   = "high"
	ConfidenceMedium = "medium"
	ConfidenceNone   = "none"
)

Confidence levels Result.Confidence can hold.

Variables

View Source
var OOMLogPatterns = []string{"oomkilled", "out of memory", "exit code 137", "code: 137", "exit status 137"}

OOMLogPatterns are the lowercase substrings that identify a log line as an OOM-kill signal, shared with internal/rightsizing so that package's resource-recommendation engine treats "this app was OOM-killed" as the same tracked signal this package already diagnoses, not a second, possibly-drifting definition of the same thing.

Functions

This section is empty.

Types

type AttemptInput

type AttemptInput struct {
	Status string
	Error  string
}

AttemptInput is the deploy attempt signal, nil if the caller found no attempt to diagnose (e.g. an app that has never been deployed).

type ConditionInput

type ConditionInput struct {
	Type, Status, Reason, Message string
}

ConditionInput is one reconcile condition, the same shape GET /api/v1/apps/{name}/deploys already returns.

type CrashloopInput

type CrashloopInput struct {
	Firing                bool
	RestartCount          int
	RestartCountThreshold int
	RestartWindow         string
}

CrashloopInput is a crashloop alert rule's current evaluation state, nil if no crashloop rule is configured for this app.

type Input

type Input struct {
	ServiceName    string
	Attempt        *AttemptInput
	Conditions     []ConditionInput
	Crashloop      *CrashloopInput
	RecentLogLines []string
}

Input bundles every signal Diagnose considers. Every field is optional except ServiceName: a caller with fewer signals available (no telemetry configured, no crashloop rule set up) still gets a best-effort result, it just has less evidence to draw on.

type Result

type Result struct {
	Explanation    string
	Suggestion     string
	Confidence     string
	MatchedSignals []Signal
}

Result is what Diagnose returns.

func Diagnose

func Diagnose(in Input) Result

Diagnose synthesizes in's signals into a human-readable explanation and suggested next action. Deterministic: the same Input always produces the same Result.

type Signal

type Signal struct {
	Source  string
	Excerpt string
}

Signal is one piece of evidence a signature matched against, always tied to the literal text it was read from.

Jump to

Keyboard shortcuts

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