core

package
v1.0.41 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 13 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 core holds the types aviary's halves exchange: the issues and comments a source produces, the state a run reads back from GitHub, and the target syntax that names where either comes from. It is deliberately small and dependency free, so the browser driver in package browser and the root package can both speak them without importing each other.

Index

Constants

View Source
const (
	// PausedBlocked is an issue waiting for the open issues it depends on to
	// close.
	PausedBlocked = "blocked"
	// PausedStacked is a ready pull request stacked on its blocker's branch,
	// waiting for the blocker's pull request to merge or close.
	PausedStacked = "stacked"
	// PausedPullRequest is a finished run whose ready pull request is held
	// for a human to merge (a DONOTMERGE directive). It waits for that pull
	// request to merge, which completes the work, or to close unmerged, which
	// restarts it fresh.
	PausedPullRequest = "pull-request"
	// PausedManual is work the owner paused from a dashboard. No
	// GitHub event wakes it; it waits until the owner retries it. Only its
	// issue closing finishes it, so it does not linger once the work is gone
	//.
	PausedManual = "manual"
)

The kinds of paused work. Paused work is out of the dispatch queue and holds no agent slot. It waits on one GitHub terminal event (a merge or a close) and goes back into the queue through the normal claim path when that event happens. Review activity never wakes it.

View Source
const (
	JobKindIssue      = "issue"
	JobKindDiscussion = "discussion"
	JobKindSchedule   = "schedule"
	// JobKindMerge is a pull request queued on demand for gh-safe-merge, and
	// JobKindDiscuss a Discussion thread queued on demand for gh-discuss
	// (issue #1095). Unlike a Discussions board's JobKindDiscussion, both
	// wait in the persisted job queue and accept every job action.
	JobKindMerge   = "merge"
	JobKindDiscuss = "discuss"
)

Job kinds.

View Source
const (
	PullRequestDraft  = "draft"
	PullRequestOpen   = "open"
	PullRequestMerged = "merged"
)

The states of a job's pull request the board draws.

View Source
const (
	BoardStarting = "starting"
	BoardPaused   = "paused"
	BoardRunning  = "running"
	BoardDone     = "done"
	BoardFailed   = "failed"
)

The five states the board shows a job in. Every engine status maps onto exactly one of them.

View Source
const BoardScheduled = "scheduled"

BoardScheduled is the state of a schedule's board entry between runs: its runs collapse into one entry per schedule (see boardEntries), which is starting or running while a run is in flight, failed while its last run failed and was not dismissed, and scheduled otherwise. It is never done.

View Source
const DefaultIssueFilter = "assignee:@me"

DefaultIssueFilter is the search filter a run uses when none is configured: the issues assigned to the authenticated user. Assignment is the gate; only someone with triage access can assign an issue, while anyone can author one.

View Source
const DefaultReleaseRepo = "lsegal/aviary"

DefaultReleaseRepo is aviary's own repository, whose release pages the version display and the update notice link to.

View Source
const ManualPauseReason = "paused by owner"

ManualPauseReason is what the dashboards say a job the owner paused waits on.

View Source
const StalledPauseReason = "its agent kept ending turns without progress; retry it to resume"

StalledPauseReason is what the dashboards say a job waits on when Code Loop paused it because its agent kept ending turns with the issue still open and nothing new on GitHub. Like a manual pause, only the owner retrying it resumes it.

Variables

BoardStates lists the board states in the order the board shows them.

View Source
var ErrNotReady = errors.New("run is still starting")

ErrNotReady is returned by the settings and job-action handlers when the run loop has not yet reached its dispatch select statement. Before that point the handlers would otherwise block indefinitely on an unbuffered channel nothing is reading from yet, leaving the dashboard's "loading settings..." spinner stuck with no error and no timeout. The dashboard treats this as a signal to retry rather than a hard failure.

Functions

func ChecklistProgress

func ChecklistProgress(body string) (done, total int)

ChecklistProgress counts the task-list items in a pull request body and how many of them are checked. Every item counts the same, wherever it sits in the body, and items inside fenced code blocks are ignored. A body without task-list items reports a total of zero.

func DependencyReferences added in v0.7.1

func DependencyReferences(repo string, dependencies []IssueDependency) []string

DependencyReferences names each dependency as seen from repo, as PausedWork.WaitingOn records them.

func FormatInterval

func FormatInterval(d time.Duration) string

FormatInterval renders a poll interval for display. Go's own duration string spells whole hours as `1h0m0s`, and the web UI used to divide the same nanosecond value into whole seconds (`3600s`), so one run read differently depending on which status bar was open. Zero components are dropped so short intervals stay as short as they read (`20s`, not `0h0m20s`).

func HeldForOwner

func HeldForOwner(reason string) bool

HeldForOwner reports whether a paused job's reason says only the owner can resume it, so nothing read from GitHub, and no watchdog, wakes it.

func InferJobKind added in v1.0.25

func InferJobKind(job JobSnapshot) string

