engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package engine scores one PR: fetch, plan calls, ask, and decide. The score, action, and replay commands all go through Score.

Index

Constants

View Source
const OwnCheck = "LGTM"

OwnCheck is LGTM's check run name (ghout.CheckName). It is never counted as a required check of its own PR.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Config  *config.Config
	Decider jev.Decider
	Limits  prstate.Limits // zero means prstate.DefaultLimits
	// Fetch reads the PR's diff. Nil reads it from GitHub.
	Fetch prstate.Fetcher
	// Trusted reports whether a fork PR's author has write access. Nil
	// asks GitHub; replay passes a stored answer.
	Trusted func(ctx context.Context, pr prstate.PR) (bool, error)
	// CI returns the required checks that failed on the PR's head. Nil asks
	// GitHub; replay passes one that returns nothing, since a merged PR's CI
	// says little about scoring it again.
	CI func(ctx context.Context, pr prstate.PR) ([]string, error)
}

Options configure a scoring run.

type QuestionResult

type QuestionResult struct {
	rubric.Question
	Value  float64
	Err    error
	Answer *jev.Answer // from the lowest-scoring call when batched
	Calls  int
}

QuestionResult is one question's outcome.

type Result

type Result struct {
	PR        prstate.PR
	Mode      config.Mode
	Model     string
	ApproveAt float64
	DenyAt    float64
	VetoAt    float64
	Verdict   verdict.Result
	Questions []QuestionResult // rubric order
	Excluded  []prstate.File
	Unseen    []prstate.Unseen
	Partial   []string
	// LockSources are lockfile package sources outside the allowed
	// registries; any of them holds approve.
	LockSources []prstate.LockSource
	AutoRuns    []prstate.AutoRun
	// CIFailed are required checks that failed on the head; CIErr says why
	// they couldn't be read, which doesn't hold the PR.
	CIFailed []string
	CIErr    error
	// Sensitive are changed paths that config marks sensitive.
	Sensitive []string
	// ChangedLines counts added and deleted lines in files the model sees.
	ChangedLines int
	Untrusted    bool
	TrustErr     error
	Served       []string // distinct model versions the replies named
	Usage        jev.Usage
	CostUSD      float64
	Calls        int
}

Result is everything a report needs.

func Score

func Score(ctx context.Context, gh *github.Client, pr prstate.PR, opts Options) *Result

Score never returns an error: every failure becomes a needs-human result whose Verdict.Failure says why.

func ScoreSnapshot

func ScoreSnapshot(ctx context.Context, gh *github.Client, snap *prstate.Snapshot, opts Options) *Result

ScoreSnapshot scores a fetched snapshot without changing it, so replay can score edited copies of one PR.

func (*Result) Values

func (r *Result) Values() []verdict.Value

Values are the normalised answers in the form verdict.Decide takes.

Jump to

Keyboard shortcuts

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