Documentation
¶
Overview ¶
Package reviewplan builds the pure PR review action plan.
Index ¶
- Constants
- func ReviewEventForFindings(findings []review.Finding, opts EventOptions) review.ReviewEvent
- type Action
- type ActionIDGenerator
- type ActionKind
- type ActionStatus
- type AggregateUsage
- type AnchoredFinding
- type Diff
- type DiffFile
- type DiffHunk
- type EventOptions
- type InlineCommentPayload
- type MarkerPlacement
- type Outcome
- type Plan
- type PostMode
- type ProviderCaps
- type Request
- type ResolveThreadPayload
- type ReviewerCoverageSummary
- type ReviewerFailureSummary
- type ReviewerSummary
- type RollupCommentPayload
- type RunSummary
- type SubmitReviewPayload
- type Summary
- type ThreadCounts
- type ThreadReplyPayload
- type ThreadResponseRequest
- type WorkstreamUsage
Constants ¶
const UnattributedReviewer = "unattributed"
UnattributedReviewer labels rendered findings with no reviewer attribution.
Variables ¶
This section is empty.
Functions ¶
func ReviewEventForFindings ¶
func ReviewEventForFindings(findings []review.Finding, opts EventOptions) review.ReviewEvent
ReviewEventForFindings implements the default event mapping from severity.
Types ¶
type Action ¶
type Action struct {
ActionID string
Kind ActionKind
FindingID review.FindingID
ThreadID string
PlannedAt time.Time
Status ActionStatus
Required bool
Marker MarkerPlacement
InlineComment *InlineCommentPayload
ThreadReply *ThreadReplyPayload
ResolveThread *ResolveThreadPayload
RollupComment *RollupCommentPayload
SubmitReview *SubmitReviewPayload
}
Action is one planner-local planned action.
func SortActions ¶
SortActions returns actions in durable outbox order.
type ActionIDGenerator ¶
type ActionIDGenerator func(ActionKind) (string, error)
ActionIDGenerator allocates a deterministic action id for an action kind.
type ActionKind ¶
type ActionKind string
ActionKind is the planner-local outbox action kind.
const ( ActionKindInlineComment ActionKind = "inline_comment" ActionKindThreadReply ActionKind = "thread_reply" ActionKindResolveThread ActionKind = "resolve_thread" ActionKindRollupComment ActionKind = "rollup_comment" ActionKindSubmitReview ActionKind = "submit_review" )
Action kind values.
type ActionStatus ¶
type ActionStatus string
ActionStatus is the planner-local planned action status.
const ( ActionStatusPending ActionStatus = "pending" ActionStatusPlannedOnly ActionStatus = "planned_only" )
Action status values.
type AggregateUsage ¶ added in v0.3.73
type AggregateUsage struct {
TokensIn *int
TokensOut *int
CacheRead *int
CacheCreate *int
CostUSD *float64
CostEstimated bool
ComputeDurationMS *int64
}
AggregateUsage holds run-wide totals. Each field is non-nil only when every workstream reports it; availability is decided here in data, once, so the rendered footer and dry-run JSON cannot disagree.
type AnchoredFinding ¶
type AnchoredFinding struct {
FindingID review.FindingID
Severity review.Severity
FilePath string
Anchoring review.Anchoring
Side *review.DiffSide
Line *int
DiffPosition *int
Body string
}
AnchoredFinding records durable finding anchoring after normalization.
type Diff ¶
type Diff struct {
Files []DiffFile
}
Diff is the planner-owned diff metadata needed for anchoring.
type DiffHunk ¶
type DiffHunk struct {
OldStart int
OldEnd int
NewStart int
NewEnd int
FallbackSide review.DiffSide
FallbackLine int
DiffPosition int
}
DiffHunk describes line ranges and fallback target metadata for one hunk.
type EventOptions ¶
type EventOptions struct {
MajorEventRequestsChanges bool
PostingIdentityIsPRAuthor bool
AllowSelfApprove bool
}
EventOptions controls default review-event mapping.
type InlineCommentPayload ¶
type InlineCommentPayload struct {
Body string
Path string
Side review.DiffSide
Line int
SubjectType review.AnchorKind
DiffPosition int
}
InlineCommentPayload mirrors the provider-neutral inline comment payload.
type MarkerPlacement ¶
type MarkerPlacement struct {
BodyBearing bool
Skip bool
ThreadSummary bool
ActionKind ActionKind
Outcome Outcome
}
MarkerPlacement records where the post phase should place markers.
type Outcome ¶
type Outcome string
Outcome is the planner-local review outcome.
const ( OutcomeApproved Outcome = "approved" OutcomeComment Outcome = "comment" OutcomeRequestChanges Outcome = "request_changes" OutcomeNothingToReview Outcome = "nothing_to_review" )
Outcome values.
func OutcomeFromReviewEvent ¶
func OutcomeFromReviewEvent(event review.ReviewEvent) (Outcome, error)
OutcomeFromReviewEvent maps a review-domain event into a planner outcome.
type Plan ¶
type Plan struct {
Outcome Outcome
RollupMarkdown string
Actions []Action
AnchoredFindings []AnchoredFinding
// Summary is the derived rollup metadata the rendered markdown was
// built from; dry-run JSON exposes the same object.
Summary Summary
}
Plan is the complete pure action plan.
func BuildThreadResponses ¶ added in v0.9.190
func BuildThreadResponses(req ThreadResponseRequest) (Plan, error)
BuildThreadResponses turns thread response-domain values into a response-only action plan. It never creates rollup comments or submit-review actions.
type PostMode ¶
type PostMode string
PostMode controls whether planned actions are postable or inspect-only.
type ProviderCaps ¶
ProviderCaps contains host capabilities that affect planning choices.
type Request ¶
type Request struct {
PostMode PostMode
ProviderCaps ProviderCaps
Diff Diff
Findings []review.Finding
Rollup review.Rollup
ThreadActions []review.ThreadAction
// ThreadResponses are lifecycle-domain replies/resolutions for existing
// inline discussion threads.
ThreadResponses []review.ThreadResponseAction
EventOptions EventOptions
NoDiff bool
Profile string
PostingIdentity string
HeadSHA string
AgentDefinitionsChanged bool
IncludeNits bool
MaxInlineComments int
// RunSummary is the execution metadata rendered in the rollup footer.
RunSummary RunSummary
// FindingReviewers maps each finding to the reviewer agent ID that
// produced it; findings absent from the map group as unattributed.
FindingReviewers map[review.FindingID]string
Now func() time.Time
NewActionID ActionIDGenerator
}
Request is the pure input to Build.
type ResolveThreadPayload ¶
type ResolveThreadPayload struct{}
ResolveThreadPayload mirrors the resolve-thread payload.
type ReviewerCoverageSummary ¶ added in v0.9.186
type ReviewerCoverageSummary struct {
AgentID string
Status string
Scope []string
InspectedFiles []string
SkippedFiles []string
Constraints []string
Diagnostic string
}
ReviewerCoverageSummary describes whether a selected reviewer actually covered its assignment. It is compact by design so rollups can include it without pulling diff or file content into context.
type ReviewerFailureSummary ¶ added in v0.9.176
ReviewerFailureSummary is a reviewer task diagnostic rendered in the rollup.
type ReviewerSummary ¶ added in v0.3.73
ReviewerSummary is one reviewer row in the rollup summary table.
type RollupCommentPayload ¶
type RollupCommentPayload struct {
Body string
}
RollupCommentPayload mirrors the rollup comment payload.
type RunSummary ¶ added in v0.3.73
type RunSummary struct {
// ToolVersion is the raw version string (e.g. "0.3.63"); the renderer
// adds the "cr " prefix.
ToolVersion string
Adapter string
Model string
PostingIdentity string
SelectedReviewers []string
ReviewerFailures []ReviewerFailureSummary
ReviewerCoverage []ReviewerCoverageSummary
WallDurationMS *int64
Workstreams []WorkstreamUsage
}
RunSummary is the execution metadata input for the rollup footer. Usage fields are nullable: nil means the adapter did not report the value.
type SubmitReviewPayload ¶
type SubmitReviewPayload struct {
Body string
Event review.ReviewEvent
}
SubmitReviewPayload mirrors the submit-review payload.
type Summary ¶ added in v0.3.73
type Summary struct {
Reviewers []ReviewerSummary
Threads ThreadCounts
Run RunSummary
// Totals is derived from Run.Workstreams by Build; it lives here rather
// than on the caller-supplied RunSummary so callers cannot populate a
// value that Build would silently overwrite.
Totals AggregateUsage
}
Summary is the complete derived rollup metadata contract. The rendered rollup comment and dry-run JSON both consume this object, so they cannot disagree.
type ThreadCounts ¶ added in v0.3.73
ThreadCounts summarizes PR discussion thread handling.
type ThreadReplyPayload ¶
ThreadReplyPayload mirrors the thread reply payload.
type ThreadResponseRequest ¶ added in v0.9.190
type ThreadResponseRequest struct {
PostMode PostMode
ProviderCaps ProviderCaps
Responses []review.ThreadResponseAction
Now func() time.Time
NewActionID ActionIDGenerator
}
ThreadResponseRequest is the pure input to BuildThreadResponses.
type WorkstreamUsage ¶ added in v0.3.73
type WorkstreamUsage struct {
Name string
Model string
TokensIn *int
TokensOut *int
CacheRead *int
CacheCreate *int
CostUSD *float64
// CostEstimated is true when CostUSD was derived from token prices because
// the adapter did not report a real cost.
CostEstimated bool
DurationMS *int64
}
WorkstreamUsage is adapter-reported usage for one workstream: the reserved orchestrator stage names or a reviewer agent ID.