InferJobKind returns job's kind, inferring an empty one from the rest of the job: a run with a schedule ID is a scheduled run, and anything else is an issue's job. Work paused or restored without its kind keeps a kind, so a board filtering by kind never drops it while still counting it (issue #1722).

func IsDiscussionTarget

func IsDiscussionTarget(repo string) bool

IsDiscussionTarget reports whether a target names a repository's Discussions.

func IsProjectTarget

func IsProjectTarget(repo string) bool

IsProjectTarget reports whether a target names a Projects (v2) board.

func IssueBlocked

func IssueBlocked(issue Issue) (bool, string)

IssueBlocked reports whether an issue is not work yet, and why: it either has sub-issues of its own, which makes it a tracking issue, or it depends on an issue that is not closed.

func IssueFilterTerms

func IssueFilterTerms(filter string) []string

IssueFilterTerms splits a --filter into the terms a query is actually built from, dropping every qualifier that names the kind or the state of what to look for.

aviary only ever dispatches an open issue: a closed one has nothing left to do and a pull request is not work it can pick up, so "is:issue" and the open state are appended to every query rather than being defaults a --filter can displace. They are therefore not part of the filter a user is shown or overrides, and a filter that names its own kind or state has that term dropped here instead of contradicting the qualifiers aviary adds.

It is shared with ProjectItemQuery, which appends the same two qualifiers in a project board's own narrower vocabulary.

func IssueRepository

func IssueRepository(target string, issue Issue) string

IssueRepository resolves the OWNER/REPO an issue belongs to, falling back to the target it was listed from when the issue does not name one itself.

func IssueSearchTerms

func IssueSearchTerms(filter string, allIssues bool) []string

IssueSearchTerms builds the search terms for filter, the query body shared by the API path and the browser mode's page URL. "is:issue" and "state:open" always open the query; see IssueFilterTerms.

allIssues drops the filter entirely, leaving the bare qualifiers.

func OpenPullRequests

func OpenPullRequests(state OriginatingWorkState) []int

OpenPullRequests returns the numbers of the open, unmerged pull requests in state.

func ProgressPercent

func ProgressPercent(done, total int) (int, bool)

ProgressPercent is the share of a plan's tasks that are done, rounded down so a plan reads 100% only once every task is checked. It reports false when there is no plan to measure against.

func ProjectItemInProgress

func ProjectItemInProgress(target string, issue Issue) bool

ProjectItemInProgress reports whether issue is a project item currently parked in the "In Progress" column, which is how a aviary instance marks work it has claimed.

func ProjectItemQuery

func ProjectItemQuery(filter string, allIssues bool) string

ProjectItemQuery builds the item filter a project board is asked for, both as the board page's ?filterQuery= and as the GraphQL/`gh project item-list` item query.

The kind and state qualifiers always open the query, exactly as IssueSearchTerms does for the issues page, and a filter naming its own is stripped of it by IssueFilterTerms rather than contradicting them.

A board speaks a narrower search vocabulary than the issues page: it knows "is:open"/"is:closed" but not "state:open", so the open state is named the board's own way here.

func ProjectReadyState

func ProjectReadyState(configured, current string) string

ProjectReadyState returns the status that marks a board item ready.

func ProjectStatusAllowsDispatch

func ProjectStatusAllowsDispatch(status, readyState string) bool

ProjectStatusAllowsDispatch reports whether a board item's status marks it ready, matching readyState or, when it is empty, the default ready column names below.

func Queued added in v0.7.25

func Queued(kind string) bool

Queued returns whether kind is one of the job kinds queued on demand.

func RejectedPullRequest

func RejectedPullRequest(state OriginatingWorkState) (int, string)

RejectedPullRequest reports the pull request closed without merging that rejects the work on an open issue: none of its pull requests is open or merged, and at least one was closed unmerged. A closed issue or a merged pull request means the work is done and is never restarted.

func ReleasePageURL

func ReleasePageURL(repo, version string) string

ReleasePageURL is the GitHub release page of version in repo. A development or untagged build, whose version is not plain dotted numbers, has no release page, so it links to the repository's releases index instead of a tag URL that would 404.

func RemoteIssueAllowsDispatch

func RemoteIssueAllowsDispatch(target string, issue Issue, readyState string) bool

RemoteIssueAllowsDispatch reports whether an issue as GitHub reports it may be dispatched on target: open, unblocked, and ready.

func ShouldDispatchIssue

func ShouldDispatchIssue(repo string, issue Issue, isActive, wasActive, wasCompleted, seen bool, readyState string) bool

ShouldDispatchIssue decides whether a repository or project issue that is not already active locally is a dispatch candidate. Remote ownership can no longer be read synchronously for repository issues (no label survives to check), so a never-seen issue is always a candidate, and one this instance has already seen is a candidate again only if it wasn't already completed; negotiateContestedIssues is what asks, via comments, whether another instance already owns a reappearing candidate.

func SkipCITokens added in v0.7.32

func SkipCITokens(message string) []string

SkipCITokens returns every skip-CI marker in message, in order, so a merge that carried one into the default branch can say which (issue #1176).

func ValidRepo

func ValidRepo(repo string) bool

ValidRepo reports whether repo is a bare OWNER/REPO pair.

func ValidateIssueFilter added in v0.7.41

func ValidateIssueFilter(filter string) error

ValidateIssueFilter checks filter's search syntax, the checks GitHub's search skips by silently matching nothing: balanced quotes and parentheses, and a value after every qualifier.

func WorkProgress

func WorkProgress(state OriginatingWorkState) string

WorkProgress fingerprints what an agent's turn can visibly change on GitHub: the issue's comments, and each pull request's existence, state, head commit, comments, and plan checklist. Two equal fingerprints mean nothing new was committed, opened, or commented in between.

Types

type AgentOption

type AgentOption struct {
	Name string `json:"name"`
	// Models and Levels are the agent's allow-lists. Empty means the agent
	// accepts any value, so the UI offers no closed list for it.
	Models []string `json:"models,omitempty"`
	Levels []string `json:"levels,omitempty"`
}

AgentOption describes one agent the registry knows, so the dashboard's agent selector can offer it -- and the models and levels it accepts -- from what the run actually registered rather than from a hardcoded pair.

type AttachmentCommentPoster added in v0.7.6

type AttachmentCommentPoster interface {
	PostCommentWithAttachments(ctx context.Context, repo string, number int, body string, files []string) (string, error)
}

AttachmentCommentPoster posts a comment with local image or video files uploaded and embedded in it, reporting the comment's URL.

type CheckpointResult

type CheckpointResult struct {
	Target  string
	Number  int
	Branch  string `json:",omitempty"`
	Outcome string
	Detail  string `json:",omitempty"`
}

CheckpointResult is one active run's outcome in the shutdown checkpoint aviary takes before it restarts or exits: Outcome is "pushed", "nothing to push", "failed", or "timed out", and Detail says why.

type ClearClonesResult

type ClearClonesResult struct {
	Removed   []CloneEntry `json:"removed"`
	Kept      int          `json:"kept"`
	Reclaimed int64        `json:"reclaimed"`
	Errors    []string     `json:"errors,omitempty"`
}

ClearClonesResult reports what clearing unused clones removed, how many bytes that reclaimed, how many clones it kept, and any removal failures. Reclaimed is the sum of the removed entries' sizes; failed removals count nothing.

type CloneEntry

type CloneEntry struct {
	Path string `json:"path"`
	// Repository is the OWNER/REPO the clone was made from, and Issue the
	// issue it was made for. Either is empty or zero when it is not known.
	Repository string `json:"repository,omitempty"`
	Issue      int    `json:"issue,omitempty"`
	// PullRequest is the job's pull request once one is known, hosted in
	// PullRequestRepository when that differs from Repository.
	PullRequest           int    `json:"pullRequest,omitempty"`
	PullRequestRepository string `json:"pullRequestRepository,omitempty"`
	// Job is the work key (target#number) the clone belongs to.
	Job string `json:"job,omitempty"`
	// InUse reports that a live job of this instance (active, waiting,
	// queued, paused or stopping) holds the clone, so clearing keeps it.
	// Kept reports a clone nothing holds that clearing still leaves alone,
	// such as one outside the configured temp directories. Reason says why
	// the clone is in use, kept, or unused.
	InUse  bool   `json:"inUse"`
	Kept   bool   `json:"kept,omitempty"`
	Reason string `json:"reason,omitempty"`
	// Size is the clone's bytes on disk: measured by listing, and right
	// before removal by a clear. Nil means it could not be measured in time.
	Size *int64 `json:"size,omitempty"`
}

CloneEntry is one checkout directory aviary has on record for a job (issue #830), as the settings dashboards list it.

type ClonesSnapshot

type ClonesSnapshot struct {
	Roots      []string     `json:"roots"`
	Clones     []CloneEntry `json:"clones"`
	TotalSize  int64        `json:"totalSize"`
	Unmeasured int          `json:"unmeasured,omitempty"`
}

ClonesSnapshot lists every recorded clone and the temp directories new clones are placed in, in the order they are tried. TotalSize sums the clones whose size was measured; Unmeasured counts the ones left out.

type Comment

type Comment struct {
	Body      string
	Author    string
	CreatedAt time.Time
	// ID is GitHub's ID for the comment, review comment or review, when the
	// source reports one. The three kinds are numbered separately, so URL,
	// whose fragment names the kind, is what tells two comments apart.
	ID int64
	// URL is the comment's permalink, when the source reports one.
	URL string
}

Comment is a single issue or pull request comment relevant to the cooperative handoff protocol.

type CommentClient

type CommentClient interface {
	CommentPoster
	CommentLister
}

CommentClient is the combined capability needed to run the handoff handshake described in issue #214.

type CommentLister

type CommentLister interface {
	ListComments(ctx context.Context, repo string, number int) ([]Comment, error)
}

CommentLister lists the comments on an issue or pull request.

type CommentPoster

type CommentPoster interface {
	PostComment(ctx context.Context, repo string, number int, body string) error
}

CommentPoster posts a comment to an issue or pull request.

type CommentReactor

type CommentReactor interface {
	AddReaction(ctx context.Context, repo string, commentID int64, content string) error
}

CommentReactor adds an emoji reaction to a specific comment, identified by its GitHub comment ID. It is kept separate from CommentClient so a driver with no reaction affordance (a fake in a test, or a future comment source with no API to react through) is not forced to implement it.

type FilterOverrides added in v0.7.41

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

FilterOverrides holds per-target issue search filters, each replacing the run's filter and all-issues setting for its target. A running engine reads them on every poll, so a change applies without a restart. A nil FilterOverrides has none.

func NewFilterOverrides added in v0.7.41

func NewFilterOverrides(filters map[string]string) *FilterOverrides

NewFilterOverrides returns overrides holding filters.

func (*FilterOverrides) For added in v0.7.41

func (o *FilterOverrides) For(target, filter string, allIssues bool) (string, bool)

For returns the issue search filter and all-issues setting of target: its own override, else filter and allIssues.

func (*FilterOverrides) Set added in v0.7.41

func (o *FilterOverrides) Set(filters map[string]string)

Set replaces every override with filters.

type ForkSource

type ForkSource interface {
	ForkFor(context.Context, string) (string, error)
}

ForkSource decides where the fix for a repository's issue is pushed (issue #712). It answers an empty string when the authenticated user can write to repo, and otherwise the OWNER/REPO of the user's fork of it, creating that fork when it does not exist yet.

type GitHubRateLimit added in v1.0.18

type GitHubRateLimit struct {
	// Limited reports the budget spent and not reset yet. REST reads
	// wait until Reset; browser delivery keeps reading comments meanwhile.
	Limited          bool
	Limit, Remaining int
	// Reset is when the current window ends; zero once it has.
	Reset time.Time
}

GitHubRateLimit is the GitHub REST core rate-limit budget.

type GitHubSession

type GitHubSession struct {
	// SignedOut reports that the most recent read was served to a signed-out
	// session, so it found nothing and was reported as an error rather than
	// as "no issues".
	SignedOut bool `json:"signed_out"`
	// URL and Status are the page that showed the signed-out session, and
	// its HTTP status when a 404 or 403 is what gave it away.
	URL    string `json:"url,omitempty"`
	Status int    `json:"status,omitempty"`
	// Since is when the signed-out spell began.
	Since time.Time `json:"since,omitzero"`
	// SigningIn reports a sign-in window that is open now.
	SigningIn bool `json:"signing_in"`
	// WindowUnavailable names why no sign-in window can appear on this
	// machine, such as a container with no display. The banner then offers
	// gh polling or importing a profile instead.
	WindowUnavailable string `json:"window_unavailable,omitempty"`
	// LastError is why the last sign-in attempt did not work.
	LastError string `json:"last_error,omitempty"`
}

GitHubSession is what browser delivery knows about its GitHub sign-in.

type Issue

type Issue struct {
	Number        int               `json:"number"`
	Repository    string            `json:"repository,omitempty"`
	Title         string            `json:"title,omitempty"`
	Body          string            `json:"body,omitempty"`
	State         string            `json:"state,omitempty"`
	CreatedAt     time.Time         `json:"createdAt,omitempty"`
	Labels        []IssueLabel      `json:"labels,omitempty"`
	DependsOn     []IssueDependency `json:"dependsOn,omitempty"`
	HasSubIssues  bool              `json:"hasSubIssues,omitempty"`
	ProjectStatus string            `json:"projectStatus,omitempty"`
	ProjectItemID string            `json:"-"`
	Target        string            `json:"-"`
	// Fork is the OWNER/REPO of the user's fork the fix is pushed to when the
	// user cannot write to Repository. Empty pushes to Repository.
	Fork string `json:"-"`
	// Prompt replaces the gh-fix invocation for a scheduled run, which has no
	// issue, and ScheduleID names the schedule it fired from.
	Prompt     string `json:"-"`
	ScheduleID string `json:"-"`
	// Skill is the skill a job queued on demand runs, gh-safe-merge or
	// gh-discuss, in place of the target's own (issue #1095).
	Skill string `json:"-"`
}

Issue is a GitHub issue as aviary reads it, whichever source it came from.

type IssueCreate

type IssueCreate struct {
	Repository string `json:"repository"`
	Text       string `json:"text"`
	Model      string `json:"model,omitempty"`
	// Attachments are local image or video files gh-create uploads and
	// embeds in the issue.
	Attachments []string `json:"attachments,omitempty"`
	// Session is the chat session asking, when there is one. A second,
	// different request from it on the same repository while one is filing
	// or shortly after one filed is refused unless Distinct is set.
	Session  string `json:"session,omitempty"`
	Distinct bool   `json:"distinct,omitempty"`
}

IssueCreate asks for an issue to be filed on Repository through the gh-create skill, described by Text. Model, when set, overrides the configured prompt-agent model for this request.

type IssueCreateResult

type IssueCreateResult struct {
	URL         string   `json:"url"`
	Agent       string   `json:"agent"`
	Attachments []string `json:"attachments,omitempty"`
}

IssueCreateResult is the issue an IssueCreate filed and the agent that filed it.

type IssueDependency

type IssueDependency struct {
	Number     int    `json:"number"`
	State      string `json:"state"`
	Repository string `json:"repository,omitempty"`
}

IssueDependency is an issue this one is blocked by. Repository is the OWNER/REPO the dependency lives in, which can differ from the dependent issue's own repository.

func OpenDependencies

func OpenDependencies(issue Issue) []IssueDependency

OpenDependencies returns the issues issue depends on that are not closed, each with its Repository resolved: a dependency that names none lives in issue's own repository.

func StackableDependency

func StackableDependency(issue Issue) (IssueDependency, bool)

StackableDependency returns the one open dependency an issue could be stacked on instead of waiting for it to close: with GitHub stacked pull requests, the dependent issue's pull request is built on the blocker's branch. A tracking issue with sub-issues is never stackable, and neither is an issue blocked by more than one open issue, because a stack is a single chain of branches. A blocker in another repository is never stackable either, because a stack's branches all live in one repository.

func (IssueDependency) Key added in v0.7.1

func (d IssueDependency) Key() string

Key names the dependency uniquely across repositories, as OWNER/REPO#NN with the repository lowercased, so two repositories' issues that share a number never collide. Repository must already be resolved.

func (IssueDependency) Reference added in v0.7.1

func (d IssueDependency) Reference(repo string) string

Reference names the dependency as seen from an issue in repo: a bare #NN when it lives in the same repository, and OWNER/REPO#NN when it does not.

type IssueLabel

type IssueLabel struct {
	Name string `json:"name"`
}

IssueLabel is one label on an issue.

type IssueSource

type IssueSource interface {
	ListIssues(context.Context, string) ([]Issue, error)
}

IssueSource lists the issues a watched target currently offers.

type IssueUpdate

type IssueUpdate struct {
	Repository string `json:"repository"`
	Number     int    `json:"number"`
	Text       string `json:"text"`
	// Attachments are local image or video files uploaded and embedded in
	// the comment.
	Attachments []string `json:"attachments,omitempty"`
}

IssueUpdate is an update to post as a comment on Repository's issue or pull request Number, mentioning its author so the owning job hears it through aviary's mention path.

type IssueUpdatePoster

type IssueUpdatePoster interface {
	IssueAuthor(ctx context.Context, repo string, number int) (string, error)
	PostCommentURL(ctx context.Context, repo string, number int, body string) (string, error)
}

IssueUpdatePoster is the GitHub access the MCP update-issue tool and the prompt agent's update action need: the author of an issue or pull request, and posting a comment that reports its URL. Every comment client aviary wraps another in must pass it through, or updates stop working in the mode that wraps it.

type IssueUpdateResult

type IssueUpdateResult struct {
	URL         string   `json:"url"`
	Author      string   `json:"author"`
	Attachments []string `json:"attachments,omitempty"`
}

IssueUpdateResult is the comment an IssueUpdate posted.

type JobAction

type JobAction struct {
	Action string `json:"action"`
	Target string `json:"target"`
	Number int    `json:"number"`
}

JobAction is a retry, stop, or pause a dashboard asks the run to perform on one job.

type JobActions

type JobActions struct {
	Retry       bool
	RetryReason string
	Stop        bool
	Pause       bool
}

JobActions says which job actions the run accepts for a job in one state, so a dashboard never enables a button whose request is guaranteed to fail . RetryReason says why retry is refused, when it is.

func JobActionAvailability

func JobActionAvailability(status string) JobActions

JobActionAvailability reports the job actions the run accepts for a job in status. The web dashboard's jobActionAvailability mirrors it.

func JobActionsFor

func JobActionsFor(job JobSnapshot) JobActions

JobActionsFor reports the job actions the run accepts for job. A scheduled run has no issue to resume, so it is never paused, and Retry fires its schedule again once the run has finished. A discussion is only stopped: the next poll answers a thread that still has no reply.

type JobSnapshot

type JobSnapshot struct {
	Number int
	Target string
	// Repository is the OWNER/REPO hosting the job's issue, which differs
	// from Target when Target is a project, so the dashboards can link the
	// issue number to its page.
	Repository        string
	Title             string
	Status            string
	CheckoutDirectory string
	SessionID         string
	Agent             string
	Model             string
	Effort            string
	Started           time.Time
	Log               string
	// LogTruncated marks a Log the job store cut down to its tail, so the
	// views say earlier output was dropped (issue #1646).
	LogTruncated bool
	// WaitReason and WakeAt describe a job whose agent scheduled a wakeup and
	// is waiting for it, with Status "waiting". WaitReason also
	// says what a job with Status "paused" waits on.
	WaitReason string
	WakeAt     time.Time
	// PullRequest is the number of the job's current pull request, or 0 while
	// it has none. PullRequestRepository is the OWNER/REPO hosting it, set
	// only when that differs from the issue's repository, such as a pull
	// request opened from a fork.
	PullRequest           int
	PullRequestRepository string
	// PullRequestState is the current pull request's PullRequestDraft,
	// PullRequestOpen, or PullRequestMerged, so the board can color its icon.
	PullRequestState string
	// TasksDone and TasksTotal count the checked and all items in the plan
	// checklist of the job's current pull request, and Progress is the
	// percentage done the dashboards draw as a progress bar. A
	// job whose pull request has no checklist, or that has no pull request,
	// has a TasksTotal of zero and shows no bar. Progress is computed here
	// only, so the two dashboards can never disagree about it.
	TasksDone  int
	TasksTotal int
	Progress   int
	// Kind is JobKindIssue, JobKindDiscussion, JobKindSchedule, JobKindMerge,
	// or JobKindDiscuss, and ScheduleID names the schedule a scheduled run
	// fired from. RunID is the scheduler job a scheduled run runs as, which
	// the task's run pages look its output up by (issue #1646).
	Kind       string
	ScheduleID string
	RunID      string
	// QueuePosition is a merge job's priority among its repository's merges
	// still waiting for a slot, from 1 for the next to start, and 0 for
	// running merges and every other job. Merges run concurrently, so it
	// orders their starts, not their finishes.
	QueuePosition int
	// Finished is when a scheduled run ended, Summary its one-line result,
	// and Fallback whether its precompiled script failed so the model ran
	// it. Dismissed hides a failed scheduled run from the board's Failed
	// state until the schedule's next run.
	Finished  time.Time
	Summary   string
	Fallback  bool
	Dismissed bool
	// Retrying marks an issue's job whose run ended with an error while
	// Code Loop still dispatches its work again, so Status "failed" is not
	// terminal yet: the board shows it waiting, with WaitReason saying why,
	// until a run picks it up or a poll finds nothing left to retry
	// (issue #1424).
	Retrying bool
	// GHCalls is the gh calls the job's CLI made directly rather than
	// through its MCP tools, across its runs since dispatch (#1712), so a job
	// that polls GitHub with gh stands out.
	GHCalls int
	// GHFallbacks is how many of GHCalls were reads the job's MCP read
	// tools answer, made while it had them: fallbacks from those tools to gh
	// (#1742).
	GHFallbacks int
}

JobSnapshot is one agent run as the dashboards draw it.

func (JobSnapshot) BoardState

func (j JobSnapshot) BoardState() string

BoardState is the state the board shows the job in. A queued job, and an issue's run whose agent has not reported its clone yet, are starting; a job waiting out a wakeup is paused alongside paused work, with WaitReason saying why.

Failed means terminal and unrecoverable only: the job cannot continue on its own (issue #1424). A failed run Code Loop is about to dispatch again waits in the paused state instead, and failing CI never fails a job, because the engine never derives a job's status from its checks.

func (JobSnapshot) Failed added in v0.7.76

func (j JobSnapshot) Failed() bool

Failed reports whether the job is Failed under the board's definition: terminal, with nothing left that continues it (issue #1424).

func (*JobSnapshot) Finish

func (j *JobSnapshot) Finish()

Finish marks the job's plan done, so a completed job reads 100% (issue #755). A job with no checklist still shows no bar.

func (JobSnapshot) HasProgress

func (j JobSnapshot) HasProgress() bool

HasProgress reports whether the job has a plan checklist to measure its progress against.

func (JobSnapshot) IssueURL

func (j JobSnapshot) IssueURL() string

IssueURL is the GitHub page of the job's issue, or "" when its repository is unknown.

func (JobSnapshot) PullRequestLabel

func (j JobSnapshot) PullRequestLabel() string

PullRequestLabel is how the dashboards name a job's pull request next to its issue number: "PR #750", or "PR fork/repo#750" when it lives in another repository. A job without a pull request has no label.

func (JobSnapshot) PullRequestURL

func (j JobSnapshot) PullRequestURL() string

PullRequestURL is the GitHub page of the job's pull request, in its own repository when that differs from the issue's, or "" when the job has no pull request.

func (*JobSnapshot) SetPullRequest

func (j *JobSnapshot) SetPullRequest(state OriginatingWorkState, issueRepository string) bool

SetPullRequest records the current pull request in state as the job's, and reports whether that changed what the dashboards show, along with the progress its plan checklist makes.

type ManualTargets added in v0.7.54

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

ManualTargets is the set of targets in manual mode, which a running engine never discovers issues for. It reads them on every poll, so a mode change applies without a restart. A nil ManualTargets holds none.

func NewManualTargets added in v0.7.54

func NewManualTargets(targets []string) *ManualTargets

NewManualTargets returns the set holding targets.

func (*ManualTargets) Has added in v0.7.54

func (m *ManualTargets) Has(target string) bool

Has reports whether target is in manual mode.

func (*ManualTargets) List added in v0.7.54

func (m *ManualTargets) List() []string

List returns the manual targets, sorted.

func (*ManualTargets) Set added in v0.7.54

func (m *ManualTargets) Set(targets []string) []string

Set replaces the set with targets and returns the targets that left it, switching back to watch mode.

type OriginatingWorkState

type OriginatingWorkState struct {
	IssueState string
	// IssueBody is the issue's description, compared between checks so an
	// edit made while an agent is working is relayed into its session
	//.
	IssueBody string
	// IssueComments counts the comments on the issue.
	IssueComments int
	PullRequests  []PullRequestWorkState
}

OriginatingWorkState is what a run reads back about the issue an agent is working, so a closure or an edit made while it runs can be relayed into the session.

type PausedCheck

type PausedCheck struct {
	Issue    Issue
	Own      *OriginatingWorkState
	Blockers map[string]OriginatingWorkState
}

PausedCheck is the GitHub state a wake check reads. Issue is the issue as the poll listed it. Own is the state of the issue's own pull requests, and Blockers holds the state of each issue it waits on, keyed by IssueDependency.Key. A state that could not be read is left out, and a check never wakes on missing state.

type PausedWake

type PausedWake int

PausedWake is what a paused record's wake check decided.

const (
	// PausedStay leaves the work paused.
	PausedStay PausedWake = iota
	// PausedResume puts the work back in the queue to pick it back up.
	PausedResume
	// PausedRestart puts the work back in the queue to start over, because
	// its pull request was closed without merging.
	PausedRestart
	// PausedComplete ends the work: its pull request merged or its issue
	// closed.
	PausedComplete
)

func WakePaused

func WakePaused(paused PausedWork, check PausedCheck) (PausedWake, string)

WakePaused decides whether paused work wakes, and why. It only reads GitHub terminal state: issue and pull request open, closed, and merged. Reviews, review comments, and approvals are not part of the input, so they can never wake paused work. Every instance that reads the same GitHub state decides the same thing.

type PausedWork

type PausedWork struct {
	Kind string `json:"kind"`
	// WaitingOn lists the open issues the work is blocked by, each named
	// as IssueDependency.Reference does from the paused issue's repository.
	WaitingOn []string `json:"waitingFor,omitempty"`
	// PullRequests lists the work's own open pull requests.
	PullRequests []int `json:"pullRequests,omitempty"`
	// Reason overrides what the dashboards say a manual pause waits on, for
	// one Code Loop made itself rather than the owner.
	Reason string `json:"reason,omitempty"`
}

PausedWork is the one record every kind of paused work shares: what kind it is, the issues it waits on, and the pull requests it left behind. The record only saves work; whether it wakes is always read back from GitHub.

func (PausedWork) ManualReason

func (p PausedWork) ManualReason() string

ManualReason is what a manual pause waits on: its own reason, or the owner having paused it.

type ProjectStateSource

type ProjectStateSource interface {
	ProjectState(context.Context, string) (string, error)
}

ProjectStateSource returns a cheap fingerprint of a project board's dispatchable state. GitHub publishes no projects_v2 webhook for user-owned Projects, so board-only edits (dragging an issue onto the board, moving a card into the ready column) produce no delivery at all. Push mode probes this fingerprint on a short interval and only pays for a full poll when it actually changes, instead of waiting out the fallback interval.

type PullRequestWorkState

type PullRequestWorkState struct {
	// Repository is the OWNER/REPO hosting the pull request. It differs from
	// the issue's repository when the fix was opened elsewhere, such as from
	// a fork, and is empty when unknown.
	Repository string
	Number     int
	State      string
	Merged     bool
	// MergedAt is when the pull request merged, zero while it has not.
	MergedAt time.Time
	// Additions and Deletions are the lines the pull request's diff adds and
	// removes, as GitHub reports them.
	Additions int
	Deletions int
	// IsDraft reports whether the pull request is still a draft. A run that
	// finishes with an open, unmerged, non-draft pull request left behind has
	// deliberately marked its fix ready and is waiting on a human rather than
	// stalled.
	IsDraft bool
	// Stacked reports whether the pull request targets a branch other than
	// its repository's default branch, which is how a pull request stacked on
	// an open blocker's branch looks until that blocker merges. A ready one
	// is paused waiting on its base rather than held for a human.
	Stacked bool
	// TasksDone and TasksTotal count the checked and all task-list items in
	// the pull request's body, the run's plan checklist.
	TasksDone  int
	TasksTotal int
	// HeadSHA is the pull request's head commit, and Comments counts its
	// conversation and review comments, so a turn that pushed or commented
	// counts as progress.
	HeadSHA  string
	Comments int
	// MergeCommitSHA is the commit a merged pull request left on its base
	// branch, empty while it has not merged.
	MergeCommitSHA string
}

PullRequestWorkState is one pull request linked to an issue an agent is working, and how far along it is.

func CurrentPullRequest

func CurrentPullRequest(state OriginatingWorkState) (PullRequestWorkState, bool)

CurrentPullRequest returns the pull request an issue's work is on now: the newest open one, or else the newest merged one. A pull request closed without merging was rejected or superseded, so it is never current, and a newer pull request replaces an older one.

func (PullRequestWorkState) InRepo

func (p PullRequestWorkState) InRepo(repo string) bool

InRepo reports whether the pull request lives in repo, treating an unrecorded repository as the issue's own.

func (PullRequestWorkState) RepoOr

func (p PullRequestWorkState) RepoOr(fallback string) string

RepoOr returns the repository hosting the pull request, or fallback (the issue's repository) when it was not recorded.

type ReviewCommentLister

type ReviewCommentLister interface {
	ListReviewComments(ctx context.Context, repo string, number int) ([]Comment, error)
}

ReviewCommentLister lists the inline review comments and submitted review bodies on a pull request, oldest first, so a run in progress hears a mention posted in a review of the pull request it opened.

type ReviewReactor

type ReviewReactor interface {
	AddReviewCommentReaction(ctx context.Context, repo string, commentID int64, content string) error
	AddReviewReaction(ctx context.Context, repo string, nodeID string, content string) error
}

ReviewReactor reacts to pull request review comments and review bodies, which the issue comment reaction endpoint does not reach. A review body has no REST reaction endpoint, so it is named by its GraphQL node ID.

type SettingsSnapshot

type SettingsSnapshot struct {
	Concurrency       int      `json:"concurrency"`
	ReadyState        string   `json:"readyState"`
	ReadyStateDefault string   `json:"readyStateDefault"`
	AllowedCommenters []string `json:"allowedCommenters"`
	NoMerge           bool     `json:"noMerge"`
	NoChangelog       bool     `json:"noChangelog"`
	// AutoUpdate reports whether updates restart aviary even while agents
	// are busy.
	AutoUpdate bool `json:"autoUpdate"`
	// TempDirs is the configured, ordered temp directories, empty for the
	// system temp directory, and TempDirDefault is that system directory
	//.
	TempDirs       []string `json:"tempDirs"`
	TempDirDefault string   `json:"tempDirDefault"`
	// Agents lists every CLI provider the run's registry defines, built-in
	// and config-defined alike; the in-process aviary backend is not one.
	Agents []string `json:"agents"`
	// AgentOptions carries the same agents with their model and level
	// allow-lists, for a selector that offers more than a bare name.
	AgentOptions []AgentOption `json:"agentOptions,omitempty"`
	// ConfiguredAgents lists the agent specs this run dispatches with, as
	// the Aviary agents its projects are attached to resolve them.
	ConfiguredAgents []string `json:"configuredAgents"`
	// UnblockInterval, UnblockAgent, and UnblockModel are the stuck-job
	// watchdog's settings, and UnblockDefault is the agent spec
	// its unblock call uses when no agent or model override is set.
	UnblockInterval string `json:"unblockInterval"`
	UnblockAgent    string `json:"unblockAgent"`
	UnblockModel    string `json:"unblockModel"`
	UnblockDefault  string `json:"unblockDefault"`
}

SettingsSnapshot reports the settings a running aviary instance can change on the fly, and their current values.

type SettingsUpdate

type SettingsUpdate struct {
	Concurrency       *int      `json:"concurrency,omitempty"`
	ReadyState        *string   `json:"readyState,omitempty"`
	AllowedCommenters *[]string `json:"allowedCommenters,omitempty"`
	NoMerge           *bool     `json:"noMerge,omitempty"`
	NoChangelog       *bool     `json:"noChangelog,omitempty"`
	// AutoUpdate chooses whether the updater restarts onto a new release
	// while agents are busy; off waits until none are active.
	AutoUpdate *bool `json:"autoUpdate,omitempty"`
	// TempDirs replaces the ordered temp directories new clones are placed in
	//. An empty list means the system temp directory.
	TempDirs *[]string `json:"tempDirs,omitempty"`
	// UnblockInterval is how often the stuck-job watchdog runs, as a
	// duration such as "5m", or "0" to turn it off.
	UnblockInterval *string `json:"unblockInterval,omitempty"`
	// UnblockAgent and UnblockModel override the agent and model of the
	// watchdog's unblock call. Empty means the coding agent and its model.
	UnblockAgent *string `json:"unblockAgent,omitempty"`
	UnblockModel *string `json:"unblockModel,omitempty"`
}

SettingsUpdate carries a partial update to aviary's live-editable runtime settings. Nil fields are left unchanged.

type Snapshot

type Snapshot struct {
	// Identity is this dispatcher instance's own handoff ID. The
	// dashboards show it as the leftmost status segment so an operator
	// watching several running instances can tell which one they are looking
	// at without cross-referencing a terminal title or log line.
	Identity    string
	Targets     []string
	IssueCounts map[string]int
	Running     int
	Queued      int
	Completed   int
	// Merged24h counts the pull requests of this run's jobs that merged in
	// the last 24 hours.
	Merged24h int
	Failed    int
	// Paused counts work out of the queue waiting on a GitHub merge or close,
	// holding no agent slot.
	Paused      int
	Concurrency int
	// AllowedCommenters are the GitHub logins whose comments steer jobs, as
	// the run applies them: the authenticated gh user when none are
	// configured.
	AllowedCommenters []string
	NextPoll          time.Time
	// LastPoll is when the most recent poll of GitHub finished. The poll loop
	// only logs what it found when that changes, so this is the
	// run's standing evidence that it is still checking.
	LastPoll      time.Time
	Interval      time.Duration
	UseWebhooks   bool
	WebhookURL    string
	WebhookOnline bool
	// WebUIURL is the local browser dashboard address when it is enabled.
	// The terminal dashboard shows it as a persistent bottom line so operators
	// can open the companion interface without searching the startup logs.
	WebUIURL   string
	TokensUsed int
	TokenLimit int
	Quota      string
	Quotas     map[string]string
	// Jobs holds every in-flight job. The terminal dashboard draws just the
	// first VisibleJobs; the web dashboard pages through all of
	// them VisibleJobs at a time, and /api/state publishes the Log only for
	// the jobs on the requested page.
	Jobs        []JobSnapshot
	VisibleJobs int
	// GitHub is the browser-delivery GitHub session, which the board shows as
	// a signed-out banner. It is zero outside browser delivery.
	GitHub GitHubSession
	// RateLimit is the GitHub REST budget as the token's last response
	// reported it, which the boards show as a banner while it is spent
	// (issue #1693).
	RateLimit GitHubRateLimit
}

Snapshot is the whole run as the dashboards draw it. The terminal dashboard in the root package and the browser dashboard in package webui both render it, so it lives here rather than in either of them.

type StackSource

type StackSource interface {
	StacksEnabled(context.Context, string) (bool, error)
}

StackSource reports whether a repository has GitHub stacked pull requests enabled, so an issue blocked by an open issue can be built on the blocker's branch instead of waiting for it to close.

type Target

type Target struct {
	Repo, Owner, ProjectID string
	ProjectOwnerType       string
	IsProject              bool
	IsDiscussion           bool
	// DiscussionCategory is the slug of the single Discussions category a
	// discussion target watches. Empty means every category.
	DiscussionCategory string
}

Target is a parsed watch target: an OWNER/REPO repository, a Projects (v2) board, or a repository's Discussions.

func ParseTarget

func ParseTarget(value string) (Target, error)

ParseTarget reads a watch target written as OWNER/REPO or as a GitHub repository, project, or discussions URL.

type UIReporter

type UIReporter interface {
	Snapshot(Snapshot)
	Log(string)
}

UIReporter receives the published state of a run.

type WorkClosureChecker

type WorkClosureChecker interface {
	OriginatingWorkState(context.Context, string, int) (OriginatingWorkState, error)
}

WorkClosureChecker reports the current state of the issue behind active work.

Jump to

Keyboard shortcuts

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