priorledger

package
v0.167.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: BSD-3-Clause Imports: 9 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 priorledger records the runs of priorart, so that the act priorart is meant to precede can ask whether it did.

priorart (#193) answers "has this already been done?" for whoever runs it. Nothing tied that answer to the act of filing: twice in two days (go-gitsafe/gitsafe#99, a duplicate of go-gitsafe/gitsafe#90 that go-gitsafe/gitsafe#96 was already implementing; then go-quake1/engine#88) priorart and `ghissue --new` ran in ONE shell command, so its verdict -- exit 1, "found" -- arrived after the issue existed. A check in the same command as the act it guards is a log, not a gate. ghissue now asks this ledger instead.

The ledger is append-only JSON lines under the user's cache directory, the directory 0700 and the file 0600: it names repositories and subjects, which are not secret, but nothing else on the machine needs to write it. It is bounded: past MaxBytes it keeps its most recent half.

Index

Constants

View Source
const (
	None  = 0 // read every surface, found nothing
	Found = 1 // found prior art
	Gap   = 2 // a surface could not be read, or the question could not be put
)

Verdicts, as priorart exits.

View Source
const MaxBytes = 1 << 20

MaxBytes bounds the ledger file.

Variables

View Source
var ErrNone = errors.New("no priorart run covers this repository")

ErrNone is returned by Latest when no run covers the repository in time.

View Source
var Path = func() (string, error) {
	dir, err := os.UserCacheDir()
	if err != nil {
		return "", err
	}
	return filepath.Join(dir, "fleettools", "priorart.jsonl"), nil
}

Path is the ledger file; tests point it elsewhere.

Functions

func Append

func Append(r Record) error

Append adds r to the ledger.

Types

type Record

type Record struct {
	Time    time.Time `json:"time"`
	Repos   []string  `json:"repos,omitempty"` // --repo owner/name, lower-cased
	Org     string    `json:"org,omitempty"`   // --org name, lower-cased
	Subject string    `json:"subject"`
	Verdict int       `json:"verdict"`
}

Record is one priorart run.

func Latest

func Latest(repo string, within time.Duration, now time.Time) (Record, error)

Latest returns the most recent run that covers repo and is no older than within, as of now.

func (Record) Covers

func (r Record) Covers(repo string) bool

Covers reports whether the run read repo (owner/name): named with --repo, or inside the --org it read.

Jump to

Keyboard shortcuts

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