drainrule

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 12 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 drainrule reads the drained repository's own record of which open issues an unattended drain may take alone (itd-82 decision 4; the product thinker's rulings BX2 and H11 of 2026-09-29).

BX2, verbatim: "the PROJECT MUST HOLD the eligibility decision in its own record (e.g. added at setup); drain refuses there until it does." H11, verbatim: "MAY LOOSEN abcd's floors (a project may let drain take major/critical and security issues). NOTE for the lane: make a loosened floor loud (drain --dry-run and the drain start name every floor the project loosened), and keep abcd's own repository at the stricter default."

The record is an accepted decision record in the repository's own store (.abcd/development/decisions/adrs/) whose frontmatter carries four fields:

drain_categories: [tech-debt, documentation, inconsistency, drift, bug, ux]
drain_severities: [nitpick, minor]
drain_security: handback
drain_remedy: required

The baseline is abcd's strict rule, bundled here; a record is measured against it, and every floor it loosens is named in Rule.Loosened. A record may narrow the fixable set and the severities, may widen the severities to major and critical, and may take security issues. It may not widen the categories past the fixable set (the other categories are decisions by kind), and it may not drop the remedy: the remedy is the brief a lane works from. Anything else it says, or fails to say, refuses: a partial or malformed record never falls back to a looser rule, or to a stricter one in silence.

The package is a leaf over the frontmatter scanner and the issue schema, so the capture package (which applies the rule) and the setup offer (which writes the baseline as a record) both read the one definition.

Index

Constants

View Source
const (
	FieldCategories = "drain_categories"
	FieldSeverities = "drain_severities"
	FieldSecurity   = "drain_security"
	FieldRemedy     = "drain_remedy"
)

The record's four fields.

View Source
const (
	// SecurityHandBack: a security issue is always a person's (the baseline).
	SecurityHandBack = "handback"
	// SecurityTake: a drain may take a security issue that passes every other
	// rule, a loosened floor (H11).
	SecurityTake = "take"
	// RemedyRequired: a drain takes no issue without a remedy. It is the only
	// value: the remedy is the brief the issue-keyed lane works from
	// (itd-2609201916151817 decision 10), so a project cannot drop it.
	RemedyRequired = "required"
)

The values drain_security and drain_remedy take.

View Source
const ADRsRelDir = ".abcd/development/decisions/adrs"

ADRsRelDir is the decision store the rule is read from, repo-relative and slash-separated. A test pins it to core/decide's own constant.

View Source
const HowToAdd = "add it: run `abcd ahoy install` at a terminal and accept the drain rule it offers, " +
	"which writes abcd's strict baseline as an accepted decision record; or give an accepted decision record " +
	"in " + ADRsRelDir + "/ the four fields " + FieldCategories + ", " + FieldSeverities + ", " +
	FieldSecurity + " and " + FieldRemedy + " (mint one with `abcd decide \"<title>\"`)"

HowToAdd is the remedy every ErrUnrecorded refusal names.

View Source
const ProposalTitle = "A drain takes an issue alone only when its fields say it needs no decision"

ProposalTitle is the title the setup offer gives the record it writes.

View Source
const SecurityCategory = "security"

SecurityCategory is the issue category drain_security decides.

Variables

View Source
var (
	// ErrUnrecorded: the repository holds no accepted record of the rule.
	ErrUnrecorded = errors.New("this repository holds no drain eligibility record")
	// ErrMalformed: the record is partial, misspelt, or states a value the rule
	// does not take.
	ErrMalformed = errors.New("the drain eligibility record is malformed")
	// ErrAmbiguous: more than one accepted record states the rule.
	ErrAmbiguous = errors.New("more than one accepted record states the drain eligibility rule")
	// ErrUnreadable: the decision store, or a record in it, could not be read
	// safely: a link, a file past the size cap, or a read that failed.
	ErrUnreadable = errors.New("the decision store the drain eligibility rule is read from could not be read safely")
)

The refusals. Each is wrapped with the record and field it is about.

Functions

func ProposalBody

func ProposalBody() string

ProposalBody is the record's body below its title: the four sections every decision record carries, stating the baseline in words.

func ProposalFrontmatter

func ProposalFrontmatter() string

ProposalFrontmatter is the baseline as the four frontmatter lines a record carries, each ending in a newline.

Types

type Rule

type Rule struct {
	// Record is the decision record's id (adr-N); empty for the bundled
	// baseline, which is never applied as a repository's rule.
	Record string `json:"record"`
	// Path is the record's repo-relative, slash-separated path.
	Path string `json:"path"`
	// Categories are the categories a drain may take, in the order it takes
	// them; "security" is last when the record takes it.
	Categories []string `json:"categories"`
	// Severities are the severities a drain may take, in the order it takes
	// them (nitpick, minor, major, critical).
	Severities []string `json:"severities"`
	Security   string   `json:"security"`
	Remedy     string   `json:"remedy"`
	// Loosened names every floor the record loosens against abcd's baseline,
	// "severity major", "severity critical" and "security", in that order.
	// Always non-nil, so a JSON reader sees an empty list rather than none.
	Loosened []string `json:"loosened"`
}

Rule is one repository's drain eligibility rule, as its record states it.

func Baseline

func Baseline() Rule

Baseline is abcd's strict rule: the fixable set, nitpick and minor, security handed back, a remedy required. abcd's own repository states exactly this in adr-2609291342092738, and the setup offer writes it.

func Load

func Load(repoRoot string) (Rule, error)

Load reads the repository's drain eligibility rule from its decision store. It refuses, with ErrUnrecorded, a repository whose store holds no accepted record carrying the drain fields; with ErrAmbiguous, one holding two; and with ErrMalformed, a record that is partial, states a value the rule does not take, states any key twice, or claims an id its file name does not give it; and with ErrUnreadable, a store or record that cannot be read safely.

The store is read inside an os.Root at the checkout, and each record through the capped trust-boundary reader, so a store that is a symlink at all (or sits below one), wherever it points, a record that is a symlink at all, and a record past the size cap are refused, never followed or read whole: the rule is the drained tree's committed history at its own path, and a rule reached through a link is not it.

func (Rule) TakesCategory

func (r Rule) TakesCategory(c string) bool

TakesCategory reports whether the rule lets a drain take category c.

func (Rule) TakesSeverity

func (r Rule) TakesSeverity(s string) bool

TakesSeverity reports whether the rule lets a drain take severity s.

Jump to

Keyboard shortcuts

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