/** * Test Integrity Validator * * Detects circular test validation — the problem where AI agents generate * tests that only pass because they test the agent's own output, not real * behavior. A test that passes on both the pre-change and post-change * codebase proves nothing about the change. * * Strategy: * 1. Snapshot which test files existed before the agent ran * 2. After the run, identify NEW test files the agent created * 3. For each new test: check if it imports/references pre-existing code * (real test) or only references agent-generated code (circular test) * 4. Flag tests that don't exercise any pre-existing function * * This module provides the analysis primitives. The verification pipeline * calls these during the post-run verification step. */ export interface TestIntegrityReport { totalNewTests: number; realTests: number; suspiciousTests: number; findings: TestIntegrityFinding[]; verdict: "pass" | "warn" | "fail"; summary: string; } export interface TestIntegrityFinding { filePath: string; issue: "no_pre_existing_imports" | "self_referential" | "trivial_assertion" | "empty_test"; severity: "high" | "medium" | "low"; detail: string; } /** * Detect test files in a directory tree. */ export declare function findTestFiles(rootDir: string): string[]; /** * Check if a filename matches test file patterns. */ export declare function isTestFile(filename: string, fullPath?: string): boolean; /** * Snapshot existing test files before an agent run. */ export declare function snapshotTestFiles(rootDir: string): Set; /** * Identify new test files created during an agent run. */ export declare function identifyNewTests(rootDir: string, preRunSnapshot: Set): string[]; /** * Extract import paths from a TypeScript/JavaScript file. */ export declare function extractImports(content: string): string[]; /** * Check if a test file contains only trivial assertions. */ export declare function hasTrivialAssertionsOnly(content: string): boolean; /** * Check if a test file imports any pre-existing source files. */ export declare function importsPreExistingCode(testContent: string, preRunSourceFiles: Set): boolean; /** * Validate the integrity of tests created during a governed run. */ export declare function validateTestIntegrity(rootDir: string, preRunTestSnapshot: Set, preRunSourceFiles: Set): TestIntegrityReport;