plan

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plan is the GitHub plugin's round planner: over the plugin's pull requests and the host's round state, books, events and workspaces, it decides which automatic rounds are due, why, and what each covers.

Index

Constants

View Source
const (
	// MarkReviewed is my last review and the head on a pull request I review.
	MarkReviewed = "reviewed"
	// MarkAddressedReviews is the newest review an address round triaged on
	// a pull request I develop.
	MarkAddressedReviews = "addressed.reviews"
	// MarkAddressedChecks is the head whose failing checks an address round
	// covered.
	MarkAddressedChecks = "addressed.checks"
	// MarkAddressedConflict is the head whose conflict with the base an
	// address round covered.
	MarkAddressedConflict = "addressed.conflict"
	// MarkFirstSkipped is set when the user skipped the automatic first
	// round; the planner plans no other one.
	MarkFirstSkipped = "first.skipped"
)

The marks the rounds of a pull request write, by what they covered; the host keeps them and hands them back in the round state.

View Source
const (
	RoundFollowup = "follow-up"
	RoundFirst    = "first"
	RoundAddress  = "address"
)

The rounds a plan names.

View Source
const (

	// WhyPartial is why no round is due while the workspace listing may
	// miss a workspace.
	WhyPartial = "the workspace listing is incomplete, no rounds this sweep"
)

Variables

This section is empty.

Functions

func ActiveBlock

func ActiveBlock(evs []pr.Event, viewer string) (pr.Event, bool)

ActiveBlock is the round_blocked event that still holds among evs, in time order: none has cleared it since, by an unblock, a sent or held round, or a review of mine after it.

func LastPublished

func LastPublished(b src.Book, role string) (head string, at time.Time, ok bool)

LastPublished is the head and time of the newest verdict a turn of role published in b: the head its last record covered, else the turn's.

func NewestReview

func NewestReview(b src.Book) (time.Time, bool)

NewestReview is when b's newest review turn was sent.

func StartBlock

func StartBlock(ev pr.Event) bool

StartBlock says ev is the host's start block of a round, which names the agent's question or an untrusted folder in its key; any other block is the planner's.

Types

type Board

type Board struct {
	// Carded says a workspace targets the pull request.
	Carded          bool `json:"carded,omitempty"`
	ReviewWorkspace bool `json:"review_workspace,omitempty"`
	// AuthorWorkspace says an author workspace targets it and holds no
	// address round, nor one a partial listing hides.
	AuthorWorkspace bool `json:"author_workspace,omitempty"`
	// Checkout is the author workspace an author card reads; nil for none.
	Checkout *Checkout `json:"checkout,omitempty"`
}

Board is what the host's board reads of a pull request's workspaces: the review and author workspaces the planner targets it with, and the one an author card reads its checkout from.

type Checkout

type Checkout struct {
	ID   string `json:"id"`
	Path string `json:"path"`
}

Checkout is a local workspace an author card reads.

type Config

type Config struct {
	ReviewPrefix string
	// Owners restricts automated rounds to these owners; empty means the
	// owners of every repository the workspace managers know.
	Owners                    []string
	TrustedAuthors            []string
	FollowupsWithoutWorkspace bool
	AddressWithoutWorkspace   bool
	AddressReviews            bool
	AddressSkipReviewers      []string
	AddressChecks             bool
	IgnoreChecks              []string
	AddressConflicts          bool
	// Completed are the completed columns of the boards.
	Completed  []string
	Fast, Slow time.Duration
	Projects   []Project
}

Config is what the planner reads of the configuration: GitHub's settings, the board columns a finished review workspace sits in, the sweeps' intervals and the projects that override some settings.

func (Config) For

func (c Config) For(owner, repo string) Config

For is the settings that apply to a pull request of owner/repo: the first project that matches it overrides the top-level ones.

type Git

