import type { CompiledRule } from './compiler.js'; /** * Valid values for the `surface:` frontmatter field on a test fixture. * * Per ADR-104 § Convergence: the existing single-file fixture schema is * extended additively with `surface: rules | hooks`. The field dispatches * which matcher consumes the fixture. Defaults to `'rules'` when absent * (backwards-compat for existing fixtures predating the hook engine). */ export declare const FIXTURE_SURFACES: readonly ["rules", "hooks"]; export type FixtureSurface = (typeof FIXTURE_SURFACES)[number]; /** * Valid values for the `corpus:` frontmatter field on a test fixture. * * Per ADR-104 § Convergence: tags a fixture as a positive (`pass`) or * negative (`fail`) case. Defaults to `'pass'` when absent (backwards-compat * for existing dual-section rules-surface fixtures, where the pass/fail * semantic was carried by ## section headings inside the fixture body). */ export declare const FIXTURE_CORPORA: readonly ["pass", "fail"]; export type FixtureCorpus = (typeof FIXTURE_CORPORA)[number]; /** * Fixture for verifying compiled rule patterns against examples. * Used by the rule testing infrastructure to validate hits (fail lines) * and misses (pass lines) for regex and AST-grep rules. * * The `surface` and `corpus` fields are filled with their defaults when * absent from the fixture frontmatter (ADR-104 § Convergence — additive, * backwards-compatible). PR-1's runtime keeps the existing dual-section * behavior on `surface: rules`; the hooks-surface dispatch lands in the * PR-1 follow-on. */ export interface RuleTestFixture { /** lessonHash of the rule to test */ ruleHash: string; /** Virtual file path for glob matching (e.g., "src/example.ts") */ filePath: string; /** Lines that SHOULD trigger the rule */ failLines: string[]; /** Lines that should NOT trigger the rule */ passLines: string[]; /** Source file path of the fixture */ fixturePath: string; /** * Which matcher pipeline consumes this fixture. Always populated by * `parseFixture` (defaults to `'rules'`). Marked optional so existing * call sites that construct fixtures inline (test scaffolding, the * compile pipeline) compile without per-site updates. */ surface?: FixtureSurface; /** * Whether the fixture asserts a positive or negative case. Always * populated by `parseFixture` (defaults to `'pass'`). Optional for the * same reason as `surface`. */ corpus?: FixtureCorpus; } export interface RuleTestResult { ruleHash: string; ruleHeading: string; fixturePath: string; /** Lines from fail section that did NOT trigger (false negatives) */ missedFails: string[]; /** Lines from pass section that DID trigger (false positives) */ falsePositives: string[]; /** Whether the test passed (no missed fails AND no false positives) */ passed: boolean; } export interface RuleTestSummary { total: number; passed: number; failed: number; skipped: number; skippedFixtures: { path: string; ruleHash: string; ruleHeading: string; }[]; results: RuleTestResult[]; } /** Return true when every line in the fixture is a scaffolding placeholder. */ export declare function isTodoFixture(fixture: RuleTestFixture): boolean; export declare function parseFixture(content: string, fixturePath: string): RuleTestFixture | null; /** Generate a markdown test fixture skeleton compatible with {@link parseFixture}. */ export declare function scaffoldFixture(opts: { ruleHash: string; filePath?: string; failLines?: string[]; passLines?: string[]; heading?: string; }): string; /** Return the canonical fixture path for a given rule hash: `/test-.md`. */ export declare function scaffoldFixturePath(testsDir: string, ruleHash: string): string; /** * Existing test infrastructure for compiled rule verification. * Validates regex patterns against hit/miss examples from fixture files. * Use this instead of building new verification functions. */ export declare function testRule(rule: CompiledRule, fixture: RuleTestFixture): RuleTestResult; export declare function loadFixtures(testsDir: string): RuleTestFixture[]; export declare function runRuleTests(rulesPath: string, testsDir: string): RuleTestSummary; //# sourceMappingURL=rule-tester.d.ts.map