reviewplan

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package reviewplan builds the pure PR review action plan.

Index

Constants

View Source
const (
	ActionKindInlineComment = plannedactions.ActionKindInlineComment
	ActionKindThreadReply   = plannedactions.ActionKindThreadReply
	ActionKindResolveThread = plannedactions.ActionKindResolveThread
	ActionKindRollupComment = plannedactions.ActionKindRollupComment
	ActionKindSubmitReview  = plannedactions.ActionKindSubmitReview
)

Action kind values.

View Source
const (
	ActionStatusPending     = plannedactions.ActionStatusPending
	ActionStatusPlannedOnly = plannedactions.ActionStatusPlannedOnly
)

Action status values.

View Source
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 {
	plannedactions.Action
	Marker MarkerPlacement
}

Action is one planner-local planned action.

type ActionIDGenerator

type ActionIDGenerator func(ActionKind) (string, error)

ActionIDGenerator allocates a deterministic action id for an action kind.

type ActionKind

type ActionKind = plannedactions.ActionKind

ActionKind is an alias for the canonical planned action kind.

type ActionStatus

type ActionStatus = plannedactions.ActionStatus

ActionStatus is an alias for the canonical planned action status.

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 DiffFile

type DiffFile struct {
	OldPath string
	Path    string
	Binary  bool
	Deleted bool
	Hunks   []DiffHunk
}

DiffFile describes one changed file in the PR diff.

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 = plannedactions.InlineCommentPayload

InlineCommentPayload is an alias for the canonical 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.

func (Outcome) Valid

func (o Outcome) Valid() bool

Valid reports whether o is a known 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 Build

func Build(req Request) (Plan, error)

Build turns validated review-domain values into a deterministic 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.

const (
	PostModeLive   PostMode = "live"
	PostModeDryRun PostMode = "dry_run"
)

PostMode values.

func (PostMode) Valid

func (m PostMode) Valid() bool

Valid reports whether m is a known post mode.

type ProviderCaps

type ProviderCaps struct {
	NativeFileLevelComments bool
	ThreadResolution        bool
}

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
	RepoGuidanceUnavailable       bool
	RepoGuidanceUnavailableReason string
	Profile                       string
	PostingIdentity               string
	HeadSHA                       string
	AgentDefinitionsChanged       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 = plannedactions.ResolveThreadPayload

ResolveThreadPayload is an alias for the canonical 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

type ReviewerFailureSummary struct {
	AgentID string
	Error   string
}

ReviewerFailureSummary is a reviewer task diagnostic rendered in the rollup.

type ReviewerSummary added in v0.3.73

type ReviewerSummary struct {
	Name     string
	Findings int
}

ReviewerSummary is one reviewer row in the rollup summary table.

type RollupCommentPayload

type RollupCommentPayload = plannedactions.RollupCommentPayload

RollupCommentPayload is an alias for the canonical 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 = plannedactions.SubmitReviewPayload

SubmitReviewPayload is an alias for the canonical 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

type ThreadCounts struct {
	Considered int
	Summarized int
	Resolved   int
}

ThreadCounts summarizes PR discussion thread handling.

type ThreadReplyPayload

type ThreadReplyPayload = plannedactions.ThreadReplyPayload

ThreadReplyPayload is an alias for the canonical 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.

Jump to

Keyboard shortcuts

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