changelog

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 16 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 changelog is abcd's transport-agnostic release-derivation domain: the version and the changelog are facts derived from the records that shipped, not numbers and lines a human types (itd-73, spc-10).

This file holds the domain's smallest and most-shared piece — impact, the one-word product judgement a record carries. It lives here, not in internal/core/lint, because the lints that GATE the judgement and the derivation that CONSUMES it must agree on exactly one enum; two copies of it would drift the moment one side gained a member. Nothing here reads git, reads records, or does bump arithmetic: it is a pure value type plus its boundary validator, so both consumers can import it without inheriting a dependency.

Index

Constants

View Source
const MaxChangelogBytes = 4 << 20

MaxChangelogBytes caps the guarded CHANGELOG read. The file is a few hundred kilobytes of prose at most; the cap exists so a symlinked or replaced CHANGELOG.md cannot stream an unbounded file into a preview command. It is exported because the ship verb that WRITES the file reads it first, and one ceiling read two different ways is a ceiling that eventually disagrees.

Variables

View Source
var ErrUnreadableReleaseHeading = errors.New("the newest CHANGELOG release heading is not a dated vX.Y.Z heading")

ErrUnreadableReleaseHeading is returned by ReleasedVersionIn when the newest release heading is one the dated-heading reader does not parse.

Functions

func DeriveNext

func DeriveNext(prev launch.Semver, bump Impact) (launch.Semver, bool)

DeriveNext is the whole version policy in one pure function: given the previous release and the strongest impact in the cut, it returns the next version. It is deliberately free of git, files, and clocks so the policy can be walked cell by cell in a table test rather than inferred from a pipeline.

The arithmetic is over launch.Semver — the repo's one SemVer type — and the result is always a release CORE: any prerelease/build metadata on prev is dropped, because the derived number becomes a git tag and a manifest value, and carrying "rc1" forward would publish a release that claims to be a pre-release of itself.

The policy, per plan §3:

prev >= 1.0.0   breaking -> major++, minor = patch = 0
                additive -> minor++, patch = 0
                fix      -> patch++
prev is 0.x     breaking -> minor++, patch = 0
                additive -> patch++
                fix      -> patch++

The pre-1.0 row is load-bearing, not a shortcut. While abcd is at 0.x it has declared no stable surface, so a break bumps the minor (ADR-37, as amended: pre-1.0, a minor may break — the bump itself is the signal, since the derived changelog has no Breaking section). The consequence is deliberate: NO input can derive 1.0.0 from a 0.x base. The first 1.0.0 is a human's explicit override, because declaring stability is a product decision no set of records can make on the maintainer's behalf.

The second return is the "nothing to release" signal, and it is a distinct value rather than a silent `return prev`: an all-internal or empty cut moves no version, and a caller that could not tell the two apart would write a duplicate dated heading — which auto-release.yml would then try to tag against an already-tagged version.

func IsDatedHeading

func IsDatedHeading(line string) bool

IsDatedHeading reports whether a line is a dated release heading — the same predicate this package reads the CHANGELOG with, exposed so the ship verb that WRITES a heading can assert its output against the reader's rule rather than against a second copy of the pattern.

func IsTargetMoveNote added in v0.12.0

func IsTargetMoveNote(line string) bool

IsTargetMoveNote reports whether a changelog line is a move note: a line that names intents a release did not ship, so no reader credits that release with them.

func LatestChangelogVersion

func LatestChangelogVersion(root string) (launch.Semver, bool, error)

LatestChangelogVersion returns the version of the newest dated heading in root's CHANGELOG.md — the heading auto-release.yml would tag on the next push to main.

"Newest" is POSITIONAL, not the SemVer maximum: like the workflow's `grep -m1`, the first dated heading in the file wins, because Keep-a-Changelog order (newest first) is the record's own convention and mirroring the tagger exactly matters more here than being independently clever about ordering.

The read is guarded and READ-ONLY. Nothing in this package writes to CHANGELOG.md: the whole point of derived releases is that changelog lines are generated from records at the ship, never edited in place by a preview.

An absent CHANGELOG.md returns found=false and no error — the file is not this package's to require; the ship verb that writes the heading is.

func LatestReleaseTag

func LatestReleaseTag(root string) (launch.Semver, bool, error)

LatestReleaseTag resolves the base a release is derived against: the newest `vX.Y.Z` git tag under root, by SemVer order.

The tag — not the newest CHANGELOG heading — is the anchor, and the distinction is load-bearing. auto-release.yml creates the tag AFTER the ship PR merges, so between the merge and the tag the heading is one release ahead of the tag and the two describe different releases; deriving from the heading in that window would compute the cut against a base that does not exist yet. The tag is the only immutable anchor.

