001package gudusoft.gsqlparser.analyzer.v2;
002
003/**
004 * Configuration for the IR-based Analyzer v2 system.
005 * <p>
006 * Controls feature flags, analysis depth, dynamic SQL handling,
007 * and output formatting. Supports gradual rollout via dual-track mode.
008 *
009 * <pre>
010 * Rollout stages:
011 *   Stage 1: useIRPath=false, enableLegacyDiff=false  → Pure legacy
012 *   Stage 2: useIRPath=false, enableLegacyDiff=true   → Legacy primary, IR parallel + diff
013 *   Stage 3: useIRPath=true,  enableLegacyDiff=true   → IR primary, legacy fallback
014 *   Stage 4: useIRPath=true,  enableLegacyDiff=false  → IR only, legacy removable
015 * </pre>
016 */
017public class AnalyzerV2Config {
018
019    // === Path Control ===
020
021    /** Whether to enable the new IR path (default off, gradually enable during rollout). */
022    public boolean useIRPath = false;
023
024    /** Whether to run legacy path in parallel and output diff report. */
025    public boolean enableLegacyDiff = false;
026
027    // === Dynamic SQL Strategy ===
028
029    /** Dynamic SQL parsing strategy. */
030    public EDynamicSqlStrategy dynamicSqlStrategy = EDynamicSqlStrategy.BEST_EFFORT;
031
032    // === Analysis Depth Control ===
033
034    /** Maximum call graph depth (prevents infinite expansion on cyclic dependencies). */
035    public int maxCallGraphDepth = 50;
036
037    /** Whether to track cursor data flow (OPEN/FETCH/CLOSE lifecycle). */
038    public boolean trackCursorDataFlow = true;
039
040    /** Whether to track exception control flow (EXCEPTION WHEN → handler). */
041    public boolean trackExceptionFlow = true;
042
043    // === Output Control ===
044
045    /** Whether JSON output includes detailed sourceAnchor information. */
046    public boolean includeSourceAnchors = true;
047
048    /** Whether JSON output includes evidence chains. */
049    public boolean includeEvidence = true;
050
051    // === Factory Methods ===
052
053    /**
054     * Creates default configuration (legacy path, IR disabled).
055     */
056    public static AnalyzerV2Config createDefault() {
057        return new AnalyzerV2Config();
058    }
059
060    /**
061     * Creates IR-enabled configuration.
062     */
063    public static AnalyzerV2Config createIREnabled() {
064        AnalyzerV2Config config = new AnalyzerV2Config();
065        config.useIRPath = true;
066        return config;
067    }
068
069    /**
070     * Creates dual-track configuration for regression testing.
071     * Both IR and legacy paths run, with diff reporting enabled.
072     */
073    public static AnalyzerV2Config createDualTrack() {
074        AnalyzerV2Config config = new AnalyzerV2Config();
075        config.useIRPath = true;
076        config.enableLegacyDiff = true;
077        return config;
078    }
079}