Help us shape the future of Go! Take the 2026 Go Developer Survey

report

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package report defines LintPal's validated, deterministic findings artifact.

Index

Constants

View Source
const MaxBundleBytes = 64 << 20
View Source
const SchemaVersion = "v5"

Variables

View Source
var ErrExport = errors.New("lint report export failed")
View Source
var ErrGate = errors.New("lint severity gate failed")
View Source
var ErrInvalidFormat = errors.New("invalid lint report format")
View Source
var ErrInvalidReport = errors.New("invalid lint report")
View Source
var ErrInvalidThreshold = errors.New("invalid lint severity threshold")

Functions

func BlockingCount added in v0.4.0

func BlockingCount(bundle Bundle) int

func BundleBlocks added in v0.4.0

func BundleBlocks(bundle Bundle) bool

func MeetsGate

func MeetsGate(artifact Report, threshold Threshold) (bool, error)

func RenderGitHubFinding added in v0.4.0

func RenderGitHubFinding(finding Finding) []byte

RenderGitHubFinding builds one deterministic inline body from validated finding fields. It does not add semantic analysis or remediation text.

func RenderGitHubResult added in v0.4.0

func RenderGitHubResult(bundle Bundle, unanchoredIDs []string) ([]byte, error)

RenderGitHubResult builds the deterministic top-level GitHub feedback body. unanchoredIDs contains validated findings that the GitHub transport could not attach to a diff line. Unknown or duplicate IDs are rejected.

func RenderMarkdown added in v0.4.0

func RenderMarkdown(bundle Bundle) []byte

RenderMarkdown builds complete feedback from a validated findings bundle.

func Validate

func Validate(report Report) error

Validate checks the public artifact before it is rendered or gated. Exact changed-line provenance is checked by New, which has the Git work items.

func WriteAndGate

func WriteAndGate(writer io.Writer, artifact Report, format Format, threshold Threshold) error

func WriteArtifact added in v0.4.0

func WriteArtifact(path string, payload []byte) error

WriteArtifact replaces a report file only after the complete payload is synced.

func WriteJSON

func WriteJSON(writer io.Writer, artifact Report) error

func WriteMarkdown added in v0.4.0

func WriteMarkdown(writer io.Writer, artifact Report) error

Types

type Bundle added in v0.4.0

type Bundle struct {
	Version      string    `json:"version"`
	ReviewID     string    `json:"review_id"`
	BaseSHA      string    `json:"base_sha"`
	HeadSHA      string    `json:"head_sha"`
	MergeBaseSHA string    `json:"merge_base_sha"`
	Findings     []Finding `json:"findings"`
	Skips        []Skip    `json:"skips"`
	Stats        Stats     `json:"stats"`
}

func BundleFromReport added in v0.4.0

func BundleFromReport(artifact Report) (Bundle, error)

BundleFromReport converts an internal report through its public v5 shape.

func ParseBundle added in v0.4.0

func ParseBundle(data []byte) (Bundle, error)

ParseBundle validates a shared findings v5 artifact before using its fields.

func ReadBundle added in v0.4.0

func ReadBundle(path string) (Bundle, error)

ReadBundle bounds a stored report before parsing it. Errors contain no report text.

type Diagnostic

type Diagnostic struct {
	RuleID     string         `json:"rule_id"`
	WorkItemID string         `json:"work_item_id"`
	Severity   rules.Severity `json:"severity"`
	Path       string         `json:"path"`
	Side       git.Side       `json:"side"`
	StartLine  int            `json:"start_line"`
	EndLine    int            `json:"end_line"`
	Title      string         `json:"title"`
	Message    string         `json:"message"`
	Provider   string         `json:"provider"`
	Model      string         `json:"model"`
	Evidence   Evidence       `json:"evidence"`
}

type Evidence

type Evidence struct {
	Kind       string   `json:"kind"`
	Value      float64  `json:"value"`
	Confidence *float64 `json:"confidence,omitempty"`
}

type Finding added in v0.4.0

type Finding struct {
	ID          string `json:"id"`
	ReviewID    string `json:"review_id"`
	Category    string `json:"category"`
	Severity    string `json:"severity"`
	Title       string `json:"title"`
	Message     string `json:"message"`
	Path        string `json:"path"`
	StartLine   int    `json:"start_line"`
	EndLine     int    `json:"end_line"`
	ChangedSpan struct {
		Path      string `json:"path"`
		StartLine int    `json:"start_line"`
		EndLine   int    `json:"end_line"`
		Side      string `json:"side"`
	} `json:"changed_span"`
	Evidence struct {
		Kind   string `json:"kind"`
		RuleID string `json:"rule_id"`
		Anchor string `json:"anchor"`
	} `json:"evidence"`
	Decision struct {
		Kind  string  `json:"kind"`
		Value float64 `json:"value"`
	} `json:"decision"`
	Blocking   bool   `json:"blocking"`
	Provider   string `json:"provider"`
	Model      string `json:"model"`
	WorkItemID string `json:"work_item_id"`
}

type Format

type Format string
const (
	JSON     Format = "json"
	Markdown Format = "markdown"
)

type Report

type Report struct {
	SchemaVersion string       `json:"schema_version"`
	BaseSHA       string       `json:"base_sha"`
	HeadSHA       string       `json:"head_sha"`
	MergeBaseSHA  string       `json:"merge_base_sha"`
	Diagnostics   []Diagnostic `json:"diagnostics"`
	Skips         []Skip       `json:"skips"`
	Stats         Stats        `json:"stats"`
	// contains filtered or unexported fields
}

func New

func New(result git.Result, decisions []rules.Decision, provider, model string, stats Stats, identitySalt ...string) (Report, error)

New checks every decision against the original changed-line work items.

func WithGate added in v0.4.0

func WithGate(artifact Report, threshold Threshold) Report

WithGate binds the report's blocking flags to the selected CLI gate.

func (Report) MarshalJSON added in v0.4.0

func (artifact Report) MarshalJSON() ([]byte, error)

type Skip

type Skip struct {
	OldPath string         `json:"old_path,omitempty"`
	NewPath string         `json:"new_path,omitempty"`
	Reason  git.SkipReason `json:"reason"`
}

type Stats

type Stats struct {
	WorkItems    int `json:"work_items"`
	Skipped      int `json:"skipped"`
	Groups       int `json:"groups"`
	Batches      int `json:"batches"`
	Questions    int `json:"questions"`
	Diagnostics  int `json:"diagnostics"`
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

type Threshold

type Threshold string
const (
	None     Threshold = "none"
	Low      Threshold = "low"
	Medium   Threshold = "medium"
	High     Threshold = "high"
	Critical Threshold = "critical"
)

Jump to

Keyboard shortcuts

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