Documentation
¶
Overview ¶
Package review provides daemon-free review orchestration: parallel batch execution, synthesis, and comment formatting.
Index ¶
- Constants
- Variables
- func BuildSynthesisPrompt(reviews []ReviewResult, minSeverity string) string
- func CountQuotaFailures(reviews []ReviewResult) int
- func CountTimeoutCancellations(reviews []ReviewResult) int
- func FormatAllFailedComment(reviews []ReviewResult, headSHA string) string
- func FormatRawBatchComment(reviews []ReviewResult, headSHA string) string
- func FormatSynthesizedComment(output string, reviews []ReviewResult, headSHA string) string
- func IsQuotaFailure(r ReviewResult) bool
- func IsTimeoutCancellation(r ReviewResult) bool
- func SkippedAgentNote(reviews []ReviewResult) string
- func Synthesize(ctx context.Context, results []ReviewResult, opts SynthesizeOpts) (string, error)
- func TrimPartialRune(s string) string
- type BatchConfig
- type ReviewResult
- type SynthesizeOpts
Constants ¶
const ( ResultDone = "done" ResultFailed = "failed" )
Result status values for ReviewResult.Status.
const MaxCommentLen = 60000
MaxCommentLen is the maximum length for a GitHub PR comment. GitHub's hard limit is ~65536; we leave headroom.
const QuotaErrorPrefix = "quota: "
QuotaErrorPrefix is prepended to error messages when a review fails due to agent quota exhaustion rather than a real error. Matches the prefix set by internal/daemon/worker.go.
const TimeoutErrorPrefix = "timeout: "
TimeoutErrorPrefix is prepended to error messages when a batch job is canceled because the batch exceeded its timeout and results were posted with the available reviews.
Variables ¶
var ErrAllFailed = errors.New(
"all review jobs failed")
ErrAllFailed is returned by Synthesize when every review job in the batch failed (excluding all-quota-skipped batches).
Functions ¶
func BuildSynthesisPrompt ¶
func BuildSynthesisPrompt( reviews []ReviewResult, minSeverity string, ) string
BuildSynthesisPrompt creates the prompt for the synthesis agent. When minSeverity is non-empty (and not "low"), a filtering instruction is appended.
func CountQuotaFailures ¶
func CountQuotaFailures(reviews []ReviewResult) int
CountQuotaFailures returns the number of reviews that failed due to agent quota exhaustion rather than a real error.
func CountTimeoutCancellations ¶ added in v0.50.0
func CountTimeoutCancellations(reviews []ReviewResult) int
CountTimeoutCancellations returns the number of reviews that were canceled due to batch timeout.
func FormatAllFailedComment ¶
func FormatAllFailedComment( reviews []ReviewResult, headSHA string, ) string
FormatAllFailedComment formats a comment when every job in a batch failed.
func FormatRawBatchComment ¶
func FormatRawBatchComment( reviews []ReviewResult, headSHA string, ) string
FormatRawBatchComment formats all review outputs as expanded inline sections. Used as a fallback when synthesis fails.
func FormatSynthesizedComment ¶
func FormatSynthesizedComment( output string, reviews []ReviewResult, headSHA string, ) string
FormatSynthesizedComment wraps synthesized output with header and metadata.
func IsQuotaFailure ¶
func IsQuotaFailure(r ReviewResult) bool
IsQuotaFailure returns true if a review's error indicates a quota skip rather than a real failure.
func IsTimeoutCancellation ¶ added in v0.50.0
func IsTimeoutCancellation(r ReviewResult) bool
IsTimeoutCancellation returns true if a review was canceled because the batch timed out and posted early.
func SkippedAgentNote ¶
func SkippedAgentNote(reviews []ReviewResult) string
SkippedAgentNote returns a markdown note listing agents that were skipped due to quota exhaustion. Returns "" if none.
func Synthesize ¶
func Synthesize( ctx context.Context, results []ReviewResult, opts SynthesizeOpts, ) (string, error)
Synthesize combines multiple review results into a single formatted comment string.
Single successful result: returns it directly (no LLM call). All failed: returns failure comment. Multiple results with successes: runs synthesis agent, falls back to raw format on error.
func TrimPartialRune ¶ added in v0.40.0
TrimPartialRune removes a trailing incomplete UTF-8 sequence that may result from slicing a string at an arbitrary byte offset. Only the last rune is inspected — pre-existing invalid bytes elsewhere in the string are left untouched.
Types ¶
type BatchConfig ¶
type BatchConfig struct {
RepoPath string
GitRef string // "BASE..HEAD" range
Agents []string // agent names (resolved per-job)
ReviewTypes []string // resolved review types
Reasoning string
ContextCount int
// GlobalConfig enables workflow-aware agent/model resolution.
// When set, each job resolves its agent and model through
// config.ResolveAgentForWorkflow / ResolveModelForWorkflow,
// matching the CI poller's behavior. When nil, agents are
// used as-is (backward compatible).
GlobalConfig *config.Config
// AgentRegistry is an optional registry for dependency injection in testing.
// If nil, the global agent registry is used.
AgentRegistry map[string]agent.Agent
// MinSeverity is the minimum severity threshold for the review prompt.
// When non-empty (and not "low"), agents are instructed to filter findings.
MinSeverity string
}
BatchConfig holds parameters for a parallel review batch.
type ReviewResult ¶
type ReviewResult struct {
Agent string
ReviewType string
Output string
Status string // ResultDone or ResultFailed
Error string
}
ReviewResult holds the outcome of a single review in a batch. Decoupled from storage.BatchReviewResult for daemon-free use.
func RunBatch ¶
func RunBatch( ctx context.Context, cfg BatchConfig, ) []ReviewResult
RunBatch executes all review_type x agent combinations in parallel. Uses goroutines + sync.WaitGroup, no daemon/database.
type SynthesizeOpts ¶
type SynthesizeOpts struct {
// Agent name for synthesis (empty = first available).
Agent string
// Model override for the synthesis agent.
Model string
// MinSeverity filters findings below this level.
MinSeverity string
// RepoPath is the working directory for the synthesis agent.
RepoPath string
// GitRef is the reviewed git ref, passed to the synthesis agent.
GitRef string
// HeadSHA is used for comment formatting headers.
HeadSHA string
// GlobalConfig allows runtime agent resolution to honor ACP naming/command overrides.
GlobalConfig *config.Config
}
SynthesizeOpts controls synthesis behavior.