Documentation
¶
Overview ¶
Package review hosts the model-agnostic finding validator and the runtime Finding type used by the TUI.
Validation enforces docs/review-finding-schema.md against the parsed diff produced by internal/diff. Rejected findings are quarantined with a reason rather than guessed at, per the v1 schema contract.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(candidates []FindingCandidate, modelName string, idx *diff.Index) ([]Finding, []Quarantined)
Validate converts model candidates into validated Findings, enforcing every rule in docs/review-finding-schema.md:106-118.
Each candidate is evaluated independently; both the accepted Findings and the Quarantined slice are returned so the TUI can show debug-only rejected items without dropping them on the floor.
Types ¶
type Finding ¶
type Finding struct {
File string
Line int
Severity Severity
Title string
Evidence string
SuggestedComment string
FixHint string
Confidence float64
Model string
State FindingState
}
Finding is a validated review candidate ready for the TUI. Model and State are runtime metadata not present in the model's raw output.
type FindingCandidate ¶
type FindingCandidate struct {
File string `json:"file"`
Line int `json:"line"`
Severity string `json:"severity"`
Title string `json:"title"`
Evidence string `json:"evidence"`
SuggestedComment string `json:"suggested_comment"`
FixHint string `json:"fix_hint"`
Confidence float64 `json:"confidence"`
}
FindingCandidate is the transport-layer shape of a finding returned by a model CLI. Severity is kept as a string here; Validate converts it to a typed Severity.
Field ordering and JSON tags mirror docs/review-finding-schema.md exactly so the same struct can be used for both encoding the schema example in the prompt and decoding the model's reply.
type FindingState ¶
type FindingState int
FindingState is the TUI workflow state for a finding. Initial state on every fresh validation is StatePending; the TUI mutates state in M4.
const ( StatePending FindingState = iota StateApproved StateDismissed )
type ModelReviewResult ¶
type ModelReviewResult struct {
Model string
Findings []FindingCandidate
RawOutput string
}
ModelReviewResult is what a model adapter returns after invocation. RawOutput preserves the model's stdout so the TUI's debug surface can show it when validation rejects everything.
type Quarantined ¶
type Quarantined struct {
Candidate FindingCandidate
Reason string
}
Quarantined holds a finding that failed validation, with the reason preserved so the TUI's debug surface can explain why.
type ReviewInput ¶
type ReviewInput struct {
Target ReviewTarget
Title string
Author string
Files []*diff.DiffFile
RawDiff string
}
ReviewInput is the normalized input the review core consumes. Provider adapters produce this shape regardless of which CLI fetched the diff.
type ReviewTarget ¶
type ReviewTarget struct {
Host Host
URL string
Owner string
Repo string
Number int
HeadRef string
HeadSHA string
BaseRef string
BaseSHA string
StartSHA string
}
ReviewTarget identifies the PR/MR being reviewed.
HeadSHA is the commit OID at the time the diff was fetched. It is the capture-time anchor used when posting review comments back upstream — re-resolving at post time would risk silently re-anchoring to a moved HEAD if the PR got pushed mid-review.
BaseSHA and StartSHA are the GitLab diff-refs required to post inline review threads (positioned at file:line in the diff view). GitHub uses HeadSHA alone; for GitLab we need all three. Empty for GitHub targets.
type Severity ¶
type Severity int
Severity enumerates the four severity buckets v1 supports.
func ParseSeverity ¶
ParseSeverity maps a model-output severity string to the typed enum. Unknown strings return an error so the validator quarantines the candidate rather than guessing.