Skip to content

Commit a0892c9

Browse files
committed
fix(wasm): sort aliasTargets by confidence in pts fallback paths
The Phase 8.3 and Phase 8.3f pts alias loops iterated aliasTargets without sorting first. The native engine's emit_pts_alias_edges calls sort_targets_by_confidence before the alias loop (build_edges.rs:398), ensuring the highest-confidence target wins the ptsEdgeRows dedup. Apply the same descending-confidence sort to both TS pts fallback paths to close this parity gap.
1 parent 6cf61d8 commit a0892c9

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/domain/graph/builder/stages/build-edges.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,15 @@ function buildFileCallEdges(
12011201
importedNames,
12021202
typeMap as Map<string, unknown>,
12031203
);
1204-
for (const t of aliasTargets) {
1204+
const sortedAliasTargets =
1205+
aliasTargets.length > 1
1206+
? [...aliasTargets].sort(
1207+
(a, b) =>
1208+
computeConfidence(relPath, b.file, aliasFrom ?? null) -
1209+
computeConfidence(relPath, a.file, aliasFrom ?? null),
1210+
)
1211+
: aliasTargets;
1212+
for (const t of sortedAliasTargets) {
12051213
const edgeKey = `${caller.id}|${t.id}`;
12061214
if (t.id !== caller.id && !seenCallEdges.has(edgeKey) && !ptsEdgeRows.has(edgeKey)) {
12071215
const conf =
@@ -1237,7 +1245,15 @@ function buildFileCallEdges(
12371245
importedNames,
12381246
typeMap as Map<string, unknown>,
12391247
);
1240-
for (const t of aliasTargets) {
1248+
const sortedAliasTargets =
1249+
aliasTargets.length > 1
1250+
? [...aliasTargets].sort(
1251+
(a, b) =>
1252+
computeConfidence(relPath, b.file, aliasFrom ?? null) -
1253+
computeConfidence(relPath, a.file, aliasFrom ?? null),
1254+
)
1255+
: aliasTargets;
1256+
for (const t of sortedAliasTargets) {
12411257
const edgeKey = `${caller.id}|${t.id}`;
12421258
if (t.id !== caller.id && !seenCallEdges.has(edgeKey) && !ptsEdgeRows.has(edgeKey)) {
12431259
const conf =

0 commit comments

Comments
 (0)