/** * MCP tool handlers for call-graph analysis: * get_call_graph, get_subgraph, analyze_impact, get_critical_hubs, * get_leaf_functions, get_low_risk_refactor_candidates, get_god_functions, * trace_execution_path. */ import type { CachedContext } from './utils.js'; import type { SerializedCallGraph, FunctionNode } from '../../analyzer/call-graph.js'; import type { DecisionNode } from '../../decisions/project.js'; /** * Build forward (caller→callees) and backward (callee→callers) adjacency maps * from a serialised call graph, returning both maps and a node lookup. * * Inheritance propagation rides on the materialized, provenance-labeled override * edges (`kind: 'overrides'`, `confidence: 'synthesized'`) the CHA pass writes into * `cg.edges` (spec: add-type-hierarchy-resolved-dispatch) — read here through the * same edge loop as call edges, so the in-memory and DB-backed paths agree and * `directResolvedOnly` excludes them for free. This replaces the prior class-level * all-parent-methods × all-child-methods cross-product, which connected unrelated * methods, silently dropped class pairs whose product exceeded 200, and existed * only here (so it disagreed with the DB-backed reachability path). */ export declare function buildAdjacency(cg: SerializedCallGraph, opts?: { directResolvedOnly?: boolean; }): { nodeMap: Map; forward: Map>; backward: Map>; }; /** BFS up to `maxDepth`. Returns a map of visited node-id → depth reached. */ export declare function bfs(seeds: string[], adjacency: Map>, maxDepth: number): Map; /** * DB-backed lazy BFS — fetches only edges for visited nodes instead of loading all edges. * direction: 'forward' = downstream (callees), 'backward' = upstream (callers). */ export declare function bfsFromDB(seeds: string[], direction: 'forward' | 'backward', maxDepth: number, es: CachedContext['edgeStore'], opts?: { directResolvedOnly?: boolean; }): Map; /** A node's minimal accumulated call-distance from the seed set. */ export interface WeightedReach { /** Sum of edge call-distances along the cheapest path from a seed. */ distance: number; /** Hop count along that cheapest-distance path. */ hops: number; /** Predecessor node id on that path, or null for a seed. */ predecessor: string | null; } /** * Build weighted forward/backward adjacency from `calls` edges, each weighted by * {@link callDistance}. External (Infinity-cost) edges are omitted so internal * scoping never routes through synthetic stdlib/HTTP leaves. */ export declare function buildWeightedAdjacency(cg: SerializedCallGraph): { forward: Map; backward: Map; }; /** * Dijkstra over a weighted adjacency (small in-memory neighbourhoods; a linear * min-frontier scan is cheaper than a heap here). Returns each reachable node's * minimal accumulated call-distance, the hop count along that cheapest path, and * its predecessor — sufficient to reconstruct the path. Seeds start at distance * 0; nodes whose distance would exceed `maxDistance` are never expanded. */ export declare function weightedBfs(seeds: string[], adjacency: Map>, maxDistance: number): Map; /** * Compute a risk score [0–100] for a node. * * Weights: fan-in × 4, fan-out × 2, isHub × 20, blastRadius × 1.5. Capped at 100. */ export declare function computeRiskScore(node: FunctionNode, blastRadius: number, isHub: boolean): number; /** Derive a plain-language refactoring strategy from the risk profile. */ export declare function recommendStrategy(riskScore: number, fanIn: number, fanOut: number, isHub: boolean): { approach: string; rationale: string; }; export declare function nodeToSummary(n: FunctionNode | undefined): { name: string; file: string; className: string | null; depth: number; }; /** * Render a projected decision node as a typed graph neighbor (spec-16). * `nodeType: 'decision'` lets callers distinguish governing decisions from code nodes. */ export declare function decisionToNeighbor(d: DecisionNode): { supersedes?: string | undefined; nodeType: "decision"; id: string; title: string; status: import("../../../types/index.js").DecisionStatus; rationale: string; consequences: string; affectedDomains: string[]; governs: string[]; }; /** A node is infrastructure if its language is one of the IaC ecosystems (spec-17). */ export declare function isInfraNode(n: FunctionNode | undefined): boolean; /** Render an IaC resource node as a typed cross-domain neighbor (spec-17). */ export declare function infraToNeighbor(n: FunctionNode, direction: 'upstream' | 'downstream', depth: number): { nodeType: "infrastructure"; name: string; file: string; ecosystem: string; direction: "upstream" | "downstream"; depth: number; }; /** * Return the call graph summary from cached analysis. */ export declare function handleGetCallGraph(directory: string): Promise; /** * Extract a depth-limited subgraph centred on a named function. * Falls back to semantic search if no exact name match is found. */ export declare function handleGetSubgraph(directory: string, functionName: string, direction?: 'downstream' | 'upstream' | 'both', maxDepth?: number, format?: 'json' | 'mermaid', directResolvedOnly?: boolean): Promise; /** * Deep impact analysis for a single symbol. * Falls back to semantic search if no exact name match is found. */ export declare function handleAnalyzeImpact(directory: string, symbol: string, depth?: number, directResolvedOnly?: boolean, valueLevel?: boolean, valueParam?: string): Promise; /** * Return the N safest functions to refactor. */ export declare function handleGetLowRiskRefactorCandidates(directory: string, limit?: number, filePattern?: string): Promise; /** * Return leaf functions (fan-out === 0). */ export declare function handleGetLeafFunctions(directory: string, limit?: number, filePattern?: string, sortBy?: 'fanIn' | 'name' | 'file'): Promise; /** * Return critical hub functions ranked by composite criticality. */ export declare function handleGetCriticalHubs(directory: string, limit?: number, minFanIn?: number): Promise; /** * Detect god functions (high fan-out) and return their call-graph neighborhood. */ export declare function handleGetGodFunctions(directory: string, filePath?: string, fanOutThreshold?: number): Promise; /** * Return the file-level import dependencies for a given file. * * Uses the dependency-graph.json produced by `openlore analyze`. * direction: * "imports" — files this file depends on (outgoing edges) * "importedBy" — files that depend on this file (incoming edges) * "both" — both directions */ export declare function handleGetFileDependencies(directory: string, filePath: string, direction?: 'imports' | 'importedBy' | 'both'): Promise; /** * Find all execution paths between two functions in the call graph. * Useful for debugging: "how does request X reach function Y?", * "which call chain produced this error?". * * Uses DFS with visited-set cycle detection. Returns paths ordered * by hop count (shortest first), capped at maxPaths. */ export declare function handleTraceExecutionPath(directory: string, entryFunction: string, targetFunction: string, maxDepth?: number, maxPaths?: number, directResolvedOnly?: boolean, valueLevel?: boolean, valueParam?: string): Promise; //# sourceMappingURL=graph.d.ts.map