diff --git a/src/domain/graph/builder/helpers.ts b/src/domain/graph/builder/helpers.ts index dd94ea2b..4dfd6f46 100644 --- a/src/domain/graph/builder/helpers.ts +++ b/src/domain/graph/builder/helpers.ts @@ -361,6 +361,9 @@ export function batchInsertEdges(db: BetterSqlite3Database, rows: unknown[][]): } } +/** Confidence assigned to CHA-expanded interface/abstract dispatch edges. */ +export const CHA_DISPATCH_CONFIDENCE = 0.8; + /** * CHA (Class Hierarchy Analysis) post-pass. * @@ -514,7 +517,7 @@ export function runChaPostPass(db: BetterSqlite3Database): number { const key = `${source_id}|${methodNode.id}`; if (seen.has(key)) continue; seen.add(key); - newEdges.push([source_id, methodNode.id, 'calls', 0.8, 0, 'cha']); + newEdges.push([source_id, methodNode.id, 'calls', CHA_DISPATCH_CONFIDENCE, 0, 'cha']); } } diff --git a/src/domain/graph/builder/stages/native-orchestrator.ts b/src/domain/graph/builder/stages/native-orchestrator.ts index e10de98e..bdfcd588 100644 --- a/src/domain/graph/builder/stages/native-orchestrator.ts +++ b/src/domain/graph/builder/stages/native-orchestrator.ts @@ -49,6 +49,7 @@ import type { PipelineContext } from '../context.js'; import { batchInsertEdges, batchInsertNodes, + CHA_DISPATCH_CONFIDENCE, collectFiles as collectFilesUtil, fileHash, fileStat, @@ -570,8 +571,8 @@ function runPostNativeCha( } // Find existing call edges targeting qualified methods (e.g., 'IWorker.doWork'). - // Include the caller node's file so confidence can be computed file-pair-aware, - // matching the WASM path's computeConfidence(callerFile, targetFile, null) - CHA_DISPATCH_PENALTY formula. + // Include caller_file and method_file so affectedFiles can be populated for + // incremental role reclassification; confidence is CHA_DISPATCH_CONFIDENCE matching runChaPostPass. // When scopeToChangedFiles is true, restrict to call sites in the changed files // (safe because no hierarchy or RTA evidence changed outside those files). let callToMethods: Array<{ source_id: number; method_name: string; caller_file: string | null }>; @@ -667,10 +668,7 @@ function runPostNativeCha( const key = `${source_id}|${methodNode.id}`; if (seen.has(key)) continue; seen.add(key); - // Use the same hardcoded 0.8 that runChaPostPass (helpers.ts) uses for - // DB-level CHA dispatch edges. This aligns the native orchestrator path - // with the WASM and hybrid paths, which both go through runChaPostPass. - const conf = 0.8; + const conf = CHA_DISPATCH_CONFIDENCE; newEdges.push([source_id, methodNode.id, 'calls', conf, 0, 'cha']); newEdgeCount++; if (caller_file) affectedFiles.add(caller_file); diff --git a/src/extractors/cpp.ts b/src/extractors/cpp.ts index e9065e5b..aacba4b5 100644 --- a/src/extractors/cpp.ts +++ b/src/extractors/cpp.ts @@ -5,7 +5,7 @@ import type { TreeSitterNode, TreeSitterTree, } from '../types.js'; -import { extractModifierVisibility, findChild, nodeEndLine } from './helpers.js'; +import { extractModifierVisibility, findChild, nodeEndLine, setTypeMapEntry } from './helpers.js'; /** * Extract symbols from C++ files. @@ -236,7 +236,7 @@ function handleCppDeclaration(node: TreeSitterNode, ctx: ExtractorOutput): void if (!nameNode) continue; const varName = unwrapCppDeclaratorName(nameNode); if (varName) { - ctx.typeMap.set(varName, { type: typeName, confidence: 0.9 }); + setTypeMapEntry(ctx.typeMap, varName, typeName, 0.9); } } } diff --git a/src/extractors/cuda.ts b/src/extractors/cuda.ts index f98726a7..2ec8364f 100644 --- a/src/extractors/cuda.ts +++ b/src/extractors/cuda.ts @@ -5,7 +5,7 @@ import type { TreeSitterNode, TreeSitterTree, } from '../types.js'; -import { extractModifierVisibility, findChild, nodeEndLine } from './helpers.js'; +import { extractModifierVisibility, findChild, nodeEndLine, setTypeMapEntry } from './helpers.js'; /** * Extract symbols from CUDA files. @@ -236,7 +236,7 @@ function handleCudaDeclaration(node: TreeSitterNode, ctx: ExtractorOutput): void if (!nameNode) continue; const varName = extractCudaFieldName(nameNode); if (varName) { - ctx.typeMap.set(varName, { type: typeName, confidence: 0.9 }); + setTypeMapEntry(ctx.typeMap, varName, typeName, 0.9); } } }