Tag listing and strictness are delegated to launch.GitExistingTags, the repo's one tag reader: it keeps only strict `v`-prefixed SemVer release cores, dropping prereleases (whose core would be a phantom release) and anything else. Ordering is launch.CoreGreater, the repo's one version comparison, so v0.10.0 wins over v0.9.0 where a lexical maximum would not.

A repo with no release tag returns found=false and no error: an absent anchor is a state the caller decides about, not a failure to read git.

func ReleaseInFlight added in v0.12.0

func ReleaseInFlight(root string) (bool, string, error)

ReleaseInFlight reports whether a release sits between its cut and its tag — the newest CHANGELOG heading ahead of the newest release tag — and the reason Derive refuses it with. It reads only the tags and the CHANGELOG, so a caller can ask it before work that would otherwise refuse first on a symptom of the same window: the ship's payload parity diff, whose baseline advice names a flag the ship does not take (iss-2609252117203691). No tag is not in flight; Derive refuses that case on its own.

func ReleasedVersionIn added in v0.11.0

func ReleasedVersionIn(data []byte) (launch.Semver, bool, error)

ReleasedVersionIn is the strict reading of the version a released tree names, for a caller that BINDS something to that version rather than merely reports it. latestVersionIn skips every heading datedHeadingRe does not match, which is right for a preview but wrong for a binding: a pre-release head ("## [1.0.0-rc.1] - …"), a build-metadata head or an undated version head would be skipped, and the reader would answer with the PREVIOUS release's version.

So this reader takes the newest "## [" heading other than "## [Unreleased]" and requires it to be a dated heading latestVersionIn parses; anything else is ErrUnreadableReleaseHeading, naming the line. found=false means the file names no release heading at all, which the caller decides about.

func TargetMoveNote added in v0.12.0

func TargetMoveNote(moves []launch.TargetMove) string

TargetMoveNote renders the note for the moves a cut makes, or "" when it makes none. Each move reads `<id> (targeted <what the record carried>)`.

func UnreleasedSection added in v0.11.1

func UnreleasedSection(lines []string) (heading, firstEntry int, found bool)

UnreleasedSection locates the `## [Unreleased]` heading in a changelog's lines and the first non-blank line under it, before the next `## ` heading. heading is the heading's 0-based index and found reports whether there is one; firstEntry is -1 when the section is empty.

It is the ONE reading of "the Unreleased section is empty": the release ingest refuses a cut over a non-empty section (a derived cut never folds hand-written prose into a generated one), and record-lint's changelog_unreleased_empty rule refuses the change that would put an entry there in the first place, so the two cannot disagree about what counts as an entry (iss-256).

Types

type DatedRelease

type DatedRelease struct {
	Version string `json:"version"`
	Date    string `json:"date"`
}

DatedRelease is one dated release heading: the version it names and the date it carries, exactly as written.

func DatedReleases

func DatedReleases(root string) ([]DatedRelease, bool, error)

DatedReleases returns every dated heading in root's CHANGELOG.md, in file order — newest first, the record's own Keep-a-Changelog convention.

It reads the headings through datedHeadingRe, the same predicate LatestChangelogVersion and the tagger use, and takes the date as the rest of the line after that match rather than through a second pattern: two regexps over one heading is two definitions of what a release is, and they drift.

An absent CHANGELOG.md returns found=false and no error. A repository that records no releases is a state — the site omits the sections that depend on them and renders the rest.

type Derivation

type Derivation struct {
	// Base is the version of the anchor tag the cut is measured from.
	Base launch.Semver
	// BaseTag is Base as a git tag ("v0.3.0"), empty when no anchor resolved.
	BaseTag string
	// Records is the cut: what entered and left the terminal record folders.
	Records RecordSet
	// Bump is the strongest impact in the cut — the judgement that decides the
	// version. ImpactInternal means nothing user-facing shipped.
	Bump Impact
	// Next is the derived version; only meaningful when Bumped.
	Next launch.Semver
	// NextTag is Next as a git tag, empty when nothing is released.
	NextTag string
	// Bumped reports whether the cut moves the version at all.
	Bumped bool
	// Refused reports that the cut must not be derived.
	Refused bool
	// RefusalKind classifies the refusal for a caller that must act on it. The
	// prose in RefusalReason is for a human; this is for the ship verb, which
	// decides whether to name a record, a version, or a missing tag — and must
	// not pattern-match English to tell them apart.
	RefusalKind RefusalKind
	// RefusalReason names what to fix; empty unless Refused.
	RefusalReason string
}

