/** * Shared report model — turns raw findings into the structured shape both the * Markdown and HTML renderers consume, so they can never drift. Computes the * tier split, de-noising, per-file quick-win patches (combined unified diff via * proof.ts), guidance clusters, and severity counts. */ import type { AuditFinding } from "./core.js"; import type { UnclaimedFile } from "./discover.js"; import { type Authority, type Category, type FixKind, type RuleMeta, type Tier } from "./catalog.js"; import { type ProveOptions } from "./proof.js"; import type { Severity } from "../lint/rule.js"; /** * Version of the machine-readable JSON report. Stability contract: additive * changes (new fields) keep the same major; renamed/removed fields bump the * major. Consumers should check the major and ignore unknown fields. See * `docs/cli/audit`. */ export declare const REPORT_SCHEMA_VERSION = "1.0"; export declare const SEVERITY_WEIGHT: Record; export interface EnrichedFinding extends AuditFinding { meta: RuleMeta; } /** A per-file quick-win: a combined patch plus any findings still needing input. */ export interface QuickWinFile { file: string; /** Combined unified diff of the deterministic fixes applied to this file. */ diff?: string; /** Rules the diff addresses. */ addressed: RuleMeta[]; /** Deduped findings that are deterministic but blocked on a value (e.g. a SHA). */ needsInput: EnrichedFinding[]; } /** Guidance findings grouped by their primary authority. */ export interface GuidanceCluster { name: string; url?: string; rules: Array<{ meta: RuleMeta; findings: EnrichedFinding[]; }>; } export interface ReportCounts { total: number; quickWin: number; needsReview: number; reportOnly: number; errors: number; warnings: number; infos: number; /** Findings by category (#415) — what kind of issue, not how confident the fix. */ security: number; correctness: number; bestPractice: number; } export interface ReportModel { counts: ReportCounts; quickWins: QuickWinFile[]; needsReview: GuidanceCluster[]; reportOnly: EnrichedFinding[]; /** All shown findings (after de-noise), flat and sorted — for serialization. */ findings: EnrichedFinding[]; } /** Provenance snapshot of what was audited (anchors findings to a commit). */ export interface AuditSnapshot { target: string; host?: string; repo?: string; ref?: string; commit?: string; files: string[]; generatedAt: string; toolVersion: string; } /** A finding flattened for the machine-readable JSON report. */ export interface SerializedFinding { checkId: string; severity: Severity; message: string; file: string; entity?: string; lexicon: string; tier: Tier; fixKind: FixKind; /** What kind of finding this is (security / correctness / best-practice). */ category: Category; title: string; remediation: string; authority: Authority[]; /** Link to this rule's entry in the audit rules reference. */ docUrl: string; } /** The versioned machine-readable audit report. */ export interface AuditReportJson { schemaVersion: string; tool: { name: string; version: string; }; /** * Whether the audit had lexicons to look with (#1623). `"ok"` when at least * one audit lexicon resolved; `"no-lexicons"` means nothing was inspected and * the report carries no findings by construction. */ status: "ok" | "no-lexicons"; snapshot?: AuditSnapshot; summary: ReportCounts; findings: SerializedFinding[]; /** Candidate files that looked like they wanted a lexicon that is not installed. */ unclaimed?: UnclaimedFile[]; } export declare function metaFor(id: string, catalog?: Record): RuleMeta; export declare function sortFindings(a: EnrichedFinding, b: EnrichedFinding): number; export interface BuildModelOptions { files?: Array<{ path: string; content: string; }>; resolveSha?: ProveOptions["resolveSha"]; resolveDigest?: ProveOptions["resolveDigest"]; /** The resolved audit catalog (core static + active lexicons' contributions, #687). Defaults to core's static `RULE_CATALOG`. */ catalog?: Record; } /** Build the structured report model from raw findings. */ export declare function buildReportModel(findings: AuditFinding[], opts?: BuildModelOptions): ReportModel; /** Build the versioned, machine-readable JSON report (stable contract). */ export declare function buildReportJson(findings: AuditFinding[], opts?: { snapshot?: AuditSnapshot; toolVersion?: string; catalog?: Record; unclaimed?: UnclaimedFile[]; }): AuditReportJson; //# sourceMappingURL=report-model.d.ts.map