/** * Accepted public-surface breakages (change: add-public-surface-acceptance-baseline). * * A checked-in, deterministic JSON Lines file under `.openlore/` that records breaking * `certify_public_surface` findings an operator intentionally shipped. Each entry names the rule * code, subject, and discriminator (the same `code` + `subject` + `discriminator` identity the * enforcement ratchet uses — the discriminator pins WHICH break, so accepting one narrowing never * covers a later, different one), a REQUIRED justification, and optionally a decision id. A * decision-anchored acceptance is honored only while that decision is current: a superseded, * rejected, or unknown decision makes the entry stale, and the finding reports again. * * Reading is fail-closed: a file that cannot be read or parsed honors nothing, so a corrupt * baseline can never hide a breaking change. Only the CLI writes the file. */ import type { Stats } from 'node:fs'; import type { GovernanceFinding } from './enforcement-policy.js'; /** Upper bound on one justification, so a baseline line stays reviewable. */ export declare const MAX_JUSTIFICATION_LENGTH = 1000; /** One accepted breakage. `decision` is an 8-character decision id, or absent. */ export interface AcceptedBreakage { code: string; subject: string; /** The finding's discriminator (which break); absent for a break the code and subject pin fully. */ discriminator?: string; justification: string; decision?: string; } /** Whether an anchored decision is still current, from the decision store. */ export type DecisionCurrency = { current: true; } | { current: false; reason: string; supersededBy?: string; }; export interface BaselineApplication { /** Findings the baseline does not honor: these still report and can block. */ findings: GovernanceFinding[]; /** Findings matched by an honored entry: reported, never blocking. */ accepted: Array; /** Entries that match a current finding but are not honored because their decision is not current. */ stale: Array; /** Entries that match no current finding. */ unmatched: Array<{ code: string; subject: string; discriminator?: string; }>; } /** Can this finding be accepted? Only breaking-classed public-surface findings can. */ export declare function isAcceptableFinding(finding: GovernanceFinding): boolean; /** Validate a justification; returns an error message, or null when it is acceptable. */ export declare function justificationError(justification: string | undefined): string | null; /** Parse a baseline file. Throws on any malformed content: the caller must honor nothing. */ export declare function parseAcceptedBaseline(text: string): AcceptedBreakage[]; /** Serialize entries deterministically: one sorted record per line. */ export declare function serializeAcceptedBaseline(entries: readonly AcceptedBreakage[]): string; /** * Apply the baseline to a diff's findings. Pure. An entry is honored when it matches an acceptable * finding's `code` + `subject` + `discriminator` and carries no decision or a current one. Everything else still * reports: a stale entry is listed with the reason, and the finding stays in `findings`. */ export declare function applyAcceptedBaseline(findings: readonly GovernanceFinding[], entries: readonly AcceptedBreakage[], decisionCurrency: ReadonlyMap): BaselineApplication; /** Decision ids of the entries that match one of `findings` — the only anchors worth checking. */ export declare function anchorsToCheck(findings: readonly GovernanceFinding[], entries: readonly AcceptedBreakage[]): string[]; export interface BaselineRead { entries: AcceptedBreakage[]; present: boolean; /** Exact bytes and identity read, for a compare-and-swap write. */ text?: string; stat?: Stats; } /** * Read the baseline from `rootPath`. Absent → `present: false`. Throws when the file exists but * cannot be read safely or parsed (a symlinked path, an oversized or non-UTF-8 file, bad records). */ export declare function readAcceptedBaseline(rootPath: string): Promise; /** * Whether Git will pick the baseline up. `.gitignore` is never edited (a `.openlore/` rule is the * common case, and rewriting ignore rules in a cloned repository can expose `.openlore/config.json`). * An ignored baseline needs one `git add -f`; once tracked, ignore rules no longer apply to it. */ export type BaselineGitTracking = { state: 'tracked' | 'trackable' | 'not-a-git-work-tree'; } | { state: 'ignored'; addCommand: string; } | { state: 'unknown'; reason: string; }; export interface AcceptResult { path: string; added: AcceptedBreakage[]; /** Existing entries re-accepted with a new justification or decision, with what they were before. */ replaced: Array<{ before: AcceptedBreakage; after: AcceptedBreakage; }>; written: boolean; git: BaselineGitTracking; } /** * Record `findings` as accepted with one justification (and optional decision id). Only acceptable * findings are recorded. An existing entry for the same identity is replaced — but an entry that is * anchored to a decision is replaced only by another decision-anchored acceptance, so re-accepting * never silently turns an expiring acceptance into a permanent one. Serialized under an advisory * lock and written with compare-and-swap against the bytes read, so a concurrent edit is refused * instead of lost. Reports whether Git will pick the file up; never edits `.gitignore`. */ export declare function writeAcceptedBreakages(rootPath: string, findings: readonly GovernanceFinding[], justification: string, decision?: string): Promise; //# sourceMappingURL=public-surface-baseline.d.ts.map