/** * The lessons file the learning loop writes (#4581 ADR-502, ADR-511): SONA patterns that verified outcomes trained, * at or above the routing gate as lessons, repeated verified failures as cautions. * * ADR-511 adds what a lesson can act on: the project files the passing fixes edited, counted per pattern in the * ingest ledger and named (at most three, most often first) in the lesson. A path reaches the file only if it passes * `lessonFile`, the same screen the mod applies when it records and again when it reads. */ import { type HoldReason, type PatternStats } from './verified-guards.js'; /** The SONA routing gate (sona-optimizer.ts `SONA_ROUTING_GATE`); a lesson below it never influences routing. */ export declare const LESSON_GATE = 0.6; export declare const MAX_LESSONS = 20; /** Verified failures (and more failures than successes) before a pattern becomes a caution. */ export declare const CAUTION_MIN_FAILURES = 2; /** ADR-511: files a record may carry, files a pattern counts, and files a lesson names. */ export declare const MAX_RECORD_FILES = 5; export declare const MAX_PATTERN_FILES = 20; export declare const MAX_LESSON_FILES = 3; export interface Lesson { readonly id: string; readonly kind: 'lesson' | 'caution'; readonly agent: string; readonly keywords: string[]; readonly confidence: number; readonly successes: number; readonly failures: number; readonly evidence: string; /** ADR-511: files the passing fixes edited, most often first (a lesson only). */ readonly files?: string[]; } export interface LessonsFile { version: 1; gate: number; generatedAt: number; lessons: Lesson[]; /** Verified patterns still below the gate, for the cold-start progress line. */ belowGate: number; /** Patterns at or above the gate that the anomaly gate kept out of the prompt (ADR-503 §2.4). */ held: Array<{ id: string; reason: HoldReason; }>; } /** What `SonaLike.exportPatterns()` returns. */ export type PatternExport = Record; /** The ledger's view of one verified pattern that buildLessons reads. */ export interface VerifiedPattern { evidence: string; at: number; stats?: PatternStats; /** ADR-511: edited file → verified successes that edited it. */ files?: Record; } /** * ADR-511: whether a path may be named in a lesson. Project-relative source files only: no absolute path, no `..`, * no dot-file or dot-directory, no name that may hold a secret, no test file and no verifier config. */ export declare function lessonFile(path: unknown): path is string; /** A record's `files`, screened. */ export declare const recordFiles: (raw: unknown) => string[]; /** A ledger pattern's file counts, screened; a hostile ledger keeps nothing it should not. */ export declare function parseFileCounts(raw: unknown): Record; /** Counts one verified success's files; past the cap, the least-counted file makes room. */ export declare function addFiles(counts: Record, files: readonly string[]): void; /** The files a lesson names: most often first, ties by name, at most three. */ export declare const topFiles: (counts: Record | undefined) => string[]; /** A lesson's citation: a short hash of the SONA pattern key, so the key's own text never reaches a prompt. */ export declare const lessonId: (patternKey: string) => string; /** * Builds the lessons file from SONA's patterns, keeping only the ones verified outcomes trained. A would-be lesson the * anomaly gate holds (ADR-503 §2.4) is listed under `held` instead: it stays in SONA, never in a prompt. */ export declare function buildLessons(patterns: PatternExport, verified: Record, now: number): LessonsFile; //# sourceMappingURL=verified-lessons.d.ts.map