/**
 * Sugar Optimizer - Auto-detect @path routes from connections.
 *
 * Analyzes control-flow connections and identifies routes through the graph
 * that can be expressed as @path macros. @connect is the escape hatch for
 * connections that @path can't cover.
 */
import type { TConnectionAST, TNodeInstanceAST, TNodeTypeAST, TWorkflowMacro, TPathMacro, TPortDefinition } from './ast/types.js';
export interface DetectedSugar {
    paths: TPathMacro[];
}
/**
 * Validate that a @path macro's connections still exist in the actual
 * connection set. Checks both control-flow AND data connections (scope
 * walking). Also checks that all step nodes exist as instances (or are
 * Start/Exit).
 *
 * Returns true if the path is still valid, false if it should be dropped.
 *
 * When nodeTypes/startPorts/exitPorts are provided, data connections are
 * validated using the same scope-walking algorithm that expandPathMacros
 * uses. Without them, only control-flow is checked (legacy behavior).
 */
export declare function validatePathMacro(path: TPathMacro, connections: TConnectionAST[], instances: TNodeInstanceAST[], nodeTypes?: TNodeTypeAST[], startPorts?: Record<string, TPortDefinition>, exitPorts?: Record<string, TPortDefinition>): boolean;
/**
 * Filter existing macros, removing any @path macros whose connections
 * (control-flow AND data) no longer exist in the connection set.
 * Non-path macros are passed through unchanged.
 */
export declare function filterStaleMacros(macros: TWorkflowMacro[], connections: TConnectionAST[], instances: TNodeInstanceAST[], nodeTypes?: TNodeTypeAST[], startPorts?: Record<string, TPortDefinition>, exitPorts?: Record<string, TPortDefinition>): TWorkflowMacro[];
/**
 * Detect @path routes from a set of connections.
 *
 * Algorithm:
 * 1. Build control-flow adjacency from unscoped connections
 * 2. DFS from Start to enumerate all Start-to-Exit routes
 * 3. Validate data connections for each candidate (scope walking safety)
 * 4. Greedy route selection to cover all control-flow edges
 */
export declare function detectSugarPatterns(connections: TConnectionAST[], instances: TNodeInstanceAST[], existingMacros: TWorkflowMacro[], nodeTypes: TNodeTypeAST[], startPorts: Record<string, TPortDefinition>, exitPorts: Record<string, TPortDefinition>): DetectedSugar;
/**
 * Check if a connection is covered by detected sugar and should be omitted from @connect output.
 */
export declare function isConnectionCoveredBySugar(conn: TConnectionAST, sugar: DetectedSugar): boolean;
//# sourceMappingURL=sugar-optimizer.d.ts.map