prrow

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: 37 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 prrow derives the row of a pull request from what the store, the gate and the turns say of it: the github provider of the read model.

Index

Constants

View Source
const (
	FacetWhere   = "where"
	FacetAuthor  = "author"
	FacetWait    = "wait"
	FacetWaitsOn = "waits-on"
	FacetKind    = "kind"
	FacetType    = "type"
	FacetRisk    = "risk"
	FacetSize    = "size"
	FacetStatus  = "status"
	FacetTag     = "tag"
	FacetIs      = "is"
	FacetCI      = "ci"
	FacetOpened  = "opened"
	FacetScope   = "scope"
	FacetAge     = "age"
	FacetLane    = "lane"
	FacetDue     = "due"
)

Facet ids of the GitHub rows.

View Source
const FacetExtra = "extra."

FacetExtra prefixes the facet of an enum field of the brief intent's extra: extra.<name>.

View Source
const NudgeMaintainers = "the maintainers (no reviewer requested)"

NudgeMaintainers is whom a nudge asks on the user's own pull request with no reviewer: the skill mentions nobody, or the one code owner.

View Source
const RenudgeAfter = 24 * time.Hour

RenudgeAfter is how long a wait that a nudge did not move stays nudged.

Variables

This section is empty.

Functions

func BookOf

func BookOf(in any) (turn.Book, bool)

BookOf is the turn book of the input's pull request, when it has one.

func BriefState added in v0.3.0

func BriefState(rec dinv.BriefRecord, found bool) intake.BriefState

BriefState is what an intake shows of the brief record rec, found false for none.

func BriefSummary

func BriefSummary(b brief.Summary) *api.BriefSummary

BriefSummary is the row's view of a brief.

func EventsOf

func EventsOf(in any) []dinv.Event

EventsOf are the events a row's input holds, oldest first; the caller must not change them.

func ExtraFacetSpecs added in v0.2.0

func ExtraFacetSpecs(reg *dintent.Registry) []api.FacetSpec

ExtraFacetSpecs are the facets of the brief intent's enum extras, their values in the schema's order.

func IgnoreOf

func IgnoreOf(cfg config.Config) []string

IgnoreOf is who a row never waits on and a nudge never mentions.

func InScope

func InScope(r api.Row) bool

InScope: the row has reasons, a review workspace, or is adopted or tracked.

func NeedsMe

func NeedsMe(r api.Row) bool

NeedsMe is the needs-me predicate of the row's situation, evaluated on UnmutedKind and UnmutedWaitingOn when the row is muted; the row's needs-me flag holds only when it holds and the row is not muted.

func NudgeRefusal

func NudgeRefusal(ref github.Ref, who []string, why string, since time.Time, evs []dinv.Event, unstarted map[string]bool, now time.Time) string

NudgeRefusal is the text a nudge is refused with now, "" when it would go; unstarted are the turns that ended before their agent started them, whose nudged events do not count.

func NudgeTargets

func NudgeTargets(r api.Row, author, viewer string, ignore []string) ([]string, string)

NudgeTargets is who a nudge mentions, or why it mentions nobody: r's kind, waits-on and reason, author its pull request's author.

func Override

func Override(o dinv.Override) api.Override

Override is the wire form of a stored override.

func PROf

func PROf(in any) (dinv.PR, bool)

PROf is the pull request a row's input derives from.

func Signals added in v0.3.0

func Signals(r api.Row) map[string]bool

Signals are the link signals of r, a GitHub row derived under the host's overlays: stalled, an open pull request in scope whose situation lasted past its threshold; in_loop, an open one a review workspace holds; ready, an open one whose work is approved and no host state overlays; workspace, one a workspace of which remains, open or not. None of another provider's row.

func SituationOf added in v0.3.0

func SituationOf(r Report, f *TurnFact, m overlay.Mute, evs []dinv.Event, now time.Time) (res, unmuted overlay.Situation)

SituationOf is the situation of the report at now under the host's overlays: the run that drives its row, then the user's mute m, whose time is its newest muted event among evs; unmuted is it without the mute.

