Help us shape the future of Go! Take the 2026 Go Developer Survey

failures

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package failures owns the append-only failure registry (SPEC §4.1): a JSON array of failure notes under a repository path, distilled into lessons (§11). From §19.2 it also backs the lesson-candidate list — findings the critic raised that no artifact confirmed, kept to detect a recurring class. Load and Append are the thin I/O shell; a missing file reads as empty. Writes are atomic.

Index

Constants

View Source
const (
	// RegistryFile is the confirmed failure registry (§4.1): a deterministic check
	// that a critic finding named actually failed.
	RegistryFile = ".adh/failures.json"
	// CandidatesFile is the §11 lesson-candidate list (§19.2): a critic finding no
	// artifact confirmed, recorded so a class can be promoted once it recurs.
	CandidatesFile = ".adh/lesson-candidates.json"
	// RecordsFile is the stamped failure-record log (§19.2): one record per disposed
	// finding carrying its stratum, the arc's routing scope, and its root cause — the
	// evidence the §11 temporal gate, scope-tagging, and root-cause triage read.
	RecordsFile = ".adh/failure-records.json"
)
View Source
const (
	RootUngrounded   = "ungrounded"    // failed with no routed context — fix routing
	RootGroundedMiss = "grounded-miss" // failed despite routed context — fix content
)

Root-cause categories (§19.2 triage) — derived deterministically from the arc's grounding at failure time, so a human reading the log sees whether to fix routing or fix the routed content.

Variables

This section is empty.

Functions

func Append

func Append(path string, notes ...string) error

Append adds notes to the registry at path, creating it and its directory if absent, and rewrites the file atomically. Appending nothing is a no-op, so it never creates an empty registry.

func AppendRecords

func AppendRecords(path string, recs ...Record) error

AppendRecords adds records to the log at path, creating it and its directory if absent, and rewrites the file atomically. Appending nothing is a no-op, so it never creates an empty log.

func ClassifyRootCause

func ClassifyRootCause(grounded bool) string

ClassifyRootCause triages a failed attempt by whether it was grounded — whether any context was routed to it (§19.2). A grounded miss points at the content; an ungrounded one points at routing.

func Load

func Load(path string) ([]string, error)

Load reads the note list at path. A missing file is empty, not an error; a malformed one is EINVALID.

func RootCauseCounts

func RootCauseCounts(recs []Record, class string) map[string]int

RootCauseCounts tallies a class's records by root cause (§19.2 triage), so a human deciding whether to promote sees whether the class is a routing or a content problem. Pure.

func ScopeFor

func ScopeFor(recs []Record, class string) (labels, paths []string)

ScopeFor returns the distinct labels and paths a class recurred under, sorted — the routing scope a promoted lesson should carry so it routes to where it was learned, not globally (§19.2 scope-tagging). Pure.

func StrataCount

func StrataCount(recs []Record) map[string]int

StrataCount maps each class to the number of distinct time strata it recurred across (§11 temporal gate). Records with no stratum contribute nothing. Pure.

Types

type Record

type Record struct {
	Class     string   `json:"class"`
	Stratum   string   `json:"stratum,omitempty"`
	Labels    []string `json:"labels,omitempty"`
	Paths     []string `json:"paths,omitempty"`
	RootCause string   `json:"root_cause,omitempty"`
}

Record is one disposed critic finding, stamped so accretion can gate on it (§19.2): Class is the finding kind it grouped under, Stratum the year-month it occurred in (the §11 temporal gate), Labels/Paths the arc's routing scope (so a promoted lesson routes to where it was learned), and RootCause the deterministic triage of the attempt's grounding.

func LoadRecords

func LoadRecords(path string) ([]Record, error)

LoadRecords reads the stamped failure-record log at path. A missing file is empty, not an error; a malformed one is EINVALID.

Jump to

Keyboard shortcuts

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