verdict

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package verdict defines the classification vocabulary flakehunter uses and the mitigation advice attached to each category.

Index

Constants

View Source
const DefaultConfidenceFloor = 0.5

DefaultConfidenceFloor is the point below which a specific category is downgraded to Unknown. A confidently wrong label is worse than an honest "I don't know" — a maintainer can act on the second and is misled by the first.

Variables

View Source
var ErrInvalid = errors.New("invalid verdict")

ErrInvalid marks a verdict that failed schema validation.

Functions

This section is empty.

Types

type Category

type Category string

Category is the root cause assigned to a flaky occurrence.

const (
	NetworkTimeout      Category = "network_timeout"
	RaceCondition       Category = "race_condition"
	InfraFlake          Category = "infra_flake"
	ResourceExhaustion  Category = "resource_exhaustion"
	TestOrderDependency Category = "test_order_dependency"
	GenuineBug          Category = "genuine_bug"
	Unknown             Category = "unknown"
)

The closed set of categories. Anything outside this set is rejected by the schema validator, so a model cannot invent its own taxonomy.

func AllCategories

func AllCategories() []Category

AllCategories lists every valid category, in report order.

func ParseCategory

func ParseCategory(s string) (Category, error)

ParseCategory converts a string to a Category, erroring on anything outside the closed set.

func (Category) Label

func (c Category) Label() string

Label returns a human-readable name for reports.

func (Category) Severity

func (c Category) Severity() int

Severity ranks categories for report ordering: a genuine bug hiding behind a rerun matters more than a runner blip.

func (Category) String

func (c Category) String() string

func (Category) Valid

func (c Category) Valid() bool

Valid reports whether c is a recognised category.

type Mitigation

type Mitigation struct {
	Summary string   `json:"summary"`
	Steps   []string `json:"steps"`
	// Owner hints at who should act, which is what actually gets a flake fixed.
	Owner string `json:"owner"`
}

Mitigation is the concrete advice attached to a category.

func MitigationFor

func MitigationFor(c Category) Mitigation

MitigationFor returns the advice registered for c, falling back to the Unknown guidance for anything unrecognised.

type Verdict

type Verdict struct {
	Category            Category `json:"category"`
	Confidence          float64  `json:"confidence"`
	Explanation         string   `json:"explanation"`
	CitedLines          []string `json:"cited_lines"`
	SuggestedMitigation string   `json:"suggested_mitigation"`

	// Set when the raw category was demoted for falling under the floor.
	Downgraded  bool     `json:"downgraded,omitempty"`
	RawCategory Category `json:"raw_category,omitempty"`
	// Citations the model produced that are not present in the excerpt.
	Hallucinated []string `json:"hallucinated_citations,omitempty"`
}

Verdict is the structured result of classifying one flaky occurrence.

func (Verdict) ApplyConfidenceFloor

func (v Verdict) ApplyConfidenceFloor(floor float64) Verdict

ApplyConfidenceFloor demotes a low-confidence verdict to Unknown, preserving the original label so a reviewer can still see what the model leaned towards.

func (Verdict) Mitigation

func (v Verdict) Mitigation() Mitigation

Mitigation returns the curated advice for this verdict's category.

func (Verdict) Validate

func (v Verdict) Validate() error

Validate checks the verdict against the schema contract: a known category, a confidence in [0,1] and a non-empty explanation.

func (Verdict) VerifyCitations

func (v Verdict) VerifyCitations(excerpt string) Verdict

VerifyCitations drops any cited line that does not literally appear in the excerpt, recording it under Hallucinated.

This is the tool's main defence against a fabricated justification: a model that invents a plausible-sounding log line would otherwise produce a verdict that reads as evidence-backed but is not. Comparison is on trimmed substrings because models routinely re-indent or clip what they quote.

Jump to

Keyboard shortcuts

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