type Git interface {
	// Upstream is the remote branch the checkout at dir pushes to; "" for
	// none.
	Upstream(ctx context.Context, dir string) (string, error)
	LocalBranchTip(ctx context.Context, dir, branch string) (string, error)
	// CheckedOutAt is the worktree that has branch checked out; "" for none.
	CheckedOutAt(ctx context.Context, dir, branch string) (string, error)
	HasCommit(ctx context.Context, dir, oid string) (bool, error)
	IsAncestor(ctx context.Context, dir, ancestor, commit string) (bool, error)
}

Git reads what a round would find of a pull request's branches in a local checkout.

type Inputs

type Inputs struct {
	Now    time.Time
	Viewer string
	Rows   []pr.PR
	// Details are the stored full reads; one of another version is no read.
	Details map[pr.Ref]store.Detail
	// Adopted are the pull requests taken over into the loop.
	Adopted map[pr.Ref]bool
	// Wanted is the profile's review_wanted, by pull request; one it does
	// not name is wanted when it requests the viewer's review by name.
	Wanted  map[pr.Ref]bool
	Books   map[pr.Ref]src.Book
	Rounds  map[pr.Ref]src.RoundState
	Events  map[pr.Ref][]pr.Event
	Listing src.Listing
	// Unlisted says the workspaces could not be read: no round is due.
	Unlisted bool
	// Git nil reads no checkout.
	Git Git
	Cfg Config
}

Inputs are everything the planner reads at one instant: the plugin's stored pull requests, and the host's books, round state, events and workspaces.

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner derives results over one read of its inputs.

func New

func New(ctx context.Context, in Inputs) *Planner

New is the planner over in.

func (*Planner) BoardOf

func (p *Planner) BoardOf(ref pr.Ref, r Result) Board

BoardOf is ref's board under r.

func (*Planner) Derive

func (p *Planner) Derive(ref pr.Ref) (Result, error)

Derive is what the rules decide on ref.

func (*Planner) Facts

func (p *Planner) Facts(ref pr.Ref, r Result) []src.Fact

Facts are the workflow facts r decides on ref.

func (*Planner) Plan

func (p *Planner) Plan(ref pr.Ref, r Result) src.Plan

Plan is the rounds r plans on ref, each with the marks the host writes when it sends or skips it.

func (*Planner) RankOf

func (p *Planner) RankOf(ref pr.Ref, r Result) Rank

RankOf is r's rank of ref.

func (*Planner) Requested

func (p *Planner) Requested(ref pr.Ref) bool

Requested says whether a first round may review ref: an open, ready pull request I did not open, which the profile's review_wanted holds for and, unless it requests my review by name, that I never reviewed.

func (*Planner) Settle

func (p *Planner) Settle(ref pr.Ref, r Result) Settlement

Settle is what r leaves behind on ref: the fingerprint a review stored without its head gets, the first round skip a review workspace clears, and the first rounds' block and unblock events.

type Project

type Project struct {
	Match                     string
	TrustedAuthors            []string
	FollowupsWithoutWorkspace *bool
	AddressWithoutWorkspace   *bool
}

Project overrides some settings for the repositories its match names; nil keeps the top-level value.

type Rank

type Rank struct {
	Path int       `json:"path"`
	At   time.Time `json:"at,omitzero"`
	Idx  int       `json:"idx,omitempty"`
}

Rank orders units as the rounds are planned: follow-ups by their review's time, first rounds by the pull request's age, address rounds by their workspace's place and then among my pull requests, then the units no round is due on.

func (Rank) Compare

func (a Rank) Compare(b Rank) int

Compare orders a before b.

type Result

type Result struct {
	// contains filtered or unexported fields
}

Result is what the review, first-round and address rules decide on one pull request; the host's turn.start guards filter it further.

func (Result) Due

func (r Result) Due(now time.Time) time.Time

Due is the earliest instant after now a decision of r changes with no input changing; zero for none.

func (Result) Runs

func (r Result) Runs() bool

Runs says whether a round of r would run without the user: due and not only observed.

type Settlement

type Settlement struct {
	Marks  map[string]string
	Events []pr.Event
}

Settlement is what planning leaves behind on a pull request: the marks to set, "" removing one, and the events to record.

Jump to

Keyboard shortcuts

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