validation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsAll

func ContainsAll(required, actual []string) bool

ContainsAll returns true if actual contains every element in required.

func ContainsAny

func ContainsAny(items, actual []string) bool

ContainsAny returns true if actual contains at least one element from items.

func Extra

func Extra(expected, actual []string) []string

Extra returns elements in actual that are not in expected.

func FormatResult

func FormatResult(r ComparisonResult) string

FormatResult returns a human-readable summary of a comparison result.

func Missing

func Missing(expected, actual []string) []string

Missing returns elements in expected that are not in actual.

func Precision

func Precision(expected, actual []string) float64

Precision computes |expected ∩ actual| / |actual|. Returns 1.0 if actual is empty.

func Recall

func Recall(expected, actual []string) float64

Recall computes |expected ∩ actual| / |expected|. Returns 1.0 if expected is empty.

Types

type ComparisonResult

type ComparisonResult struct {
	Subject string

	MustReadRecall    float64
	MustReadPrecision float64
	MustReadMissing   []string
	MustReadExtra     []string

	RelatedRecall  float64
	RelatedMissing []string

	TestsRecall  float64
	TestsMissing []string

	ForbiddenViolations        []string // must_read_forbidden items found in actual must_read
	RelatedForbiddenViolations []string // related_forbidden items found in actual related
	OrderingViolations         []string // must_read_ordered pairs where order is wrong
	IgnoreMissing              []string // ignore_must_contain items found in positive sections

	ExternalRecall  float64
	ExternalMissing []string

	StableMissing []string // expect_stable entries not found as stable in must_read

	Pass bool
}

ComparisonResult holds the outcome of comparing actual output to a fixture.

func Compare

func Compare(fixture *Fixture, actual *model.AnalysisOutput, th Thresholds) ComparisonResult

Compare checks actual analysis output against fixture expectations.

type Fixture

type Fixture struct {
	Subject           string   `json:"subject"`
	MustRead          []string `json:"must_read"`
	MustReadForbidden []string `json:"must_read_forbidden"`
	MustReadOrdered   []string `json:"must_read_ordered,omitempty"`
	Related           []string `json:"related"`
	RelatedForbidden  []string `json:"related_forbidden,omitempty"`
	Tests             []string `json:"tests"`
	IgnoreMustContain []string `json:"ignore_must_contain"`
	External          []string `json:"external,omitempty"`
	ExpectStable      []string `json:"expect_stable,omitempty"`
}

Fixture defines expected analysis output for a single subject file.

func LoadFixture

func LoadFixture(path string) (*Fixture, error)

LoadFixture reads a single fixture JSON file.

func LoadFixturesDir

func LoadFixturesDir(dir string) ([]*Fixture, error)

LoadFixturesDir loads all .json fixtures from a directory.

type Thresholds

type Thresholds struct {
	MustReadRecall    float64
	MustReadPrecision float64
	RelatedRecall     float64
	TestsRecall       float64
	ExternalRecall    float64
}

Thresholds configures pass/fail cutoffs for fixture comparison.

func DefaultThresholds

func DefaultThresholds() Thresholds

DefaultThresholds returns the targets from the testing strategy.

Jump to

Keyboard shortcuts

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