func Situations

func Situations(k readmodel.Kept, at time.Time) []dinv.Situation

Situations are the followed open pull requests whose row's situation, "<kind>:<waiting-on>", differs from their newest situation event, seen at at. A pull request whose started turn's session could not be read is left for a later snapshot, so a failed read never records it as working.

func Started

func Started(facts map[github.Ref]TurnFact) bool

Started tells whether any fact is a started turn with a session.

func TurnFacts

func TurnFacts(books map[unit.Unit]turn.Book, reg *dintent.Registry) map[github.Ref]TurnFact

TurnFacts reads every book's driving turn, with the session of a started one; whether that session waits is resolved by Waiting.

func Unmuted

func Unmuted(in any) any

Unmuted is the input as it stands with no override at all.

func Unstarted added in v0.3.0

func Unstarted(b turn.Book) map[string]bool

Unstarted are the ids of b's turns that ended before their agent started them, which posted nothing.

func Waiting

func Waiting(facts map[github.Ref]TurnFact, agents []turns.AgentObservation, agentsOK bool, session func(handle string) (turn.Session, bool, error), logf func(string, ...any))

Waiting resolves each started turn against Orca's agents: session reads a session by handle. With agentsOK false every started turn is unread.

func Workspace

func Workspace(w dinv.Workspace) api.Workspace

Workspace is the wire form of a pull request's workspace.

Types

type Board added in v0.3.0

type Board struct {
	Carded          bool      `json:"carded,omitempty"`
	ReviewWorkspace bool      `json:"review_workspace,omitempty"`
	AuthorWorkspace bool      `json:"author_workspace,omitempty"`
	Checkout        *Checkout `json:"checkout,omitempty"`
}

Board is what the board reads of a pull request's workspaces: whether a workspace targets it, a review one or an author one free of an address round, and the author workspace an author card reads its checkout from.

type Briefs

type Briefs interface {
	Briefed(ctx context.Context) (map[github.Ref]brief.Summary, map[github.Ref]dinv.BriefRecord, error)
	// AttemptOf is the brief attempt a first turn of pr waits on.
	AttemptOf(pr dinv.PR, rec dinv.BriefRecord) int
}

Briefs reads the brief records with their summaries.

type Checkout added in v0.3.0

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

Checkout is a local workspace an author card reads.

type Deriver

type Deriver struct {
	Viewer  string
	Teams   []string
	Ignore  []string
	Now     time.Time
	Stalled config.Stalled
	// Plans are the automatic rounds the open plan gates hold, by unit.
	Plans map[unit.Unit]overlay.Pending
	// Mutes are the user's mutes of pull requests, their tasks' wakes.
	Mutes map[unit.Unit]overlay.Mute
	Turns map[github.Ref]TurnFact
	// What the actions read besides the row.
	Loaded          *intentload.Loaded
	Specs           []api.ActionSpec // nil: catalog.Specs(Loaded)
	Cfg             config.Config
	GateOn, BriefOn bool
	Forceable       func(unit.Unit) string
	Intakes         map[pr.Ref][]intake.Intake
	SpecsVersion    string
	// Asked is the action a request asks for, whose inputs an open intake
	// joins on; zero for a row served to a client.
	Asked catalog.Asked
	// Reasons are the plugin's words of the reasons its rows name, by key, which a notification says.
	Reasons map[string]string
}

Deriver derives rows at one instant from what every row shares.

func DeriverAt

func DeriverAt(base readmodel.Base, set readmodel.RowSettings, briefOn bool, at time.Time) Deriver

DeriverAt is the deriver of a request: base and the settings, at the minute at, with no turn and no intake of any pull request.

func (Deriver) AddActivity

func (d Deriver) AddActivity(p *Payload, a turn.Activity)

AddActivity puts the pull request's turns, usage and brief retry in the payload's facts.

func (Deriver) Attention

func (d Deriver) Attention(r api.Row, in any) *api.Attention

Attention is the notification of r, a row of needs-me derived from in, nil when it notifies nothing. A held round's id holds the day.

func (Deriver) FactsOf