Derivation is the deterministic outcome of a release cut: what the next version is, which records decide it, and — when it cannot be decided — why.

A refusal is modelled as a VALUE, not an error, in the same shape as launch.RetentionPlan: "this cut cannot be derived" is a legitimate result a read-only preview must render, not an exceptional failure. Errors are reserved for "the repository could not be read at all".

Three states are deliberately distinguishable, because a caller that conflated them would write a wrong CHANGELOG heading:

Refused          — do not derive; RefusalReason says what to fix.
!Refused, !Bumped — nothing to release; write no heading.
!Refused, Bumped  — Next/NextTag are the release.

func Derive

func Derive(root string) (Derivation, error)

Derive runs the whole deterministic release derivation over the repository at root and writes nothing. It is the one composition of this package's parts: resolve the anchor tag, refuse a release already in flight, diff the record end-states, then apply the version policy to the strongest impact in the cut.

It refuses (rather than deriving a number that would be wrong) in four cases, each fail-closed:

  • No release tag. There is no immutable base; inventing one would report every record ever written as this release's contents.
  • The newest CHANGELOG heading is ahead of the newest tag. auto-release.yml tags AFTER the ship PR merges, so this is the post-merge/pre-tag window: the heading and the tag describe different releases and the base is mismatched. The next cut derives correctly once the tag lands.
  • A record ADDED by the cut carries no valid impact. An unlabelled record ranks below every real impact, so deriving over it would silently under-bump a release that may contain a break. The lints gate this at the record lifecycle; this is the backstop at the cut, and it names both the record and the file to edit. The removed side cannot refuse — its blob is read from the anchor tag's immutable tree, so an unlabelled one is unfixable by definition (see RecordSet.UnlabelledAdded).
  • The working tree's terminal record folders differ from HEAD. The cut is read at HEAD, so a spec close or an issue resolve left uncommitted would be silently missing from a cut that otherwise looks plausible — the v0.13.0 near-miss (iss-2610050259118177). Every path is named. Dirt outside those folders is not the derivation's concern: the ship's pre-flight dirty-tree gate judges the whole tree before it writes.

type Finding added in v0.8.0

type Finding struct {
	// ID is the record id (iss-N), taken from the filename for the reason
	// Record.ID is.
	ID string `json:"id"`
	// Path is the record's repo-relative path, so an operator can open it.
	Path string `json:"path"`
	// Severity is the grade as the record states it, "" when the record carries
	// none. An unreadable grade BLOCKS: see gradeBlocks.
	Severity string `json:"severity"`
	// Reason is the recorded deferral reason, carried on a waived finding only.
	// It is reported rather than swallowed: a deferral nobody can see in the
	// release report is the silence this whole gate exists to refuse.
	Reason string `json:"reason,omitempty"`
	// WaiverErr is why an attempted waiver was not honoured, empty when the
	// record attempted none or when the waiver stands. A rejected waiver leaves
	// the record BLOCKING and says why, in the same fail-safe direction
	// parseShippedIn takes: a field whose job is to let a release through must
	// never do it on a value nobody could read.
	WaiverErr string `json:"waiver_err,omitempty"`
}

Finding is one ledger record the cut is answerable for: a record that entered the ledger since the anchor and is still in open/.

type FindingGuard added in v0.8.0

type FindingGuard struct {
	// BaseTag is the anchor the cycle is measured from.
	BaseTag string `json:"base_tag"`
	// Status is the verdict.
	Status FindingGuardStatus `json:"status"`
	// Unfixed is every blocking finding, in path order.
	Unfixed []Finding `json:"unfixed,omitempty"`
	// Waived is every finding that would have blocked and carries a standing
	// waiver. It is populated on a PASS, deliberately: a conscious deferral is
	// only conscious if the release report says what was deferred and why.
	Waived []Finding `json:"waived,omitempty"`
	// Deleted is every blocking record that sat in open/ at the anchor and is in
	// no status directory at HEAD — a record the cut removed from the ledger
	// instead of answering. Its Path and Severity are read at the ANCHOR, the
	// last ref that still holds the file.
	Deleted []Finding `json:"deleted,omitempty"`
	// Uncommitted is every record file under open/ whose working-tree state
	// differs from HEAD — added, modified, deleted, staged or untracked —
	// repo-relative and sorted. Both halves above read the ledger at HEAD, so a
	// finding captured or regraded and not yet committed is invisible to them;
	// the gate refuses rather than judge a ledger the cut does not carve from
	// (iss-2610050927169919).
	Uncommitted []string `json:"uncommitted,omitempty"`
	// Reason names what to fix; empty on a clean pass.
	Reason string `json:"reason,omitempty"`
}

