Documentation
¶
Overview ¶
Package verdict defines the classification vocabulary flakehunter uses and the mitigation advice attached to each category.
Index ¶
Constants ¶
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 ¶
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 ¶
ParseCategory converts a string to a Category, erroring on anything outside the closed set.
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 ¶
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 ¶
Validate checks the verdict against the schema contract: a known category, a confidence in [0,1] and a non-empty explanation.
func (Verdict) VerifyCitations ¶
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.