func (d Deriver) FactsOf(pr dinv.PR, evs []dinv.Event, m overlay.Mute, r api.Row, p Payload, unmuted api.Row) catalog.Facts

FactsOf gathers the facts of a row of the inventory; unmuted is the situation without the user's mute, which a nudge reads.

func (Deriver) Notice

func (d Deriver) Notice(r api.Row, in any) (Notice, bool)

Notice is what r, a row of this provider derived from in, notifies at d.Now; ok is false when it notifies nothing.

func (Deriver) Parts

func (d Deriver) Parts(rep Report, evs []dinv.Event, o dinv.Override) (api.Row, Payload)

Parts derives a pull request's row and payload before Seal: a caller adds the brief, the intake and the activity in between. evs are the host's events of the pull request and o its overrides there.

func (Deriver) Row

func (d Deriver) Row(rep Report, evs []dinv.Event, o dinv.Override) api.Row

Row derives the row of a pull request the plugin reported.

func (Deriver) Seal

func (d Deriver) Seal(r api.Row, p Payload) api.Row

Seal fills the row's summary line, facets and search texts from p and encodes p as its payload.

func (Deriver) UntrackedRow

func (d Deriver) UntrackedRow(c dgh.Candidate, o dinv.Override) api.Row

UntrackedRow is the row of a pull request the inventory lacks, from a GitHub read: open from its state, mine from its author, nothing else.

type LastHuman

type LastHuman struct {
	Who  string    `json:"who"`
	What string    `json:"what"` // the event kind: opened, push, review, comment
	At   time.Time `json:"at"`
	Link string    `json:"link"`
}

type Mute

type Mute struct {
	Until            time.Time `json:"until,omitzero"`
	UntilStateChange bool      `json:"until_state_change,omitempty"`
}

type Notice

type Notice struct {
	Case NoticeCase
	// Token lasts as long as what is notified: the pending round's since,
	// the held day, the blocking reason, the question's record, the waiting
	// episode.
	Token string
	// Record is the question's turn record.
	Record    int64
	Attention api.Attention
}

Notice is what a needs-me row notifies; Attention carries no ID and no Category, which the caller keys.

type NoticeCase

type NoticeCase string

NoticeCase is what a needs-me row notifies of.

const (
	NoticeRound    NoticeCase = "round"
	NoticeHeld     NoticeCase = "held"
	NoticeBlocked  NoticeCase = "blocked"
	NoticeQuestion NoticeCase = "question"
	NoticeWait     NoticeCase = "wait"
)

func (NoticeCase) Gate added in v0.3.0

func (c NoticeCase) Gate() gate.Kind

Gate is the kind of the gate the case stands for: a plan gate holds a pending or held round, a trust gate a blocked one; "" for the others.

type Payload

type Payload struct {
	Author           string            `json:"author"`
	Repo             string            `json:"repo"`
	Head             string            `json:"head"`
	Approved         bool              `json:"approved"`
	Reasons          []string          `json:"reasons"`
	Workspace        api.Workspace     `json:"workspace"`
	Override         api.Override      `json:"override,omitzero"`
	Brief            *api.BriefSummary `json:"brief,omitempty"`
	Intake           *api.Intake       `json:"intake,omitempty"`
	Facts            *api.RowFacts     `json:"facts,omitempty"`
	Viewer           string            `json:"viewer"`                       // the deriver's viewer login
	UnmutedKind      string            `json:"unmuted_kind,omitempty"`       // the kind the row would have without its mute ("" when not muted)
	UnmutedWaitingOn string            `json:"unmuted_waiting_on,omitempty"` // the waiting-on the row would have without its mute
	UnmutedReason    string            `json:"unmuted_reason,omitempty"`     // the reason the row would have without its mute
	LastHuman        *LastHuman        `json:"last_human,omitempty"`         // newest human event on the PR not by the viewer; nil none
	Mute             *Mute             `json:"mute,omitempty"`               // the mute its task's wake holds; nil when not muted
	// contains filtered or unexported fields
}

