diagnostic

package
v0.11.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

orphan: agent self-debugging (master plan §5.7); to be invoked from error-recovery flow once a result-channel is plumbed

Package diagnostic — 10-tier feedback loop ladder (master plan §4.13).

When a fix attempt fails, escalate the verification depth one tier at a time. Each tier is more expensive than the last; we only climb when the previous tier passed but the bug recurred (a stronger signal that the last tier didn't actually exercise the broken behavior).

The ladder is deliberately ordered cheapest → most expensive:

  1. compile — does it build?
  2. unit-test — does the failing test now pass?
  3. broader-test — do the surrounding tests pass?
  4. lint — does static analysis flag anything?
  5. cli — does invoking via CLI reproduce the symptom?
  6. curl — does an end-to-end network probe pass?
  7. headless-browser — does headless browser smoke pass?
  8. property — does property-based / fuzz testing find a counterexample?
  9. bisect — git bisect against prior known-good?
  10. hitl-bash — surface to the human; ask them to run a bash check.

The ladder is data — callers (tools, slash command, the agent itself) pick a starting tier and climb. We don't execute the commands here; callers map a Tier to the right tool/CLI invocation for their context.

Index

Constants

This section is empty.

Variables

View Source
var ErrLadderExhausted = errors.New("diagnostic: ladder exhausted (escalate to human)")

ErrLadderExhausted indicates Climb was called past the top tier.

Functions

func FormatApproach

func FormatApproach(approach *Approach) string

func FormatReport

func FormatReport(report *DiagnosticReport) string

Types

type AnalyzeRequest

type AnalyzeRequest struct {
	Error         string            `json:"error"`
	ErrorOutput   string            `json:"error_output"`
	ModifiedFiles []string          `json:"modified_files"`
	FileContents  map[string]string `json:"file_contents"`
	RecentActions []string          `json:"recent_actions"`
}

type Analyzer

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

func NewAnalyzer

func NewAnalyzer(provider providers.Provider, model string) *Analyzer

func (*Analyzer) Analyze

func (a *Analyzer) Analyze(ctx context.Context, req AnalyzeRequest) (*DiagnosticReport, error)

func (*Analyzer) ClassifyError

func (a *Analyzer) ClassifyError(errMsg string) string

type Approach

type Approach struct {
	ID            int      `json:"id"`
	Description   string   `json:"description"`
	Steps         []string `json:"steps"`
	Confidence    float64  `json:"confidence"`
	Risk          string   `json:"risk"`
	EstimatedTime string   `json:"estimated_time"`
	FilesToChange []string `json:"files_to_change"`
}

type DiagnosticReport

type DiagnosticReport struct {
	Error          string      `json:"error"`
	ErrorType      string      `json:"error_type"`
	AffectedFiles  []FileInfo  `json:"affected_files"`
	RootCauses     []RootCause `json:"root_causes"`
	Approaches     []Approach  `json:"approaches"`
	Confidence     float64     `json:"confidence"`
	Recommendation string      `json:"recommendation"`
	Timestamp      time.Time   `json:"timestamp"`
}

type FileInfo

type FileInfo struct {
	Path         string `json:"path"`
	Role         string `json:"role"`
	Modified     bool   `json:"modified"`
	LinesAdded   int    `json:"lines_added"`
	LinesRemoved int    `json:"lines_removed"`
}

type FileRole

type FileRole struct {
	Path    string   `json:"path"`
	Role    string   `json:"role"`
	Package string   `json:"package"`
	Type    string   `json:"type"`
	Exports []string `json:"exports"`
}

func AnalyzeFile

func AnalyzeFile(path string, content string) FileRole

type Ladder

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

Ladder tracks progress up the tiers. Climb() returns the next tier to try, or io.EOF-style sentinel when exhausted.

func FromTier

func FromTier(t Tier) *Ladder

FromTier creates a ladder starting at the given tier (skip cheaper checks).

func NewLadder

func NewLadder() *Ladder

NewLadder creates a fresh ladder pointing at TierCompile.

func (*Ladder) Climb

func (l *Ladder) Climb() (Tier, error)

Climb advances to the next tier. Returns ErrLadderExhausted when there are no more rungs.

func (*Ladder) Current

func (l *Ladder) Current() Tier

Current returns the tier the ladder is currently sitting on.

func (*Ladder) Reset

func (l *Ladder) Reset()

Reset returns the ladder to its bottom rung.

type RootCause

type RootCause struct {
	Description string   `json:"description"`
	File        string   `json:"file"`
	Line        int      `json:"line"`
	Confidence  float64  `json:"confidence"`
	Evidence    []string `json:"evidence"`
}

type Tier

type Tier int

Tier is one step on the verification ladder.

const (
	TierCompile Tier = iota + 1
	TierUnitTest
	TierBroaderTest
	TierLint
	TierCLI
	TierCurl
	TierHeadlessBrowser
	TierProperty
	TierBisect
	TierHITLBash
)

func AllTiers

func AllTiers() []Tier

AllTiers returns the ladder in order.

func (Tier) Description

func (t Tier) Description() string

Description explains what the tier verifies.

func (Tier) Name

func (t Tier) Name() string

Name is a human-readable label for the tier.

func (Tier) SuggestedCommand

func (t Tier) SuggestedCommand(lang string) string

SuggestedCommand returns a starter shell command for the tier given a language ecosystem. Empty when no obvious default applies.

Jump to

Keyboard shortcuts

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