FindingGuard is the outcome of the unfixed-findings guardrail at a release cut.

Like SurfaceGuard and Derivation, a failure is modelled as a VALUE rather than an error: "this cut is stepping over its own findings" is a legitimate result a read-only preview must render, and errors are reserved for "the repository could not be read at all".

func GuardFindings added in v0.8.0

func GuardFindings(root string, baseTag string) (FindingGuard, error)

GuardFindings runs the unfixed-findings guardrail over the repository at root and writes nothing.

It asks one question: of the findings THIS CYCLE produced, is any of them consequential, still open, and unanswered? A release that steps over a defect of its own making spends the credibility the release exists to build, and "it was already there when I started" is not available as a defence for a finding the cycle itself recorded.

WHAT COUNTS AS THIS CYCLE'S is the load-bearing decision, and it is a set-difference of ledger membership between the anchor tag's tree and HEAD — the same shape, and for the same reasons, as ShippedSince. Two alternatives were considered and rejected:

  • The record id. Ids minted since 2026-08 are timestamp-numeric, so an id looks like a capture date. But the ledger's first ~380 records carry plain ordinals with no timestamp in them at all, so the rule would need a fallback and the fallback would be the real rule. Worse, a timestamp is the moment an id was MINTED, which is neither the moment the finding entered the record nor a fact git can check: it is a string in a file the gate is judging, and a gate whose verdict is decided by an editable field is a gate its subject can edit.
  • A git-log walk of when the record file appeared. This repository allows squash and rebase merges, both of which rewrite when a file "appeared", so the same tree yields different answers depending on how a branch happened to land — the caveat shipped.go's RecordSet doc comment already states.

Membership is keyed on the record ID across ALL THREE status directories, not on the path. A record's path changes when it is resolved or re-slugged, so a path-keyed difference would report a standing backlog issue that merely moved as newly captured. The id is what survives the move.

resolved/ and wontfix/ both clear the gate, and wontfix does so without a special case: the guardrail looks only at open/, so a record that reached either terminal folder has been answered. That is the intended reading. A wontfix carries a recorded reason and is exactly the conscious, cited non-action the rule asks for — the opposite of ignoring a finding, not a loophole in the gate.

A DELETION is not one of those routes, and the second half of this gate is what says so (iss-2609091143455568). Looking only at open/ at HEAD made the cheapest way past the gate the one that destroys the finding: every legitimate route leaves a trace the next reader can follow — a resolution, a wontfix, a deferral with its reason — and `git rm` leaves nothing at all. So the gate also asks the question its sibling asks (RS001, scripts/check-issue-resolution.sh, which refuses a trailer satisfied by a bare delete): a blocking record present in open/ at the anchor and absent from the WHOLE ledger at HEAD is a deletion rather than a disposition, and it refuses, naming the record and the deletion.

Absence from the whole ledger, not from open/, is what makes the two halves agree: a record that merely moved — resolved, wontfixed, or re-slugged — is still somewhere under the status directories, and only a record that left the ledger entirely is unauditable afterwards.

