decisions

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: 15 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 decisions owns the decision records' folder: one flat folder, `.abcd/work/decisions/`, holding one `dcn-<id>-<slug>.md` file per decision (adr-2610110925465593, itd-2609151138388536). A decision is a record like any other: its id comes from the adr-45 mint (internal/core/recordid), its slug is cut at recordid.MaxSlugLen, and recording one writes a new file and appends to nothing, so two branches that each record a decision merge with nothing to reconcile.

This file is the READ side: the folder's path, the parse of one record, and the listing of every record in id order. record.go is the WRITE side, Record, and the verb's listing (spc-2610110931381316, step 2). The package is transport-agnostic: it never writes to stdout and knows no front door.

A record is:

---
id: dcn-<yymmddHHMMSS><rrrr>
slug: <at most 40 characters>
date: <YYYY-MM-DD>
---
<YYYY-MM-DD> — <the decision, in the words it was recorded in>

The date is the id's stamp, never a second clock reading, and the body opens with it, as every entry of the retired single log did.

Index

Constants

View Source
const Family = "dcn"

Family is the decision records' id prefix. It is `dcn`, not `dec`: the lifeboat keys a line of a frozen decisions log as `dec-L<line>`, and the distinct prefix keeps the two apart (spc-2610110931381316, decision 16).

View Source
const FrozenLog = ".abcd/work/DECISIONS.md"

FrozenLog is a managed repository's frozen decision log, repo-relative and slash-separated: read-only history, never written.

RelDir is the decisions folder, repo-relative and slash-separated. It is recordid's constant, re-exported so a caller that reaches the folder through this package names it here.

View Source
const SharedTierRel = ".abcd/work"

SharedTierRel is the shared working tier the folder sits in. Record creates the folder inside it and never creates the tier itself: once `ahoy install` has laid the tier it is abcd's namespace, and outside one there is nothing to commit a decision to (spec decision 10).

Variables

View Source
var ErrNoSharedTier = errors.New("this repository has no shared working tier (" + SharedTierRel +
	"/), so a decision has nowhere to be committed; run `abcd ahoy install` to lay it, then record the decision again")

ErrNoSharedTier is Record's refusal when the repository has no shared tier.

View Source
var ErrNoSlug = errors.New("the decision's text has no letters or digits to name its file by")

ErrNoSlug is Record's refusal for a text with nothing slug-able in it: the slug becomes the filename, so a text that yields none cannot be filed.

View Source
var Required = []string{"id", "slug", "date"}

Required is the frontmatter every decision record carries. record-lint's dcn store declares the same list, and both refuse a record without one of them.

Functions

func List

func List(repoRoot string) ([]Decision, []Skipped, error)

List reads every decision record in repoRoot's folder and returns them in id order, oldest first: the id is the stamp, so id order is mint order. A folder that does not exist holds no decisions, and that is an empty list rather than an error, since a repository need not have recorded one.

The folder's README, any file that is not markdown and any subdirectory are not records (record-lint reports a subdirectory of the flat store). Every other entry that cannot be read as one — a link, a file whose name is outside the grammar, a record Parse refuses — comes back in the skipped list with its reason. A folder that is itself a link, or that cannot be read, is an error: reporting no decisions when the truth is "the folder could not be read" would hide every one of them.

func Names

func Names(text string, ids ...string) bool

Names reports whether text names any of ids as a whole word: an id that only starts a longer one (itd-10 inside itd-100) is not named. Empty ids are ignored.

func RequireSharedTier

func RequireSharedTier(root string) error

RequireSharedTier refuses a repository whose shared tier is absent, and one whose tier is not a real directory: a link there would carry the record out of the checkout. Record runs it first; a writer that must know before its own write whether a decision can land after it (ideate's verdict, whose pointer is a decision) runs it too, so the refusal comes before anything is written.

Types

type Decision

type Decision struct {
	// ID is the record's handle, `dcn-<digits>`.
	ID string `json:"id"`
	// Slug is the kebab-case slug its filename and frontmatter both carry.
	Slug string `json:"slug"`
	// Date is the ISO date the id's stamp carries.
	Date string `json:"date"`
	// Path is the record's file, repo-relative and slash-separated.
	Path string `json:"path"`
	// Text is the record's body as written, opening with its date, with the
	// blank lines around it trimmed.
	Text string `json:"text"`
}

Decision is one decision record as read from its file.

func Parse

func Parse(rel string, content []byte) (Decision, error)

Parse reads one decision record. rel is the file's repo-relative path; its base name must be the record's filename, `dcn-<id>-<slug>.md`, because the filename and the frontmatter state the id and the slug twice and must agree.

It refuses, naming the fault, a record that has no frontmatter, states a key twice, omits or blanks a required property, carries an id that is not the dcn grammar or a date its id's stamp does not carry, disagrees with its filename, or has a body that does not open with its date.

func Record

func Record(dir, text string) (Decision, error)

Record writes text as a new decision record in the repository dir sits in, and returns it as the reader would read it. On any refusal nothing is written.

It resolves the checkout root from dir and refuses outside a checkout, refuses a repository without the shared tier, and refuses a text with nothing slug-able in it. The text is collapsed to one line and passed through the canonical scanner, failing closed on a degraded one, because it becomes committed prose and, through the slug, a filename. The id comes from the adr-45 mint, the date from the id's stamp, and the file is created exclusively under the folder's mint lock, so no path but the record's own is touched.

type FrozenEntry

type FrozenEntry struct {
	// Line is the 1-based line the entry's bullet opens on, stable for an
	// unchanged file.
	Line int
	// Text is the entry, its bullet and continuation lines joined by newlines.
	Text string
}

FrozenEntry is one entry of a frozen log: a top-level list item and the indented lines that continue it, as written.

func FrozenEntries

func FrozenEntries(log string) []FrozenEntry

FrozenEntries splits a frozen log into its entries. An entry opens on a line starting `- ` and takes every following line that starts with a space or a tab; any other line ends it. The header and any prose between entries belong to no entry.

type Listing

type Listing struct {
	Decisions []Decision
	Skipped   []Skipped
	// Frozen is the frozen log's repo-relative path where one exists, and
	// empty otherwise.
	Frozen string
}

Listing is the folder read for the verb's bare form: every record newest first, the files the reader skipped, and whether a frozen log sits beside the folder.

func ReadListing

func ReadListing(dir string) (Listing, error)

ReadListing reads the listing for the repository dir sits in. It resolves the checkout root and refuses outside a checkout; it reads the folder and stats the frozen log, and writes nothing.

func (Listing) Entries

func (l Listing) Entries() []Decision

Entries is the listing's JSON form: every record, newest first, as {id, date, slug, path, text}. An empty folder is an empty array, never null.

func (Listing) Text

func (l Listing) Text() string

Text is the listing's human form: one block per record, the id and then the body, newest first; a line naming the frozen log as earlier history where one exists. A folder with no records says so and names how to record one.

type Skipped

type Skipped struct {
	Path   string `json:"path"`
	Reason string `json:"reason"`
}

Skipped is a file in the folder that List could not read as a record, and why. The reader validates before it reads, so a malformed record is skipped, and naming it here is what keeps the skip from being silent.

Jump to

Keyboard shortcuts

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