Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2b6a00d
fix: scope codegraph batch complexity targets to file paths
carlos-alm Jul 5, 2026
b28051a
fix: exclude parameters and interface/type members from dead-role cla…
carlos-alm Jul 5, 2026
17fbcba
fix: credit import-type usages as exports consumers
carlos-alm Jul 5, 2026
26918bb
fix: prevent fn-impact/query crash when -f/--file is passed
carlos-alm Jul 5, 2026
be6432c
fix: correct exported-symbol detection for literal and object-literal…
carlos-alm Jul 5, 2026
4ead840
fix: exclude primitive type keywords from ast --kind string matching
carlos-alm Jul 5, 2026
f6326bf
fix: resolve call edges through renamed import specifiers
carlos-alm Jul 5, 2026
590f560
fix: couple file_hashes updates with edge regeneration in incremental…
carlos-alm Jul 5, 2026
d3ea4a4
fix: compare signature-change diffs using new-file line ranges
carlos-alm Jul 5, 2026
c306812
feat: add environment doctor check for stale native binary and missin…
carlos-alm Jul 5, 2026
8bb5893
fix: eliminate non-deterministic ordering in community detection
carlos-alm Jul 6, 2026
46037b1
fix: sync update-graph.sh hook extension allowlist with EXTENSIONS
carlos-alm Jul 6, 2026
6a84cf9
fix: recompute directory structure metrics for affected directories o…
carlos-alm Jul 6, 2026
8d936d1
refactor: register hardcoded execFileSync/execSync maxBuffer values i…
carlos-alm Jul 6, 2026
11c84be
fix: gate blast-radius check on newly introduced risk, not pre-existi…
carlos-alm Jul 6, 2026
963301a
fix: gate identifier-argument dynamic call edges on callback-acceptin…
carlos-alm Jul 6, 2026
3e8035d
fix: gate Array.from's callback arg by position, not just callee name
carlos-alm Jul 6, 2026
879635e
fix: scope reexportedSymbols to actually-named re-export specifiers
carlos-alm Jul 6, 2026
0fe9fc3
fix: stop CFG block/edge count from overriding AST-derived cyclomatic…
carlos-alm Jul 6, 2026
ccf3c19
fix: backfill edges.technique for incrementally-inserted calls edges
carlos-alm Jul 6, 2026
d5b1162
fix: wrap remote embedding JSON parse failure in EngineError
carlos-alm Jul 6, 2026
8971017
refactor: extract shared platform-default-path helper in config.ts
carlos-alm Jul 6, 2026
056c5e4
refactor: decompose loadConfig and related high-effort functions in c…
carlos-alm Jul 6, 2026
0738171
refactor: decompose findDbPath and openRepo in db/connection.ts (docs…
carlos-alm Jul 6, 2026
6f2423c
refactor: dedupe busy/locked error detection into isBusyOrLockedError
carlos-alm Jul 6, 2026
4c02378
fix: log statSync failures in findDbPath instead of silently swallowi…
carlos-alm Jul 6, 2026
0698e16
test: add direct unit coverage for closeDbPair/closeDbPairDeferred/cl…
carlos-alm Jul 6, 2026
4ac3b99
fix: correct blast-radius/fn-impact computation for line-shifted decl…
carlos-alm Jul 6, 2026
6767f09
feat: wire points-to solver max-iterations cap through DEFAULTS.analy…
carlos-alm Jul 6, 2026
5f6f30a
refactor: route console.log calls in domain/search through logger
carlos-alm Jul 6, 2026
b479318
refactor: reduce cyclomatic complexity of computeDeltaModularityDirected
carlos-alm Jul 6, 2026
c39ac40
refactor: unify impact-level rendering format between audit and fn-im…
carlos-alm Jul 6, 2026
067674f
refactor: dedupe computeSavings via pct helper and persist partial to…
carlos-alm Jul 6, 2026
f6807b4
fix: add main.rs driver to rust dynamic tracer fixture
carlos-alm Jul 6, 2026
1c07a54
fix: scope diff file-header detection to between-hunk positions
carlos-alm Jul 6, 2026
bf82aa2
fix: update titan-grind's dead-symbol script for current roles --json…
carlos-alm Jul 6, 2026
cd02d27
fix: thread configured busyTimeoutMs through remaining read-only quer…
carlos-alm Jul 6, 2026
980b5dc
fix: resolve computed string-literal keys in object-literal extractio…
carlos-alm Jul 6, 2026
4a873a3
fix: add same-class bare-call fallback to incremental rebuild path (d…
carlos-alm Jul 6, 2026
8f3348a
fix: unify Object.defineProperty accessor fallback kind-filtering bet…
carlos-alm Jul 6, 2026
acf804c
refactor: share chunked statement-cache primitive between builder and…
carlos-alm Jul 6, 2026
986c851
refactor: cache prepared statements in applyEdgeTechniquesAfterNative…
carlos-alm Jul 6, 2026
71e9174
fix: replace fixed-depth directory-proximity check with symmetric dis…
carlos-alm Jul 6, 2026
d2935cc
refactor: remove unreachable Partition delta-computation interface me…
carlos-alm Jul 6, 2026
6515186
fix: emit reference edges for function identifiers used as object-lit…
carlos-alm Jul 6, 2026
30c491a
refactor: unify call-ref and tests rendering format between audit and…
carlos-alm Jul 6, 2026
9db911b
fix: classify destructured bindings as constant, not function (docs c…
carlos-alm Jul 6, 2026
70559fc
refactor: adopt timeMedian in remaining benchmark timing loops
carlos-alm Jul 6, 2026
822e0eb
refactor: decompose runPerfBenchmarks in token-benchmark.ts
carlos-alm Jul 6, 2026
fcdfe7d
fix: attribute liveness to Lua functions assigned to global/builtin i…
carlos-alm Jul 6, 2026
ee6362c
refactor: extract shared sedi() helper for tracer scripts
carlos-alm Jul 6, 2026
d4e6212
fix: restore reflection dynamicKind for .call/.apply/.bind (docs chec…
carlos-alm Jul 6, 2026
aec5d2b
fix: restrict entry-role classification to function/method-kind symbo…
carlos-alm Jul 6, 2026
d250f8d
fix: credit destructured dynamic import() bindings as exports consumers
carlos-alm Jul 6, 2026
75978e2
fix: recognize Lua function nodes in complexity metrics computation (…
carlos-alm Jul 6, 2026
af17b6d
fix: scope global call-resolution fallback to same-language candidate…
carlos-alm Jul 6, 2026
efd7a0c
fix: resolve merge conflicts with main
carlos-alm Jul 8, 2026
040be44
fix: treat .h as ambiguous with C++ in language-family scoping (#1928)
carlos-alm Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1342,9 +1342,13 @@ fn emit_receiver_edge(
samefile_candidates
} else {
// Fall back to any cross-file class/struct/interface candidate.
// Cross-language candidates are never legitimate receiver targets
// (#1783) — a `new Foo()` in one language can't statically resolve to
// an unrelated same-named class in another. Mirrors JS resolveReceiverEdge.
ctx.nodes_by_name.get(effective_receiver).cloned().unwrap_or_default()
.into_iter()
.filter(|n| ctx.receiver_kinds.contains(n.kind.as_str()))
.filter(|n| ctx.receiver_kinds.contains(n.kind.as_str())
&& resolve::is_same_language_family(rel_path, &n.file))
.collect()
};

Expand Down Expand Up @@ -2393,6 +2397,65 @@ mod call_edge_tests {
);
}

/// Issue #1783: the global (cross-file) receiver fallback had no
/// language-consistency check at all, so `Widget.render()` in a Python
/// caller with no same-file `Widget` definition could resolve to an
/// unrelated same-named class declared in a JS file purely by name.
#[test]
fn receiver_edge_rejects_cross_language_match() {
let all_nodes = vec![
node(1, "main", "function", "widget.py", 3),
node(2, "Widget", "class", "widget.js", 1),
];

let files = vec![make_file(
"widget.py",
10,
vec![def("main", "function", 3, 8)],
vec![call("render", 7, Some("Widget"))],
vec![],
vec![],
)];

let edges = build_call_edges(files, all_nodes, vec![], MAX_SOLVER_ITERATIONS);

let receiver_edge = edges.iter().find(|e| e.kind == "receiver");
assert!(
receiver_edge.is_none(),
"a Python caller must not resolve a receiver edge to an unrelated same-named JS class; got: {:?}",
edges.iter().map(|e| (&e.kind, e.source_id, e.target_id)).collect::<Vec<_>>()
);
}

/// Same-language global receiver fallback must still work after the
/// #1783 language-scoping fix — only cross-language candidates are rejected.
#[test]
fn receiver_edge_still_resolves_same_language_cross_file_match() {
let all_nodes = vec![
node(1, "main", "function", "widget.py", 3),
node(2, "Widget", "class", "widget_impl.py", 1),
];

let files = vec![make_file(
"widget.py",
10,
vec![def("main", "function", 3, 8)],
vec![call("render", 7, Some("Widget"))],
vec![],
vec![],
)];

let edges = build_call_edges(files, all_nodes, vec![], MAX_SOLVER_ITERATIONS);

let receiver_edge = edges.iter().find(|e| e.kind == "receiver");
assert!(
receiver_edge.is_some(),
"same-language cross-file receiver fallback must still resolve; got: {:?}",
edges.iter().map(|e| (&e.kind, e.source_id, e.target_id)).collect::<Vec<_>>()
);
assert_eq!(receiver_edge.unwrap().target_id, 2);
}

/// Issue #1453: `this.logger.error()` inside `UserService.create` where the
/// constructor seeded the class-scoped key `UserService.logger → Logger`.
/// The resolver must fall back to the `ClassName.prop` typeMap key (#1323).
Expand Down
145 changes: 145 additions & 0 deletions crates/codegraph-core/src/domain/graph/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};

use rayon::prelude::*;

use crate::domain::parser::LanguageKind;
use crate::types::{ImportResolutionInput, PathAliases, ResolvedImport};

/// Check file existence using known_files set when available, falling back to FS.
Expand Down Expand Up @@ -307,6 +308,53 @@ fn directory_distance(a: &str, b: &str) -> usize {
dist
}

/// Coarse "language family" for a file, derived from its extension via
/// `LanguageKind::from_extension`. Collapses TypeScript/Tsx into the same
/// family as JavaScript: despite being distinct `LanguageKind` variants (one
/// per tree-sitter grammar), `.ts`/`.tsx` files routinely import from and
/// call into `.js` files and vice versa within the same project (this
/// codebase's own `src/` tree does this throughout) — treating them as
/// separate families would reject huge amounts of legitimate same-project
/// resolution. Every other `LanguageKind` variant keeps its own family,
/// preserving `from_extension`'s existing per-language extension groupings
/// (e.g. C's `.c`+`.h`, C++'s `.cpp`/`.cc`/`.cxx`/`.hpp`) — EXCEPT `.h`,
/// treated as ambiguous (returns `None`) rather than inheriting
/// `from_extension`'s C-only mapping: `from_extension` needs one canonical
/// grammar per extension, but a `.h` header is real-world ambiguous between
/// C and C++, and the extremely common case of a `.cpp` file calling into
/// its own project's `.h` header would otherwise be misclassified as
/// cross-language and rejected outright — a real regression from the
/// pre-#1783 same-directory score of 0.7 (Greptile review). This keeps the
/// C/C++-header case working without merging C and C++ source-file families
/// wholesale (`.c` vs `.cpp` intentionally do NOT merge — see
/// is_same_language_family_does_not_merge_c_and_cpp).
fn language_family(file: &str) -> Option<LanguageKind> {
if file.to_ascii_lowercase().ends_with(".h") {
return None;
}
match LanguageKind::from_extension(file) {
Some(LanguageKind::TypeScript) | Some(LanguageKind::Tsx) => Some(LanguageKind::JavaScript),
other => other,
}
}

/// True when `file_a` and `file_b` belong to the same language family, or
/// when either extension is unrecognised (ambiguous cases are not rejected —
/// they fall through to normal scoring). False only when both extensions are
/// recognised AND resolve to different families.
///
/// Guards the global-by-name call-resolution fallback against matching a
/// same-named symbol across unrelated languages — e.g. a Ruby file's bare
/// `load` call has no static relationship to a same-named `load` export in a
/// JS file, even when both happen to live in the same directory (issue
/// #1783). Mirrors `isSameLanguageFamily()` in resolve.ts.
pub fn is_same_language_family(file_a: &str, file_b: &str) -> bool {
match (language_family(file_a), language_family(file_b)) {
(Some(a), Some(b)) => a == b,
_ => true,
}
}

/// Compute proximity-based confidence for call resolution.
/// Mirrors `computeConfidence()` in resolve.ts.
pub fn compute_confidence(
Expand All @@ -325,6 +373,12 @@ pub fn compute_confidence(
return 1.0;
}
}
// Cross-language candidates are never legitimate call targets (#1783) —
// reject before scoring proximity so a same-directory, same-named symbol
// in an unrelated language can never pass the resolver's 0.5 threshold.
if !is_same_language_family(caller_file, target_file) {
return 0.0;
}

let caller_dir = Path::new(caller_file)
.parent()
Expand Down Expand Up @@ -558,4 +612,95 @@ mod tests {
// not a direct sibling pair despite sharing the `src` ancestor.
assert_eq!(directory_distance("src/graph/algorithms", "src/features"), 3);
}

// Regression tests for #1783: the global-by-name call-resolution fallback
// had no language-consistency check at all, so a bare-name call with no
// import/receiver match could resolve against a same-named symbol in a
// completely unrelated language — e.g. a Ruby file's builtin `Kernel#load`
// call matched a JS ESM loader hook's unrelated `load` export purely
// because both files sat in the same directory (confidence 0.7 from
// proximity alone, well above the resolver's 0.5 threshold).

#[test]
fn is_same_language_family_rejects_ruby_and_js() {
assert!(!is_same_language_family("tracer/ruby-tracer.rb", "tracer/loader-hooks.mjs"));
}

#[test]
fn is_same_language_family_rejects_python_and_go() {
assert!(!is_same_language_family("src/main.py", "src/main.go"));
}

#[test]
fn is_same_language_family_accepts_same_extension() {
assert!(is_same_language_family("src/a.rb", "lib/b.rb"));
}

#[test]
fn is_same_language_family_merges_javascript_and_typescript() {
assert!(is_same_language_family("src/a.ts", "src/b.js"));
assert!(is_same_language_family("src/a.tsx", "src/b.mjs"));
assert!(is_same_language_family("src/a.cjs", "src/b.jsx"));
}

#[test]
fn is_same_language_family_merges_c_source_and_header() {
assert!(is_same_language_family("src/a.c", "src/a.h"));
}

#[test]
fn is_same_language_family_treats_h_as_ambiguous_with_cpp() {
// Greptile follow-up to #1783: `.h` is real-world ambiguous between C
// and C++ (LANGUAGE_REGISTRY/from_extension assigns it to C alone for
// grammar-selection purposes), so a `.cpp` file calling into its own
// project's `.h` header must not be rejected as cross-language.
assert!(is_same_language_family("src/widget.cpp", "src/widget.h"));
}

#[test]
fn is_same_language_family_merges_cpp_source_and_header_variants() {
assert!(is_same_language_family("src/a.cpp", "src/a.hpp"));
assert!(is_same_language_family("src/a.cc", "src/a.cxx"));
}

#[test]
fn is_same_language_family_does_not_merge_c_and_cpp() {
assert!(!is_same_language_family("src/a.c", "src/a.cpp"));
}

#[test]
fn is_same_language_family_does_not_reject_unrecognised_extensions() {
// Ambiguous (unrecognised) extensions fall through rather than being rejected.
assert!(is_same_language_family("README", "src/b.rb"));
assert!(is_same_language_family("src/a.rb", "Makefile"));
}

#[test]
fn compute_confidence_rejects_cross_language_same_directory_match() {
// The exact #1783 repro shape: same directory, different languages.
let conf = compute_confidence(
"tests/benchmarks/resolution/tracer/ruby-tracer.rb",
"tests/benchmarks/resolution/tracer/loader-hooks.mjs",
None,
);
assert_eq!(conf, 0.0);
}

#[test]
fn compute_confidence_still_scores_same_language_same_directory_pair() {
let conf = compute_confidence(
"tests/benchmarks/resolution/tracer/ruby-tracer.rb",
"tests/benchmarks/resolution/tracer/other-tracer.rb",
None,
);
assert_eq!(conf, 0.7);
}

#[test]
fn compute_confidence_does_not_regress_same_project_js_ts_resolution() {
// A .ts caller resolving a same-directory .js target must be unaffected —
// TS/JS are one family despite being different LanguageKind variants.
let conf = compute_confidence("src/graph/a.ts", "src/graph/b.js", None);
assert_eq!(conf, 0.7);
}
}
10 changes: 8 additions & 2 deletions src/domain/graph/builder/call-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* `resolveByMethodOrGlobal` delegates its two branches to strategy helpers
* in `../resolver/strategy.ts` to keep per-strategy complexity manageable.
*/
import { computeConfidence } from '../resolve.js';
import { computeConfidence, isSameLanguageFamily } from '../resolve.js';
import {
isModuleScopedLanguage,
resolveByGlobal,
Expand Down Expand Up @@ -347,9 +347,15 @@ export function resolveReceiverEdge(
const sameFileAll = lookup.byNameAndFile(effectiveReceiver, relPath);
const isLocalDefinition = sameFileAll.length > 0 && !importedNames?.has(effectiveReceiver);
const sameFileCandidates = sameFileAll.filter((n) => RECEIVER_KINDS.has(n.kind ?? ''));
// Cross-language candidates are never legitimate receiver targets (#1783) —
// a `new Foo()` in one language can't statically resolve to an unrelated
// same-named class in another. Only the global (cross-file) branch needs
// the check: sameFileCandidates are already scoped to relPath itself.
const candidates = isLocalDefinition
? sameFileCandidates
: lookup.byName(effectiveReceiver).filter((n) => RECEIVER_KINDS.has(n.kind ?? ''));
: lookup
.byName(effectiveReceiver)
.filter((n) => RECEIVER_KINDS.has(n.kind ?? '') && isSameLanguageFamily(relPath, n.file));
if (candidates.length === 0) return null;
const recvTarget = candidates[0]!;
const recvKey = `recv|${caller.id}|${recvTarget.id}`;
Expand Down
86 changes: 86 additions & 0 deletions src/domain/graph/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { loadNative } from '../../infrastructure/native.js';
import { normalizePath } from '../../shared/constants.js';
import { toErrorMessage } from '../../shared/errors.js';
import type { BareSpecifier, BatchResolvedMap, ImportBatchItem, PathAliases } from '../../types.js';
import { LANGUAGE_REGISTRY } from '../parser.js';

// ── package.json exports resolution ─────────────────────────────────

Expand Down Expand Up @@ -518,6 +519,87 @@ function directoryDistance(a: string, b: string): number {
return dist;
}

// ── Language-family scoping for global-by-name fallback resolution ─────────

/**
* LANGUAGE_REGISTRY ids that must be treated as one family for cross-file
* call resolution. TypeScript/TSX compile to and interoperate directly with
* JavaScript — a `.ts` file routinely imports from and calls into a `.js`
* file and vice versa (this codebase's own `src/` tree does this
* throughout) — despite being three separate grammar entries in
* LANGUAGE_REGISTRY. Every other registry id keeps its own family, which
* preserves LANGUAGE_REGISTRY's existing per-language extension groupings
* (e.g. C's `.c`+`.h`, C++'s `.cpp`/`.cc`/`.cxx`/`.hpp`).
*/
const JS_FAMILY_REGISTRY_IDS = new Set(['javascript', 'typescript', 'tsx']);

/**
* Extensions excluded from the family map entirely, so `languageFamily`
* returns null for them and they fall through to the ambiguous-extension
* path (ordinary distance-based scoring, never rejected outright).
*
* `.h` is real-world ambiguous between C and C++: LANGUAGE_REGISTRY assigns
* it to the `c` entry alone (grammar selection needs one canonical parser),
* but the extremely common case of a `.cpp` file calling into its own
* project's `.h` header would otherwise be misclassified as cross-language
* and rejected outright (confidence 0) — a real regression from the
* pre-#1783 same-directory score of 0.7 (Greptile review). Treating `.h` as
* ambiguous — like an unrecognised extension — keeps the C/C++-header case
* working without merging C and C++ source-file families wholesale (`.c`
* vs `.cpp` intentionally do NOT merge — see
* is_same_language_family_does_not_merge_c_and_cpp).
*/
const AMBIGUOUS_EXTENSIONS = new Set(['.h']);

/**
* extension → language-family lookup, derived from LANGUAGE_REGISTRY (the
* single source of truth for language definitions) so newly-added languages
* are automatically covered without a second hand-maintained extension list.
*/
const _extToLanguageFamily: Map<string, string> = new Map();
for (const entry of LANGUAGE_REGISTRY) {
const family = JS_FAMILY_REGISTRY_IDS.has(entry.id) ? 'javascript' : entry.id;
for (const ext of entry.extensions) {
if (AMBIGUOUS_EXTENSIONS.has(ext)) continue;
_extToLanguageFamily.set(ext, family);
}
}
Comment on lines +559 to +566

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 C++ .h headers silently blocked after the fix

_extToLanguageFamily maps .h'c' (from LANGUAGE_REGISTRY's id: 'c', extensions: ['.c', '.h']) and .cpp'cpp'. So isSameLanguageFamily("lib/widget.cpp", "lib/widget.h") returns false, and computeConfidenceJS (and the Rust mirror) now returns 0 for any .cpp caller targeting a symbol defined in a .h file.

Before this PR that same pair scored 0.7 (same-directory), so call/receiver edges into inline functions or template definitions in .h headers are now silently dropped. This is a pre-existing LANGUAGE_REGISTRY classification choice (.h → C grammar), but the confidence gate is new — the practical regression applies to any C++ codebase where header symbols were previously resolvable via the global fallback. Adding .h to the C++ family or merging C/C++ into one family would close the gap; neither option appears to be intentionally excluded in the test suite (there is no .cpp + .h test case).

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — confirmed via LANGUAGE_REGISTRY that .h maps only to 'c', so a .cpp caller into its own .h header would indeed have been rejected. Made .h ambiguous in both engines' language-family check (treated like an unrecognized extension, falling through to normal scoring) rather than merging C/C++ wholesale — preserves the existing does_not_merge_c_and_cpp guarantee for actual .c/.cpp source pairs. Added regression tests to both engines in 040be44e.


/**
* Resolve a file's coarse language family from its extension. Returns null
* for extensionless or unrecognised files so ambiguous cases fall through to
* ordinary distance-based scoring rather than being rejected outright.
*/
function languageFamily(file: string): string | null {
const dot = file.lastIndexOf('.');
if (dot === -1) return null;
return _extToLanguageFamily.get(file.slice(dot).toLowerCase()) ?? null;
}

/**
* True when `fileA` and `fileB` belong to the same language family, or when
* either extension is unrecognised (ambiguous cases are not rejected — they
* fall through to normal scoring). False only when both extensions are
* recognised AND resolve to different families.
*
* Guards the global-by-name call-resolution fallback against matching a
* same-named symbol across unrelated languages — e.g. a Ruby file's bare
* `load` call has no static relationship to a same-named `load` export in a
* JS file, even when both happen to live in the same directory (issue
* #1783). This codebase has no cross-language static-call mechanism its
* resolvers legitimately model (the `dead-ffi` role classifier only
* suppresses false dead-code flags for compiled-language files consumed via
* FFI — it never creates call edges), so rejecting cross-family candidates
* is a strict precision improvement with no legitimate resolution to
* regress.
*/
export function isSameLanguageFamily(fileA: string, fileB: string): boolean {
const famA = languageFamily(fileA);
const famB = languageFamily(fileB);
if (!famA || !famB) return true;
return famA === famB;
}

function computeConfidenceJS(
callerFile: string,
targetFile: string,
Expand All @@ -528,6 +610,10 @@ function computeConfidenceJS(
if (importedFrom === targetFile) return 1.0;
// Workspace-resolved imports get high confidence even across package boundaries
if (importedFrom && _workspaceResolvedPaths.has(importedFrom)) return 0.95;
// Cross-language candidates are never legitimate call targets (#1783) — reject
// before scoring proximity so a same-directory, same-named symbol in an
// unrelated language can never pass the resolver's 0.5 confidence threshold.
if (!isSameLanguageFamily(callerFile, targetFile)) return 0;
const dist = directoryDistance(path.dirname(callerFile), path.dirname(targetFile));
if (dist === 0) return 0.7; // same directory
if (dist === 1) return 0.6; // direct parent/child directory
Expand Down
Loading
Loading