checklist

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 19 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 checklist is a working copy's checklist on disk: the list of what a session is working on, what it waits on and what it has promised, kept in the local tier so it survives compaction and crashes (itd-2610170638184486, spc-2610230805429429 step 1). This file holds the v1 schema, its strict decode and its validation; store.go holds the checked write and the falling-back read.

The file is JSON with typed fields rather than prose, so it can be validated and scanned for secrets field by field (the spec's "Settled here"). A credential is recorded only by its kind, scope and expiry, each from a closed vocabulary or a timestamp, never as free text (adr-2610222026265719, brief invariant 24).

No refusal in this package repeats the value it refused. A value that fails the schema is untrusted, and a secret pasted into the wrong field is exactly what the schema would see first; naming the field and the rule is enough to find it.

Index

Constants

View Source
const (
	FileRelPath     = TierRelPath + "/checklist.json"
	LastGoodRelPath = TierRelPath + "/checklist.last-good.json"
)

FileRelPath is the checklist, one per working copy (dcn-2610180913444971), and LastGoodRelPath the copy only a checked write produces (spc-2610230805429429, "The write").

View Source
const LockRelPath = TierRelPath + "/checklist.lock"

LockRelPath is the lock every read-change-write of the checklist holds.

View Source
const MaxTitleRunes = 200

MaxTitleRunes caps an item's title, in characters (the spec's "The file").

View Source
const NoExpiry = "none"

NoExpiry is the expiry of a credential that does not expire: the ADR's "or that it has none", spelt as a word rather than an absent field so a forgotten expiry is a refusal, not a silent "never".

View Source
const Schema = "abcd/checklist/v1"

Schema is the v1 schema's name, carried in every file's `schema` field. A reader meeting any other value refuses the file rather than guessing at it.

View Source
const TierRelPath = ".abcd/.work.local"

TierRelPath is the local tier the checklist lives in, repo-relative and slash-separated (an os.Root path). As for the mode store, its presence is the managed-only property: the writer requires it and never creates it.

Variables

View Source
var ErrLockHeld = errors.New("checklist: another writer holds the checklist's lock, or its lock file is not a plain file; nothing was written")

ErrLockHeld is Update's refusal when another writer held the checklist's lock past the wait, or the lock file is not a plain file: nothing was written.

View Source
var ErrNoLocalTier = errors.New("checklist: no local-ephemeral tier")

ErrNoLocalTier is the write's refusal when the checkout has no local tier.

View Source
var ErrNotKept = errors.New("checklist: the checklist file here does not keep the owner-only mode or the owner the reader requires, so the list cannot be kept in this working copy; remove checklist.json (or chmod it 600 as its owner) and add again, on a filesystem that keeps both")

ErrNotKept is the write's refusal when the checklist the reader would see is one it refuses for its mode or owner: a filesystem that does not keep the 0600 mode or the owner, or a file changed by something other than the verb. A write the next read refuses loses every item, so none is made.

View Source
var ErrScannerUnavailable = errors.New("checklist: the secret scanner is unavailable")

ErrScannerUnavailable is the refusal when the native secret scanner cannot be built or runs degraded. Both the write and the read fail closed on it: a file that could not be checked is never written, and never shown.

View Source
var ErrTracked = errors.New("checklist: git tracks the checklist in this checkout; untrack it with `git rm --cached` first")

ErrTracked is the write's refusal when git tracks a checklist file: a write would change the committed file, and the reader refuses a tracked file, so every item written would be lost to the next read.

Functions

func Render

func Render(res Result, budget int) string

Render is the checklist as the text a session's context is given, within budget bytes: the reader's reason first when it did not read checklist.json clean, then the open items (working, waiting), then the done and dropped ones, each group newest first, one line an item.

"Newest" is file order read backwards: an item carries no time of its own, and the verbs append each new item to the end of the list.

Over budget, the render keeps the reason and the newest open items, drops the rest from the end (the closed items before any open one), and ends with a line saying how many it left out and that `abcd checklist` shows them all. The budget is in bytes, which never undercounts a host that measures in characters. An empty list that does not fit renders as the reason alone. When not even the reason fits, the render is empty; a FromNothing result renders as the reason line alone.

Every field the reader passed is one line with no control character (Validate), so each prints as it stands.

func Update

func Update(repoRoot string, change func(Result) (Checklist, error)) error

Update is the one read-change-write cycle: it reads the checklist as Read does, hands the result to change, and writes what change returns through write, holding the checklist's lock across all three. Every writer that builds on what is there goes through it.

WHY a lock: a session's verb, its stop hook and sub-agents sharing the worktree write one checklist, and two unlocked cycles that read the same list each write back their own item over the other's, losing one; a lost item is the failure the checklist exists to prevent. The lock is fsutil's one inter-process primitive (iss-129), the one `abcd decide` and the memory store take, never a lock of this package's own.

func WriteForTest

func WriteForTest(repoRoot string, c Checklist) error

WriteForTest writes c as write does, for a test outside this package that needs a checklist on disk; production writes go through Update.

Types

type Checklist

type Checklist struct {
	Schema    string `json:"schema"`
	UpdatedAt string `json:"updated_at"`
	// UpdatedBy is the host's session id for the session that last wrote.
	UpdatedBy string `json:"updated_by"`
	Items     []Item `json:"items"`
}

