Documentation
¶
Overview ¶
Package baseline implements signal control SC1 (ADR-0027): a user-private, per-developer record of already-accepted findings so that repeat runs surface only NEW issues instead of re-dumping the whole brownfield backlog every time.
The record lives at <repoRoot>/.commitbrief/baseline.json. That directory is already gitignored by `setup --local`, so the file never enters a diff, never reaches CI, and never weakens the senior/CI gate — those still see every finding. The baseline only quiets the local developer's own runs.
A finding is identified by a line-drift-resilient fingerprint:
sha256(File + "\0" + Severity + "\0" + normalize(Title))
Line is deliberately excluded (code shifts as the file grows, and a brownfield baseline must survive that); Description and Snippet are excluded because they are LLM-volatile prose that would churn the fingerprint on every re-run. normalize trims, collapses internal whitespace, and lowercases the Title. The documented limit is that the same Title twice in one file at the same severity collides into a single fingerprint; the escape hatch is `--update-baseline`.
Index ¶
Constants ¶
const FileVersion = 1
FileVersion is the schema version stamped into baseline.json. It is the file's own format version and is unrelated to the locked --json schema (render.SchemaVersion); bumping it lets a future format change reject or migrate an older file rather than silently mis-reading it.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter splits findings into the ones to KEEP (not in the baseline) and a count of how many were dropped because their fingerprint is baselined. This is a TRUE removal (ADR-0027): the kept slice is what fail-on, JSON findings[], and display all see — distinct from the display-only --min-severity filter. An empty/nil Set keeps everything (count 0), so the no-baseline-file path is a transparent pass-through. The kept slice is always non-nil (callers downstream distinguish nil = graceful degrade from empty = clean), preserving that invariant.
func Fingerprint ¶
Fingerprint derives the stable identity of a finding per ADR-0027: sha256(File + "\0" + Severity + "\0" + normalize(Title)), hex-encoded. The NUL separators keep the three fields unambiguous (no field can contain a NUL), so "ab" + "c" and "a" + "bc" never collide.
func Write ¶
Write replaces baseline.json with the fingerprints of the given findings. It is the `--update-baseline` action: the whole current set becomes the new accepted baseline (an absorb, not a merge), so removing a finding from the code and re-baselining drops its fingerprint too. The parent .commitbrief/ directory is created if absent; the write is atomic (temp + rename) so an interrupted run never leaves a half-written file. Returns the number of distinct fingerprints written.
Types ¶
type Set ¶
type Set map[string]struct{}
Set is the in-memory form of a loaded baseline: the set of accepted fingerprints. The zero value (nil map) is a valid empty set — every Contains call returns false — so a missing file degrades to "baseline off" without special-casing at the call site.
func Load ¶
Load reads the baseline for repoRoot. A missing file is NOT an error — it yields an empty Set and a nil error, so a first-ever run (or a developer who never opted in) simply has nothing baselined. A present-but-malformed file IS an error so a corrupted baseline surfaces loudly instead of silently unhiding findings the developer thought were accepted.