Skip to content

Commit fc6bc92

Browse files
committed
fix(cha): add self-loop guard to runPostNativeCha and TODO for confidence alignment (#1514)
runPostNativeCha's BFS inner loop was missing the same self-loop guard already added to runChaPostPass and runPostNativeThisDispatch, allowing B.m→B.m edges to persist on the native CHA path when super-dispatch triggers CHA expansion. Also adds a TODO comment on the hardcoded 0.8 confidence in runChaPostPass noting it needs alignment with the formula used in runPostNativeCha (requires extending findMethodStmt to fetch file).
1 parent 893af0f commit fc6bc92

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/domain/graph/builder/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
515515
const key = `${source_id}|${methodNode.id}`;
516516
if (seen.has(key)) continue;
517517
seen.add(key);
518-
newEdges.push([source_id, methodNode.id, 'calls', 0.8, 0, 'cha']);
518+
newEdges.push([source_id, methodNode.id, 'calls', 0.8, 0, 'cha']); // TODO: align with runPostNativeCha: computeConfidence(callerFile, methodFile) - CHA_DISPATCH_PENALTY (requires extending findMethodStmt to fetch file)
519519
}
520520
}
521521

src/domain/graph/builder/stages/native-orchestrator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ function runPostNativeCha(
654654
method_file: string | null;
655655
}>;
656656
for (const methodNode of methodNodes) {
657+
if (methodNode.id === source_id) continue; // skip self-loops
657658
const key = `${source_id}|${methodNode.id}`;
658659
if (seen.has(key)) continue;
659660
seen.add(key);

0 commit comments

Comments
 (0)