superloop

package
v0.171.0-rc.52 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 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 superloop is the supervisor's fixed procedure as a pure function: beekeeper's events, the roster and the tracked pull requests in, the transitions to take out. `beekeeper supervisor loop` gathers the input, runs each action through beekeeper's own commands and logs it under its key, which is what keeps a restarted loop from taking it twice.

Index

Constants

View Source
const (
	KindReview   = "review"
	KindGo       = "go"
	KindForward  = "forward"
	KindEscalate = "escalate"
	// KindDone takes an agent off the roster: one that reported done, or
	// one the loop retires (a reviewer whose verdict it acted on, the
	// worker of a pull request it gave the go for that merged).
	KindDone     = "done"
	KindNext     = "next"
	KindRelease  = "release"
	KindClassify = "classify"
	KindQuestion = "question"
	// KindEnd ends the tracking of a pull request that merged or closed.
	KindEnd = "end"
)

The kinds of action, each logged as "supervisor.<kind>".

View Source
const (
	VerbDone    = "agents.done"
	VerbIdle    = "agents.idle"
	VerbReport  = "agents.report"
	VerbProblem = "agents.problem"
	VerbPark    = "agents.park"
)

The verbs of the events the rules act on.

View Source
const (
	Approved         = "approved"
	ChangesRequested = "changes requested"
)

The verdicts of a review.

View Source
const (
	Open   = "OPEN"
	Merged = "MERGED"
	Closed = "CLOSED"
)

The states of a pull request, as gh reports them.

Variables

This section is empty.

Functions

func Detail

func Detail(a Action, what string) string

Detail is the log detail of action a taken for its agent.

func EventAgent

func EventAgent(verb, detail, by string) string

EventAgent is the roster name of the agent an event of verb concerns: the name its detail opens with ("<name> done: …", "<name>: …"), which agents idle and agents park write from the roster, else by, the name of the party that logged it (its session's title, which may differ).

func IsPull

func IsPull(on string) bool

IsPull reports whether a park's On names an issue or pull request.

func ParkedOn

func ParkedOn(detail string) (on, waits string)

ParkedOn reads an agents.park detail ("<name>: parked on <on>: <waits>" or "<name>: parked: <waits>"): what it is parked on and what it waits for.

func ReviewedHead

func ReviewedHead(body, commit string) string

ReviewedHead is the head a review judged: the commit its body names on a "Head reviewed:" line, else the commit GitHub recorded it on.

func ReviewerName

func ReviewerName(ref string, rd int) string

ReviewerName is the roster name of the reviewer of round rd of ref (owner/repo#n): "Review <repo> <n> r<rd>".

func Tracked

func Tracked(workers []Worker, taken []Taken) []string

Tracked are the pull requests a pass reads: every one an agent is parked on, every one the loop started a review of that it has not seen merged or closed, nor escalated, and every ended one whose worker waits for its retirement.

func Verbs

func Verbs() []string

Verbs is every log verb the loop writes.

func Verdict

func Verdict(state, body string) string

Verdict is a review's verdict: GitHub's own (APPROVED, CHANGES_REQUESTED), else that of a commented review whose first line ends in ": approved" or ": changes requested" (a review posted from the author's own account cannot approve on GitHub). "" for a review without one.

Types

type Action

type Action struct {
	Key   string
	Kind  string
	Ref   string // the pull request, when there is one
	URL   string
	Agent string // the worker it concerns
	Head  string
	Round int
	// SelfHosted asks for a reviewer on no self-hosted provider.
	SelfHosted bool
	// Message is what the worker or the guide is told.
	Message string
	// Event is the event a done, next or classify action acts on.
	Event *Event
	// Note is the note a question re-addresses.
	Note int
	// Version is the release to install.
	Version string
}

Action is one transition to take.

func Plan

func Plan(in Input) []Action

Plan is the pass: the actions in, in a stable order, none whose key was taken.

func (Action) Line

func (a Action) Line(what string) string

Line is the action's log detail: its key first, then what it did.

type Event

type Event struct {
	At     time.Time
	Verb   string
	Agent  string // the party that logged it
	Detail string
}

Event is one line of the event log the loop acts on.

type Input

type Input struct {
	Workers []Worker
	// Pulls are the tracked pull requests (Tracked) by ref.
	Pulls map[string]Pull
	// Events are the log's events since the loop's first start.
	Events []Event
	Notes  []Note
	// Release is a newer release's version, "" when there is none.
	Release string
	// Taken are the actions already taken, oldest first.
	Taken []Taken
	// Rounds is supervisor.reviewRounds.
	Rounds int
	// Person is the guide's person.
	Person string
}

Input is everything a pass plans from.

type Note

type Note struct {
	ID   int
	For  string
	By   string
	Text string
}

Note is an open note.

type Pull

type Pull struct {
	Ref   string // owner/repo#n
	URL   string
	State string
	Head  string
	// Green is every check on Head concluded successfully (none is not
	// green: they have not reported yet).
	Green   bool
	Reviews []Review // oldest first
}

Pull is a tracked pull request as GitHub reports it.

type Review

type Review struct {
	ID      string
	Head    string
	Verdict string
	Body    string
	At      time.Time
}

Review is one review of a pull request with a verdict.

type Taken

type Taken struct {
	Key   string
	Kind  string
	Ref   string
	Agent string
	At    time.Time
}

Taken is an action the loop took, read back from its log line.

func ParseTaken

func ParseTaken(at time.Time, verb, subject, detail string) (Taken, bool)

ParseTaken reads a loop log line (verb "supervisor.<kind>", detail "[<key>] <agent>: …") back; false for another line.

type Worker

type Worker struct {
	Name string
	// SelfHosted is a worker whose model a self-hosted provider serves:
	// its reviewer runs on none of them.
	SelfHosted bool
	// ParkedOn is what the agent is parked on (owner/repo#n, #12, …), ""
	// when it is not parked; ParkedAt since when.
	ParkedOn string
	ParkedAt time.Time
	// Started is a session beekeeper started: only such a one the loop
	// retires; a session its person started stays.
	Started bool
}

Worker is an agent on the roster.

Jump to

Keyboard shortcuts

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