/** * `dim check` (KARPATHY_LAYERS Feature 4) — Verifier layer, shifted left. * * Verification today runs *after* code lands (post-merge hook). `dim check` * runs it against a diff BEFORE the commit, so contradictions are caught at * author time. It analyzes `git diff --staged` (or an arbitrary ref) against * the memories scoped to the changed files: * * - STATIC_CHECK evidence → re-run; a FAIL means the change broke the claim * - GUARDRAIL (never) → keyword-match the added lines against the claim * - INVARIANT / CONVENTION scoped to a changed file → advisory reminder * * Exit policy is the caller's: warn (exit 0) by default, block (exit 1) opt-in. */ import type { MemoryStore } from "../db/store.js"; import type { MemoryEntry } from "../types.js"; export interface DiffFile { path: string; addedLines: string[]; } export type Severity = "fail" | "warn"; export interface CheckViolation { memory: MemoryEntry; severity: Severity; detail: string; } export interface CheckReport { changedFiles: string[]; checked: number; violations: CheckViolation[]; } /** Parse a unified diff (—U0) into per-file added lines. */ export declare function parseDiff(diff: string): DiffFile[]; /** Run `git diff` for staged changes (default) or against a ref. */ export declare function gitDiff(repoRoot: string, ref?: string): string; /** * Evaluate whether a FAILED_APPROACH memory's `appliesWhen` conditions are * satisfied by the current change context. Conditions can be: * - `path:` — matches if any changed file starts with the pattern * - `symbol:` — matches if the symbol appears in added lines * - `keyword:` — matches if the term appears in added text * - `original_commit:` — always matches (historical reference, not a precondition) * - bare text — treated as a keyword match * Returns true if all conditions are satisfied (or if no conditions are given). */ export declare function evaluateAppliesWhen(appliesWhen: string[] | undefined, changedFiles: string[], addedText: string): boolean; export declare function checkDiffText(store: MemoryStore, diff: string, repoRoot: string): CheckReport; export declare function checkDiff(store: MemoryStore, repoRoot: string, opts?: { ref?: string; }): CheckReport;