Checklist is the v1 file. Timestamps are kept as RFC 3339 strings and parsed by Validate, not by the decoder: encoding/json's time error quotes the value it could not parse, and a refusal here never quotes a value.

func (Checklist) Validate

func (c Checklist) Validate() error

Validate checks every field against the v1 schema and answers the first offending one as a *FieldError, in file order.

type Credential

type Credential struct {
	Kind   CredentialKind    `json:"kind"`
	Scope  []CredentialScope `json:"scope"`
	Expiry string            `json:"expiry"`
}

Credential names a credential an item needs by its kind, scope and expiry only (adr-2610222026265719). There is deliberately no field for anything else, and the strict decode refuses one in the file.

type CredentialKind

type CredentialKind string

CredentialKind is what sort of credential an item needs. The list is the three adr-2610222026265719 names as examples; the ADR fixes that the list is closed, not its members, so a new kind is an edit here.

const (
	AppInstallationToken CredentialKind = "app-installation-token"
	ModelServiceKey      CredentialKind = "model-service-key"
	SigningKey           CredentialKind = "signing-key"
)

type CredentialScope

type CredentialScope string

CredentialScope is one thing a credential reaches. adr-2610222026265719 describes scope as "a repository and the acts allowed, a service" and requires a fixed list; it gives none, so this one is defined here: the acts an App installation token is granted on a repository, a model service, and signing. The repository itself is not recorded, because a fixed list cannot hold its name and the ADR allows no free text in a credential.

const (
	ScopeContentsRead  CredentialScope = "contents-read"
	ScopeContentsWrite CredentialScope = "contents-write"
	ScopePullRequests  CredentialScope = "pull-requests"
	ScopeIssues        CredentialScope = "issues"
	ScopeReleases      CredentialScope = "releases"
	ScopeWorkflows     CredentialScope = "workflows"
	ScopeModelService  CredentialScope = "model-service"
	ScopeSigning       CredentialScope = "signing"
)

type FieldError

type FieldError struct {
	Field   string
	Problem string
}

FieldError is a schema refusal. Field is the path to the offending field (`items[2].state`), Problem the rule it breaks; neither carries the value.

func (*FieldError) Error

func (e *FieldError) Error() string

type Item

type Item struct {
	// ID is a short stable slug the verbs address the item by.
	ID    string `json:"id"`
	Title string `json:"title"`
	State State  `json:"state"`
	// WaitsOn is a record id, `pr:<n>`, `person:<role>` or `slot:<kind>`.
	WaitsOn  string `json:"waits_on,omitempty"`
	NextLook string `json:"next_look,omitempty"`
	// Promise is a trigger and the act it promises; the remainder of the spec
	// types the trigger, and step 1 keeps both as one-line text.
	Promise *Promise `json:"promise,omitempty"`
	// OwnerRefs names the work the item is about: a record id (a reservation),
	// `pr:<n>` or `branch:<name>`.
	OwnerRefs  []string    `json:"owner_refs,omitempty"`
	Credential *Credential `json:"credential,omitempty"`
}

Item is one entry. WaitsOn, NextLook, Promise, OwnerRefs and Credential are optional.

type Promise

type Promise struct {
	Trigger string `json:"trigger"`
	Act     string `json:"act"`
}

Promise is an item's "when this happens, do that".

type Result

type Result struct {
	Checklist Checklist
	Source    Source
	Reason    string
}

Result is a Read's answer: the checklist (zero for FromNothing), the file it came from, and the reason as one sentence a render can print as it stands. The reason names files, fields and bundled pattern kinds, never a value.

WHY the reason is fixed text: the session-start hook injects it into every session's context, where nothing taken from the repository may go (iss-2608241115201044, cli.go's session-start notices). So no clause carries an error's text, which can quote the tracked .abcd/config/pii.json or name the checkout's absolute path, nor a pattern kind that file declared; each names a file abcd defines and a cause in abcd's own words.

func Read

func Read(repoRoot string) Result

Read reads the checklist under an already-resolved checkout root. The reader is the enforcement (the spec's "Settled here"): a file written past the verb, by a shell or an editor, reaches it unchecked, so it validates and scans FileRelPath, and on any failure validates and scans LastGoodRelPath, and on a second failure answers FromNothing. It never writes, so a read never promotes a file to last-good. A temp file a killed writer left is never read: only the two named paths are.

type SecretError

type SecretError struct {
	Field string
	Kind  string
}

SecretError is the write's refusal for a field the native scanner matched (adr-2610222026265719): the field's path and the pattern kind, never the match.

func (*SecretError) Error

func (e *SecretError) Error() string

type Source

type Source string

Source says which file a Read used.

const (
	// FromFile is the checklist itself.
	FromFile Source = "checklist"
	// FromLastGood is the last copy a checked write produced, used because the
	// checklist itself failed.
	FromLastGood Source = "last-good"
	// FromNothing means neither file passed; the result carries no checklist.
	FromNothing Source = "nothing"
)

type State

type State string

State is an item's state: one of the four the spec names.

const (
	Working State = "working"
	Waiting State = "waiting"
	Done    State = "done"
	Dropped State = "dropped"
)

func States

func States() []State

States returns the four states in the order they are documented: the one enumeration a refusal or a surface's completion reads.

Jump to

Keyboard shortcuts

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