/** * Detector Worker - Worker thread for running pattern detectors * * This worker runs in a separate thread and handles: * - Loading and running detectors on file content * - Tree-sitter AST parsing * - Pattern matching and violation detection * * @requirements 2.6 - Parallel file processing with worker threads */ /** * Warmup task - preloads detectors without processing files */ export interface WarmupTask { type: 'warmup'; categories?: string[] | undefined; criticalOnly?: boolean | undefined; } /** * Warmup result */ export interface WarmupResult { type: 'warmup'; detectorsLoaded: number; duration: number; } /** * Task input for detector worker */ export interface DetectorWorkerTask { /** Task type - 'scan' for file processing, 'warmup' for preloading */ type?: 'scan' | undefined; /** Relative path to the file */ file: string; /** Root directory */ rootDir: string; /** Project files list (for context) */ projectFiles: string[]; /** Project config */ projectConfig: Record; /** Detector IDs to run (empty = all) */ detectorIds?: string[] | undefined; /** Categories to filter by */ categories?: string[] | undefined; /** Only run critical detectors */ criticalOnly?: boolean | undefined; } /** * Pattern match from detector * * Enhanced to preserve all metadata from detectors including: * - Full location range (endLine/endColumn) * - Outlier information (isOutlier, outlierReason) * - Matched text for context * - Custom detector metadata */ export interface WorkerPatternMatch { patternId: string; detectorId: string; detectorName: string; detectorDescription: string; category: string; subcategory: string; confidence: number; location: { file: string; line: number; column: number; /** End line for full range highlighting */ endLine?: number; /** End column for full range highlighting */ endColumn?: number; }; /** Whether this match deviates from the established pattern */ isOutlier?: boolean; /** Explanation for why this is an outlier */ outlierReason?: string; /** The actual text that was matched */ matchedText?: string; /** Custom metadata from the detector (auth types, route info, etc.) */ metadata?: Record; } /** * Violation from detector */ export interface WorkerViolation { patternId: string; detectorId: string; category: string; severity: 'error' | 'warning' | 'info' | 'hint'; file: string; line: number; column: number; message: string; explanation?: string | undefined; suggestedFix?: string | undefined; } /** * Result from detector worker */ export interface DetectorWorkerResult { /** File that was processed */ file: string; /** Detected language */ language: string | null; /** Pattern matches found */ patterns: WorkerPatternMatch[]; /** Violations found */ violations: WorkerViolation[]; /** Number of detectors that ran */ detectorsRan: number; /** Number of detectors skipped */ detectorsSkipped: number; /** Processing duration in milliseconds */ duration: number; /** Error message if processing failed */ error?: string | undefined; } /** * Process a single file with detectors * * This is the main export that Piscina will call for each task. */ export default function processFile(task: DetectorWorkerTask | WarmupTask): Promise; //# sourceMappingURL=detector-worker.d.ts.map