/** * Contract-based rule executor that evaluates rules through the canonical contract layer. * This executor provides the same results as the legacy RuleEngine but with contract validation. */ import type { Finding } from "../rules/types"; import type { LoadedRule } from "../rules/loader"; /** * Configuration for the contract rule executor. */ export type ContractRuleExecutorOptions = { /** * Whether to validate rules against the contract on load. * Enables early error detection but adds minimal overhead. */ validateOnLoad?: boolean; /** * Whether to validate findings against the FindingSchema contract. * Catches schema violations for observability. */ validateFindings?: boolean; /** * Whether to enforce compatibility constraints. * If false, deprecated rules will still execute. */ enforceCompatibility?: boolean; }; /** * Contract-based rule executor that evaluates rules through the contract layer. * This executor is a drop-in replacement for RuleEngine with contract validation. */ export declare class ContractRuleExecutor { private readonly loadedRules; private readonly options; constructor(loadedRules: readonly LoadedRule[], options?: ContractRuleExecutorOptions); /** * Validates all loaded rules against the RuleDefinition contract. * Throws an error if any rule fails validation. */ private validateRules; /** * Converts a RuleMatch + Finding data into a canonical FindingSchema. */ private toFindingSchema; /** * Evaluates all loaded rules against a file using the contract layer. * Returns findings in the same format as the legacy RuleEngine for compatibility. * * @param filePath Normalized file path for location tracking * @param content Complete file content * @returns Array of findings, deterministically ordered */ evaluate(filePath: string, content: string): Finding[]; /** * Gets information about loaded rules for diagnostics. */ getRuleInfo(): Array<{ ruleId: string; name: string; compatible: boolean; reason?: string; }>; }