/** * Main decompilation entry points. * * This module contains the primary functions for decompiling dimensional * rules back into pattern representation. */ import type { DimensionalRule, PatternDecompileResult } from '../dsl-types'; /** * Decompile a dimensional rule into pattern representation. * * This function transforms low-level dimensional rules back into readable * pattern templates. It uses a catalog of pattern mappings with confidence * scoring to find the best representation. * * The decompilation process: * 1. Validates the input dimensional rule * 2. Finds all pattern mappings that match the dimensions * 3. Calculates confidence scores for each match * 4. Returns the best match with alternatives * * If no patterns match, it falls back to creating a generic pattern based * on the action (e.g., "modified \{target\}"). * * @param dimensional - The dimensional rule to decompile * @returns Decompilation result with pattern, confidence, and alternatives * * @example Basic decompilation * ```typescript * const result = decompileToPattern({ * type: 'dimensional', * action: ['removed'], * target: ['export'], * impact: ['narrowing'], * returns: 'major' * }) * * if (result.success) { * console.log(result.pattern?.template) // 'removed {target}' * console.log(result.confidence) // ~0.8 * console.log(result.alternatives?.length) // 0-3 alternatives * } * ``` * * @example Type change decompilation * ```typescript * const result = decompileToPattern({ * type: 'dimensional', * action: ['modified'], * aspect: ['type'], * impact: ['narrowing'], * target: ['return-type'], * returns: 'major' * }) * // result.pattern.template = '{target} type narrowed' * // result.confidence ≈ 0.9 (high due to aspect + impact match) * ``` * * @example Fallback for unrecognized dimensions * ```typescript * const result = decompileToPattern({ * type: 'dimensional', * returns: 'patch' * // No action, aspect, or target specified * }) * // Falls back to 'modified {target}' with low confidence (0.2) * ``` * * @alpha */ export declare function decompileToPattern(dimensional: DimensionalRule): PatternDecompileResult; /** * Find the best matching pattern template for a dimensional rule. * * This is a convenience function that returns just the template string * without the full decompilation result. Useful for quick lookups or * when you only need the template. * * @param dimensional - The dimensional rule to match * @returns Best matching pattern template string, or null if invalid input * * @example * ```typescript * const template = findBestPattern({ * type: 'dimensional', * action: ['removed'], * target: ['export'], * returns: 'major' * }) * // Returns: 'removed {target}' * ``` * * @example With confidence threshold * ```typescript * const template = findBestPattern(rule) * // Returns fallback template if no match has confidence >= 0.3 * ``` * * @alpha */ export declare function findBestPattern(dimensional: DimensionalRule): string | null; //# sourceMappingURL=decompiler.d.ts.map