/** * Spec 11 R1 — Findings Ledger * * Append-only audit history stored in the SQLite index. Every audit surface * (CLI, MCP, library, hook) writes to the ledger unconditionally. The ledger * survives clearIndex like user-authored data. */ import Database from 'better-sqlite3'; import type { Violation } from './types.js'; export interface LedgerRunInput { gitSha?: string; gitDirty: boolean; toolVersion: string; command: string; surface: 'cli' | 'mcp' | 'library' | 'hook'; scope: string; target: string; } export interface LedgerRunRecord { runId: string; timestamp: string; gitSha: string | null; gitDirty: boolean; toolVersion: string; command: string; surface: string; scope: string; target: string; durationMs: number; exitStatus: number; } export interface LedgerFindingRecord { runId: string; analyzer: string; rule: string; severity: string; message: string; file: string; line: number | null; symbol: string; fingerprint: string; } export interface LedgerRunSummary { runId: string; timestamp: string; command: string; surface: string; scope: string; findingCount: number; durationMs: number; exitStatus: number; gitSha?: string | null; } export interface LedgerStats { totalRuns: number; perAnalyzer: Record; severityDistribution: Record; }>; } export declare function writeAuditToLedger(db: Database.Database, runInput: LedgerRunInput, violations: Violation[], durationMs: number, exitStatus: number): string; /** Update the exit status of a ledger run — called by CLI/MCP after determining it. */ export declare function updateLedgerRunStatus(db: Database.Database, runId: string, exitStatus: number): void; export declare function detectRunInput(command: string, surface: LedgerRunInput['surface'], scope: string, target: string, toolVersion: string): LedgerRunInput; export declare function listRuns(db: Database.Database): LedgerRunSummary[]; export declare function exportLedger(db: Database.Database, since?: string): { runs: LedgerRunRecord[]; findings: LedgerFindingRecord[]; }; export interface TrendRuleSummary { rule: string; newCount: number; fixedCount: number; net: number; } export interface TrendRunPair { previousRunId: string; previousTimestamp: string; currentRunId: string; currentTimestamp: string; } export interface TrendReport { target: string; runPairs: TrendRunPair[]; timeRange: { start: string; end: string; }; perRule: Record; } /** * Compare consecutive full-audit runs of the same target and report per-rule * new/fixed/net trends. Non-full runs are excluded. If fewer than 2 comparable * runs exist, returns null. * * @param db The better-sqlite3 database handle. * @param sinceRunId Only consider runs after this run ID. */ export declare function getTrends(db: Database.Database, sinceRunId?: string): TrendReport | null; export declare function getLedgerStats(db: Database.Database): LedgerStats; /** * D1 interim archive format (Directive D1): directory of JSON files per run. * Each file: { timestamp, command, surface, scope, violations: [...] } * This is a legacy bridge — D1 is retired once the interim directory is ingested. */ export interface D1InterimRun { timestamp?: string; command?: string; surface?: string; scope?: string; target?: string; toolVersion?: string; violations?: Array<{ analyzer?: string; rule?: string; severity?: string; message?: string; file?: string; line?: number; symbol?: string; }>; } export declare function importLedgerFromDir(db: Database.Database, dirPath: string): { imported: number; skipped: number; }; //# sourceMappingURL=ledger.d.ts.map