workgh

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package workgh reads GitHub issues, read-only, into nova-work's tree model (internal/workfile). It is the recut of the GitHub capture that nova-work carried before (its GraphQL page query, its mutation refusal, its page chain), widened to every field SPEC-WORK-V1 section 1.3 names and to every repository of an organization, with no field cut at a bound: a connection longer than one page is fetched to its end, never truncated.

Every call goes through one seam, Query, and is counted; the production Query runs `gh api graphql` and refuses any document that is not a query, so this package cannot write to GitHub.

Index

Constants

View Source
const MinPageSize = 5

MinPageSize is the smallest page a failed page is retried at.

Variables

View Source
var ErrBudget = errors.New("call budget spent")

ErrBudget is returned when the next call would pass the fetcher's budget.

Functions

func DefaultProgram

func DefaultProgram() string

DefaultProgram is the GitHub CLI the production Query runs when none is named.

func RefuseMutation

func RefuseMutation(doc string) error

RefuseMutation refuses a GraphQL document that is not a plain query.

Types

type Fetcher

type Fetcher struct {
	Q Query
	// PageSize is the issues asked for per page, 1 to 100. A page GitHub
	// fails to answer is asked again at half the size, down to MinPageSize.
	PageSize int
	// MaxCalls is the budget: the call past it is refused with ErrBudget.
	MaxCalls int
	// Log takes one line per retried page; nil is silent.
	Log io.Writer

	Calls     int
	Points    int
	Remaining int // GraphQL points left in the hour after the last call, -1 before any
}

Fetcher reads repositories and issues through Q, counting every call (Calls) and the GraphQL points GitHub charged for them (Points).

func (*Fetcher) Issues

func (f *Fetcher) Issues(ctx context.Context, meta RepoMeta) (workfile.Repo, error)

Issues reads every issue of the repository, open and closed, with its full contents, sorted by number. It refuses a fetch whose count disagrees with the count GitHub gave (the repository changed while it was read).

func (*Fetcher) Repo

func (f *Fetcher) Repo(ctx context.Context, name string) (RepoMeta, error)

Repo reads one repository's listing entry.

func (*Fetcher) Repos

func (f *Fetcher) Repos(ctx context.Context, org string) ([]RepoMeta, error)

Repos lists every repository of org, sorted by name, with its issue count.

type Query

type Query func(ctx context.Context, doc string, vars map[string]any) ([]byte, error)

Query runs one read-only GraphQL document with its variables and returns the raw response body.

func GhQuery

func GhQuery(program string) Query

GhQuery is the production Query: `<program> api graphql --input -` with the document and variables as the JSON body on stdin. It refuses a document that is not a plain query before anything runs.

func Replay

func Replay(dir string) (Query, error)

Replay is a Query over a recorded conversation: dir holds call-NN.json files, each {"vars": ..., "reply": ...}, answered in order. A call whose variables differ from the next record's, or a call past the last, is an error. It is the fixture seam of the tests; it reaches no network.

type RepoMeta

type RepoMeta struct {
	Name     string
	URL      string
	Archived bool
	Issues   int // GitHub's count of its issues, open and closed
}

RepoMeta is one repository as the organization lists it.

Jump to

Keyboard shortcuts

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