currentstate

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package currentstate validates parsed ADR application authority and topics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Message string
}

Finding is one current-state claim-handshake violation. It carries no rank: every provenance and transition violation is structural and blocking, so a rank field would have exactly one representable useful value (ADR-0183 item 5).

func Check

func Check(records []adr.ADR, corpusTopics []topic.Topic) []Finding

Check validates retired-segment absence, operation history, forward results, and inverse provenance. Parsed record formats identify the legacy bootstrap.

func CheckPair

func CheckPair(before, after Universe, mode TransitionMode) []Finding

CheckPair validates the current-state transition from the before universe to the after universe (ADR-0135): every current-state-v1 ADR status change across the pair is a legal lifecycle edge, and the claim add/update/remove mutations between the two topic corpora correspond exactly to the operations of the ADRs that reached Implemented across the pair. An update must preserve the claim Origin, grow its Revised-by to the duplicate-free union of the prior list and the updating ADRs (ADR-0191), and change a canonical field that is neither provenance nor formatting; a claim mutation with no matching operation and an operation with no matching mutation are both rejected, while a dominated update whose claim an applied remove already absorbed expects no mutation. It also runs the full after-state static Check, so a legal transition still lands in a valid state. Parsed record formats identify the closed migration bootstrap. Findings are returned sorted by message. The mode selects the per-step or aggregate contract; see TransitionMode.

type Introduction added in v0.30.0

type Introduction struct {
	Identity string
	Format   adr.Format
}

Introduction identifies an ADR that exists only in the result universe and carries a format older than the current authoring format.

func OlderIntroductions added in v0.30.0

func OlderIntroductions(before, after Universe, current adr.Format) []Introduction

OlderIntroductions returns provisional older-format ADR introductions in identity order. It consumes the same pairing resolution as CheckPair so a retained record, numbered pending record, or sanctioned slugless renumber is never misclassified as a new result record.

type Loaded

type Loaded struct {
	ADRs []adr.ADR
	// Sources owns the parsed ADR bytes keyed by identity for operation-local
	// qualification against merge-parent evidence.
	Sources map[string][]byte
	// Corpus is the identity-indexed view over ADRs, built and validated once
	// here. Consumers take it rather than rebuilding one, so the corpus-wide
	// duplicate-identity refusal (ADR-0202 item 4) has a single evaluation point
	// per load instead of one per consumer.
	Corpus adr.Corpus
	Topics topic.Corpus
}

Loaded is one immutable current-state view: the intrinsically routed ADR records and the topic corpus assembled from the same snapshot. A caller runs Check over the records and topics and EvaluateCoverage over the topic corpus, so both the static handshake and coverage read a single consistent universe.

func LoadFromTree

func LoadFromTree(tree *snapshot.Tree, cfg *config.Config) (Loaded, error)

LoadFromTree assembles the ADR and topic corpora from a single snapshot Tree, so a working-tree, index, or commit universe yields exactly the current-state view that tree encodes (ADR-0135). cfg supplies the docs directory, configured domains, and marker-source families; parse it from the same tree for a single-universe load. It does not run Check or EvaluateCoverage; the command layer applies eligibility filters and routes findings.

func (Loaded) Universe

func (l Loaded) Universe() Universe

Universe reduces a Loaded view to the before/after inputs CheckPair compares.

type Qualification added in v0.30.0

type Qualification struct {
	Introduction Introduction
	Qualified    bool
}

Qualification reports whether one older-format introduction is carried by an incoming parent with only sanctioned integration substitutions.

func QualifyIncoming added in v0.30.0

func QualifyIncoming(first, result Universe, incoming []Universe, current adr.Format) []Qualification

QualifyIncoming qualifies every provisional result introduction against all incoming parents and returns results in identity order.

type TransitionMode added in v0.30.0

type TransitionMode int

TransitionMode selects which contract CheckPair applies to a pair.

const (
	// AuthoredCommit requires every operation occurrence to be independently
	// observable in the before/after pair, so one claim may be targeted only
	// once. Distinct-target batches and legal ordered Status history are not
	// otherwise capped.
	AuthoredCommit TransitionMode = iota
	// MergeAggregate permits a claim's ordered operation chain to be folded to
	// its net effect because recorded merge provenance preserves the authored
	// transactions that made each occurrence observable (ADR-0182).
	MergeAggregate
)

type Universe

type Universe struct {
	ADRs    []adr.ADR
	Topics  []topic.Topic
	Sources map[string][]byte
}

Universe is one parsed current-state view reduced to the two inputs the transition check compares: the intrinsically formatted ADR records and the topic set. It is the loader-agnostic shape the working, index, and commit loaders each collapse to, mirroring Check's parsed-input contract so CheckPair reads a Git diff without knowing how either side was loaded. Loaded.Universe builds one.

func LoadUniverseFromSelection added in v0.30.0

func LoadUniverseFromSelection(selection *snapshot.Selection, cfg *config.Config) (Universe, error)

LoadUniverseFromSelection assembles historical policy authority from a sparse selection. It does not materialize that selection as a Tree.

Jump to

Keyboard shortcuts

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