runner

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package runner orchestrates one review run end to end — checkout, prompt assembly, reviewer passes, result merging, and persistence — so every frontend (TUI, web GUI) drives the same pipeline and stores the same artifacts.

Index

Constants

View Source
const DiffFilesDir = ".review-diffs"

DiffFilesDir is where oversized diffs are written inside the checkout so the reviewer can Read them (the review session has no Bash to run git).

Variables

View Source
var ErrNothingToReview = errors.New("nothing to review: every changed file is excluded by configuration or has no retrievable diff")

ErrNothingToReview means every changed file was filtered out before any review pass could run. Incremental runs treat it as "nothing new" rather than a failure.

Functions

func BuildRequests

func BuildRequests(cfg config.Config, detail gitlabx.MRDetail, diffs []gitlabx.FileDiff, commits []gitlabx.Commit, template, repoPath string) ([]review.Request, []string, []string, error)

BuildRequests assembles the reviewer request(s) from project-resolved config: chunked diffs and combined custom instructions. The requests are agent-neutral; the runner specialises a copy per selected agent. Diffs too large to inline are written into the checkout under DiffFilesDir so the reviewer can still see them. It returns the requests, informational progress lines, and warnings worth persisting with the result (only genuine information loss qualifies).

func RebaseWarning

func RebaseWarning(detail gitlabx.MRDetail) string

RebaseWarning describes why the MR branch is not up to date with its target, for the findings-screen warning banner.

Types

type CheckoutFunc

type CheckoutFunc func(ctx context.Context, mr gitlabx.MRDetail, progress func(string)) (path string, cleanup func(context.Context) error, err error)

CheckoutFunc prepares a review worktree for an MR and returns its path plus a cleanup function. Progress lines go to the run's progress log.

type Outcome

type Outcome struct {
	Result  *review.Result
	Rec     *resultstore.Record
	LogPath string
	Err     error
}

Outcome is everything a frontend needs after a run: the merged result, the stored record (nil on failure, cancellation, or when storage is disabled), and the progress log location.

type Runner

type Runner struct {
	Cfg      config.Config
	Svc      gitlabx.Service
	Reviewer review.Reviewer
	Checkout CheckoutFunc
	// Catalog is the available agents (builtins + user agents); nil means
	// builtins only. Project agents shipped in the checkout are merged in
	// after checkout, so they can shadow or satisfy selected names.
	Catalog *agents.Catalog
	// AgentNames is the agent selection for this run (from the picker or
	// --agents); empty falls back to cfg.Review.Agents.
	AgentNames []string
	// AgentModels overrides the review model per agent (agent name → model
	// ID), from the picker. It takes precedence over an agent's frontmatter
	// model and cfg.Review.Model; agents absent from the map keep those
	// defaults. Nil applies no overrides.
	AgentModels map[string]string
	// Incremental asks for a delta review: when Results holds a previous
	// review of this MR, only the changes pushed since its head go through
	// the review passes, and the previous findings — with their curation
	// states — carry forward (dropping ones whose anchor lines changed).
	// It falls back to a full review when no usable baseline exists: first
	// review, a rebase, or an unreachable stored head. Frontends expose the
	// inverse override (--full, "full re-review") to force scanning the
	// whole diff again.
	Incremental bool
	// Logs stores the run's progress log; nil disables storing.
	Logs *runlog.Store
	// Results stores the run's result record; nil disables storing.
	Results *resultstore.Store
}

Runner bundles everything one review run needs. Cfg must already be resolved for the MR's project (per-project overrides applied).

func (Runner) Run

func (r Runner) Run(ctx context.Context, detail gitlabx.MRDetail, diffs []gitlabx.FileDiff, commits []gitlabx.Commit, emit func(string)) Outcome

Run executes the whole review, reporting every progress line through emit (may be nil) and mirroring it into the stored run log. On success the result is saved as a record so the review can be reopened later; curation screens keep re-saving the same record as states change.

Jump to

Keyboard shortcuts

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