reporting

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package reporting assembles per-file scores into aggregate attribution results. It is a pure domain package with no infrastructure dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AILines

func AILines(fs *FileScoreInput) int

AILines returns the total AI lines (exact + formatted + modified) for a single file score input.

func RenderDiagnosticNote

func RenderDiagnosticNote(in DiagnosticsInput) string

RenderDiagnosticNote produces a human-readable diagnostic note explaining why a particular AI percentage was computed. When AI% is 0 it identifies which pipeline stage had no data. When AI% > 0 and non-exact matches contributed, it breaks down the match tiers.

Types

type AggregateResult

type AggregateResult struct {
	Percent        float64
	TotalLines     int
	AILines        int
	ExactLines     int // tier 1: exact trimmed match
	ModifiedLines  int // tier 0 with hunk overlap
	FormattedLines int // tier 2: whitespace-normalized match
	FilesTouched   int // unique files in the diff
	Providers      []ProviderAttribution
}

AggregateResult contains the full attribution breakdown produced by AggregatePercent. The Percent field is the headline number; the remaining fields support richer commit trailers and diagnostics.

func AggregatePercent

func AggregatePercent(scores []FileScoreInput, providerModel map[string]string, filesTouched int) AggregateResult

AggregatePercent reduces per-file scores into a single AggregateResult with provider breakdown sorted by AI lines (descending), then name.

type CheckpointDiagnostics

type CheckpointDiagnostics struct {
	EventsConsidered int
	EventsAssistant  int
	PayloadsLoaded   int
	AIToolEvents     int
	Note             string
}

CheckpointDiagnostics holds event stats and a diagnostic note for checkpoint-only blame results.

type CheckpointResult

type CheckpointResult struct {
	CheckpointID   string
	FilesAITouched int
	FilesTotal     int
	FilesEdited    []FileChangeOutput
	Diagnostics    CheckpointDiagnostics
}

CheckpointResult is the attribution result for a checkpoint without a linked commit. It reports AI activity but has no line-level scores.

func BuildCheckpointResult

func BuildCheckpointResult(in CheckpointResultInput) CheckpointResult

BuildCheckpointResult assembles a checkpoint-only attribution result. Checkpoint blame has no diff and no line-level scoring - it reports which files were touched by AI and event-level diagnostics.

type CheckpointResultInput

type CheckpointResultInput struct {
	CheckpointID string
	TouchedFiles map[string]bool // AI-touched file paths
	EventStats   EventStatsInput // for diagnostics
}

CheckpointResultInput holds the narrow inputs for assembling a checkpoint-only attribution result (no diff, no line-level scoring).

type CommitResult

type CommitResult struct {
	AIExactLines     int
	AIFormattedLines int
	AIModifiedLines  int
	AILines          int // exact + formatted + modified
	HumanLines       int
	TotalLines       int
	AIPercentage     float64 // (exact + formatted + modified) / total * 100
	FilesAITouched   int
	FilesTotal       int // created + edited (excludes deleted)
	FilesCreated     []FileChangeOutput
	FilesEdited      []FileChangeOutput
	FilesDeleted     []FileChangeOutput
	Files            []FileAttributionOutput
	ProviderDetails  []ProviderAttribution
}

CommitResult is the full attribution breakdown for a single commit, produced by BuildCommitResult.

func BuildCommitResult

func BuildCommitResult(in CommitResultInput) CommitResult

BuildCommitResult assembles a full commit attribution result from scored file data, diff metadata, and candidate metadata. It builds per-file attribution rows, headline totals, file change lists, and provider details.

type CommitResultInput

type CommitResultInput struct {
	FileScores     []FileScoreInput  // one per diff file, in diff order
	FilesCreated   []string          // paths created (from /dev/null)
	FilesDeleted   []string          // paths deleted (to /dev/null)
	TouchedFiles   map[string]bool   // AI-touched file paths (for AI flag on file changes)
	ProviderModels map[string]string // provider -> model
}

CommitResultInput holds the narrow inputs needed to assemble a full commit attribution result from scored data and diff metadata.

type DiagnosticsInput

type DiagnosticsInput struct {
	EventStats EventStatsInput
	MatchStats MatchStatsInput
	AIPercent  float64
}

DiagnosticsInput combines event stats, match stats, and the computed AI percentage for rendering the diagnostic note.

type EventStatsInput

type EventStatsInput struct {
	EventsConsidered int
	EventsAssistant  int
	PayloadsLoaded   int
	AIToolEvents     int
}

EventStatsInput carries event-processing counters into reporting.

type FileAttributionOutput

type FileAttributionOutput struct {
	Path             string
	AIExactLines     int
	AIFormattedLines int
	AIModifiedLines  int
	HumanLines       int
	TotalLines       int
	DeletedNonBlank  int
	AIPercent        float64 // (exact + formatted + modified) / total * 100
}

FileAttributionOutput holds per-file attribution scores in the commit result.

type FileChangeOutput

type FileChangeOutput struct {
	Path string
	AI   bool
}

FileChangeOutput records whether a file change was performed by AI.

type FileScoreInput

type FileScoreInput struct {
	Path            string
	TotalLines      int
	ExactLines      int
	FormattedLines  int
	ModifiedLines   int
	HumanLines      int
	ProviderLines   map[string]int // provider -> AI lines for this file
	DeletedNonBlank int            // deleted non-blank lines (display only, not attributed)
}

FileScoreInput is the narrow input shape for a single file's score data.

type MatchStatsInput

type MatchStatsInput struct {
	ExactMatches      int
	NormalizedMatches int
	ModifiedMatches   int
}

MatchStatsInput carries match counters from scoring into reporting.

type ProviderAttribution

type ProviderAttribution struct {
	Provider string
	Model    string // empty if unknown
	AILines  int
}

ProviderAttribution holds per-provider AI line counts.

Jump to

Keyboard shortcuts

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