The residual, stated because it bounds what this gate proves: a record captured AFTER the anchor and deleted before HEAD appears in neither tree, so no set-difference between two trees can see it. The alternative is a git-log walk of the range, which this package already refuses for deciding what a cycle produced (see WHAT COUNTS AS THIS CYCLE'S above) and for the same reason — squash and rebase merges rewrite when a file appeared and vanished, so a capture-and-delete inside one squashed branch leaves no add and no delete to find. The sibling gate covers part of that window and not all of it: RS001 refuses a delete that a commit CLAIMS is a resolution, and a delete claiming nothing is outside its question too.

Both halves read the ledger at HEAD, so the third half refuses a working tree whose open/ records differ from it (iss-2610050927169919): a finding captured or regraded and left uncommitted would otherwise be invisible to the gate, and --allow-dirty past the ingest's dirty-tree gate would let the cut step over it. It reads the tree through launch.DirtyTreeFiles, as the derivation's uncommitted-records refusal does for the terminal folders.

func (FindingGuard) DeletedReason added in v0.9.0

func (g FindingGuard) DeletedReason() string

DeletedReason is UnfixedReason's twin for the removed records.

func (FindingGuard) UncommittedReason added in v0.13.3

func (g FindingGuard) UncommittedReason() string

UncommittedReason is the third half: the open records the working tree holds differently from HEAD.

func (FindingGuard) UnfixedReason added in v0.9.0

func (g FindingGuard) UnfixedReason() string

UnfixedReason and DeletedReason are the two halves of the verdict's prose, each recomposed from the findings it reports. Reason carries both, which is what an operator reads; a caller that raises ONE of them as its own refusal needs that half alone, and a refusal carrying the other half's remedy sends its reader to perform a step that does not apply. Both return "" when their half is clean.

type FindingGuardStatus added in v0.8.0

type FindingGuardStatus string

FindingGuardStatus is the unfixed-findings guardrail's verdict on a cut.

FindingGuardPassed — every finding this cycle produced has been answered.
FindingGuardFailed — any of the three lists GuardFindings fills is
                     non-empty: Unfixed, a consequential finding this
                     cycle produced that is still open and unwaived;
                     Deleted, a blocking record in open/ at the anchor
                     that is gone from the ledger without a resolution;
                     Uncommitted, an open/ record whose working-tree
                     state differs from HEAD, at any severity. Reason
                     names every entry of every list.

There is deliberately no "refused" state, unlike SurfaceGuard. That guardrail can be unable to compare at all — no tag, no baseline in the tag's tree — and must not report "nothing broke" when it means "I could not tell". This one has no such window: it runs only after the derivation has already proved the anchor, and both sides of its comparison are read from git, so a read that fails is a repository that could not be read (an error) rather than a verdict.

const (
	FindingGuardPassed FindingGuardStatus = "passed"
	FindingGuardFailed FindingGuardStatus = "failed"
)

The two verdicts. The string values are what a rendered preview prints and what a machine-readable front door emits, so renaming a constant is safe and changing a value is a contract change.

type Impact

type Impact string

Impact is the product judgement a record (an intent or an issue) declares about what shipping it does to the public surface. It drives the SemVer bump and changelog inclusion, and nothing else — it deliberately does not decide a Keep-a-Changelog section, because a four-value enum cannot express Security/Deprecated/Removed granularity and conflating the two would make the version hostage to editorial judgement.

const (
	// ImpactAdditive is a new capability that breaks nothing.
	ImpactAdditive Impact = "additive"
	// ImpactBreaking removes or narrows something callers depend on.
	ImpactBreaking Impact = "breaking"
	// ImpactFix corrects behaviour within the existing surface.
	ImpactFix Impact = "fix"
	// ImpactInternal is invisible to users: excluded from the changelog and
	// drives no bump. It exists so plumbing work (lint internals, atomic-write
	// hardening) is not forced into a user-facing changelog by a hard default.
	ImpactInternal Impact = "internal"
)

The four members of the enum. The string values are the wire format: they are what a record's `impact:` frontmatter field carries, so renaming a constant without changing its value is safe and changing a value is a record migration.

func ParseImpact

func ParseImpact(v string) (Impact, error)

ParseImpact is the boundary validator for the `impact:` frontmatter field.

Matching is exact: no case folding and no trimming. The shared frontmatter scanner (internal/core/frontmatter) already trims the value it hands over, so any whitespace still present here came from inside the value and is an authoring defect worth naming rather than silently absorbing. Case is not folded because the records are the source of truth for a machine-read enum; accepting "Additive" would make the corpus inconsistent with no gate to pull it back.

An empty value is an error, not a default. The rule it replaces — "issues default to fix" — under-bumped genuinely feature-adding issues, and the surface guardrail only backstops breaks, never additive under-bumps. There is therefore no defaulting anywhere in this package: the judgement is the author's, made explicitly, or the gate refuses.

func (Impact) DrivesBump

func (i Impact) DrivesBump() bool

DrivesBump reports whether a record with this impact moves the version. Only internal (and anything that never passed ParseImpact) does not.

func (Impact) InChangelog

func (i Impact) InChangelog() bool

InChangelog reports whether a record with this impact earns a changelog line. It coincides with DrivesBump today because outcome 8 states one rule for both — internal is excluded from the changelog AND drives no bump — but the two are named apart because they gate different pipelines (version arithmetic versus the prose bijection) and a future class could plausibly split them.

type Record

type Record struct {
	// Path is the repo-relative, slash-separated path of the record file.
	Path string
	// ID is the record id derived from the FILENAME (itd-73, iss-24), not from
	// frontmatter: the filename is what the id-uniqueness lint already governs,
	// and issue frontmatter quotes its id, so the filename is the cheaper and
	// more consistent source.
	ID string
	// Impact is the parsed judgement, or "" when the record carries none.
	Impact Impact
	// ImpactErr is why the impact could not be parsed, empty when it parsed. A
	// record is reported as unlabelled rather than defaulted, because defaulting
	// a missing judgement silently under-bumps the release.
	ImpactErr string
	// Title names the record: its `# ` heading, else its frontmatter slug, else
	// its id. It is never empty (see summarise).
	Title string
	// Summary is the record's opening paragraph, collapsed and capped. Title and
	// Summary are the SOURCE MATERIAL a changelog composer writes prose from;
	// they are carried on the record because the blob is read once here, and a
	// later reader could disagree with this one about what a record says.
	Summary string
	// ShippedIn is the release that actually carried this record's work, when the
	// record says so — the `shipped_in:` frontmatter field, parsed as a version.
	// Empty when the field is absent, null, or does not parse.
	//
	// THIS IS A MIGRATION MECHANISM. A repository abcd manages from its first
	// commit should never set it: RS001 makes resolution ride the fixing commit,
	// so a record reaching a terminal folder and the work shipping are the same
	// event, and the cut is right by construction. The field exists because abcd
	// was built before that rule existed — a 2026-08-24 hygiene sweep closed 33
	// records for work released as far back as v0.2.0, and the v0.6.4 cut derived
	// its version from four of them.
	//
	// Say that here rather than in a note elsewhere: a migration accommodation
	// that does not name itself becomes permanent architecture by default, and
	// the next author builds on it (less-but-better).
	//
	// It exists because the cut is a set-difference of FOLDER MEMBERSHIP, which
	// answers "did this record reach a terminal folder since the anchor?" and is
	// read as "did this work ship in this release?". Those coincide only while
	// resolution lands in the fixing commit. A ledger hygiene sweep is the
	// legitimate exception — it closes records for work released long ago — and
	// on 2026-08-24 one closed 33 of them, after which the v0.6.4 cut tried to
	// announce fixes first released in v0.2.0 as new (iss-2608241612087533).
	//
	// Nothing is INFERRED here. An earlier design tested whether
	// resolved_by.commit was reachable from the anchor, which would have judged
	// 85 of 376 resolved records and guessed at the rest. A record either states
	// which release carried it or it does not, and a record that does not say is
	// treated as this cut's — the direction that risks a redundant line rather
	// than a silent omission.
	ShippedIn string
	// ShippedInErr is why a present `shipped_in:` did not parse, empty otherwise.
	// A record carrying an unparseable value stays IN the cut: excluding on a
	// value nobody could read would drop real content from a release record on a
	// typo, which is the worse of the two failures.
	ShippedInErr string
	// PressRelease is the body of the record's `## Press Release` section, empty
	// when it has none. It is the source a release page's quotes are verified
	// against, read from the same blob as Title and Summary so the page and the
	// changelog cannot disagree about what a record says.
	PressRelease string
}

Record is one record in a release cut: where it lives, what it is called, and the one product judgement it declares.

func (Record) InChangelog

func (r Record) InChangelog() bool

InChangelog reports whether this record must be cited in the generated prose. It is the one definition of "must be reported", written here rather than at each call site so the preview, the composer's view of the cut, and the completeness bijection can never disagree about which records are required.

It is NOT simply Impact.InChangelog(). An UNLABELLED record is required too, and that is the whole reason this method exists: an unlabelled record's judgement is unknown, not internal, and the only unlabelled records that ever reach a ready cut are on the Removed side (UnlabelledAdded refuses the other direction), read from the anchor tag's IMMUTABLE tree. Folding one into "earns no line" would drop a supersession from the permanent release record for a defect the operator cannot fix — the silent omission UnlabelledAdded's contract promises never happens.

type RecordSet

type RecordSet struct {
	// BaseRef is the anchor the cut is measured from (a tag such as v0.3.0).
	BaseRef string
	// Added are records present at HEAD and absent at the anchor — the cut.
	Added []Record
	// Removed are records present at the anchor and absent at HEAD. A record
	// leaves a terminal folder when it is superseded or withdrawn; either way
	// it is a user-visible change that must surface as a Removed/Changed line
	// rather than silently vanish from the release. A re-slug inside its own
	// folder is not a removal: membership is keyed on the id.
	Removed []Record
}

RecordSet is a release cut: the set-difference of record END STATES between the anchor tag and HEAD.

It is deliberately NOT a git-log walk of moves. A squash or rebase merge collapses the commit that moved a record into its terminal folder, so a walk over `<tag>..HEAD -- <paths>` reports a different set depending on how a branch happened to land — the same tree, two answers. Comparing end states asks the only question that matters ("which records are in the terminal folders now, and which were there at the tag?") and is immune to the shape of the history in between.

func ShippedSince

func ShippedSince(root string, baseRef string) (RecordSet, error)

ShippedSince computes the release cut between baseRef (the anchor tag) and HEAD, as the set-difference of the record ids in the terminal folders.

Both sides are read out of git, never out of the working tree: a removed record exists only in the anchor's tree, and reading the added side from git too keeps a dirty or half-staged working tree from changing what a release reports. The other half of that rule is Derive's: a tree whose terminal folders differ from HEAD is refused (uncommittedRecords), because a record move left uncommitted would otherwise be silently missing from the cut. Every returned slice is sorted by path — the set feeds a rendered preview and a changelog bijection, both of which must be reproducible.

A baseRef git cannot resolve is an error, never an empty set: reporting "nothing shipped" against a tag that does not exist would let a cut silently claim there is nothing to release.

func (RecordSet) All

func (s RecordSet) All() []Record

All returns the whole cut — added then removed — for callers that must account for every record, such as the changelog completeness bijection.

func (RecordSet) ChangelogRequired

func (s RecordSet) ChangelogRequired() []Record

ChangelogRequired is the cut minus every internal record: exactly the set of records the generated prose must cite, no more and no less. internal records are excluded here (not filtered later, per-caller) so the changelog and the version agree on one definition of "user-facing".

func (RecordSet) DeclaresBreak

func (s RecordSet) DeclaresBreak() bool

DeclaresBreak reports whether the cut declares that it narrows the public surface on purpose — the release guardrail's "was this break declared?" test.

It judges the ADDED side only, and that restriction is the whole point of the method existing separately from Impact(). A Removed record's blob is read from the anchor tag's immutable tree, so its label is what the LAST release declared, not what this one does. Supersession is a supported flow — a shipped intent leaves the folder when a later one replaces it — and the historical impact back-fill puts `breaking` labels on old intents, so a cut that ships nothing breaking can easily carry a superseded `breaking` record on its Removed side. Counting that as a declaration would wave an undeclared removal through the guardrail, silently, which is the exact fail-open the guardrail exists to prevent. The same reasoning excludes Removed from UnlabelledAdded.

A withdrawal that genuinely narrows the surface therefore ships its own superseding record labelled `breaking`.

Impact() deliberately keeps counting both sides: the version must account for every record in the cut, because a record leaving a terminal folder is itself a user-visible change.

func (RecordSet) Impact

func (s RecordSet) Impact() Impact

Impact is the strongest impact in the cut — the one that decides the bump. An empty or all-internal cut yields ImpactInternal, which reads at the call site as "nothing to release".

func (RecordSet) PressReleaseRequired added in v0.10.0

func (s RecordSet) PressReleaseRequired() []Record

PressReleaseRequired is the release page's set: the ADDED intents whose impact earns a changelog line.

PressReleaseRequired = Added ∩ itd-* ∩ InChangelog

Removed records, issues and `impact: internal` intents fall out by construction, and a record carrying a valid `shipped_in:` is already absent from Added. An unlabelled Added record never reaches a ready cut (UnlabelledAdded refuses it), so InChangelog means "user-facing" here without qualification. It is written once, here, so the preview, the composer's view of the cut and the page bijection read one definition.

func (RecordSet) Unlabelled

func (s RecordSet) Unlabelled() []Record

Unlabelled returns every record in the cut whose impact is absent or invalid, for a preview that must show the operator the whole picture. It is NOT the refusal set — see UnlabelledAdded for that.

func (RecordSet) UnlabelledAdded

func (s RecordSet) UnlabelledAdded() []Record

UnlabelledAdded returns the unlabelled records on the ADDED side only: the ones a caller may refuse the cut over, because an unlabelled record ranks below every real impact and deriving over it would quietly under-bump a release that may contain a break.

Removed records are deliberately excluded. Their blob is read from the anchor tag's immutable tree, so one that predates the impact back-fill can never be labelled: at HEAD the file is gone (a supersession; a re-slug inside its own folder is no removal, since membership is keyed on the id). Refusing over it would name a remedy the operator cannot perform and would block every release until the move was reverted. Such a record still travels in Removed, so the release still reports it rather than dropping it silently.

type RefusalKind

type RefusalKind string

RefusalKind is the machine-readable classification of a derivation refusal. The string values are what a machine-readable front door emits, so renaming a constant is safe and changing a value is a contract change.

const (
	// RefusalNone is the zero value: this derivation did not refuse.
	RefusalNone RefusalKind = ""
	// RefusalNoReleaseTag: no immutable base to measure the cut from.
	RefusalNoReleaseTag RefusalKind = "no-release-tag"
	// RefusalReleaseInFlight: the newest CHANGELOG heading is ahead of the
	// newest tag, so a release is between its merge and its tag.
	RefusalReleaseInFlight RefusalKind = "release-in-flight"
	// RefusalUnlabelledRecord: a record ADDED by the cut carries no valid impact.
	RefusalUnlabelledRecord RefusalKind = "unlabelled-record"
	// RefusalUncommittedRecords: the working tree's terminal record folders
	// differ from HEAD, which is where the cut reads them.
	RefusalUncommittedRecords RefusalKind = "uncommitted-records"
)

The refusal kinds, one per fail-closed case in Derive.

type SurfaceGuard

type SurfaceGuard struct {
	// BaseTag is the release tag the baseline snapshot was read from, empty
	// when no tag resolved.
	BaseTag string `json:"base_tag"`
	// Status is the verdict.
	Status SurfaceGuardStatus `json:"status"`
	// Breaks is every structural narrowing found, in canonical order. It is
	// populated on a PASS too when a break was declared: the release notes have
	// to describe what broke, so a declared break is reported, not discarded.
	Breaks []surface.Break `json:"breaks,omitempty"`
	// BreakingDeclared reports whether the cut ADDS a record whose impact is
	// breaking — the author's declaration that this release narrows the surface
	// on purpose. See RecordSet.DeclaresBreak for why the removed side does not
	// count.
	BreakingDeclared bool `json:"breaking_declared"`
	// Reason names what to fix; empty on a clean pass.
	Reason string `json:"reason,omitempty"`
}

SurfaceGuard is the outcome of the surface-break guardrail at a release cut.

Like Derivation, a refusal is modelled as a VALUE rather than an error: "this cut cannot be guarded" is a legitimate result a read-only preview must render, and errors are reserved for "the repository could not be read at all".

func GuardSurface

func GuardSurface(root string, current surface.Snapshot) (SurfaceGuard, error)

GuardSurface runs the release surface guardrail over the repository at root and writes nothing (spc-10 AC 4, plan outcome 5).

The comparison is the BASELINE AS OF THE LAST RELEASE TAG against the current surface the caller hands in. Reading the baseline out of the tag is the single load-bearing decision in this function, and the obvious "simplification" is what would destroy it: the committed snapshot is kept byte-equal to the live command tree by a drift test, so comparing the committed FILE against the current tree would compare a file with itself, never report a break, and leave a green light where a guardrail was meant to be.

current is passed in rather than built here because building it means walking the live cobra command tree, and internal/core must not know cobra. The front door (internal/surface/cli) owns the walk; this owns the judgement.

The cut's own records answer "was this break declared?". Both the record set and the impact ordering are phase 1's (ShippedSince and RecordSet.DeclaresBreak), so the guardrail and the version derivation can never disagree about what shipped or about what breaking means. A break passes when — and only when — the cut ADDS a record whose impact is breaking; a superseded record leaving the terminal folder declares nothing about this release.

It refuses, rather than passing, in three fail-closed cases:

  • No release tag. There is no immutable anchor to read a baseline from.
  • The tag's tree carries no snapshot. This is the repository's real state until a release is cut that contains the baseline, and it is deliberate: the first cut is the highest-risk one and must not sail through unguarded. The refusal text names the clean-cutover manual roll, which is what puts a baseline into a tag.
  • current disagrees with the snapshot committed at HEAD. See currentMatchesHead: the caller walks a compiled-in command tree, and a binary older than the tree being released reproduces the LAST release's surface, which would diff the baseline against itself.

A snapshot that is present at the tag but cannot be decoded is an ERROR, not a refusal: a corrupt baseline read as "no surface" would make every command in the release look like surface that never existed.

type SurfaceGuardStatus

type SurfaceGuardStatus string

SurfaceGuardStatus is the guardrail's verdict on a cut. Three states, kept apart because a caller that conflated them would ship the wrong release:

SurfaceGuardPassed  — the cut may proceed.
SurfaceGuardFailed  — the surface narrowed and nothing in the cut declares
                      it; Reason names every changed surface.
SurfaceGuardRefused — the guardrail could not compare at all; Reason says
                      what to do about it.

A refusal is NOT a pass. Failing to distinguish them is the whole risk of the first cut, which is the one with no baseline to compare against.

const (
	SurfaceGuardPassed  SurfaceGuardStatus = "passed"
	SurfaceGuardFailed  SurfaceGuardStatus = "failed"
	SurfaceGuardRefused SurfaceGuardStatus = "refused"
)

The three verdicts. The string values are what a rendered preview prints and what a machine-readable front door emits, so renaming a constant is safe and changing a value is a contract change.

Jump to

Keyboard shortcuts

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