reviewplan

package
v0.3.121 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package reviewplan builds the pure PR review action plan.

Index

Constants

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 {
	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

func SortActions(actions []Action) []Action

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
	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 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.

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.

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
	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 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 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
	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

type ThreadCounts struct {
	Considered int
	Summarized int
	Resolved   int
}

ThreadCounts summarizes PR discussion thread handling.

type ThreadReplyPayload

type ThreadReplyPayload struct {
	Body    string
	Summary bool
}

ThreadReplyPayload mirrors the thread reply payload.

type WorkstreamUsage added in v0.3.73

type WorkstreamUsage struct {
	Name        string
	Model       string
	TokensIn    *int
	TokensOut   *int
	CacheRead   *int
	CacheCreate *int
	CostUSD     *float64
	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