workfile

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package workfile is nova-work's tree file: every issue of every repository of a source, with its full contents, as one restricted s-expression read by internal/worklang (docs/SPEC-WORK-V1.md section 1).

The package holds the model (Tree, Repo, Issue and what an issue carries), the canonical writer (Encode), the strict reader (Decode) and the field-for-field comparison (Diff). Encode then Decode is the identity on every Tree Encode accepts; Encode refuses a value it could not write back unchanged rather than writing it lossily. Nothing here reaches a network.

Index

Constants

View Source
const Format = "v1"

Format is the tree file's format word, the second element of the top form.

View Source
const Web = "https://github.com/"

Web is the source's web root every repository and issue URL starts with.

Variables

This section is empty.

Functions

func Encode

func Encode(t *Tree) ([]byte, error)

Encode writes the tree in its canonical form: repositories sorted by name, issues by number, labels and assignees sorted, every key of every record always written in one order, so one tree has exactly one file. It refuses what it could not read back unchanged: an enumeration outside [A-Z_], a repository or issue out of order or repeated, a number that is not positive. SPEC-WORK-V1 section 1.2 is the shape.

func IssueURL

func IssueURL(repo string, n int) string

IssueURL is the URL of issue n of repo (owner/name).

func Limits

func Limits(maxBytes int) worklang.Limits

Limits is the reader's bounds for a tree file of at most maxBytes: the depth of the shape (section 1.2) with room to spare, and at most one atom per byte, so the byte bound is the one that binds.

func OriginOf

func OriginOf(association string) string

OriginOf is the origin an author association gives: an issue filed by the owner, a member or a collaborator is internal, any other is external (SPEC-WORK-V1 section 1.4).

func Path

func Path(repo string, number int) string

Path is an issue's path in the tree: repos/<owner>/<repo>/issues/<n>.

func Show

func Show(s string) string

Show renders a value for a difference line: whole when it is short and one line, else its length and the head of its SHA-256, so a line never carries a body and two different values never render alike.

Types

type Comment

type Comment struct {
	ID                string
	URL               string
	Author            string
	AuthorAssociation string
	Created           string
	Updated           string
	Body              string
}

Comment is one comment on an issue.

type Counts

type Counts struct {
	Repos, Issues, Comments, References, LinkedPRs int
}

Counts is the size of a tree.

type Difference

type Difference struct {
	Kind  string // MISSING, EXTRA or DRIFT
	Path  string
	Field string
	Want  string
	Got   string
}

Difference is one way a tree and a fresh fetch disagree, at one path: MISSING is on the source and not in the tree, EXTRA is in the tree and not on the source, DRIFT is a field whose value differs. Want is the source's value and Got the tree's, each rendered by Show.

func Diff

func Diff(got, want *Tree, scope []string) []Difference

Diff compares the tree (got) with a fresh fetch (want), field for field, over the repositories named in scope (every repository of either when scope is empty). The result is sorted by path, then field; empty means the tree holds everything the source holds and nothing else.

func DiffIssue

func DiffIssue(repo string, g, w *Issue) []Difference

DiffIssue compares every field of one issue, its comments by id, and its references and linked pull requests as sets of records.

type Issue

type Issue struct {
	Number            int
	URL               string
	NodeID            string
	Title             string
	State             string
	StateReason       string
	Origin            string // internal or external (section 1.4)
	Author            string
	AuthorAssociation string
	Created           string
	Updated           string
	Closed            string
	Locked            bool
	LockReason        string
	Labels            []string // sorted
	Assignees         []string // sorted
	Milestone         *Milestone
	Body              string
	Comments          []Comment   // in creation order
	References        []Reference // cross-references to this issue, in timeline order
	LinkedPRs         []LinkedPR  // pull requests that close it, in GitHub's order
}

Issue is one issue with its full contents. Enumerations (State, StateReason, AuthorAssociation, a comment's association, a linked pull request's state) keep GitHub's spelling (OPEN, NOT_PLANNED); the file writes them as keywords (:open, :not-planned). An empty string is GitHub's null.

type LinkedPR

type LinkedPR struct {
	Repo   string
	Number int
	URL    string
	State  string
}

LinkedPR is a pull request that closes the issue when it merges.

type Milestone

type Milestone struct {
	Number int
	Title  string
}

Milestone is an issue's milestone.

type Reference

type Reference struct {
	Kind      string
	Repo      string
	Number    int
	URL       string
	Actor     string
	At        string
	WillClose bool
}

Reference is a cross-reference to the issue from an issue or a pull request: the source's kind (Issue or PullRequest), repository, number and URL, who made it and when, and whether the source will close the issue.

type Repo

type Repo struct {
	Name     string // owner/name
	URL      string
	Archived bool
	Issues   []Issue
}

Repo is one repository: owner/name, its URL, whether it is archived, and every issue it holds, sorted by number.

type Tree

type Tree struct {
	Source  string // "github"
	Org     string
	Fetched string // RFC 3339, UTC
	Repos   []Repo
}

Tree is the root: the source it was imported from, the organization, the time the fetch began, and every repository imported, sorted by name.

func Decode

func Decode(file string, data []byte, lim worklang.Limits) (*Tree, error)

Decode reads a tree file through internal/worklang (nothing is evaluated) and refuses, naming the path and the key, any record that is not exactly the shape Encode writes: a missing, repeated or unknown key, a value of the wrong kind, an issue whose URL is not the one its path gives. Every such problem of the file is named in the one error (SPEC-WORK-V1 section 1.2).

func (*Tree) Count

func (t *Tree) Count() Counts

Count counts a tree.

Jump to

Keyboard shortcuts

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