reviewplan

package
v0.1.33 Latest Latest
Warning

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

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

Documentation

Overview

Package reviewplan builds the pure PR review action plan.

Index

Constants

This section is empty.

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

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

	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 RollupCommentPayload

type RollupCommentPayload struct {
	Body string
}

RollupCommentPayload mirrors the rollup comment payload.

type SubmitReviewPayload

type SubmitReviewPayload struct {
	Body  string
	Event review.ReviewEvent
}

SubmitReviewPayload mirrors the submit-review payload.

type ThreadReplyPayload

type ThreadReplyPayload struct {
	Body    string
	Summary bool
}

ThreadReplyPayload mirrors the thread reply payload.

Jump to

Keyboard shortcuts

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