prrow

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 34 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 (
	ViewPlan    = "plan"
	ViewDash    = "dash"
	ViewExplore = "explore"
	ViewRecent  = "recent"
)

View ids the GitHub plugin serves besides api's core ids.

View Source
const (
	FacetRepo    = "repo"
	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.

View Source
const SourceSession = "session"

SourceSession is the intake source of a request a managed session asked.

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 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 FacetSpecs

func FacetSpecs() []api.FacetSpec

FacetSpecs are the served facets of Facets.

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 LapsedMutes

func LapsedMutes(k readmodel.Kept) []dinv.Override

LapsedMutes are the stored overrides whose "mute until state change" lapsed: the rows of k show them unmuted.

func MuteLapsed

func MuteLapsed(pr dinv.PR, o dinv.Override, kind situation.Kind) bool

MuteLapsed tells whether o's "mute until state change" lapsed: the pull request is open and its situation, kind, is no longer the muted one. The row then shows no mute, and the read model's keeper clears the stored one.

func NeedsMe

func NeedsMe(r api.Row) bool

NeedsMe is the exact needs-me predicate of Deriver.views, evaluated on UnmutedKind and UnmutedWaitingOn when the row is muted; views adds needs-me 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, now time.Time) string

NudgeRefusal is the text a nudge is refused with now, "" when it would go.

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 SituationSpecs

func SituationSpecs() []api.SituationSpec

SituationSpecs are the served situations of Situations.

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 ViewSpecs

func ViewSpecs() []api.ViewSpec

ViewSpecs are the served views of Views.

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 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 Deriver

type Deriver struct {
	Viewer  string
	Teams   []string
	Ignore  []string
	Now     time.Time
	Stalled config.Stalled
	Pending map[unit.Unit]round.Pending
	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
}

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, o dinv.Override, 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(pr dinv.PR, 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.

func (Deriver) Row

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

Row derives the row of a pull request of the inventory.

func (Deriver) Seal

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

Seal fills the row's summary line and facets 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) Item

func (c NoticeCase) Item() string

Item is the id prefix of the derived item whose entry carries the case's notification; "" for a question, which the turn's Inbox message carries.

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 override's mute; 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 Provider

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

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

func New

func New(src Source) *Provider

New is the provider over src.

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) Facets

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

Facets are today's cockpit fields, in its order, plus the time facet due that the is flag "due" reads, then the brief intent's enum extras.

func (*Provider) Listed

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

Listed lists every pull request of the inventory 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) OffersActions added in v0.2.0

func (p *Provider) OffersActions() bool

OffersActions says the deriver offers the whole catalog on its rows.

func (*Provider) Provider

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

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) Views

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

Views are today's cockpit views, in its order.

type Source

type Source struct {
	readmodel.RowDeps
	Store  Store
	Briefs Briefs
}

Source is where the provider reads rows from: the daemon's RowDeps, the inventory and the brief queue. Briefs may be nil: the brief off.

type Store

type Store interface {
	PRsWithOverrides(ctx context.Context) ([]dinv.PR, 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 inventory.

type TurnFact

type TurnFact struct {
	Facts situation.TurnFacts
	// 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
}

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

Jump to

Keyboard shortcuts

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