prinventory

package
v0.164.10 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package prinventory owns the remote pull-request inventory. It is separate from worktree discovery: the latter describes local WB-managed checkouts, while this package describes every open PR visible to GitHub for an owner.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderMarkdown

func RenderMarkdown(report Report) string

RenderMarkdown renders a stable, reviewable snapshot. Rows are already sorted by Inventory; sorting again makes hand-built reports deterministic.

Types

type Check

type Check struct {
	Name       string `json:"name"`
	Status     string `json:"status,omitempty"`
	Conclusion string `json:"conclusion,omitempty"`
}

type Counts

type Counts struct {
	OwnersRequested int `json:"owners_requested"`
	OwnersCompleted int `json:"owners_completed"`
	OwnersFailed    int `json:"owners_failed"`
	PullRequests    int `json:"pull_requests"`
}

type Diagnostic

type Diagnostic struct {
	Owner    string `json:"owner,omitempty"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
}

type Filters

type Filters struct {
	State           string `json:"state"`
	IncludeArchived bool   `json:"include_archived"`
	CreatedBefore   string `json:"created_before,omitempty"`
}

Filters is recorded in every report so an operator can see the scope that was actually queried, rather than inferring it from the rows returned.

type Options

type Options struct {
	Owners          []Owner
	ExcludeArchived bool
	CreatedBefore   string
	Runner          Runner
	Now             func() time.Time
	Parallel        int
}

Options controls one immutable snapshot.

type Owner

type Owner struct {
	Login     string `json:"login"`
	Qualifier string `json:"qualifier"` // org or user
}

Owner identifies one GitHub search qualifier.

func (Owner) String

func (o Owner) String() string

type OwnerResult

type OwnerResult struct {
	Owner         Owner        `json:"owner"`
	Complete      bool         `json:"complete"`
	TotalReported int          `json:"total_reported"`
	Retrieved     int          `json:"retrieved"`
	PullRequests  int          `json:"pull_requests"`
	Diagnostics   []Diagnostic `json:"diagnostics,omitempty"`
}

type PullRequest

type PullRequest struct {
	ID               string    `json:"id,omitempty"`
	Repository       string    `json:"repository"`
	Number           int       `json:"number"`
	Title            string    `json:"title"`
	URL              string    `json:"url"`
	Author           string    `json:"author,omitempty"`
	Draft            bool      `json:"draft"`
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
	Mergeable        string    `json:"mergeable,omitempty"`
	MergeStateStatus string    `json:"merge_state_status,omitempty"`
	Conflict         bool      `json:"conflict"`
	Checks           []Check   `json:"checks,omitempty"`
}

type Report

type Report struct {
	SchemaVersion    int           `json:"schema_version"`
	SnapshotAt       time.Time     `json:"snapshot_at"`
	Complete         bool          `json:"complete"`
	Owners           []Owner       `json:"owners"`
	EffectiveFilters Filters       `json:"effective_filters"`
	Counts           Counts        `json:"counts"`
	PullRequests     []PullRequest `json:"pull_requests"`
	OwnerResults     []OwnerResult `json:"owner_results"`
	Diagnostics      []Diagnostic  `json:"diagnostics,omitempty"`
}

func Inventory

func Inventory(ctx context.Context, options Options) Report

Inventory queries each owner independently, allowing GitHub's owner-filter limit to be bypassed without changing the declared scope. Owner results are reconciled before deduplication so a partial owner can never look complete.

type Runner

type Runner interface {
	Run(context.Context, ...string) ([]byte, error)
}

Runner is the narrow GitHub command boundary. Tests can inject a deterministic runner while production uses gh, which keeps authentication and API details in the same boundary WB already uses elsewhere.

Jump to

Keyboard shortcuts

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