Payload is the GitHub row's payload; JSON keys as today's Row, plus viewer, unmuted_kind, unmuted_waiting_on, last_human and mute.

func PayloadOf

func PayloadOf(r api.Row) (Payload, bool)

PayloadOf is false for another provider or no payload.

type Plan added in v0.3.0

type Plan struct {
	Rank  Rank  `json:"rank"`
	Board Board `json:"board"`
}

Plan is the planner's part of a report.

type Provider

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

Provider is the github provider of the read model: one row per pull request the GitHub plugin reported, but lapsed ones nobody adopted.

func New

func New(src Source) *Provider

New is the provider over src.

func (*Provider) Book added in v0.3.0

func (p *Provider) Book(in any) (turn.Book, bool)

Book is the turn book of the input's pull request, when it has one.

func (*Provider) CardSignals added in v0.4.0

func (p *Provider) CardSignals() []api.SignalSpec

CardSignals are the GitHub plugin's words of its cards' signals.

func (*Provider) Derive

func (p *Provider) Derive(base readmodel.Base, in any, at time.Time) (api.Row, error)

Derive is the row of one pull request at the minute at.

func (*Provider) Details added in v0.3.0

func (p *Provider) Details() []api.DetailSpec

Details are the words of the GitHub plugin's detail fields.

func (*Provider) Events added in v0.3.0

func (p *Provider) Events() []api.EventSpec

Events are the words of the GitHub plugin's event kinds.

func (*Provider) Facets

func (p *Provider) Facets() []api.FacetSpec

Facets are the GitHub plugin's facets, as its manifest declares them, then the brief intent's enum extras.

func (*Provider) Lens added in v0.4.0

func (p *Provider) Lens() api.ProviderWords

Lens are the GitHub plugin's own row words.

func (*Provider) Listed

func (p *Provider) Listed(ctx context.Context) ([]unit.Unit, error)

Listed lists every pull request the plugin reported but the lapsed ones nobody adopted, the most recently updated first.

func (*Provider) Load

func (p *Provider) Load(ctx context.Context, units []unit.Unit) (map[unit.Unit]any, error)

Load reads what the rows of units derive from, in one query per kind of input.

func (*Provider) Notice added in v0.3.0

func (p *Provider) Notice(base readmodel.Base, row api.Row, in any, at time.Time) (readmodel.Notice, bool)

Notice is what row, a row of this provider derived from in, notifies at the minute at.

func (*Provider) Provider

func (p *Provider) Provider() unit.ProviderID

func (*Provider) Reasons added in v0.4.0

func (p *Provider) Reasons() api.ProviderWords

Reasons are the GitHub plugin's words of the reasons its rows name.

func (*Provider) Signals added in v0.3.0

func (p *Provider) Signals(_ readmodel.Base, row api.Row, _ any, _ time.Time) map[string]bool

Signals are the link signals of row.

func (*Provider) Situations

func (p *Provider) Situations() []api.SituationSpec

Situations are the GitHub kinds with their labels, ranked as the cockpit orders them.

func (*Provider) Unmuted added in v0.3.0

func (p *Provider) Unmuted(in any) any

Unmuted is in as it stands with no override at all.

func (*Provider) Views

func (p *Provider) Views() []api.ViewSpec

Views are the GitHub plugin's views, as its manifest declares them.

type Rank added in v0.3.0

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

Rank orders units as the planner plans their rounds, lowest first.

func (Rank) Compare added in v0.3.0

func (a Rank) Compare(b Rank) int

Compare orders a before b.

type Report added in v0.3.0

type Report struct {
	PR        dinv.PR
	Situation src.Situation
	Payload   Payload
	Views     []string
	Facets    map[string][]string
	Card      *src.Card
	Items     []src.Item
	// Facts are the workflow facts that read the pull request alone, and
	// the planner's.
	Facts []src.Fact
	// Plan is the planner's rank of the pull request and what the board
	// reads of its workspaces.
	Plan Plan
}

Report is what the GitHub plugin last reported of a pull request, as its row reads it: the pull request, its situation from the source alone, and the source part of its payload, views and facets.

