/** * Self-Expanding Formal Verification — Phase 1 Entry Point * * Pipeline: LLM finds bug → pattern extractor → rule codifier → validation → catalog * * Usage: * // After a scan confirms a finding: * const result = await learnFromFinding(projectPath, input); * * // During a scan, run learned rules alongside hand-crafted ones: * const findings = await runLearnedRules(projectPath, code, language); */ export { extractPattern, getSupportedCategories, resetPatternCounter } from './pattern-extractor.js'; export { normalizeCategory, CANONICAL_CATEGORIES, CATEGORY_MAP } from './category-map.js'; export type { CanonicalCategory } from './category-map.js'; export { codifyRule, executeRule, updateRuleStatus, recordRuleFire, resetRuleCounter } from './rule-codifier.js'; export { validateRule, getValidationThresholds } from './validation-harness.js'; export { STARTER_RULES } from './starter-catalog.js'; export { loadRules, saveRules, addRule, updateRule, getPromotedRules, getCandidateRules, getRulesByCategory, loadStats, } from './learned-catalog.js'; export type { ExtractedPattern, LearnedRule, LearnedRuleStatus, PatternExtractionInput, PatternExtractionResult, SourceFinding, ValidationResult, TestCase, PatternKind, PRReviewComment, DiscoveredPR, DiffHunk, ParsedPRDiff, GeneralizedRule, } from './types.js'; import type { PatternExtractionInput, LearnedRule } from './types.js'; /** * Tracks per-rule fire counts across files within a single `assay assess` run. * * After a rule fires in >30% of files scanned so far (minimum 5 files), * it is suppressed for the remainder of the scan. * * Create one per scan run and pass it to `runLearnedRules()`. */ export declare class ScanSession { /** Total files processed so far. */ private fileCount; /** ruleId → number of files where the rule fired. */ private readonly fireCounts; /** Rules that have been permanently suppressed for this session. */ private readonly suppressed; /** Call once per file, before running rules on that file. */ recordFile(): void; /** Record that a rule fired on the current file. */ recordFire(ruleId: string): void; /** Check whether a rule should be suppressed. */ isSuppressed(ruleId: string): boolean; /** Snapshot of session stats (useful for diagnostics). */ stats(): ScanSessionStats; } /** Diagnostic snapshot of a scan session. */ export interface ScanSessionStats { readonly filesScanned: number; readonly suppressedRules: string[]; readonly fireCounts: Record; } export interface LearnResult { /** Whether a new rule was created. */ readonly learned: boolean; /** The rule, if created. */ readonly rule?: LearnedRule; /** Why learning didn't produce a rule. */ readonly reason?: string; } /** * Full pipeline: extract pattern → codify rule → validate → store. * * Call this after confirming an LLM finding is correct. * The system will try to extract a generalizable pattern and * create a formal rule that catches future instances. * * @param projectPath - Root of the project being scanned. * @param input - The confirmed finding with code context. * @returns Whether a rule was learned and stored. */ export declare function learnFromFinding(projectPath: string, input: PatternExtractionInput): Promise; /** * Run all promoted learned rules against code. * * Returns findings from rules that fire. * These run alongside the hand-crafted formal checks. * * @param session - Optional scan session for noise suppression. * When provided, rules that fire on >30% of files (min 5 files) * are suppressed for the remainder of the scan. The caller must * call `session.recordFile()` before each invocation. */ export declare function runLearnedRules(projectPath: string, code: string, language: string, session?: ScanSession): Promise; /** A finding produced by a learned rule. */ export interface LearnedRuleFinding { readonly ruleId: string; readonly description: string; readonly severity: 'critical' | 'high' | 'medium'; readonly category: string; readonly evidence: string; readonly matches: string[]; /** Confidence based on the rule's track record. */ readonly confidence: number; /** Whether this finding came from the server catalog or local starter rules. */ readonly source?: 'server' | 'local'; } /** * Get a summary of the learned rule system status. */ export declare function getLearnedRulesSummary(projectPath: string): Promise<{ total: number; promoted: number; candidates: number; rejected: number; categories: string[]; totalFires: number; }>;