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

incremental

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClassUnchanged = "unchanged"
	ClassChanged   = "changed"
	ClassAdded     = "added"
	ClassDeleted   = "deleted"
	ClassMoved     = "moved"
	ClassRenamed   = "renamed"
	ClassAmbiguous = "ambiguous"
)
View Source
const TagIncrementalReview = "incremental-review"
View Source
const TagReused = "incremental-reused"

Variables

This section is empty.

Functions

func BuildRangeTask

func BuildRangeTask(input PromptInput) (string, error)

BuildRangeTask returns the task for reviewing one changed range. It follows the prefix every call about the spec shares (context files, the numbered spec and the known preflight findings), so a range review judges its lines with the same material as a full review, and reads the spec from the provider's prompt cache.

func MergeReport

func MergeReport(input MergeInput) (*schema.Report, error)

func ParseRangeResponse

func ParseRangeResponse(raw string, lineCount int, rr ReviewRange) (*schema.Report, error)

ParseRangeResponse reads a complete incremental range response. See parseRangeResponse for what is kept and what is dropped.

func ValidateConfig

func ValidateConfig(cfg Config) error

ValidateConfig validates flag-derived incremental settings.

func ValidatePreviousCompatibility

func ValidatePreviousCompatibility(prev *PreviousReport, cfg Config) error

ValidatePreviousCompatibility checks whether a previous report can be used as the baseline for the current incremental request.

Types

type Config

type Config struct {
	Mode                 Mode
	MaxChangeRatio       float64
	MaxRemapFailureRatio float64
	ContextLines         int
	ChunkTokenThreshold  int
	StrictReuse          bool
	ReportMetadata       bool
	Profile              string
	Strict               bool
	SeverityThreshold    string
	ProfileHash          string
	RedactionConfigHash  string
}

Config contains incremental settings shared by CLI, web, and app code.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the spec-defined incremental defaults.

type DroppedFinding

type DroppedFinding struct {
	ID     string
	Reason string
}

type ExecutorConfig

type ExecutorConfig struct {
	SystemPrompt string
	// Prefix is the user-message prefix every call about the spec shares,
	// built by llm.BuildSpecPrefix: context files, the numbered spec unless
	// it is too large to share, and the known preflight findings.
	Prefix string
	// SpecShown says Prefix holds the whole spec. When false each range
	// task carries its own numbered lines.
	SpecShown bool
	// LongCache asks for the longer prompt-cache lifetime.
	LongCache bool
	MaxTokens int
	Effort    string
	// EnforceSchema asks the provider to constrain responses to the review
	// schema.
	EnforceSchema bool
	// NoPatches leaves patches out of the requested output.
	NoPatches   bool
	Concurrency int
	Issues      []schema.Issue
	Questions   []schema.Question
}

type FallbackReason

type FallbackReason struct {
	Code    string
	Message string
}

type LineRange

type LineRange struct {
	Start int
	End   int
}

type MergeInput

type MergeInput struct {
	Spec                *spec.Spec
	PreflightIssues     []schema.Issue
	ReusedIssues        []schema.Issue
	ReusedQuestions     []schema.Question
	RangeResults        []RangeResult
	Patches             []schema.Patch
	Model               string
	Profile             string
	Strict              bool
	SeverityThreshold   string
	ContextFiles        []string
	IncrementalMetadata *schema.IncrementalMeta
	IncludeMetadata     bool
}

type Metadata

type Metadata struct {
	Enabled          bool    `json:"enabled"`
	PreviousSpecHash string  `json:"previous_spec_hash"`
	Mode             string  `json:"mode"`
	Fallback         bool    `json:"fallback"`
	ReviewedSections int     `json:"reviewed_sections"`
	ReusedSections   int     `json:"reused_sections"`
	ReusedIssues     int     `json:"reused_issues"`
	ReusedQuestions  int     `json:"reused_questions"`
	DroppedFindings  int     `json:"dropped_findings"`
	ChangedLineRatio float64 `json:"changed_line_ratio"`
}

Metadata is emitted as meta.incremental when the user explicitly requests incremental metadata in JSON output.

type Mode

type Mode string

Mode controls whether incremental review is disabled, required, or used only when the planner can prove reuse is safe.

const (
	ModeAuto Mode = "auto"
	ModeOn   Mode = "on"
	ModeOff  Mode = "off"
)

func ParseMode

func ParseMode(raw string) (Mode, error)

ParseMode validates and normalizes an incremental mode string.

type Plan

type Plan struct {
	PreviousHash string
	CurrentHash  string
	Mode         Mode
	Sections     []SectionChange
	ReviewRanges []ReviewRange
	ReuseRanges  []ReuseRange
	Fallback     *FallbackReason
}

Plan describes the planner's decision for one current spec.

func PlanChanges

func PlanChanges(previousRaw, currentRaw string, cfg Config) (Plan, error)

PlanChanges compares previous and current spec text and returns review and reuse ranges for an incremental run.

type PreviousReport

type PreviousReport struct {
	Report              *schema.Report
	ProfileHash         string
	RedactionConfigHash string
}

PreviousReport wraps a validated previous SpecCritic report and optional metadata that does not yet exist in the public schema type.

func LoadPreviousReport

func LoadPreviousReport(path string) (*PreviousReport, error)

LoadPreviousReport loads and validates a previous SpecCritic JSON report.

func ParsePreviousReport

func ParsePreviousReport(raw []byte) (*PreviousReport, error)

ParsePreviousReport validates raw JSON from a previous SpecCritic report.

type PromptInput

type PromptInput struct {
	Spec      *spec.Spec
	Plan      Plan
	Range     ReviewRange
	Issues    []schema.Issue
	Questions []schema.Question
	// SpecShown says the shared prefix built by llm.BuildSpecPrefix holds the
	// whole numbered spec, as it does for a full or chunked review. The task
	// then names the lines to review. Without it the spec was too large to
	// share, and the task carries the range's own numbered lines and a table
	// of contents.
	SpecShown bool
}

type RangeResult

type RangeResult struct {
	Range  ReviewRange
	Report *schema.Report
	Model  string
}

func ReviewRanges

func ReviewRanges(ctx context.Context, provider llm.Provider, s *spec.Spec, plan Plan, cfg ExecutorConfig) ([]RangeResult, error)

type ReuseInput

type ReuseInput struct {
	Plan     Plan
	Previous *schema.Report
	// SpecPath is the path of the current spec. Reused evidence is pointed at
	// it, because the previous run may have named the same file differently
	// and duplicate detection compares evidence paths.
	SpecPath        string
	CurrentRaw      string
	CurrentRedacted string
	Config          Config
	PreflightIssues []schema.Issue
}

type ReuseRange

type ReuseRange struct {
	ID       string
	Previous LineRange
	Current  LineRange
}

type ReuseResult

type ReuseResult struct {
	Issues          []schema.Issue
	Questions       []schema.Question
	Dropped         []DroppedFinding
	RemapFailures   int
	RemapCandidates int
	Fallback        *FallbackReason
}

func ReuseFindings

func ReuseFindings(input ReuseInput) (ReuseResult, error)

type ReviewRange

type ReviewRange struct {
	ID      string
	Primary LineRange
	Context LineRange
}

type SectionChange

type SectionChange struct {
	ID             string
	PreviousRange  LineRange
	CurrentRange   LineRange
	Classification string
	HeadingPath    []string
}

Jump to

Keyboard shortcuts

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