Documentation
¶
Overview ¶
Package classify groups changed files by their architectural role (handler, repository, model, test, …) so each file's AOI pre-scan can be narrowed to the dimensions that actually apply. A test file doesn't need a cryptography review; a handler does need an input-validation pass.
Shared by `prr audit` (whole-repo) and `prr review` (PR diffs) — both feed the result into security.ScanAreasOfInterestClassified.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AllFileTypes = []FileType{ FileTypeTest, FileTypeHandler, FileTypeRepository, FileTypeSQL, FileTypeModel, FileTypeClient, FileTypeWorker, FileTypeBusinessLogic, FileTypeInfrastructure, FileTypeUnknown, }
AllFileTypes lists valid classification types for prompt construction.
Functions ¶
func Classify ¶
func Classify( ctx context.Context, client ai.Client, files []File, cachedTypes map[string]FileType, onProgress func(status string), ) (map[string]FileType, error)
Classify runs the LLM classifier on the given files using the cheap model. Returns a map of file path → FileType.
cachedTypes maps file paths to previously cached classifications. Files with cached results are skipped. Pass nil to classify everything.
Returns partial results plus errors.Join of any batch errors, so the caller can decide whether to fail or proceed with unknowns.
func DimensionsForType ¶
DimensionsForType returns the dimension slugs to include in the AOI prompt for the given file type. Unknown types get all dimensions.
func SetMaxConcurrency ¶
func SetMaxConcurrency(n int)
SetMaxConcurrency sets the max number of classification batches run in parallel. Values <= 0 reset to the default. Not safe to call concurrently with classification in flight; intended to be called once at startup.
Types ¶
type File ¶
File is the classifier input: a path and (a snippet of) its content. Audit reads full file content from disk via CollectFiles; review reads the head-of-branch version of each diffed file. Either way only the first ~50 lines are sent to the model — enough for imports and top-level declarations.
type FileClassification ¶
FileClassification holds a file path and its LLM-determined type.
type FileType ¶
type FileType string
FileType is the architectural role of a source file.
const ( FileTypeTest FileType = "test" FileTypeHandler FileType = "handler" FileTypeRepository FileType = "repository" FileTypeSQL FileType = "sql" FileTypeModel FileType = "model" FileTypeClient FileType = "client" FileTypeWorker FileType = "worker" FileTypeBusinessLogic FileType = "business-logic" FileTypeInfrastructure FileType = "infrastructure" FileTypeUnknown FileType = "unknown" )