func ReportIn added in v0.3.0

func ReportIn(in any) (Report, bool)

ReportIn is the plugin's report a row's input derives from.

func ReportOf added in v0.3.0

func ReportOf(s src.Snapshot) (Report, bool, error)

ReportOf is the report snapshot s carries; false for a snapshot with no pull request.

type ReportedData added in v0.3.0

type ReportedData struct {
	PR            dinv.PR           `json:"pr"`
	Detail        *inventory.Detail `json:"detail"`
	DetailVersion int               `json:"detail_version"`
	DetailReadAt  time.Time         `json:"detail_read_at"`
	Tracked       bool              `json:"tracked"`
	Adopted       bool              `json:"adopted"`
}

ReportedData is the data of the GitHub plugin's snapshot of a pull request that the host reads: the pull request, its full read and its overrides.

type ReportedPRs added in v0.3.0

type ReportedPRs struct{ Reports readmodel.Reports }

ReportedPRs are the pull requests the GitHub plugin last reported, as the host reads them; the host keeps no copy of them.

func (ReportedPRs) Data added in v0.3.0

func (r ReportedPRs) Data(ctx context.Context, units []unit.Unit) (map[unit.Unit]ReportedData, error)

Data are the reported data of units, of every reported unit when nil; a unit with no pull request is absent.

func (ReportedPRs) Details added in v0.3.0

func (r ReportedPRs) Details(ctx context.Context, refs []pr.Ref) (map[pr.Ref]inventory.Detail, error)

Details are the full reads of refs as reported; a ref with none is absent.

func (ReportedPRs) List added in v0.3.0

func (r ReportedPRs) List(ctx context.Context, open bool) ([]dinv.PR, error)

List are every reported pull request, the open ones alone when open, the last updated first.

func (ReportedPRs) PR added in v0.3.0

func (r ReportedPRs) PR(ctx context.Context, ref pr.Ref) (dinv.PR, bool, error)

PR is ref as the plugin last reported it; false when it reported none.

func (ReportedPRs) PRs added in v0.3.0

func (r ReportedPRs) PRs(ctx context.Context, refs []pr.Ref) (map[pr.Ref]dinv.PR, error)

PRs are refs as the plugin last reported them; a ref it reported none of is absent.

type Source

type Source struct {
	readmodel.RowDeps
	Reports readmodel.Reports
	Store   Store
	Briefs  Briefs
	// Catalog is the plugin's views, facets and situations; nil serves
	// none.
	Catalog readmodel.Presenter
	// Mutes are the user's mutes of pull requests; nil mutes none.
	Mutes readmodel.Mutes
}

Source is where the provider reads rows from: the daemon's RowDeps, the GitHub plugin's reports, the host's state of pull requests and the brief queue. Briefs may be nil: the brief off.

type Store

type Store interface {
	Overrides(ctx context.Context) (map[github.Ref]dinv.Override, error)
	EventsByPR(ctx context.Context, refs []github.Ref) (map[github.Ref][]dinv.Event, error)
	BriefRecords(ctx context.Context, refs ...github.Ref) (map[github.Ref]dinv.BriefRecord, error)
}

Store is what the rows read of the host's own state of pull requests: their overrides, events and brief records.

type TurnFact

type TurnFact struct {
	Facts overlay.Turn
	// Session is the handle of a started turn's session, "" otherwise.
	Session  string
	Waiting  bool
	Unread   bool // the session of a started turn could not be read
	Question *api.QuestionView
	// Unstarted are the ids of the turns that ended before their agent
	// started them.
	Unstarted map[string]bool
}

TurnFact is what a row reads of its pull request's turn book.

Directories

Path Synopsis
Package ghreporttest derives the GitHub plugin's snapshot of a pull request the host's tests hold as inventory rows, with the plugin's own code, so a host test renders the rows the running plugin's reports render.
Package ghreporttest derives the GitHub plugin's snapshot of a pull request the host's tests hold as inventory rows, with the plugin's own code, so a host test renders the rows the running plugin's reports render.

Jump to

Keyboard shortcuts

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