Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: multi-lang parse, Rust tokio fixes, and ingest progress bar

Joseph Mikhailf09ff608758d
diff --git a/core-ingestion/dist/index.js b/core-ingestion/dist/index.js
index 40ba655e..57d35d76 100644
--- a/core-ingestion/dist/index.js
+++ b/core-ingestion/dist/index.js
@@ -112,20 +112,49 @@ const TYPE_BUILTINS = new Set([
'size_t', 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t',
'int16_t', 'int32_t', 'int64_t',
]);
-// Builtins to exclude from CALLS edges
-const BUILTINS = new Set([
- 'print', 'println', 'len', 'range', 'int', 'str', 'float', 'list', 'dict',
+// Builtins to exclude from CALLS edges — split by language family to avoid
+// suppressing valid method names in other languages (e.g. `filter` is a Python
+// builtin but also a common ORM method; `warn`/`error` are JS console methods
+// but also valid Python logging method names).
+// Keywords and pseudo-variables that are never valid call targets in any language.
+const SHARED_BUILTINS = new Set([
+ 'if', 'for', 'while', 'return', 'new', 'this', 'self',
+ 'undefined', 'null', 'true', 'false',
+ 'println', // Scala/Java/Kotlin/Rust standard-output builtin — noise in any language
+]);
+// Python-specific builtins (bare function calls like `len(x)`, `range(n)`, etc.)
+const PYTHON_BUILTINS = new Set([
+ ...SHARED_BUILTINS,
+ 'print', 'len', 'range', 'int', 'str', 'float', 'list', 'dict',
'set', 'tuple', 'type', 'isinstance', 'super', 'property', 'enumerate',
'zip', 'map', 'filter', 'sorted', 'any', 'all', 'min', 'max', 'sum',
+ 'open', 'repr', 'abs', 'round', 'hash', 'id', 'callable', 'iter', 'next',
+ 'vars', 'dir', 'getattr', 'setattr', 'hasattr', 'delattr',
+]);
+// JavaScript/TypeScript-specific builtins
+const JS_BUILTINS = new Set([
+ ...SHARED_BUILTINS,
'console', 'log', 'warn', 'error', 'debug', 'info',
- 'module', 'exports', 'undefined', 'null', 'true', 'false',
- 'if', 'for', 'while', 'return', 'new', 'this', 'self',
+ 'module', 'exports',
'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean', 'JSON',
'Math', 'Date', 'Error', 'Map', 'Set', 'Symbol',
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
'process', 'Buffer', 'global', 'window', 'document',
'require', 'fetch', 'parseInt', 'parseFloat', 'isNaN', 'isFinite',
]);
+// Per-language BUILTINS lookup — falls back to shared for languages without a
+// specific set (e.g. Java, Go, Rust) so they only skip obvious non-calls.
+function builtinsForLanguage(lang) {
+ switch (lang) {
+ case SupportedLanguages.Python:
+ return PYTHON_BUILTINS;
+ case SupportedLanguages.JavaScript:
+ case SupportedLanguages.TypeScript:
+ return JS_BUILTINS;
+ default:
+ return SHARED_BUILTINS;
+ }
+}
/** Returns true if a grammar is installed for the given file's language. */
export function isGrammarSupported(filePath) {
const language = languageFromPath(filePath);
@@ -154,6 +183,49 @@ function getCachedQuery(language, grammar, querySource) {
return query;
}
// ---------------------------------------------------------------------------
+// Rust: cfg macro unwrapping
+// ---------------------------------------------------------------------------
+/**
+ * Blanks out feature-gating macro wrappers in Rust source so that the items
+ * inside become visible to tree-sitter as top-level declarations.
+ *
+ * Replaces `cfg_rt! { ... }` (and similar) with the body contents in-place,
+ * preserving every character position and line number so that entity line
+ * numbers remain accurate.
+ */
+function unwrapRustCfgMacros(source) {
+ const re = /\bcfg_(?:rt_multi_thread|not_rt|rt|io|time|sync|net|fs|process|signal)!\s*\{/g;
+ const chars = source.split('');
+ let m;
+ while ((m = re.exec(source)) !== null) {
+ const openBrace = m.index + m[0].length - 1; // position of the `{`
+ // Find matching closing brace by counting depth
+ let depth = 0;
+ let closeBrace = -1;
+ for (let i = openBrace; i < source.length; i++) {
+ if (source[i] === '{')
+ depth++;
+ else if (source[i] === '}') {
+ depth--;
+ if (depth === 0) {
+ closeBrace = i;
+ break;
+ }
+ }
+ }
+ if (closeBrace === -1)
+ continue;
+ // Blank out everything from start of macro name up to and including `{`
+ for (let i = m.index; i <= openBrace; i++) {
+ if (chars[i] !== '\n')
+ chars[i] = ' ';
+ }
+ // Blank out the matching closing `}`
+ chars[closeBrace] = ' ';
+ }
+ return chars.join('');
+}
+// ---------------------------------------------------------------------------
// Main parse function
// ---------------------------------------------------------------------------
export function parseFile(filePath, source) {
@@ -171,7 +243,23 @@ export function parseFile(filePath, source) {
try {
const parser = getParser();
parser.setLanguage(grammar);
- const tree = parser.parse(source, undefined, { bufferSize: source.length + 1 });
+ // tree-sitter-java cannot parse array-type annotations on varargs params
+ // (e.g. `@Nullable Object @Nullable ... args`). The second annotation causes
+ // error recovery to truncate the enclosing class_declaration, orphaning all
+ // subsequent methods. Strip any @Annotation immediately before `...` in-memory
+ // so the class body parses correctly.
+ let parseSource = language === SupportedLanguages.Java
+ ? source.replace(/@\w+\s*(?=\.\.\.)/g, '')
+ : source;
+ // Rust: unwrap feature-gating macros (cfg_rt! { ... }, cfg_io! { ... }, etc.)
+ // These macros are transparent pass-throughs — their bodies contain normal items
+ // that tree-sitter cannot see because they are parsed as raw token_tree nodes.
+ // We blank out the macro call and matching closing brace in-place (preserving
+ // character positions and line numbers) so the inner items become top-level.
+ if (language === SupportedLanguages.Rust) {
+ parseSource = unwrapRustCfgMacros(parseSource);
+ }
+ const tree = parser.parse(parseSource, undefined, { bufferSize: parseSource.length + 1 });
const cacheKey = isTsx ? 'tsx' : language;
const query = getCachedQuery(cacheKey, grammar, queries);
const matches = query.matches(tree.rootNode);
@@ -193,6 +281,10 @@ export function parseFile(filePath, source) {
const seenCalls = new Map();
// Track seen type references per enclosing class/file to avoid duplicate REFERENCES edges
const seenRefs = new Map();
+ // Python: map function name → (param name → declared type) for typed-parameter qualifier substitution
+ const paramTypeMap = new Map();
+ // Python: map function name → (variable name → assigned type) for untyped-param qualifier substitution
+ const assignTypeMap = new Map();
// --- First pass: collect definitions ---
for (const match of matches) {
// Definition captures: name + definition.*
@@ -209,15 +301,27 @@ export function parseFile(filePath, source) {
const lineEnd = defNode.endPosition.row + 1;
const startByte = defNode.startIndex;
const endByte = defNode.endIndex;
- // Containment: file CONTAINS or class CONTAINS
+ // Containment: file CONTAINS or class CONTAINS.
+ // For Go methods the receiver type IS the container — methods are defined
+ // outside the struct body so findEnclosing() always returns null for them.
+ // The receiver.type capture (emitted by the Go method queries) overrides this.
const enclosing = findEnclosing(classRanges, lineStart, name);
+ const receiverCapture = match.captures.find((c) => c.name === 'receiver.type');
+ // heritageClassCapture is set by the Go interface method query, where @heritage.class
+ // captures the interface name and serves as the container (like receiver.type for structs).
+ const heritageClassCapture = match.captures.find((c) => c.name === 'heritage.class');
+ const effectiveContainer = (receiverCapture && kind === 'method')
+ ? receiverCapture.node.text
+ : (heritageClassCapture && kind === 'method')
+ ? heritageClassCapture.node.text
+ : (enclosing ?? undefined);
entities.push({
name,
kind,
lineStart,
lineEnd,
language,
- container: enclosing ?? undefined,
+ container: effectiveContainer,
});
pendingChunks.push({
name,
@@ -232,8 +336,8 @@ export function parseFile(filePath, source) {
if (kind === 'class' || kind === 'interface' || kind === 'trait') {
classRanges.push({ name, start: lineStart, end: lineEnd });
}
- if (enclosing) {
- relationships.push({ srcName: enclosing, dstName: name, predicate: 'CONTAINS' });
+ if (effectiveContainer) {
+ relationships.push({ srcName: effectiveContainer, dstName: name, predicate: 'CONTAINS' });
}
else {
relationships.push({ srcName: fileName, dstName: name, predicate: 'CONTAINS' });
@@ -261,6 +365,42 @@ export function parseFile(filePath, source) {
});
continue;
}
+ // Python typed parameters: build paramTypeMap for qualifier substitution in the second pass.
+ // Maps function name → (param name → declared type) so that e.g. `query: Query` lets us
+ // rewrite `query.filter(...)` → `Query.filter` when building effectiveCallee.
+ if (language === SupportedLanguages.Python) {
+ const typedParamScope = match.captures.find((c) => c.name === '_typed_param_scope');
+ const typedParamName = match.captures.find((c) => c.name === '_typed_param_name');
+ const typedParamType = match.captures.find((c) => c.name === '_typed_param_type');
+ if (typedParamScope && typedParamName && typedParamType) {
+ const funcName = typedParamScope.node.childForFieldName?.('name')?.text;
+ if (funcName) {
+ if (!paramTypeMap.has(funcName))
+ paramTypeMap.set(funcName, new Map());
+ paramTypeMap.get(funcName).set(typedParamName.node.text, typedParamType.node.text);
+ }
+ continue;
+ }
+ // Assignment tracking: x = SomeClass() or x = Model.objects.method()
+ const assignScope = match.captures.find((c) => c.name === '_assign_scope');
+ const assignLhs = match.captures.find((c) => c.name === '_assign_lhs');
+ const assignRhsType = match.captures.find((c) => c.name === '_assign_rhs_type');
+ if (assignScope && assignLhs && assignRhsType) {
+ // Only track PascalCase RHS names (constructors by convention).
+ // Lowercase function calls like `select(...)` or `create_engine(...)` are skipped
+ // to avoid cross-module false edges (e.g. orm.query → select.where in SQLAlchemy).
+ const rhsName = assignRhsType.node.text;
+ if (/^[A-Z]/.test(rhsName)) {
+ const funcName = assignScope.node.childForFieldName?.('name')?.text;
+ if (funcName) {
+ if (!assignTypeMap.has(funcName))
+ assignTypeMap.set(funcName, new Map());
+ assignTypeMap.get(funcName).set(assignLhs.node.text, rhsName);
+ }
+ }
+ continue;
+ }
+ }
}
// --- Second pass: calls and imports ---
for (const match of matches) {
@@ -325,7 +465,17 @@ export function parseFile(filePath, source) {
const callName = match.captures.find((c) => c.name === 'call.name');
if (callName) {
const callee = callName.node.text;
- if (!callee || BUILTINS.has(callee) || callee.length <= 1)
+ if (!callee || callee.length <= 1)
+ continue;
+ // If a _qualifier capture is present (field_expression / stable_identifier
+ // patterns like NodeKind.Decision, or Python attribute calls like
+ // Session.execute), emit the fully qualified name so that resolution can use
+ // the qualifier to break ties between same-named symbols in different files.
+ // BUILTINS filtering is skipped for attribute calls: method names like
+ // `filter` or `map` are Python builtins when called bare, but are valid
+ // user-defined method calls when invoked as `query.filter(...)`.
+ const qualifierCapture = match.captures.find((c) => c.name === '_qualifier');
+ if (builtinsForLanguage(language).has(callee) && !qualifierCapture)
continue;
// Find enclosing function/method for the call; fall back to enclosing class
// (e.g. calls in val/lazy val body at class level) before falling back to file.
@@ -337,14 +487,41 @@ export function parseFile(filePath, source) {
if (!seenCalls.has(scope))
seenCalls.set(scope, new Set());
const seen = seenCalls.get(scope);
- // If a _qualifier capture is present (field_expression / stable_identifier
- // patterns like NodeKind.Decision), emit the fully qualified name so that
- // resolution can use the qualifier to break ties between same-named symbols
- // in different files (e.g. NodeKind.Decision vs SourceType.Decision).
- const qualifierCapture = match.captures.find((c) => c.name === '_qualifier');
- const effectiveCallee = qualifierCapture
- ? `${qualifierCapture.node.text}.${callee}`
- : callee;
+ const effectiveCallee = (() => {
+ if (!qualifierCapture)
+ return callee;
+ let qualifier = qualifierCapture.node.text;
+ // Python: 'self'/'cls' always refers to the enclosing class — substitute it
+ // so the edge reads 'Query.filter' instead of 'self.filter', enabling
+ // same-file resolution without type inference.
+ if (language === SupportedLanguages.Python && (qualifier === 'self' || qualifier === 'cls')) {
+ const enclosingClass = findEnclosing(classRanges, callLine, '');
+ if (enclosingClass)
+ qualifier = enclosingClass;
+ }
+ else if (qualifier === 'this') {
+ // JS/TS: 'this' inside a class method refers to the enclosing class.
+ // Substitute so e.g. `this.save()` → `Document.save` instead of `this.save`.
+ const enclosingClass = findEnclosing(classRanges, callLine, '');
+ if (enclosingClass)
+ qualifier = enclosingClass;
+ }
+ else if (language === SupportedLanguages.Python) {
+ // Typed-parameter substitution: if the qualifier is a param with a declared type,
+ // use the type name so e.g. `query.filter(...)` → `Query.filter`.
+ // Also check assignTypeMap for variables assigned from constructor/ORM calls.
+ const funcName = findEnclosingFunction(entities, callLine);
+ if (funcName) {
+ const typeForParam = paramTypeMap.get(funcName)?.get(qualifier);
+ const typeForAssign = assignTypeMap.get(funcName)?.get(qualifier);
+ if (typeForParam)
+ qualifier = typeForParam;
+ else if (typeForAssign)
+ qualifier = typeForAssign;
+ }
+ }
+ return `${qualifier}.${callee}`;
+ })();
if (!seen.has(effectiveCallee)) {
seen.add(effectiveCallee);
relationships.push({ srcName: caller, dstName: effectiveCallee, predicate: 'CALLS' });
@@ -441,7 +618,12 @@ function bestQKey(fileQKeys, filePath, plainName) {
* - Unambiguous class method: dstQualifiedKey === 'ClassName.method'
* - Ambiguous (two entities share the same plain name): edge not emitted
*/
-export function resolveEdges(results) {
+export function resolveEdges(results, stats) {
+ if (!stats) stats = {
+ importLookups: 0, transitiveLookups: 0, globalFallbacks: 0,
+ globalCandidateTotal: 0, resolvedImport: 0, resolvedTransitive: 0,
+ resolvedGlobal: 0, resolvedQualifier: 0, skippedSameFile: 0, skippedAmbiguous: 0,
+ };
// fileQKeys: filePath → (plainName → qualifiedKeys[])
// Mirrors the entityQKey computation in buildPatch so nodeIds match exactly.
const fileQKeys = new Map();
@@ -473,6 +655,11 @@ export function resolveEdges(results) {
symbolToFiles.set(sym, list);
}
}
+ // fileLanguage: filePath → language (fast language lookup)
+ const fileLanguage = new Map();
+ for (const r of results) {
+ fileLanguage.set(r.filePath, r.language);
+ }
// stemToFiles: basename-without-extension → filePath[]
// Matches the last path segment of an import to files in the batch.
const stemToFiles = new Map();
@@ -514,6 +701,22 @@ export function resolveEdges(results) {
packageToFiles.set(pkg, list);
}
}
+ // goPkgDirToFiles: Go package directory name → filePath[]
+ // In Go, the last segment of an import path IS the package directory name.
+ // e.g. import "go.etcd.io/etcd/server/etcdserver" is stripped to modName "etcdserver"
+ // by the import processor; this index maps that name to all .go files in
+ // any directory named "etcdserver" within the ingested batch.
+ const goPkgDirToFiles = new Map();
+ for (const r of results) {
+ if (nodePath.extname(r.filePath) !== '.go')
+ continue;
+ const dirName = nodePath.basename(nodePath.dirname(r.filePath));
+ const list = goPkgDirToFiles.get(dirName) ?? [];
+ if (!list.includes(r.filePath))
+ list.push(r.filePath);
+ goPkgDirToFiles.set(dirName, list);
+ }
+ // ── Helpers ────────────────────────────────────────────────────────
/** Resolve a module name to matching file paths in the batch. */
function modNameToFiles(modName, excludeFp) {
const fps = [];
@@ -524,7 +727,7 @@ export function resolveEdges(results) {
candidates.push(stripped);
// Strip file extensions so "explain.js" resolves to the "explain" stem
// (TS/JS ESM imports use .js extensions that map to .ts source files)
- const noExt = modName.replace(/\.(js|ts|mjs|cjs|jsx|tsx|py|scala|java)$/, '');
+ const noExt = modName.replace(/\.(js|ts|mjs|cjs|jsx|tsx|py|scala|java|c|cc|cpp|cxx|h|hh|hpp|hxx)$/, '');
if (noExt !== modName && noExt && !candidates.includes(noExt))
candidates.push(noExt);
// For dotted paths (Scala/Java: 'ix.memory.model.Edge'), also try last segment
@@ -549,11 +752,109 @@ export function resolveEdges(results) {
if (fp !== excludeFp && !fps.includes(fp))
fps.push(fp);
}
+ // Go package directory resolution: "etcdserver" → all .go files in .../etcdserver/
+ // The last segment of a Go import path is the package directory name, not a file stem.
+ for (const fp of goPkgDirToFiles.get(modName) ?? []) {
+ if (fp !== excludeFp && !fps.includes(fp))
+ fps.push(fp);
+ }
return fps;
}
+ function tokenizeSymbolParts(value) {
+ return value
+ .replace(/([a-z\d])([A-Z])/g, '$1 $2')
+ .replace(/[^a-zA-Z0-9]+/g, ' ')
+ .toLowerCase()
+ .split(/\s+/)
+ .filter(Boolean);
+ }
+ const GENERIC_RESOLUTION_TOKENS = new Set([
+ 'run', 'job', 'file', 'files', 'table', 'tables', 'output', 'outputs',
+ 'input', 'inputs', 'background',
+ ]);
+ function candidateStem(filePath) {
+ return nodePath.basename(filePath, nodePath.extname(filePath)).toLowerCase();
+ }
+ function pickCallerAlignedCandidate(matches, srcName, dstName) {
+ if (matches.length === 0)
+ return null;
+ const srcTokens = new Set(tokenizeSymbolParts(srcName).filter(token => !GENERIC_RESOLUTION_TOKENS.has(token)));
+ const overlapScores = matches.map(fp => {
+ const qKeys = fileQKeys.get(fp)?.get(dstName) ?? [];
+ const candidateTokens = new Set(tokenizeSymbolParts(candidateStem(fp)));
+ for (const qKey of qKeys) {
+ for (const token of tokenizeSymbolParts(qKey))
+ candidateTokens.add(token);
+ }
+ let overlap = 0;
+ for (const token of candidateTokens) {
+ if (!GENERIC_RESOLUTION_TOKENS.has(token) && srcTokens.has(token))
+ overlap++;
+ }
+ return { fp, overlap };
+ });
+ const maxOverlap = Math.max(...overlapScores.map(x => x.overlap));
+ if (maxOverlap <= 0)
+ return null;
+ const bestMatches = overlapScores.filter(x => x.overlap === maxOverlap);
+ return {
+ chosen: bestMatches.length === 1 ? bestMatches[0].fp : null,
+ best: bestMatches,
+ };
+ }
+ function narrowCCandidates(matches, srcFilePath, srcLanguage, srcName, dstName) {
+ if (matches.length <= 1)
+ return matches;
+ // C# partial class narrowing: multiple files may define the same class via
+ // partial class (e.g. JsonReader.cs + JsonReader.Async.cs both define JsonReader).
+ // Prefer the canonical file whose stem exactly matches the destination class name
+ // over variant files that have additional dot-segments in the stem.
+ if (srcLanguage === SupportedLanguages.CSharp) {
+ const dstNameLower = dstName.toLowerCase();
+ const canonicalMatches = matches.filter(fp => candidateStem(fp) === dstNameLower);
+ if (canonicalMatches.length === 1)
+ return canonicalMatches;
+ }
+ if (srcLanguage !== SupportedLanguages.C && srcLanguage !== SupportedLanguages.CPlusPlus)
+ return matches;
+ let narrowed = matches;
+ const implExts = ['.c', '.cpp', '.cc', '.cxx'];
+ const implMatches = narrowed.filter(fp => implExts.some(ext => fp.endsWith(ext)));
+ if (implMatches.length === 1)
+ narrowed = implMatches;
+ if (narrowed.length <= 1)
+ return narrowed;
+ const srcParts = srcFilePath.replace(/\\/g, '/').split('/');
+ const withProximity = narrowed.map(fp => {
+ const fpParts = fp.replace(/\\/g, '/').split('/');
+ let common = 0;
+ while (common < srcParts.length && common < fpParts.length && srcParts[common] === fpParts[common]) {
+ common++;
+ }
+ return { fp, common };
+ });
+ const maxCommon = Math.max(...withProximity.map(x => x.common));
+ const proximityMatches = withProximity.filter(x => x.common === maxCommon).map(x => x.fp);
+ if (proximityMatches.length === 1)
+ return proximityMatches;
+ const callerAligned = pickCallerAlignedCandidate(narrowed, srcName, dstName);
+ if (callerAligned?.chosen)
+ return [callerAligned.chosen];
+ const callerAlignedCandidates = pickCallerAlignedCandidate(matches, srcName, dstName);
+ if (callerAlignedCandidates?.best) {
+ const implAlignedMatches = callerAlignedCandidates.best
+ .map(match => match.fp)
+ .filter(fp => ['.c', '.cpp', '.cc', '.cxx'].some(ext => fp.endsWith(ext)));
+ if (implAlignedMatches.length === 1)
+ return implAlignedMatches;
+ }
+ return narrowed;
+ }
+ // ── Main resolution loop ───────────────────────────────────────────
const resolved = [];
for (const result of results) {
const srcFilePath = result.filePath;
+ const srcLanguage = result.language;
const srcSymbols = fileHasSymbol.get(srcFilePath);
// Build the set of file paths this file explicitly imports.
const importedFilePaths = new Set();
@@ -662,45 +963,58 @@ export function resolveEdges(results) {
if (fileHasSymbol.get(fp)?.has(dstName))
importMatches.push(fp);
}
- if (importMatches.length === 1) {
- const fp = importMatches[0];
+ const narrowedImportMatches = narrowCCandidates(importMatches, srcFilePath, srcLanguage, srcName, dstName);
+ if (narrowedImportMatches.length === 1) {
+ const fp = narrowedImportMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null)
continue; // ambiguous — do not emit bad nodeId
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.9 });
continue;
}
- if (importMatches.length > 1)
- continue; // ambiguous file — do not emit
// Tier 2.5: transitive import-scoped (confidence 0.8) — one re-export hop away
const transitiveMatches = [];
for (const fp of transitiveFilePaths) {
if (fileHasSymbol.get(fp)?.has(dstName))
transitiveMatches.push(fp);
}
- if (transitiveMatches.length === 1) {
- const fp = transitiveMatches[0];
+ const narrowedTransitiveMatches = narrowCCandidates(transitiveMatches, srcFilePath, srcLanguage, srcName, dstName);
+ if (narrowedTransitiveMatches.length === 1) {
+ const fp = narrowedTransitiveMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null)
continue;
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.8 });
continue;
}
- if (transitiveMatches.length > 1)
- continue; // ambiguous — do not emit
- // Tier 3: global fallback (confidence 0.5) — exactly one other file defines it
- // Only match files in the same language as the caller to avoid cross-language false positives.
- const srcLanguage = result.language;
- const globalMatches = (symbolToFiles.get(dstName) ?? [])
- .filter(fp => fp !== srcFilePath && languageFromPath(fp) === srcLanguage);
- if (globalMatches.length === 1) {
- const fp = globalMatches[0];
+ // Tier 3: global fallback (confidence 0.5) — uses inverted symbol index
+ // instead of scanning all files.
+ stats.globalFallbacks++;
+ const candidates = symbolToFiles.get(dstName) ?? [];
+ let globalMatches = candidates.filter(fp => fp !== srcFilePath && fileLanguage.get(fp) === srcLanguage);
+ const importHint = pickCallerAlignedCandidate(importMatches, srcName, dstName)?.chosen
+ ?? pickCallerAlignedCandidate(transitiveMatches, srcName, dstName)?.chosen;
+ if (importHint) {
+ const hintedStem = candidateStem(importHint);
+ const stemMatches = globalMatches.filter(fp => candidateStem(fp) === hintedStem);
+ if (stemMatches.length > 0)
+ globalMatches = stemMatches;
+ }
+ stats.globalCandidateTotal += globalMatches.length;
+ const resolvedMatches = narrowCCandidates(globalMatches, srcFilePath, srcLanguage, srcName, dstName);
+ if (resolvedMatches.length === 1) {
+ const fp = resolvedMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null)
continue; // ambiguous — do not emit bad nodeId
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.5 });
+ stats.resolvedGlobal++;
+ continue;
+ }
+ if (narrowedImportMatches.length > 1 || narrowedTransitiveMatches.length > 1 || resolvedMatches.length > 1) {
+ stats.skippedAmbiguous++;
}
- // 0 or >1 global matches — leave as dangling edge, do not emit
+ // 0 or >1 matches after all tiers — leave as dangling edge, do not emit
}
}
return resolved;
diff --git a/core-ingestion/dist/patch-builder.js b/core-ingestion/dist/patch-builder.js
index 89e88c19..026cba0f 100644
--- a/core-ingestion/dist/patch-builder.js
+++ b/core-ingestion/dist/patch-builder.js
@@ -38,10 +38,10 @@ function sourceType(filePath) {
return 'code';
}
export function extractorName() {
- return `tree-sitter/1.13`;
+ return `tree-sitter/1.18`;
}
/** Previous extractor versions — their patches are superseded when re-ingesting. */
-export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.12', 'tree-sitter/1.11', 'tree-sitter/1.10', 'tree-sitter/1.9', 'tree-sitter/1.8', 'tree-sitter/1.7', 'tree-sitter/1.6', 'tree-sitter/1.5', 'tree-sitter/1.4', 'tree-sitter/1.3', 'tree-sitter/1.2', 'tree-sitter/1.1'];
+export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.17', 'tree-sitter/1.16', 'tree-sitter/1.15', 'tree-sitter/1.14', 'tree-sitter/1.13', 'tree-sitter/1.12', 'tree-sitter/1.11', 'tree-sitter/1.10', 'tree-sitter/1.9', 'tree-sitter/1.8', 'tree-sitter/1.7', 'tree-sitter/1.6', 'tree-sitter/1.5', 'tree-sitter/1.4', 'tree-sitter/1.3', 'tree-sitter/1.2', 'tree-sitter/1.1'];
/** Compute a patchId for a (filePath, sourceHash, extractorVersion) triple. */
function computePatchId(filePath, sourceHash, extractor) {
return deterministicId(`${normalizePath(filePath)}:${sourceHash}:${extractor}`);
@@ -75,10 +75,16 @@ export function buildPatch(result, sourceHash, previousSourceHash) {
// For ambiguous names (appear multiple times), falls back to the plain name
// so that the edge still points to *something* deterministic.
function resolveKey(name, container) {
- const keys = nameToQKeys.get(name);
- if (!keys || keys.length === 1)
- return keys?.[0] ?? name;
- // More than one entity with this name — try to pick by container
+ const rawKeys = nameToQKeys.get(name);
+ if (!rawKeys)
+ return name;
+ // Deduplicate: @overload in Python (and similar patterns in other languages)
+ // produces multiple definitions with identical qualified keys. A Set collapses
+ // these so we don't mistake three `Session.execute` overloads for ambiguity.
+ const keys = [...new Set(rawKeys)];
+ if (keys.length === 1)
+ return keys[0];
+ // More than one distinct entity with this name — try to pick by container
if (container) {
const qualified = `${container}.${name}`;
if (keys.includes(qualified))
@@ -234,14 +240,14 @@ export function buildPatch(result, sourceHash, previousSourceHash) {
// to the actual defining file for cross-file calls resolved by resolveCallEdges.
// ---------------------------------------------------------------------------
export function buildPatchWithResolution(result, sourceHash, resolvedEdges, previousSourceHash) {
- // Build lookup: `${predicate}:${dstName}` → { dstFilePath, dstQualifiedKey }
+ // Build lookup: `${srcName}:${predicate}:${dstName}` → { dstFilePath, dstQualifiedKey }
// Callers should pass only edges for this file (pre-grouped) for best performance,
// but we still tolerate the full array for backward compatibility.
const edgeResolution = new Map();
for (const edge of resolvedEdges) {
if (edge.srcFilePath !== result.filePath)
continue;
- edgeResolution.set(`${edge.predicate}:${edge.dstName}`, {
+ edgeResolution.set(`${edge.srcName}:${edge.predicate}:${edge.dstName}`, {
dstFilePath: edge.dstFilePath,
dstQualifiedKey: edge.dstQualifiedKey,
});
@@ -259,9 +265,12 @@ export function buildPatchWithResolution(result, sourceHash, resolvedEdges, prev
nameToQKeys.set(e.name, list);
}
function resolveKey(name, container) {
- const keys = nameToQKeys.get(name);
- if (!keys || keys.length === 1)
- return keys?.[0] ?? name;
+ const rawKeys = nameToQKeys.get(name);
+ if (!rawKeys)
+ return name;
+ const keys = [...new Set(rawKeys)]; // deduplicate — @overload produces identical qks
+ if (keys.length === 1)
+ return keys[0];
if (container) {
const qualified = `${container}.${name}`;
if (keys.includes(qualified))
@@ -355,7 +364,7 @@ export function buildPatchWithResolution(result, sourceHash, resolvedEdges, prev
: resolveKey(r.dstName);
// For cross-file resolved edges (CALLS, EXTENDS), use the defining file's nodeId
let dstNodeId;
- const resolutionKey = `${r.predicate}:${r.dstName}`;
+ const resolutionKey = `${r.srcName}:${r.predicate}:${r.dstName}`;
if (edgeResolution.has(resolutionKey)) {
const { dstFilePath, dstQualifiedKey } = edgeResolution.get(resolutionKey);
dstNodeId = nodeId(dstFilePath, dstQualifiedKey);
diff --git a/core-ingestion/dist/queries.d.ts b/core-ingestion/dist/queries.d.ts
index 36c000ea..812747bf 100644
--- a/core-ingestion/dist/queries.d.ts
+++ b/core-ingestion/dist/queries.d.ts
@@ -1,13 +1,13 @@
import { SupportedLanguages } from './languages.js';
-export declare const TYPESCRIPT_QUERIES = "\n(class_declaration\n name: (type_identifier) @name) @definition.class\n\n(interface_declaration\n name: (type_identifier) @name) @definition.interface\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n; Dynamic import with string literal: import('./foo') or await import('./foo')\n(call_expression\n function: (import)\n arguments: (arguments (string) @import.source)) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (extends_clause\n value: (identifier) @heritage.extends))) @heritage\n\n; Heritage queries - class implements interface\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (implements_clause\n (type_identifier) @heritage.implements))) @heritage.impl\n\n; Heritage queries - interface extends interface\n(interface_declaration\n name: (type_identifier) @heritage.class\n (extends_type_clause\n (type_identifier) @heritage.extends)) @heritage\n\n; Type references \u2014 captures types used in annotations/parameters/return types\n(type_annotation (type_identifier) @reference.type)\n";
-export declare const JAVASCRIPT_QUERIES = "\n(class_declaration\n name: (identifier) @name) @definition.class\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n; var foo = function() {} (CommonJS var declarations)\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n; var foo = () => {} (CommonJS var arrow functions)\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n; obj.method = function name() {} (prototype/mixin method assignments)\n(expression_statement\n (assignment_expression\n left: (member_expression\n property: (property_identifier) @name)\n right: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n; Dynamic import with string literal: import('./foo') or await import('./foo')\n(call_expression\n function: (import)\n arguments: (arguments (string) @import.source)) @import\n\n; CommonJS require() \u2192 IMPORTS\n(call_expression\n function: (identifier) @_req\n arguments: (arguments (string) @import.source)\n (#eq? @_req \"require\")) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends (JavaScript uses different AST than TypeScript)\n; In tree-sitter-javascript, class_heritage directly contains the parent identifier\n(class_declaration\n name: (identifier) @heritage.class\n (class_heritage\n (identifier) @heritage.extends)) @heritage\n";
-export declare const PYTHON_QUERIES = "\n(class_definition\n name: (identifier) @name) @definition.class\n\n(function_definition\n name: (identifier) @name) @definition.function\n\n(import_statement\n name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (relative_import) @import.source) @import\n\n; from . import utils / from .models import User \u2014 also capture the imported symbol names\n(import_from_statement\n module_name: (relative_import)\n name: (dotted_name (identifier) @import.name)) @import.names\n\n(call\n function: (identifier) @call.name) @call\n\n(call\n function: (attribute\n attribute: (identifier) @call.name)) @call\n\n; Heritage queries - Python class inheritance\n(class_definition\n name: (identifier) @heritage.class\n superclasses: (argument_list\n (identifier) @heritage.extends)) @heritage\n\n; Type references \u2014 captures types used in type annotations / hints\n(typed_parameter type: (type (identifier) @reference.type))\n(typed_default_parameter type: (type (identifier) @reference.type))\n";
-export declare const JAVA_QUERIES = "\n; Classes, Interfaces, Enums, Annotations\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(enum_declaration name: (identifier) @name) @definition.enum\n(annotation_type_declaration name: (identifier) @name) @definition.annotation\n\n; Methods & Constructors\n(method_declaration name: (identifier) @name) @definition.method\n(constructor_declaration name: (identifier) @name) @definition.constructor\n\n; Imports - capture any import declaration child as source\n(import_declaration (_) @import.source) @import\n\n; Calls\n(method_invocation name: (identifier) @call.name) @call\n(method_invocation object: (_) name: (identifier) @call.name) @call\n\n; Constructor calls: new Foo()\n(object_creation_expression type: (type_identifier) @call.name) @call\n\n; Heritage - extends class\n(class_declaration name: (identifier) @heritage.class\n (superclass (type_identifier) @heritage.extends)) @heritage\n\n; Heritage - implements interfaces\n(class_declaration name: (identifier) @heritage.class\n (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(formal_parameter type: (type_identifier) @reference.type)\n(local_variable_declaration type: (type_identifier) @reference.type)\n(method_declaration type: (type_identifier) @reference.type)\n";
-export declare const C_QUERIES = "\n; Functions (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n\n; Functions returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Functions returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n\n; Structs, Unions, Enums, Typedefs\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(union_specifier name: (type_identifier) @name) @definition.union\n(enum_specifier name: (type_identifier) @name) @definition.enum\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n\n; Type references \u2014 captures types used in declaration/parameter positions\n(declaration type: (type_identifier) @reference.type)\n(parameter_declaration type: (type_identifier) @reference.type)\n";
-export declare const GO_QUERIES = "\n; Functions & Methods\n(function_declaration name: (identifier) @name) @definition.function\n(method_declaration name: (field_identifier) @name) @definition.method\n\n; Types\n(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct\n(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface\n\n; Imports\n(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import\n(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import\n\n; Struct embedding (anonymous fields = inheritance)\n(type_declaration\n (type_spec\n name: (type_identifier) @heritage.class\n type: (struct_type\n (field_declaration_list\n (field_declaration\n type: (type_identifier) @heritage.extends))))) @definition.struct\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (selector_expression field: (field_identifier) @call.name)) @call\n\n; Struct literal construction: User{Name: \"Alice\"}\n(composite_literal type: (type_identifier) @call.name) @call\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(parameter_declaration type: (type_identifier) @reference.type)\n; Return types: in tree-sitter-go, return type is a direct type_identifier child of function/method\n(function_declaration result: (type_identifier) @reference.type)\n(method_declaration result: (type_identifier) @reference.type)\n";
+export declare const TYPESCRIPT_QUERIES = "\n(class_declaration\n name: (type_identifier) @name) @definition.class\n\n(interface_declaration\n name: (type_identifier) @name) @definition.interface\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n; Dynamic import with string literal: import('./foo') or await import('./foo')\n(call_expression\n function: (import)\n arguments: (arguments (string) @import.source)) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; this.method() \u2014 capture this as qualifier so index.ts can substitute the enclosing class.\n; Analogous to Python's self/cls substitution.\n(call_expression\n function: (member_expression\n object: (this) @_qualifier\n property: (property_identifier) @call.name)) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (extends_clause\n value: (identifier) @heritage.extends))) @heritage\n\n; Heritage queries - class implements interface\n(class_declaration\n name: (type_identifier) @heritage.class\n (class_heritage\n (implements_clause\n (type_identifier) @heritage.implements))) @heritage.impl\n\n; Heritage queries - interface extends interface\n(interface_declaration\n name: (type_identifier) @heritage.class\n (extends_type_clause\n (type_identifier) @heritage.extends)) @heritage\n\n; Type references \u2014 captures types used in annotations/parameters/return types\n(type_annotation (type_identifier) @reference.type)\n";
+export declare const JAVASCRIPT_QUERIES = "\n(class_declaration\n name: (identifier) @name) @definition.class\n\n(function_declaration\n name: (identifier) @name) @definition.function\n\n(method_definition\n name: (property_identifier) @name) @definition.method\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n(lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n; var foo = function() {} (CommonJS var declarations)\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression))) @definition.function\n\n; var foo = () => {} (CommonJS var arrow functions)\n(variable_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function))) @definition.function\n\n; obj.method = function name() {} (prototype/mixin method assignments)\n(expression_statement\n (assignment_expression\n left: (member_expression\n property: (property_identifier) @name)\n right: (function_expression))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (arrow_function)))) @definition.function\n\n(export_statement\n declaration: (lexical_declaration\n (variable_declarator\n name: (identifier) @name\n value: (function_expression)))) @definition.function\n\n(import_statement\n source: (string) @import.source) @import\n\n; Re-export statements: export { X } from './y'\n(export_statement\n source: (string) @import.source) @import\n\n; Dynamic import with string literal: import('./foo') or await import('./foo')\n(call_expression\n function: (import)\n arguments: (arguments (string) @import.source)) @import\n\n; CommonJS require() \u2192 IMPORTS\n(call_expression\n function: (identifier) @_req\n arguments: (arguments (string) @import.source)\n (#eq? @_req \"require\")) @import\n\n(call_expression\n function: (identifier) @call.name) @call\n\n(call_expression\n function: (member_expression\n property: (property_identifier) @call.name)) @call\n\n; this.method() \u2014 capture this as qualifier so index.ts can substitute the enclosing class.\n; Analogous to Python's self/cls substitution.\n(call_expression\n function: (member_expression\n object: (this) @_qualifier\n property: (property_identifier) @call.name)) @call\n\n; Constructor calls: new Foo()\n(new_expression\n constructor: (identifier) @call.name) @call\n\n; Heritage queries - class extends (JavaScript uses different AST than TypeScript)\n; In tree-sitter-javascript, class_heritage directly contains the parent identifier\n(class_declaration\n name: (identifier) @heritage.class\n (class_heritage\n (identifier) @heritage.extends)) @heritage\n";
+export declare const PYTHON_QUERIES = "\n(class_definition\n name: (identifier) @name) @definition.class\n\n(function_definition\n name: (identifier) @name) @definition.function\n\n(import_statement\n name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (dotted_name) @import.source) @import\n\n(import_from_statement\n module_name: (relative_import) @import.source) @import\n\n; from . import utils / from .models import User \u2014 also capture the imported symbol names\n(import_from_statement\n module_name: (relative_import)\n name: (dotted_name (identifier) @import.name)) @import.names\n\n(call\n function: (identifier) @call.name) @call\n\n(call\n function: (attribute\n attribute: (identifier) @call.name)) @call\n\n; Attribute calls with object captured as qualifier so Tier-1b resolution can use\n; class/module name to break ties (e.g. Session.execute \u2192 resolves to Session in\n; the importing file). Emitted alongside the bare-name pattern above so that\n; bare-name global fallback still fires when qualifier resolution fails.\n(call\n function: (attribute\n object: (identifier) @_qualifier\n attribute: (identifier) @call.name)) @call\n\n; Django ORM manager pattern: Model.objects.method(...)\n; Unwinds the intermediate accessor (objects/related_manager/etc.) and captures\n; the model class as qualifier, e.g. User.objects.filter(...) \u2192 CALLS User.filter.\n; This creates cross-file edges between view/form code and model definitions.\n(call\n function: (attribute\n object: (attribute\n object: (identifier) @_qualifier\n attribute: (identifier))\n attribute: (identifier) @call.name)) @call\n\n; Chained call pattern: qualifier.method1(...).method2(...)\n; Propagates the qualifier from the inner call to the outer, e.g.\n; User.filter(...).order_by(...) \u2192 CALLS User.order_by.\n(call\n function: (attribute\n object: (call\n function: (attribute\n object: (identifier) @_qualifier\n attribute: (identifier)))\n attribute: (identifier) @call.name)) @call\n\n; Heritage queries - Python class inheritance\n(class_definition\n name: (identifier) @heritage.class\n superclasses: (argument_list\n (identifier) @heritage.extends)) @heritage\n\n; Type references \u2014 captures types used in type annotations / hints\n(typed_parameter type: (type (identifier) @reference.type))\n(typed_default_parameter type: (type (identifier) @reference.type))\n\n; Typed parameters: capture name + type together so qualifier substitution can\n; map a local variable name to its declared class (e.g. query: Query \u2192 'query' \u2192 'Query').\n(function_definition\n parameters: (parameters\n (typed_parameter\n (identifier) @_typed_param_name\n type: (type (identifier) @_typed_param_type)))) @_typed_param_scope\n\n(function_definition\n parameters: (parameters\n (typed_default_parameter\n (identifier) @_typed_param_name\n type: (type (identifier) @_typed_param_type)))) @_typed_param_scope\n\n; Assignment tracking: x = SomeClass() or x = SomeClass(args)\n; Maps local variable name \u2192 constructor type for untyped-parameter qualifier substitution.\n; Only PascalCase RHS names are tracked in TypeScript (constructor convention).\n(function_definition\n body: (block\n (expression_statement\n (assignment\n left: (identifier) @_assign_lhs\n right: (call\n function: (identifier) @_assign_rhs_type))))) @_assign_scope\n\n; Assignment tracking: x = Model.objects.method()\n; Captures the outermost identifier (model class) for ORM manager patterns.\n(function_definition\n body: (block\n (expression_statement\n (assignment\n left: (identifier) @_assign_lhs\n right: (call\n function: (attribute\n object: (attribute\n object: (identifier) @_assign_rhs_type\n attribute: (identifier))\n attribute: (identifier))))))) @_assign_scope\n";
+export declare const JAVA_QUERIES = "\n; Classes, Interfaces, Enums, Annotations\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(enum_declaration name: (identifier) @name) @definition.enum\n(annotation_type_declaration name: (identifier) @name) @definition.annotation\n\n; Methods & Constructors\n(method_declaration name: (identifier) @name) @definition.method\n(constructor_declaration name: (identifier) @name) @definition.constructor\n\n; Imports - capture any import declaration child as source\n(import_declaration (_) @import.source) @import\n\n; Calls\n(method_invocation name: (identifier) @call.name) @call\n(method_invocation object: (_) name: (identifier) @call.name) @call\n\n; Constructor calls: new Foo()\n(object_creation_expression type: (type_identifier) @call.name) @call\n\n; Heritage - extends class (plain: extends Foo)\n(class_declaration name: (identifier) @heritage.class\n (superclass (type_identifier) @heritage.extends)) @heritage\n\n; Heritage - extends class with generics (extends Foo<T>)\n(class_declaration name: (identifier) @heritage.class\n (superclass (generic_type (type_identifier) @heritage.extends))) @heritage\n\n; Heritage - implements interfaces (plain: implements Foo)\n(class_declaration name: (identifier) @heritage.class\n (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl\n\n; Heritage - implements interfaces with generics (implements Foo<T>)\n(class_declaration name: (identifier) @heritage.class\n (super_interfaces (type_list (generic_type (type_identifier) @heritage.implements)))) @heritage.impl\n\n; Heritage - interface extends interfaces (plain: extends Foo)\n(interface_declaration name: (identifier) @heritage.class\n (extends_interfaces (type_list (type_identifier) @heritage.extends))) @heritage\n\n; Heritage - interface extends interfaces with generics (extends Foo<T>)\n(interface_declaration name: (identifier) @heritage.class\n (extends_interfaces (type_list (generic_type (type_identifier) @heritage.extends)))) @heritage\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(formal_parameter type: (type_identifier) @reference.type)\n(local_variable_declaration type: (type_identifier) @reference.type)\n(method_declaration type: (type_identifier) @reference.type)\n";
+export declare const C_QUERIES = "\n; Functions (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n\n; Functions returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Functions returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n\n; Structs, Unions, Enums, Typedefs\n; Only match struct/union with a body to avoid treating forward declarations as definitions\n(struct_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.struct\n(union_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.union\n(enum_specifier name: (type_identifier) @name) @definition.enum\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n\n; Type references \u2014 captures types used in declaration/parameter positions\n(declaration type: (type_identifier) @reference.type)\n(parameter_declaration type: (type_identifier) @reference.type)\n; struct_specifier forms: e.g. \"const struct Curl_protocol foo = {...}\"\n(declaration type: (struct_specifier name: (type_identifier) @reference.type))\n(parameter_declaration type: (struct_specifier name: (type_identifier) @reference.type))\n";
+export declare const GO_QUERIES = "\n; Functions\n(function_declaration name: (identifier) @name) @definition.function\n\n; Methods \u2014 non-pointer receiver: func (r ReceiverType) Name(...)\n; The receiver.type capture lets the parser set container = ReceiverType so that\n; qualifiedKey becomes \"ReceiverType.Name\" instead of bare \"Name\".\n(method_declaration\n receiver: (parameter_list (parameter_declaration\n type: (type_identifier) @receiver.type))\n name: (field_identifier) @name) @definition.method\n\n; Methods \u2014 pointer receiver: func (r *ReceiverType) Name(...)\n(method_declaration\n receiver: (parameter_list (parameter_declaration\n type: (pointer_type (type_identifier) @receiver.type)))\n name: (field_identifier) @name) @definition.method\n\n; Types\n(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct\n(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface\n\n; Interface method signatures \u2014 emits each method inside an interface_type as a method entity.\n; @heritage.class = interface name (used as container in index.ts via heritageClassCapture).\n; node type is method_elem in tree-sitter-go v0.21+.\n(type_declaration\n (type_spec\n name: (type_identifier) @heritage.class\n type: (interface_type\n (method_elem\n name: (field_identifier) @name)))) @definition.method\n\n; Imports\n(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import\n(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import\n\n; Struct embedding \u2014 value: type Foo struct { Bar }\n; NOTE: no @definition.* capture here \u2014 if it were present, defCapture fires first and\n; the heritage block is never reached (early-exit in the first pass).\n; The . anchors require the type_identifier to be the FIRST and ONLY named child of\n; field_declaration, distinguishing anonymous embedded fields from named fields like:\n; w Writer (named field \u2014 field_identifier_list precedes type, not matched)\n(type_declaration\n (type_spec\n name: (type_identifier) @heritage.class\n type: (struct_type\n (field_declaration_list\n (field_declaration .\n (type_identifier) @heritage.extends .)))))\n\n; Struct embedding \u2014 pointer: type Foo struct { *Bar }\n; The . anchor requires pointer_type to be the first named child (anonymous embedded).\n(type_declaration\n (type_spec\n name: (type_identifier) @heritage.class\n type: (struct_type\n (field_declaration_list\n (field_declaration .\n (pointer_type (type_identifier) @heritage.extends) .)))))\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n; Qualified calls: pkg.Func() or localVar.Method() where the operand is a simple\n; identifier \u2014 capture it as @_qualifier so cross-file resolution uses the fully\n; qualified name \"scrape.NewManager\" instead of bare \"NewManager\", preventing\n; ambiguous same-named symbols in different packages from being collapsed.\n(call_expression function: (selector_expression\n operand: (identifier) @_qualifier\n field: (field_identifier) @call.name)) @call\n; Chained/complex calls: a.b.Method(), call().Method(), index[i].Method() \u2014 the\n; operand is not a simple identifier, so emit without qualifier (bare method name).\n(call_expression function: (selector_expression\n operand: (selector_expression)\n field: (field_identifier) @call.name)) @call\n\n; Struct literal construction: User{Name: \"Alice\"}\n(composite_literal type: (type_identifier) @call.name) @call\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(parameter_declaration type: (type_identifier) @reference.type)\n; Return types: in tree-sitter-go, return type is a direct type_identifier child of function/method\n(function_declaration result: (type_identifier) @reference.type)\n(method_declaration result: (type_identifier) @reference.type)\n\n; Pointer-type variants: e.g. opts *Options, func(*Options) *Result\n(field_declaration type: (pointer_type (type_identifier) @reference.type))\n(parameter_declaration type: (pointer_type (type_identifier) @reference.type))\n(function_declaration result: (pointer_type (type_identifier) @reference.type))\n(method_declaration result: (pointer_type (type_identifier) @reference.type))\n";
export declare const CPP_QUERIES = "\n; Classes, Structs, Namespaces\n(class_specifier name: (type_identifier) @name) @definition.class\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(namespace_definition name: (namespace_identifier) @name) @definition.namespace\n(enum_specifier name: (type_identifier) @name) @definition.enum\n\n; Typedefs and unions (common in C-style headers and mixed C/C++ code)\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n(union_specifier name: (type_identifier) @name) @definition.union\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Functions & Methods (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method\n\n; Functions/methods returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n\n; Functions/methods returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method\n\n; Functions/methods returning references (reference_declarator wraps function_declarator)\n(function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n\n; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method\n\n; Function declarations / prototypes (common in headers)\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Inline class method declarations (inside class body, no body: void Foo();)\n(field_declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.method\n\n; Inline class method definitions (inside class body, with body: void Foo() { ... })\n(field_declaration_list\n (function_definition\n declarator: (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)\n\n; Templates\n(template_declaration (class_specifier name: (type_identifier) @name)) @definition.template\n(template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (qualified_identifier name: (identifier) @call.name)) @call\n(call_expression function: (template_function name: (identifier) @call.name)) @call\n\n; Constructor calls: new User()\n(new_expression type: (type_identifier) @call.name) @call\n\n; Heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (type_identifier) @heritage.extends)) @heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage\n\n; Type references \u2014 captures types used in declaration/parameter positions\n(declaration type: (type_identifier) @reference.type)\n(parameter_declaration type: (type_identifier) @reference.type)\n";
-export declare const CSHARP_QUERIES = "\n; Types\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(struct_declaration name: (identifier) @name) @definition.struct\n(enum_declaration name: (identifier) @name) @definition.enum\n(record_declaration name: (identifier) @name) @definition.record\n(delegate_declaration name: (identifier) @name) @definition.delegate\n\n; Namespaces (block form and C# 10+ file-scoped form)\n(namespace_declaration name: (identifier) @name) @definition.namespace\n(namespace_declaration name: (qualified_name) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace\n\n; Methods & Properties\n(method_declaration name: (identifier) @name) @definition.method\n(local_function_statement name: (identifier) @name) @definition.function\n(constructor_declaration name: (identifier) @name) @definition.constructor\n(property_declaration name: (identifier) @name) @definition.property\n\n; Primary constructors (C# 12): class User(string name, int age) { }\n(class_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n(record_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n\n; Using\n(using_directive (qualified_name) @import.source) @import\n(using_directive (identifier) @import.source) @import\n\n; Calls\n(invocation_expression function: (identifier) @call.name) @call\n(invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call\n\n; Null-conditional method calls: user?.Save()\n; Parses as: invocation_expression \u2192 conditional_access_expression \u2192 member_binding_expression \u2192 identifier\n(invocation_expression\n function: (conditional_access_expression\n (member_binding_expression\n (identifier) @call.name))) @call\n\n; Constructor calls: new Foo() and new Foo { Props }\n(object_creation_expression type: (identifier) @call.name) @call\n\n; Target-typed new (C# 9): User u = new(\"x\", 5)\n(variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))\n\n; Heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (identifier) @heritage.extends)) @heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (generic_name (identifier) @heritage.extends))) @heritage\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(parameter type: (identifier) @reference.type)\n(variable_declaration type: (identifier) @reference.type)\n(field_declaration type: (identifier) @reference.type)\n(method_declaration return_type: (identifier) @reference.type)\n";
-export declare const RUST_QUERIES = "\n; Functions & Items\n(function_item name: (identifier) @name) @definition.function\n(struct_item name: (type_identifier) @name) @definition.struct\n(enum_item name: (type_identifier) @name) @definition.enum\n(trait_item name: (type_identifier) @name) @definition.trait\n(impl_item type: (type_identifier) @name !trait) @definition.impl\n(impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl\n(mod_item name: (identifier) @name) @definition.module\n\n; Type aliases, const, static, macros\n(type_item name: (type_identifier) @name) @definition.type\n(const_item name: (identifier) @name) @definition.const\n(static_item name: (identifier) @name) @definition.static\n(macro_definition name: (identifier) @name) @definition.macro\n\n; Use statements\n(use_declaration argument: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (scoped_identifier name: (identifier) @call.name)) @call\n(call_expression function: (generic_function function: (identifier) @call.name)) @call\n\n; Struct literal construction: User { name: value }\n(struct_expression name: (type_identifier) @call.name) @call\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(parameter pattern: (_) type: (type_identifier) @reference.type)\n(function_item return_type: (type_identifier) @reference.type)\n\n; Heritage (trait implementation) \u2014 all combinations of concrete/generic trait \u00D7 concrete/generic type\n(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n";
+export declare const CSHARP_QUERIES = "\n; Types\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(struct_declaration name: (identifier) @name) @definition.struct\n(enum_declaration name: (identifier) @name) @definition.enum\n(record_declaration name: (identifier) @name) @definition.record\n(delegate_declaration name: (identifier) @name) @definition.delegate\n\n; Namespaces (block form and C# 10+ file-scoped form)\n(namespace_declaration name: (identifier) @name) @definition.namespace\n(namespace_declaration name: (qualified_name) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace\n\n; Methods & Properties\n(method_declaration name: (identifier) @name) @definition.method\n(local_function_statement name: (identifier) @name) @definition.function\n(constructor_declaration name: (identifier) @name) @definition.constructor\n(property_declaration name: (identifier) @name) @definition.property\n\n; Primary constructors (C# 12): class User(string name, int age) { }\n(class_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n(record_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n\n; Using\n(using_directive (qualified_name) @import.source) @import\n(using_directive (identifier) @import.source) @import\n\n; Calls\n(invocation_expression function: (identifier) @call.name) @call\n(invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call\n\n; Null-conditional method calls: user?.Save()\n; Parses as: invocation_expression \u2192 conditional_access_expression \u2192 member_binding_expression \u2192 identifier\n(invocation_expression\n function: (conditional_access_expression\n (member_binding_expression\n (identifier) @call.name))) @call\n\n; Constructor calls: new Foo() and new Foo { Props }\n(object_creation_expression type: (identifier) @call.name) @call\n\n; Target-typed new (C# 9): User u = new(\"x\", 5)\n(variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))\n\n; Heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (identifier) @heritage.extends)) @heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (generic_name (identifier) @heritage.extends))) @heritage\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(parameter type: (identifier) @reference.type)\n(variable_declaration type: (identifier) @reference.type)\n(field_declaration (variable_declaration type: (identifier) @reference.type))\n(method_declaration returns: (identifier) @reference.type)\n";
+export declare const RUST_QUERIES = "\n; Functions & Items\n(function_item name: (identifier) @name) @definition.function\n(struct_item name: (type_identifier) @name) @definition.struct\n(enum_item name: (type_identifier) @name) @definition.enum\n(trait_item name: (type_identifier) @name) @definition.trait\n(impl_item type: (type_identifier) @name !trait) @definition.impl\n(impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl\n(mod_item name: (identifier) @name) @definition.module\n\n; Type aliases, const, static, macros\n(type_item name: (type_identifier) @name) @definition.type\n(const_item name: (identifier) @name) @definition.const\n(static_item name: (identifier) @name) @definition.static\n(macro_definition name: (identifier) @name) @definition.macro\n\n; Use statements\n(use_declaration argument: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (scoped_identifier\n path: (identifier) @_qualifier\n name: (identifier) @call.name)) @call\n(call_expression function: (generic_function function: (identifier) @call.name)) @call\n\n; Struct literal construction: User { name: value }\n(struct_expression name: (type_identifier) @call.name) @call\n\n; Type references \u2014 captures types used in field/param/return-type positions\n(field_declaration type: (type_identifier) @reference.type)\n(parameter pattern: (_) type: (type_identifier) @reference.type)\n(function_item return_type: (type_identifier) @reference.type)\n\n; Wrapped type references \u2014 &Type, &mut Type\n(field_declaration type: (reference_type (type_identifier) @reference.type))\n(parameter pattern: (_) type: (reference_type (type_identifier) @reference.type))\n(function_item return_type: (reference_type (type_identifier) @reference.type))\n\n; Generic wrapper types \u2014 Box<Type>, Arc<Type>, Vec<Type>, Option<Type>, Result<Type,_>, etc.\n; Capture the type argument (inner type), not the wrapper name.\n(field_declaration type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))\n(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))\n(function_item return_type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))\n\n; impl Trait in parameter / return positions\n(parameter pattern: (_) type: (abstract_type (type_identifier) @reference.type))\n(function_item return_type: (abstract_type (type_identifier) @reference.type))\n\n; dyn Trait \u2014 trait objects (direct: fn foo(x: dyn Trait) or field: x: dyn Trait)\n(field_declaration type: (dynamic_type (type_identifier) @reference.type))\n(parameter pattern: (_) type: (dynamic_type (type_identifier) @reference.type))\n(function_item return_type: (dynamic_type (type_identifier) @reference.type))\n\n; dyn Trait nested inside generic wrapper \u2014 Box<dyn Trait>, Arc<dyn Trait>, etc.\n(field_declaration type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))\n(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))\n(function_item return_type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))\n\n; Heritage (trait implementation) \u2014 all combinations of concrete/generic trait \u00D7 concrete/generic type\n(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n";
export declare const PHP_QUERIES = "\n; \u2500\u2500 Namespace \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(namespace_definition\n name: (namespace_name) @name) @definition.namespace\n\n; \u2500\u2500 Classes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @name) @definition.class\n\n; \u2500\u2500 Interfaces \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(interface_declaration\n name: (name) @name) @definition.interface\n\n; \u2500\u2500 Traits \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(trait_declaration\n name: (name) @name) @definition.trait\n\n; \u2500\u2500 Enums (PHP 8.1) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(enum_declaration\n name: (name) @name) @definition.enum\n\n; \u2500\u2500 Top-level functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(function_definition\n name: (name) @name) @definition.function\n\n; \u2500\u2500 Methods (including constructors) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(method_declaration\n name: (name) @name) @definition.method\n\n; \u2500\u2500 Class properties (including Eloquent $fillable, $casts, etc.) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(property_declaration\n (property_element\n (variable_name\n (name) @name))) @definition.property\n\n; \u2500\u2500 Imports: use statements \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Simple: use App\\Models\\User;\n(namespace_use_declaration\n (namespace_use_clause\n (qualified_name) @import.source)) @import\n\n; \u2500\u2500 Function/method calls \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Regular function call: foo()\n(function_call_expression\n function: (name) @call.name) @call\n\n; Method call: $obj->method()\n(member_call_expression\n name: (name) @call.name) @call\n\n; Nullsafe method call: $obj?->method()\n(nullsafe_member_call_expression\n name: (name) @call.name) @call\n\n; Static call: Foo::bar() (php_only uses scoped_call_expression)\n(scoped_call_expression\n name: (name) @call.name) @call\n\n; Constructor call: new User()\n(object_creation_expression (name) @call.name) @call\n\n; \u2500\u2500 Heritage: extends \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n (base_clause\n [(name) (qualified_name)] @heritage.extends)) @heritage\n\n; \u2500\u2500 Heritage: implements \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n (class_interface_clause\n [(name) (qualified_name)] @heritage.implements)) @heritage.impl\n\n; \u2500\u2500 Heritage: use trait (must capture enclosing class name) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n body: (declaration_list\n (use_declaration\n [(name) (qualified_name)] @heritage.trait))) @heritage\n\n; \u2500\u2500 Type references \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(named_type (name) @reference.type)\n";
export declare const RUBY_QUERIES = "\n; \u2500\u2500 Modules \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(module\n name: (constant) @name) @definition.module\n\n; \u2500\u2500 Classes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class\n name: (constant) @name) @definition.class\n\n; \u2500\u2500 Instance methods \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(method\n name: (identifier) @name) @definition.method\n\n; \u2500\u2500 Singleton (class-level) methods \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(singleton_method\n name: (identifier) @name) @definition.method\n\n; \u2500\u2500 Require / require_relative \u2192 IMPORTS \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Capture the string argument so the second pass emits an IMPORTS edge.\n(call\n method: (identifier) @_req\n arguments: (argument_list\n (string (string_content) @import.source))\n (#match? @_req \"^require\")) @import\n\n; \u2500\u2500 All other calls \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(call\n method: (identifier) @call.name) @call\n\n; \u2500\u2500 Bare calls without parens (identifiers at statement level are method calls) \u2500\n; NOTE: This may over-capture variable reads as calls (e.g. 'result' at\n; statement level). Ruby's grammar makes bare identifiers ambiguous \u2014 they\n; could be local variables or zero-arity method calls. Post-processing via\n; the BUILTINS set suppresses most false positives.\n(body_statement\n (identifier) @call.name @call)\n\n; \u2500\u2500 Heritage: class < SuperClass \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class\n name: (constant) @heritage.class\n superclass: (superclass\n (constant) @heritage.extends)) @heritage\n";
export declare const KOTLIN_QUERIES = "\n; \u2500\u2500 Interfaces \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; tree-sitter-kotlin (fwcd) has no interface_declaration node type.\n; Interfaces are class_declaration nodes with an anonymous \"interface\" keyword child.\n(class_declaration\n \"interface\"\n (type_identifier) @name) @definition.interface\n\n; \u2500\u2500 Classes (regular, data, sealed, enum) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; All have the anonymous \"class\" keyword child. enum class has both\n; \"enum\" and \"class\" children \u2014 the \"class\" child still matches.\n(class_declaration\n \"class\"\n (type_identifier) @name) @definition.class\n\n; \u2500\u2500 Object declarations (Kotlin singletons) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(object_declaration\n (type_identifier) @name) @definition.class\n\n; \u2500\u2500 Companion objects (named only) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(companion_object\n (type_identifier) @name) @definition.class\n\n; \u2500\u2500 Functions (top-level, member, extension) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(function_declaration\n (simple_identifier) @name) @definition.function\n\n; \u2500\u2500 Properties \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(property_declaration\n (variable_declaration\n (simple_identifier) @name)) @definition.property\n\n; \u2500\u2500 Enum entries \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(enum_entry\n (simple_identifier) @name) @definition.enum\n\n; \u2500\u2500 Type aliases \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(type_alias\n (type_identifier) @name) @definition.type\n\n; \u2500\u2500 Imports \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(import_header\n (identifier) @import.source) @import\n\n; \u2500\u2500 Function calls (direct) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(call_expression\n (simple_identifier) @call.name) @call\n\n; \u2500\u2500 Method calls (via navigation: obj.method()) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(call_expression\n (navigation_expression\n (navigation_suffix\n (simple_identifier) @call.name))) @call\n\n; \u2500\u2500 Constructor invocations \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(constructor_invocation\n (user_type\n (type_identifier) @call.name)) @call\n\n; \u2500\u2500 Infix function calls (e.g., a to b, x until y) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(infix_expression\n (simple_identifier) @call.name) @call\n\n; \u2500\u2500 Heritage: extends / implements via delegation_specifier \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Interface implementation (bare user_type): class Foo : Bar\n(class_declaration\n (type_identifier) @heritage.class\n (delegation_specifier\n (user_type (type_identifier) @heritage.extends))) @heritage\n\n; Class extension (constructor_invocation): class Foo : Bar()\n(class_declaration\n (type_identifier) @heritage.class\n (delegation_specifier\n (constructor_invocation\n (user_type (type_identifier) @heritage.extends)))) @heritage\n\n; \u2500\u2500 Type references \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(type_reference (user_type (type_identifier) @reference.type))\n";
diff --git a/core-ingestion/dist/queries.js b/core-ingestion/dist/queries.js
index 7abf429c..8e98da87 100644
--- a/core-ingestion/dist/queries.js
+++ b/core-ingestion/dist/queries.js
@@ -61,6 +61,13 @@ export const TYPESCRIPT_QUERIES = `
function: (member_expression
property: (property_identifier) @call.name)) @call
+; this.method() — capture this as qualifier so index.ts can substitute the enclosing class.
+; Analogous to Python's self/cls substitution.
+(call_expression
+ function: (member_expression
+ object: (this) @_qualifier
+ property: (property_identifier) @call.name)) @call
+
; Constructor calls: new Foo()
(new_expression
constructor: (identifier) @call.name) @call
@@ -165,6 +172,13 @@ export const JAVASCRIPT_QUERIES = `
function: (member_expression
property: (property_identifier) @call.name)) @call
+; this.method() — capture this as qualifier so index.ts can substitute the enclosing class.
+; Analogous to Python's self/cls substitution.
+(call_expression
+ function: (member_expression
+ object: (this) @_qualifier
+ property: (property_identifier) @call.name)) @call
+
; Constructor calls: new Foo()
(new_expression
constructor: (identifier) @call.name) @call
@@ -205,6 +219,37 @@ export const PYTHON_QUERIES = `
function: (attribute
attribute: (identifier) @call.name)) @call
+; Attribute calls with object captured as qualifier so Tier-1b resolution can use
+; class/module name to break ties (e.g. Session.execute → resolves to Session in
+; the importing file). Emitted alongside the bare-name pattern above so that
+; bare-name global fallback still fires when qualifier resolution fails.
+(call
+ function: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier) @call.name)) @call
+
+; Django ORM manager pattern: Model.objects.method(...)
+; Unwinds the intermediate accessor (objects/related_manager/etc.) and captures
+; the model class as qualifier, e.g. User.objects.filter(...) → CALLS User.filter.
+; This creates cross-file edges between view/form code and model definitions.
+(call
+ function: (attribute
+ object: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier))
+ attribute: (identifier) @call.name)) @call
+
+; Chained call pattern: qualifier.method1(...).method2(...)
+; Propagates the qualifier from the inner call to the outer, e.g.
+; User.filter(...).order_by(...) → CALLS User.order_by.
+(call
+ function: (attribute
+ object: (call
+ function: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier)))
+ attribute: (identifier) @call.name)) @call
+
; Heritage queries - Python class inheritance
(class_definition
name: (identifier) @heritage.class
@@ -214,6 +259,45 @@ export const PYTHON_QUERIES = `
; Type references — captures types used in type annotations / hints
(typed_parameter type: (type (identifier) @reference.type))
(typed_default_parameter type: (type (identifier) @reference.type))
+
+; Typed parameters: capture name + type together so qualifier substitution can
+; map a local variable name to its declared class (e.g. query: Query → 'query' → 'Query').
+(function_definition
+ parameters: (parameters
+ (typed_parameter
+ (identifier) @_typed_param_name
+ type: (type (identifier) @_typed_param_type)))) @_typed_param_scope
+
+(function_definition
+ parameters: (parameters
+ (typed_default_parameter
+ (identifier) @_typed_param_name
+ type: (type (identifier) @_typed_param_type)))) @_typed_param_scope
+
+; Assignment tracking: x = SomeClass() or x = SomeClass(args)
+; Maps local variable name → constructor type for untyped-parameter qualifier substitution.
+; Only PascalCase RHS names are tracked in TypeScript (constructor convention).
+(function_definition
+ body: (block
+ (expression_statement
+ (assignment
+ left: (identifier) @_assign_lhs
+ right: (call
+ function: (identifier) @_assign_rhs_type))))) @_assign_scope
+
+; Assignment tracking: x = Model.objects.method()
+; Captures the outermost identifier (model class) for ORM manager patterns.
+(function_definition
+ body: (block
+ (expression_statement
+ (assignment
+ left: (identifier) @_assign_lhs
+ right: (call
+ function: (attribute
+ object: (attribute
+ object: (identifier) @_assign_rhs_type
+ attribute: (identifier))
+ attribute: (identifier))))))) @_assign_scope
`;
// Java queries - works with tree-sitter-java
export const JAVA_QUERIES = `
@@ -237,14 +321,30 @@ export const JAVA_QUERIES = `
; Constructor calls: new Foo()
(object_creation_expression type: (type_identifier) @call.name) @call
-; Heritage - extends class
+; Heritage - extends class (plain: extends Foo)
(class_declaration name: (identifier) @heritage.class
(superclass (type_identifier) @heritage.extends)) @heritage
-; Heritage - implements interfaces
+; Heritage - extends class with generics (extends Foo<T>)
+(class_declaration name: (identifier) @heritage.class
+ (superclass (generic_type (type_identifier) @heritage.extends))) @heritage
+
+; Heritage - implements interfaces (plain: implements Foo)
(class_declaration name: (identifier) @heritage.class
(super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
+; Heritage - implements interfaces with generics (implements Foo<T>)
+(class_declaration name: (identifier) @heritage.class
+ (super_interfaces (type_list (generic_type (type_identifier) @heritage.implements)))) @heritage.impl
+
+; Heritage - interface extends interfaces (plain: extends Foo)
+(interface_declaration name: (identifier) @heritage.class
+ (extends_interfaces (type_list (type_identifier) @heritage.extends))) @heritage
+
+; Heritage - interface extends interfaces with generics (extends Foo<T>)
+(interface_declaration name: (identifier) @heritage.class
+ (extends_interfaces (type_list (generic_type (type_identifier) @heritage.extends)))) @heritage
+
; Type references — captures types used in field/param/return-type positions
(field_declaration type: (type_identifier) @reference.type)
(formal_parameter type: (type_identifier) @reference.type)
@@ -265,8 +365,9 @@ export const C_QUERIES = `
(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
; Structs, Unions, Enums, Typedefs
-(struct_specifier name: (type_identifier) @name) @definition.struct
-(union_specifier name: (type_identifier) @name) @definition.union
+; Only match struct/union with a body to avoid treating forward declarations as definitions
+(struct_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.struct
+(union_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.union
(enum_specifier name: (type_identifier) @name) @definition.enum
(type_definition declarator: (type_identifier) @name) @definition.typedef
@@ -284,33 +385,85 @@ export const C_QUERIES = `
; Type references — captures types used in declaration/parameter positions
(declaration type: (type_identifier) @reference.type)
(parameter_declaration type: (type_identifier) @reference.type)
+; struct_specifier forms: e.g. "const struct Curl_protocol foo = {...}"
+(declaration type: (struct_specifier name: (type_identifier) @reference.type))
+(parameter_declaration type: (struct_specifier name: (type_identifier) @reference.type))
`;
// Go queries - works with tree-sitter-go
export const GO_QUERIES = `
-; Functions & Methods
+; Functions
(function_declaration name: (identifier) @name) @definition.function
-(method_declaration name: (field_identifier) @name) @definition.method
+
+; Methods — non-pointer receiver: func (r ReceiverType) Name(...)
+; The receiver.type capture lets the parser set container = ReceiverType so that
+; qualifiedKey becomes "ReceiverType.Name" instead of bare "Name".
+(method_declaration
+ receiver: (parameter_list (parameter_declaration
+ type: (type_identifier) @receiver.type))
+ name: (field_identifier) @name) @definition.method
+
+; Methods — pointer receiver: func (r *ReceiverType) Name(...)
+(method_declaration
+ receiver: (parameter_list (parameter_declaration
+ type: (pointer_type (type_identifier) @receiver.type)))
+ name: (field_identifier) @name) @definition.method
; Types
(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
+; Interface method signatures — emits each method inside an interface_type as a method entity.
+; @heritage.class = interface name (used as container in index.ts via heritageClassCapture).
+; node type is method_elem in tree-sitter-go v0.21+.
+(type_declaration
+ (type_spec
+ name: (type_identifier) @heritage.class
+ type: (interface_type
+ (method_elem
+ name: (field_identifier) @name)))) @definition.method
+
; Imports
(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
-; Struct embedding (anonymous fields = inheritance)
+; Struct embedding — value: type Foo struct { Bar }
+; NOTE: no @definition.* capture here — if it were present, defCapture fires first and
+; the heritage block is never reached (early-exit in the first pass).
+; The . anchors require the type_identifier to be the FIRST and ONLY named child of
+; field_declaration, distinguishing anonymous embedded fields from named fields like:
+; w Writer (named field — field_identifier_list precedes type, not matched)
+(type_declaration
+ (type_spec
+ name: (type_identifier) @heritage.class
+ type: (struct_type
+ (field_declaration_list
+ (field_declaration .
+ (type_identifier) @heritage.extends .)))))
+
+; Struct embedding — pointer: type Foo struct { *Bar }
+; The . anchor requires pointer_type to be the first named child (anonymous embedded).
(type_declaration
(type_spec
name: (type_identifier) @heritage.class
type: (struct_type
(field_declaration_list
- (field_declaration
- type: (type_identifier) @heritage.extends))))) @definition.struct
+ (field_declaration .
+ (pointer_type (type_identifier) @heritage.extends) .)))))
; Calls
(call_expression function: (identifier) @call.name) @call
-(call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
+; Qualified calls: pkg.Func() or localVar.Method() where the operand is a simple
+; identifier — capture it as @_qualifier so cross-file resolution uses the fully
+; qualified name "scrape.NewManager" instead of bare "NewManager", preventing
+; ambiguous same-named symbols in different packages from being collapsed.
+(call_expression function: (selector_expression
+ operand: (identifier) @_qualifier
+ field: (field_identifier) @call.name)) @call
+; Chained/complex calls: a.b.Method(), call().Method(), index[i].Method() — the
+; operand is not a simple identifier, so emit without qualifier (bare method name).
+(call_expression function: (selector_expression
+ operand: (selector_expression)
+ field: (field_identifier) @call.name)) @call
; Struct literal construction: User{Name: "Alice"}
(composite_literal type: (type_identifier) @call.name) @call
@@ -321,6 +474,12 @@ export const GO_QUERIES = `
; Return types: in tree-sitter-go, return type is a direct type_identifier child of function/method
(function_declaration result: (type_identifier) @reference.type)
(method_declaration result: (type_identifier) @reference.type)
+
+; Pointer-type variants: e.g. opts *Options, func(*Options) *Result
+(field_declaration type: (pointer_type (type_identifier) @reference.type))
+(parameter_declaration type: (pointer_type (type_identifier) @reference.type))
+(function_declaration result: (pointer_type (type_identifier) @reference.type))
+(method_declaration result: (pointer_type (type_identifier) @reference.type))
`;
// C++ queries - works with tree-sitter-cpp
export const CPP_QUERIES = `
@@ -452,8 +611,8 @@ export const CSHARP_QUERIES = `
; Type references — captures types used in field/param/return-type positions
(parameter type: (identifier) @reference.type)
(variable_declaration type: (identifier) @reference.type)
-(field_declaration type: (identifier) @reference.type)
-(method_declaration return_type: (identifier) @reference.type)
+(field_declaration (variable_declaration type: (identifier) @reference.type))
+(method_declaration returns: (identifier) @reference.type)
`;
// Rust queries - works with tree-sitter-rust
export const RUST_QUERIES = `
@@ -478,7 +637,9 @@ export const RUST_QUERIES = `
; Calls
(call_expression function: (identifier) @call.name) @call
(call_expression function: (field_expression field: (field_identifier) @call.name)) @call
-(call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
+(call_expression function: (scoped_identifier
+ path: (identifier) @_qualifier
+ name: (identifier) @call.name)) @call
(call_expression function: (generic_function function: (identifier) @call.name)) @call
; Struct literal construction: User { name: value }
@@ -489,6 +650,31 @@ export const RUST_QUERIES = `
(parameter pattern: (_) type: (type_identifier) @reference.type)
(function_item return_type: (type_identifier) @reference.type)
+; Wrapped type references — &Type, &mut Type
+(field_declaration type: (reference_type (type_identifier) @reference.type))
+(parameter pattern: (_) type: (reference_type (type_identifier) @reference.type))
+(function_item return_type: (reference_type (type_identifier) @reference.type))
+
+; Generic wrapper types — Box<Type>, Arc<Type>, Vec<Type>, Option<Type>, Result<Type,_>, etc.
+; Capture the type argument (inner type), not the wrapper name.
+(field_declaration type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+(function_item return_type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+
+; impl Trait in parameter / return positions
+(parameter pattern: (_) type: (abstract_type (type_identifier) @reference.type))
+(function_item return_type: (abstract_type (type_identifier) @reference.type))
+
+; dyn Trait — trait objects (direct: fn foo(x: dyn Trait) or field: x: dyn Trait)
+(field_declaration type: (dynamic_type (type_identifier) @reference.type))
+(parameter pattern: (_) type: (dynamic_type (type_identifier) @reference.type))
+(function_item return_type: (dynamic_type (type_identifier) @reference.type))
+
+; dyn Trait nested inside generic wrapper — Box<dyn Trait>, Arc<dyn Trait>, etc.
+(field_declaration type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+(function_item return_type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+
; Heritage (trait implementation) — all combinations of concrete/generic trait × concrete/generic type
(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
diff --git a/core-ingestion/dist/role-classifier.js b/core-ingestion/dist/role-classifier.js
index 7310e77e..d1671b21 100644
--- a/core-ingestion/dist/role-classifier.js
+++ b/core-ingestion/dist/role-classifier.js
@@ -9,11 +9,13 @@ const TEST_PATH_PATTERNS = [
{ pattern: /[/\\]src[/\\]test[/\\]/i, signal: 'path:src/test/' },
{ pattern: /[/\\]test[/\\]unit[/\\]/i, signal: 'path:test/unit/' },
{ pattern: /[/\\]test[/\\]integration[/\\]/i, signal: 'path:test/integration/' },
+ // C#/.NET: directories named Foo.Tests or Foo.Test (e.g. Newtonsoft.Json.Tests/)
+ { pattern: /[/\\][^/\\]*\.tests?[/\\]/i, signal: 'path:.Tests/' },
];
const TEST_FILE_PATTERNS = [
{ pattern: /\.test\.[^.]+$/i, signal: 'filename:.test.' },
{ pattern: /\.spec\.[^.]+$/i, signal: 'filename:.spec.' },
- { pattern: /Test\.[^.]+$/, signal: 'filename:Test.' },
+ { pattern: /Tests?\.[^.]+$/, signal: 'filename:Test(s).' }, // matches Test.cs and Tests.cs
{ pattern: /Spec\.[^.]+$/, signal: 'filename:Spec.' },
{ pattern: /_test\.[^.]+$/i, signal: 'filename:_test.' },
{ pattern: /_spec\.[^.]+$/i, signal: 'filename:_spec.' },
@@ -33,6 +35,10 @@ const TEST_IMPORT_PATTERNS = [
{ pattern: /"testing"/, signal: 'import:go_testing' },
{ pattern: /require\s+['"]rspec['"]/, signal: 'import:rspec' },
{ pattern: /require\s+['"]minitest['"]/, signal: 'import:minitest' },
+ // C#/.NET test frameworks
+ { pattern: /using\s+NUnit\.Framework/, signal: 'import:nunit' },
+ { pattern: /using\s+Xunit/, signal: 'import:xunit' },
+ { pattern: /using\s+Microsoft\.VisualStudio\.TestTools\.UnitTesting/, signal: 'import:mstest' },
];
const FIXTURE_PATH_PATTERNS = [
{ pattern: /[/\\]fixtures?[/\\]/i, signal: 'path:fixtures/' },
diff --git a/core-ingestion/package-lock.json b/core-ingestion/package-lock.json
index 0754e6e4..ac6d695f 100644
--- a/core-ingestion/package-lock.json
+++ b/core-ingestion/package-lock.json
@@ -13,7 +13,7 @@
"tree-sitter-c-sharp": "^0.21.0",
"tree-sitter-cpp": "^0.22.0",
"tree-sitter-go": "^0.21.0",
- "tree-sitter-java": "^0.21.0",
+ "tree-sitter-java": "^0.23.5",
"tree-sitter-javascript": "^0.21.0",
"tree-sitter-kotlin": "^0.3.8",
"tree-sitter-php": "^0.23.12",
@@ -1270,20 +1270,20 @@
}
},
"node_modules/tree-sitter-java": {
- "version": "0.21.0",
- "resolved": "https://registry.npmjs.org/tree-sitter-java/-/tree-sitter-java-0.21.0.tgz",
- "integrity": "sha512-CKJiTo1uc3SUsgEcaZgufGx8my6dzihy8JR/JsJH40Tj3uSe2/eFLk+0q+fpbosGAyY4YiXJtEoFB2O4bS2yOw==",
+ "version": "0.23.5",
+ "resolved": "https://registry.npmjs.org/tree-sitter-java/-/tree-sitter-java-0.23.5.tgz",
+ "integrity": "sha512-Yju7oQ0Xx7GcUT01mUglPP+bYfvqjNCGdxqigTnew9nLGoII42PNVP3bHrYeMxswiCRM0yubWmN5qk+zsg0zMA==",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
- "node-addon-api": "^8.0.0",
- "node-gyp-build": "^4.8.0"
+ "node-addon-api": "^8.2.2",
+ "node-gyp-build": "^4.8.2"
},
"peerDependencies": {
- "tree-sitter": "^0.21.0"
+ "tree-sitter": "^0.21.1"
},
"peerDependenciesMeta": {
- "tree_sitter": {
+ "tree-sitter": {
"optional": true
}
}
diff --git a/core-ingestion/package.json b/core-ingestion/package.json
index b2a1404b..f9f6c0f5 100644
--- a/core-ingestion/package.json
+++ b/core-ingestion/package.json
@@ -22,7 +22,7 @@
"tree-sitter-c-sharp": "^0.21.0",
"tree-sitter-cpp": "^0.22.0",
"tree-sitter-go": "^0.21.0",
- "tree-sitter-java": "^0.21.0",
+ "tree-sitter-java": "^0.23.5",
"tree-sitter-javascript": "^0.21.0",
"tree-sitter-kotlin": "^0.3.8",
"tree-sitter-php": "^0.23.12",
diff --git a/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap b/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap
new file mode 100644
index 00000000..a97c3f17
--- /dev/null
+++ b/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap
@@ -0,0 +1,1440 @@
+// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
+
+exports[`parseFile snapshots > snapshots Identifiers.scala 1`] = `
+{
+ "entities": [
+ {
+ "kind": "file",
+ "language": "scala",
+ "lineEnd": 42,
+ "lineStart": 1,
+ "name": "Identifiers.scala",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 7,
+ "lineStart": 7,
+ "name": "NodeId",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 11,
+ "lineStart": 8,
+ "name": "NodeId",
+ },
+ {
+ "container": "NodeId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 9,
+ "lineStart": 9,
+ "name": "encoder",
+ },
+ {
+ "container": "NodeId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 10,
+ "lineStart": 10,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 13,
+ "lineStart": 13,
+ "name": "EdgeId",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 17,
+ "lineStart": 14,
+ "name": "EdgeId",
+ },
+ {
+ "container": "EdgeId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 15,
+ "lineStart": 15,
+ "name": "encoder",
+ },
+ {
+ "container": "EdgeId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 16,
+ "lineStart": 16,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 19,
+ "lineStart": 19,
+ "name": "PatchId",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 23,
+ "lineStart": 20,
+ "name": "PatchId",
+ },
+ {
+ "container": "PatchId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 21,
+ "lineStart": 21,
+ "name": "encoder",
+ },
+ {
+ "container": "PatchId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 22,
+ "lineStart": 22,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 25,
+ "lineStart": 25,
+ "name": "ClaimId",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 29,
+ "lineStart": 26,
+ "name": "ClaimId",
+ },
+ {
+ "container": "ClaimId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 27,
+ "lineStart": 27,
+ "name": "encoder",
+ },
+ {
+ "container": "ClaimId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 28,
+ "lineStart": 28,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 31,
+ "lineStart": 31,
+ "name": "ConflictId",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 35,
+ "lineStart": 32,
+ "name": "ConflictId",
+ },
+ {
+ "container": "ConflictId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 33,
+ "lineStart": 33,
+ "name": "encoder",
+ },
+ {
+ "container": "ConflictId",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 34,
+ "lineStart": 34,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 37,
+ "lineStart": 37,
+ "name": "Rev",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 41,
+ "lineStart": 38,
+ "name": "Rev",
+ },
+ {
+ "container": "Rev",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 39,
+ "lineStart": 39,
+ "name": "encoder",
+ },
+ {
+ "container": "Rev",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 40,
+ "lineStart": 40,
+ "name": "decoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 3,
+ "lineStart": 3,
+ "name": "java.util.UUID",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "io.circe.Decoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "io.circe.Encoder",
+ },
+ ],
+ "filePath": "memory-layer/src/main/scala/ix/memory/model/Identifiers.scala",
+ "fileRole": {
+ "role": "production",
+ "role_confidence": 0.5,
+ "role_signals": [],
+ },
+ "language": "scala",
+ "relationships": [
+ {
+ "dstName": "NodeId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "NodeId",
+ },
+ {
+ "dstName": "NodeId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "NodeId",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "NodeId",
+ },
+ {
+ "dstName": "EdgeId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "EdgeId",
+ },
+ {
+ "dstName": "EdgeId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "EdgeId",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "EdgeId",
+ },
+ {
+ "dstName": "PatchId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "PatchId",
+ },
+ {
+ "dstName": "PatchId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "PatchId",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "PatchId",
+ },
+ {
+ "dstName": "ClaimId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "ClaimId",
+ },
+ {
+ "dstName": "ClaimId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "ClaimId",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "ClaimId",
+ },
+ {
+ "dstName": "ConflictId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "ConflictId",
+ },
+ {
+ "dstName": "ConflictId",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "ConflictId",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "ConflictId",
+ },
+ {
+ "dstName": "Rev",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "AnyVal",
+ "predicate": "EXTENDS",
+ "srcName": "Rev",
+ },
+ {
+ "dstName": "Rev",
+ "predicate": "CONTAINS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "Rev",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "Rev",
+ },
+ {
+ "dstName": "java.util.UUID",
+ "predicate": "IMPORTS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "io.circe.Decoder",
+ "predicate": "IMPORTS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "io.circe.Encoder",
+ "predicate": "IMPORTS",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "UUID",
+ "predicate": "REFERENCES",
+ "srcName": "NodeId",
+ },
+ {
+ "dstName": "NodeId",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "NodeId.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "NodeId.decoder",
+ },
+ {
+ "dstName": "NodeId",
+ "predicate": "CALLS",
+ "srcName": "NodeId.decoder",
+ },
+ {
+ "dstName": "UUID",
+ "predicate": "REFERENCES",
+ "srcName": "EdgeId",
+ },
+ {
+ "dstName": "EdgeId",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "EdgeId.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "EdgeId.decoder",
+ },
+ {
+ "dstName": "EdgeId",
+ "predicate": "CALLS",
+ "srcName": "EdgeId.decoder",
+ },
+ {
+ "dstName": "UUID",
+ "predicate": "REFERENCES",
+ "srcName": "PatchId",
+ },
+ {
+ "dstName": "PatchId",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "PatchId.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "PatchId.decoder",
+ },
+ {
+ "dstName": "PatchId",
+ "predicate": "CALLS",
+ "srcName": "PatchId.decoder",
+ },
+ {
+ "dstName": "UUID",
+ "predicate": "REFERENCES",
+ "srcName": "ClaimId",
+ },
+ {
+ "dstName": "ClaimId",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "ClaimId.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "ClaimId.decoder",
+ },
+ {
+ "dstName": "ClaimId",
+ "predicate": "CALLS",
+ "srcName": "ClaimId.decoder",
+ },
+ {
+ "dstName": "UUID",
+ "predicate": "REFERENCES",
+ "srcName": "ConflictId",
+ },
+ {
+ "dstName": "ConflictId",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "ConflictId.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "ConflictId.decoder",
+ },
+ {
+ "dstName": "ConflictId",
+ "predicate": "CALLS",
+ "srcName": "ConflictId.decoder",
+ },
+ {
+ "dstName": "Rev",
+ "predicate": "REFERENCES",
+ "srcName": "Identifiers.scala",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "Rev.encoder",
+ },
+ {
+ "dstName": "map",
+ "predicate": "CALLS",
+ "srcName": "Rev.decoder",
+ },
+ {
+ "dstName": "Rev",
+ "predicate": "CALLS",
+ "srcName": "Rev.decoder",
+ },
+ ],
+}
+`;
+
+exports[`parseFile snapshots > snapshots Node.scala 1`] = `
+{
+ "entities": [
+ {
+ "kind": "file",
+ "language": "scala",
+ "lineEnd": 103,
+ "lineStart": 1,
+ "name": "Node.scala",
+ },
+ {
+ "container": undefined,
+ "kind": "interface",
+ "language": "scala",
+ "lineEnd": 8,
+ "lineStart": 8,
+ "name": "NodeKind",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 83,
+ "lineStart": 9,
+ "name": "NodeKind",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 10,
+ "lineStart": 10,
+ "name": "Module",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 11,
+ "lineStart": 11,
+ "name": "File",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 12,
+ "lineStart": 12,
+ "name": "Class",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 13,
+ "lineStart": 13,
+ "name": "Function",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 14,
+ "lineStart": 14,
+ "name": "Variable",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 15,
+ "lineStart": 15,
+ "name": "Config",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 16,
+ "lineStart": 16,
+ "name": "ConfigEntry",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 17,
+ "lineStart": 17,
+ "name": "Service",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 18,
+ "lineStart": 18,
+ "name": "Endpoint",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 19,
+ "lineStart": 19,
+ "name": "Intent",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 20,
+ "lineStart": 20,
+ "name": "Decision",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 21,
+ "lineStart": 21,
+ "name": "Doc",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 22,
+ "lineStart": 22,
+ "name": "Object",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 23,
+ "lineStart": 23,
+ "name": "Trait",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 24,
+ "lineStart": 24,
+ "name": "Interface",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 25,
+ "lineStart": 25,
+ "name": "Method",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 26,
+ "lineStart": 26,
+ "name": "Plan",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 27,
+ "lineStart": 27,
+ "name": "Task",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 28,
+ "lineStart": 28,
+ "name": "Bug",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 29,
+ "lineStart": 29,
+ "name": "Goal",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 30,
+ "lineStart": 30,
+ "name": "Region",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 54,
+ "lineStart": 32,
+ "name": "nameMap",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 78,
+ "lineStart": 56,
+ "name": "encoder",
+ },
+ {
+ "container": "NodeKind",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 82,
+ "lineStart": 80,
+ "name": "decoder",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 95,
+ "lineStart": 85,
+ "name": "GraphNode",
+ },
+ {
+ "container": undefined,
+ "kind": "class",
+ "language": "scala",
+ "lineEnd": 102,
+ "lineStart": 97,
+ "name": "GraphNode",
+ },
+ {
+ "container": "GraphNode",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 100,
+ "lineStart": 100,
+ "name": "encoder",
+ },
+ {
+ "container": "GraphNode",
+ "kind": "function",
+ "language": "scala",
+ "lineEnd": 101,
+ "lineStart": 101,
+ "name": "decoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 3,
+ "lineStart": 3,
+ "name": "java.time.Instant",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "io.circe.Decoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "io.circe.Encoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "io.circe.Json",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 6,
+ "lineStart": 6,
+ "name": "io.circe.generic.semiauto.deriveDecoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 6,
+ "lineStart": 6,
+ "name": "io.circe.generic.semiauto.deriveEncoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 98,
+ "lineStart": 98,
+ "name": "Provenance.instantEncoder",
+ },
+ {
+ "kind": "module",
+ "language": "scala",
+ "lineEnd": 98,
+ "lineStart": 98,
+ "name": "Provenance.instantDecoder",
+ },
+ ],
+ "filePath": "memory-layer/src/main/scala/ix/memory/model/Node.scala",
+ "fileRole": {
+ "role": "production",
+ "role_confidence": 0.5,
+ "role_signals": [],
+ },
+ "language": "scala",
+ "relationships": [
+ {
+ "dstName": "NodeKind",
+ "predicate": "CONTAINS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "CONTAINS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "Module",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Module",
+ },
+ {
+ "dstName": "File",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "File",
+ },
+ {
+ "dstName": "Class",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Class",
+ },
+ {
+ "dstName": "Function",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Function",
+ },
+ {
+ "dstName": "Variable",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Variable",
+ },
+ {
+ "dstName": "Config",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Config",
+ },
+ {
+ "dstName": "ConfigEntry",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "ConfigEntry",
+ },
+ {
+ "dstName": "Service",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Service",
+ },
+ {
+ "dstName": "Endpoint",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Endpoint",
+ },
+ {
+ "dstName": "Intent",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Intent",
+ },
+ {
+ "dstName": "Decision",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Decision",
+ },
+ {
+ "dstName": "Doc",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Doc",
+ },
+ {
+ "dstName": "Object",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Object",
+ },
+ {
+ "dstName": "Trait",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Trait",
+ },
+ {
+ "dstName": "Interface",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Interface",
+ },
+ {
+ "dstName": "Method",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Method",
+ },
+ {
+ "dstName": "Plan",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Plan",
+ },
+ {
+ "dstName": "Task",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Task",
+ },
+ {
+ "dstName": "Bug",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Bug",
+ },
+ {
+ "dstName": "Goal",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Goal",
+ },
+ {
+ "dstName": "Region",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "EXTENDS",
+ "srcName": "Region",
+ },
+ {
+ "dstName": "nameMap",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "NodeKind",
+ },
+ {
+ "dstName": "GraphNode",
+ "predicate": "CONTAINS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "GraphNode",
+ "predicate": "CONTAINS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "encoder",
+ "predicate": "CONTAINS",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "decoder",
+ "predicate": "CONTAINS",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "java.time.Instant",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "io.circe.Decoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "io.circe.Encoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "io.circe.Json",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "io.circe.generic.semiauto.deriveDecoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "io.circe.generic.semiauto.deriveEncoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "REFERENCES",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "Map",
+ "predicate": "CALLS",
+ "srcName": "NodeKind.nameMap",
+ },
+ {
+ "dstName": "contramap",
+ "predicate": "CALLS",
+ "srcName": "NodeKind.encoder",
+ },
+ {
+ "dstName": "emap",
+ "predicate": "CALLS",
+ "srcName": "NodeKind.decoder",
+ },
+ {
+ "dstName": "get",
+ "predicate": "CALLS",
+ "srcName": "NodeKind.decoder",
+ },
+ {
+ "dstName": "toRight",
+ "predicate": "CALLS",
+ "srcName": "NodeKind.decoder",
+ },
+ {
+ "dstName": "NodeId",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "NodeKind",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "Json",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "Provenance",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "Rev",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "Instant",
+ "predicate": "REFERENCES",
+ "srcName": "GraphNode",
+ },
+ {
+ "dstName": "Provenance.instantEncoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "Provenance.instantDecoder",
+ "predicate": "IMPORTS",
+ "srcName": "Node.scala",
+ },
+ {
+ "dstName": "GraphNode",
+ "predicate": "REFERENCES",
+ "srcName": "Node.scala",
+ },
+ ],
+}
+`;
+
+exports[`parseFile snapshots > snapshots doctor.ts 1`] = `
+{
+ "entities": [
+ {
+ "kind": "file",
+ "language": "typescript",
+ "lineEnd": 101,
+ "lineStart": 1,
+ "name": "doctor.ts",
+ },
+ {
+ "container": undefined,
+ "kind": "interface",
+ "language": "typescript",
+ "lineEnd": 10,
+ "lineStart": 7,
+ "name": "Check",
+ },
+ {
+ "container": undefined,
+ "kind": "function",
+ "language": "typescript",
+ "lineEnd": 100,
+ "lineStart": 12,
+ "name": "registerDoctorCommand",
+ },
+ {
+ "kind": "module",
+ "language": "typescript",
+ "lineEnd": 1,
+ "lineStart": 1,
+ "name": "commander",
+ },
+ {
+ "kind": "module",
+ "language": "typescript",
+ "lineEnd": 2,
+ "lineStart": 2,
+ "name": "chalk",
+ },
+ {
+ "kind": "module",
+ "language": "typescript",
+ "lineEnd": 3,
+ "lineStart": 3,
+ "name": "ui.js",
+ },
+ {
+ "kind": "module",
+ "language": "typescript",
+ "lineEnd": 4,
+ "lineStart": 4,
+ "name": "api.js",
+ },
+ {
+ "kind": "module",
+ "language": "typescript",
+ "lineEnd": 5,
+ "lineStart": 5,
+ "name": "config.js",
+ },
+ ],
+ "filePath": "ix-cli/src/cli/commands/doctor.ts",
+ "fileRole": {
+ "role": "production",
+ "role_confidence": 0.5,
+ "role_signals": [],
+ },
+ "language": "typescript",
+ "relationships": [
+ {
+ "dstName": "Check",
+ "predicate": "CONTAINS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "registerDoctorCommand",
+ "predicate": "CONTAINS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "commander",
+ "predicate": "IMPORTS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "chalk",
+ "predicate": "IMPORTS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "ui.js",
+ "predicate": "IMPORTS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "api.js",
+ "predicate": "IMPORTS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "config.js",
+ "predicate": "IMPORTS",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "Command",
+ "predicate": "REFERENCES",
+ "srcName": "doctor.ts",
+ },
+ {
+ "dstName": "command",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "description",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "option",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "action",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "getEndpoint",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "IxClient",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "health",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "stats",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "conflicts",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "isArray",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "run",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "push",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "every",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "stringify",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "renderSection",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "green",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "red",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "dim",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "renderSuccess",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ {
+ "dstName": "renderError",
+ "predicate": "CALLS",
+ "srcName": "registerDoctorCommand",
+ },
+ ],
+}
+`;
diff --git a/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts b/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts
new file mode 100644
index 00000000..562735de
--- /dev/null
+++ b/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts
@@ -0,0 +1,110 @@
+import * as crypto from 'node:crypto';
+
+import { describe, expect, it } from 'vitest';
+
+import type { FileParseResult, ParsedEntity, ParsedRelationship, ResolvedEdge } from '../index.js';
+import { SupportedLanguages } from '../languages.js';
+import { buildPatchWithResolution } from '../patch-builder.js';
+
+const defaultFileRole = { role: 'production' as const, role_confidence: 0.5, role_signals: [] };
+
+function entity(
+ name: string,
+ language: SupportedLanguages,
+ kind = 'function',
+ container?: string,
+): ParsedEntity {
+ return {
+ name,
+ kind,
+ lineStart: 1,
+ lineEnd: 1,
+ language,
+ container,
+ };
+}
+
+function fileResult(
+ filePath: string,
+ language: SupportedLanguages,
+ entities: ParsedEntity[],
+ relationships: ParsedRelationship[],
+): FileParseResult {
+ return {
+ filePath,
+ language,
+ entities: [
+ { name: filePath.split(/[\\/]/).pop() ?? filePath, kind: 'file', lineStart: 1, lineEnd: 1, language },
+ ...entities,
+ ],
+ relationships,
+ fileRole: defaultFileRole,
+ };
+}
+
+function deterministicId(input: string): string {
+ const hash = crypto.createHash('sha256').update(input).digest('hex');
+ return [
+ hash.slice(0, 8),
+ hash.slice(8, 12),
+ hash.slice(12, 16),
+ hash.slice(16, 20),
+ hash.slice(20, 32),
+ ].join('-');
+}
+
+function nodeId(filePath: string, name: string): string {
+ return deterministicId(`${filePath.replace(/\\/g, '/').toLowerCase()}:${name}`);
+}
+
+describe('buildPatchWithResolution', () => {
+ it('keeps same-name callees distinct when different callers resolve to different files', () => {
+ const sourceFile = '/repo/db_impl_compaction_flush.cc';
+ const result = fileResult(
+ sourceFile,
+ SupportedLanguages.CPlusPlus,
+ [
+ entity('FlushMemTableToOutputFile', SupportedLanguages.CPlusPlus),
+ entity('BackgroundCompaction', SupportedLanguages.CPlusPlus),
+ ],
+ [
+ { srcName: 'FlushMemTableToOutputFile', dstName: 'Run', predicate: 'CALLS' },
+ { srcName: 'BackgroundCompaction', dstName: 'Run', predicate: 'CALLS' },
+ ],
+ );
+
+ const resolvedEdges: ResolvedEdge[] = [
+ {
+ srcFilePath: sourceFile,
+ srcName: 'FlushMemTableToOutputFile',
+ dstFilePath: '/repo/flush_job.cc',
+ dstName: 'Run',
+ dstQualifiedKey: 'FlushJob.Run',
+ predicate: 'CALLS',
+ confidence: 0.9,
+ },
+ {
+ srcFilePath: sourceFile,
+ srcName: 'BackgroundCompaction',
+ dstFilePath: '/repo/compaction_job.cc',
+ dstName: 'Run',
+ dstQualifiedKey: 'CompactionJob.Run',
+ predicate: 'CALLS',
+ confidence: 0.9,
+ },
+ ];
+
+ const patch = buildPatchWithResolution(result, 'test-hash', resolvedEdges);
+ const callEdges = patch.ops.filter(op => op.type === 'UpsertEdge' && op.predicate === 'CALLS');
+
+ expect(callEdges).toHaveLength(2);
+ expect(callEdges).toContainEqual(expect.objectContaining({
+ src: nodeId(sourceFile, 'FlushMemTableToOutputFile'),
+ dst: nodeId('/repo/flush_job.cc', 'FlushJob.Run'),
+ }));
+ expect(callEdges).toContainEqual(expect.objectContaining({
+ src: nodeId(sourceFile, 'BackgroundCompaction'),
+ dst: nodeId('/repo/compaction_job.cc', 'CompactionJob.Run'),
+ }));
+ });
+});
diff --git a/core-ingestion/src/__tests__/queries.c.test.ts b/core-ingestion/src/__tests__/queries.c.test.ts
new file mode 100644
index 00000000..3a81de31
--- /dev/null
+++ b/core-ingestion/src/__tests__/queries.c.test.ts
@@ -0,0 +1,109 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseFile } from '../index.js';
+
+describe('C queries', () => {
+ it('captures functions, structs, typedefs, macros, and calls', () => {
+ const result = parseFile(
+ '/repo/connect.c',
+ `
+#include "curl.h"
+
+typedef struct conn_data {
+ int fd;
+} conn_data;
+
+static int do_connect(conn_data *c) {
+ return open_socket(c->fd);
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.entities.map(e => e.name)).toEqual(
+ expect.arrayContaining(['do_connect', 'conn_data']),
+ );
+ expect(result!.relationships).toContainEqual({
+ srcName: 'do_connect',
+ dstName: 'open_socket',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('captures REFERENCES from typedef type in declaration', () => {
+ const result = parseFile(
+ '/repo/http.c',
+ `
+typedef struct Curl_easy Curl_easy;
+
+static int send_request(Curl_easy *data) {
+ return 0;
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: expect.any(String),
+ dstName: 'Curl_easy',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES from struct_specifier type in declaration (e.g. const struct Foo bar = {...})', () => {
+ const result = parseFile(
+ '/repo/ftp.c',
+ `
+const struct Curl_protocol Curl_protocol_ftp = {
+ "FTP",
+};
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: expect.any(String),
+ dstName: 'Curl_protocol',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES from struct_specifier in parameter declaration', () => {
+ const result = parseFile(
+ '/repo/smtp.c',
+ `
+static int smtp_connect(struct Curl_easy *data, struct connectdata *conn) {
+ return 0;
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: expect.any(String),
+ dstName: 'Curl_easy',
+ predicate: 'REFERENCES',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: expect.any(String),
+ dstName: 'connectdata',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures includes as IMPORTS', () => {
+ const result = parseFile(
+ '/repo/curl_setup.c',
+ `
+#include "curl.h"
+#include <stdlib.h>
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ const importTargets = result!.relationships
+ .filter(r => r.predicate === 'IMPORTS')
+ .map(r => r.dstName);
+ expect(importTargets).toContain('curl.h');
+ });
+});
diff --git a/core-ingestion/src/__tests__/queries.go.test.ts b/core-ingestion/src/__tests__/queries.go.test.ts
new file mode 100644
index 00000000..273cdcb3
--- /dev/null
+++ b/core-ingestion/src/__tests__/queries.go.test.ts
@@ -0,0 +1,183 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseFile } from '../index.js';
+
+describe('Go queries', () => {
+ it('captures structs, interfaces, functions, methods, and imports', () => {
+ const result = parseFile(
+ '/repo/service.go',
+ `
+package service
+
+import "fmt"
+
+type Service struct {
+ name string
+}
+
+type Runner interface {
+ Run()
+}
+
+func NewService(name string) *Service {
+ return &Service{name: name}
+}
+
+func (s *Service) Run() {
+ fmt.Println(s.name)
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.entities.map(e => e.name)).toEqual(
+ expect.arrayContaining(['Service', 'Runner', 'NewService', 'Run']),
+ );
+ expect(result!.relationships).toContainEqual({
+ srcName: 'service.go',
+ dstName: 'fmt',
+ predicate: 'IMPORTS',
+ });
+ });
+
+ it('captures REFERENCES edges for pointer-typed struct fields (Bug 2)', () => {
+ const result = parseFile(
+ '/repo/manager.go',
+ `
+package scrape
+
+type Manager struct {
+ opts *Options
+ appendable Appendable
+ pool *scrapePool
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+
+ // Bare type field — already worked before the fix
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Manager',
+ dstName: 'Appendable',
+ predicate: 'REFERENCES',
+ });
+
+ // Pointer-typed fields — required Bug 2 fix
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Manager',
+ dstName: 'Options',
+ predicate: 'REFERENCES',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Manager',
+ dstName: 'scrapePool',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures qualified CALLS edges for package-qualified calls (Bug 3)', () => {
+ const result = parseFile(
+ '/repo/main.go',
+ `
+package main
+
+import (
+ "github.com/example/scrape"
+ "github.com/example/notifier"
+ "github.com/example/promql"
+)
+
+func main() {
+ queryEngine := promql.NewEngine(opts)
+ scrapeManager, err := scrape.NewManager(cfg, logger)
+ notifierManager := notifier.NewManager(cfg)
+ _ = queryEngine
+ _ = scrapeManager
+ _ = notifierManager
+ _ = err
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+
+ // All three package-qualified calls must produce distinct edges
+ expect(result!.relationships).toContainEqual({
+ srcName: 'main',
+ dstName: 'promql.NewEngine',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'main',
+ dstName: 'scrape.NewManager',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'main',
+ dstName: 'notifier.NewManager',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('captures chained method calls without losing them (regression: operand not identifier)', () => {
+ const result = parseFile(
+ '/repo/runner.go',
+ `
+package runner
+
+func run(s *Service) {
+ s.pool.Start()
+ s.discovery.Run()
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'run',
+ dstName: 'Start',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'run',
+ dstName: 'Run',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('emits all qualified CALLS when multiple packages share a function name', () => {
+ // Regression: before Bug 3 fix, only the first NewManager call was emitted
+ // because seenCalls deduped bare "NewManager" across all packages.
+ const result = parseFile(
+ '/repo/setup.go',
+ `
+package main
+
+func setup() {
+ a := alpha.NewManager()
+ b := beta.NewManager()
+ c := gamma.NewManager()
+ _, _, _ = a, b, c
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'setup',
+ dstName: 'alpha.NewManager',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'setup',
+ dstName: 'beta.NewManager',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'setup',
+ dstName: 'gamma.NewManager',
+ predicate: 'CALLS',
+ });
+ });
+});
diff --git a/core-ingestion/src/__tests__/queries.java.test.ts b/core-ingestion/src/__tests__/queries.java.test.ts
new file mode 100644
index 00000000..03c8859d
--- /dev/null
+++ b/core-ingestion/src/__tests__/queries.java.test.ts
@@ -0,0 +1,214 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseFile } from '../index.js';
+
+describe('Java queries', () => {
+ it('captures classes, interfaces, methods, imports, and plain heritage', () => {
+ const result = parseFile(
+ '/repo/Service.java',
+ `
+package com.example;
+
+import java.util.List;
+import com.example.base.BaseService;
+
+public class Service extends BaseService implements Runnable {
+ public void run() {
+ helper();
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.entities.map(e => e.name)).toEqual(
+ expect.arrayContaining(['Service', 'run']),
+ );
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Service',
+ dstName: 'BaseService',
+ predicate: 'EXTENDS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Service',
+ dstName: 'Runnable',
+ predicate: 'EXTENDS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Service.run',
+ dstName: 'helper',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('captures extends and implements with generic types', () => {
+ const result = parseFile(
+ '/repo/ImmutableList.java',
+ `
+package com.example;
+
+public abstract class ImmutableList<E> extends ImmutableCollection<E>
+ implements List<E>, RandomAccess {
+ public int size() {
+ return delegate.size();
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ // extends generic type
+ expect(result!.relationships).toContainEqual({
+ srcName: 'ImmutableList',
+ dstName: 'ImmutableCollection',
+ predicate: 'EXTENDS',
+ });
+ // implements generic interface
+ expect(result!.relationships).toContainEqual({
+ srcName: 'ImmutableList',
+ dstName: 'List',
+ predicate: 'EXTENDS',
+ });
+ // implements plain interface alongside generic one
+ expect(result!.relationships).toContainEqual({
+ srcName: 'ImmutableList',
+ dstName: 'RandomAccess',
+ predicate: 'EXTENDS',
+ });
+ });
+
+ it('captures interface extends (plain and generic)', () => {
+ const result = parseFile(
+ '/repo/SortedList.java',
+ `
+package com.example;
+
+public interface SortedList<E> extends List<E>, Comparable {
+ E first();
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'SortedList',
+ dstName: 'List',
+ predicate: 'EXTENDS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'SortedList',
+ dstName: 'Comparable',
+ predicate: 'EXTENDS',
+ });
+ });
+
+ it('captures class that only implements generic interfaces', () => {
+ const result = parseFile(
+ '/repo/AbstractMultimap.java',
+ `
+package com.example;
+
+abstract class AbstractMultimap<K, V> implements Multimap<K, V> {
+ public boolean put(K key, V value) {
+ return getOrCreate(key).add(value);
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'AbstractMultimap',
+ dstName: 'Multimap',
+ predicate: 'EXTENDS',
+ });
+ });
+
+ it('captures static method calls (via static import pattern)', () => {
+ const result = parseFile(
+ '/repo/Consumer.java',
+ `
+package com.example;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class Consumer {
+ public void process(Object value) {
+ checkNotNull(value);
+ checkArgument(value != null, "bad");
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Consumer.process',
+ dstName: 'checkNotNull',
+ predicate: 'CALLS',
+ });
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Consumer.process',
+ dstName: 'checkArgument',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('methods after annotated varargs param are contained in their class', () => {
+ // tree-sitter-java error-recovers on `@Annotation Type @Annotation ... param`,
+ // truncating the class_declaration. Verify our preprocessing keeps all methods
+ // attributed to the correct container.
+ const result = parseFile(
+ '/repo/Preconditions.java',
+ `
+package com.example;
+
+public final class Preconditions {
+ public static void checkArgument(
+ boolean expression,
+ String template,
+ @Nullable Object @Nullable ... args) {
+ if (!expression) throw new IllegalArgumentException(template);
+ }
+
+ public static void checkNotNull(Object obj) {
+ if (obj == null) throw new NullPointerException();
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ const containers = Object.fromEntries(
+ result!.entities
+ .filter(e => e.kind === 'method' || e.kind === 'function')
+ .map(e => [e.name, e.container]),
+ );
+ // Both methods must be contained in Preconditions, not orphaned
+ expect(containers['checkArgument']).toBe('Preconditions');
+ expect(containers['checkNotNull']).toBe('Preconditions');
+ });
+
+ it('captures constructor calls', () => {
+ const result = parseFile(
+ '/repo/Factory.java',
+ `
+package com.example;
+
+public class Factory {
+ public Widget create() {
+ return new Widget();
+ }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Factory.create',
+ dstName: 'Widget',
+ predicate: 'CALLS',
+ });
+ });
+});
diff --git a/core-ingestion/src/__tests__/queries.python.test.ts b/core-ingestion/src/__tests__/queries.python.test.ts
index e0f35e10..9e1dc0a1 100644
--- a/core-ingestion/src/__tests__/queries.python.test.ts
+++ b/core-ingestion/src/__tests__/queries.python.test.ts
@@ -54,5 +54,69 @@ def top_level():
dstName: 'save',
predicate: 'CALLS',
});
+ // The qualifier pattern also emits the fully-qualified form so Tier-1b
+ // resolution can resolve e.g. Session.execute → session.py when the
+ // qualifier is a class name present in the caller's imports.
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Service.run',
+ dstName: 'value.save',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('resolves qualifier from constructor call assignment (Pattern 1)', () => {
+ const result = parseFile(
+ '/repo/views.py',
+ `
+def my_view(request):
+ conn = MyClass()
+ conn.execute()
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ // Constructor call itself: MyClass()
+ expect(result!.relationships).toContainEqual({
+ srcName: 'my_view',
+ dstName: 'MyClass',
+ predicate: 'CALLS',
+ });
+ // conn resolved to MyClass via assignTypeMap → MyClass.execute
+ expect(result!.relationships).toContainEqual({
+ srcName: 'my_view',
+ dstName: 'MyClass.execute',
+ predicate: 'CALLS',
+ });
+ // bare callee edge is also emitted
+ expect(result!.relationships).toContainEqual({
+ srcName: 'my_view',
+ dstName: 'execute',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('resolves qualifier from Model.objects.method() assignment (Pattern 2)', () => {
+ const result = parseFile(
+ '/repo/views.py',
+ `
+def list_items():
+ queryset = MyModel.objects.all()
+ queryset.filter()
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ // ORM call emits MyModel.all via the two-level qualifier query
+ expect(result!.relationships).toContainEqual({
+ srcName: 'list_items',
+ dstName: 'MyModel.all',
+ predicate: 'CALLS',
+ });
+ // queryset resolved to MyModel via assignTypeMap → MyModel.filter
+ expect(result!.relationships).toContainEqual({
+ srcName: 'list_items',
+ dstName: 'MyModel.filter',
+ predicate: 'CALLS',
+ });
});
});
diff --git a/core-ingestion/src/__tests__/queries.rust.test.ts b/core-ingestion/src/__tests__/queries.rust.test.ts
new file mode 100644
index 00000000..5447042c
--- /dev/null
+++ b/core-ingestion/src/__tests__/queries.rust.test.ts
@@ -0,0 +1,183 @@
+import { describe, expect, it } from 'vitest';
+
+import { parseFile } from '../index.js';
+
+describe('Rust queries', () => {
+ it('captures structs, enums, traits, functions, and imports', () => {
+ const result = parseFile(
+ '/repo/lib.rs',
+ `
+use std::collections::HashMap;
+
+pub struct Config {
+ name: String,
+}
+
+pub enum Status {
+ Ok,
+ Err,
+}
+
+pub trait Runner {
+ fn run(&self);
+}
+
+pub fn create() -> Config {
+ Config { name: String::new() }
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.entities.map(e => e.name)).toEqual(
+ expect.arrayContaining(['Config', 'Status', 'Runner', 'create']),
+ );
+ expect(result!.relationships).toContainEqual(
+ expect.objectContaining({ dstName: expect.stringContaining('HashMap'), predicate: 'IMPORTS' }),
+ );
+ });
+
+ it('captures REFERENCES for bare type fields (regression guard)', () => {
+ const result = parseFile(
+ '/repo/bare.rs',
+ `
+struct Foo {
+ count: Count,
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Foo',
+ dstName: 'Count',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES for &Type and &mut Type fields (Bug 1 — reference_type)', () => {
+ const result = parseFile(
+ '/repo/refs.rs',
+ `
+struct Searcher<'a> {
+ matcher: &'a Config,
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Searcher',
+ dstName: 'Config',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES for Box<Type> and other generic wrapper fields (Bug 1 — generic_type)', () => {
+ const result = parseFile(
+ '/repo/generic.rs',
+ `
+struct Foo {
+ matcher: Box<Matcher>,
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Foo',
+ dstName: 'Matcher',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES for impl Trait parameters (Bug 1 — abstract_type)', () => {
+ const result = parseFile(
+ '/repo/impl_trait.rs',
+ `
+fn run(s: impl Sink) {
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ // Parameters are not inside a struct/class range, so the src falls back to the file name.
+ expect(result!.relationships).toContainEqual({
+ srcName: 'impl_trait.rs',
+ dstName: 'Sink',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures REFERENCES for dyn Trait fields (Bug 1 — dynamic_type)', () => {
+ const result = parseFile(
+ '/repo/dyn_trait.rs',
+ `
+struct Foo {
+ matcher: Box<dyn Matcher>,
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Foo',
+ dstName: 'Matcher',
+ predicate: 'REFERENCES',
+ });
+ });
+
+ it('captures qualified CALLS for scoped constructor calls (Bug 2 — @_qualifier)', () => {
+ const result = parseFile(
+ '/repo/builder.rs',
+ `
+fn make() {
+ let s = SearcherBuilder::new();
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'make',
+ dstName: 'SearcherBuilder.new',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('captures simple (unqualified) calls unaffected by Bug 2 fix', () => {
+ const result = parseFile(
+ '/repo/simple.rs',
+ `
+fn make() {
+ foo();
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'make',
+ dstName: 'foo',
+ predicate: 'CALLS',
+ });
+ });
+
+ it('captures method calls unaffected by Bug 2 fix', () => {
+ const result = parseFile(
+ '/repo/method.rs',
+ `
+fn make(b: Builder) {
+ b.build();
+}
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ expect(result!.relationships).toContainEqual({
+ srcName: 'make',
+ dstName: 'build',
+ predicate: 'CALLS',
+ });
+ });
+});
diff --git a/core-ingestion/src/__tests__/queries.typescript.test.ts b/core-ingestion/src/__tests__/queries.typescript.test.ts
index 7e535616..9bb3ae21 100644
--- a/core-ingestion/src/__tests__/queries.typescript.test.ts
+++ b/core-ingestion/src/__tests__/queries.typescript.test.ts
@@ -50,4 +50,33 @@ describe('TypeScript queries', () => {
predicate: 'CALLS',
});
});
+
+ it('substitutes this → enclosing class for this.method() calls', () => {
+ const result = parseFile(
+ '/repo/model.ts',
+ `
+ class Document {
+ save() {
+ this.validate()
+ this.emit('save')
+ }
+ validate() {}
+ }
+ `,
+ );
+
+ expect(result).not.toBeNull();
+ // this.validate() inside Document.save should produce Document.validate
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Document.save',
+ dstName: 'Document.validate',
+ predicate: 'CALLS',
+ });
+ // this.emit() likewise
+ expect(result!.relationships).toContainEqual({
+ srcName: 'Document.save',
+ dstName: 'Document.emit',
+ predicate: 'CALLS',
+ });
+ });
});
diff --git a/core-ingestion/src/index.ts b/core-ingestion/src/index.ts
index d05c7492..dd12532c 100644
--- a/core-ingestion/src/index.ts
+++ b/core-ingestion/src/index.ts
@@ -160,14 +160,33 @@ const TYPE_BUILTINS = new Set([
'int16_t', 'int32_t', 'int64_t',
]);
-// Builtins to exclude from CALLS edges
-const BUILTINS = new Set([
- 'print', 'println', 'len', 'range', 'int', 'str', 'float', 'list', 'dict',
+// Builtins to exclude from CALLS edges — split by language family to avoid
+// suppressing valid method names in other languages (e.g. `filter` is a Python
+// builtin but also a common ORM method; `warn`/`error` are JS console methods
+// but also valid Python logging method names).
+
+// Keywords and pseudo-variables that are never valid call targets in any language.
+const SHARED_BUILTINS = new Set([
+ 'if', 'for', 'while', 'return', 'new', 'this', 'self',
+ 'undefined', 'null', 'true', 'false',
+ 'println', // Scala/Java/Kotlin/Rust standard-output builtin — noise in any language
+]);
+
+// Python-specific builtins (bare function calls like `len(x)`, `range(n)`, etc.)
+const PYTHON_BUILTINS = new Set([
+ ...SHARED_BUILTINS,
+ 'print', 'len', 'range', 'int', 'str', 'float', 'list', 'dict',
'set', 'tuple', 'type', 'isinstance', 'super', 'property', 'enumerate',
'zip', 'map', 'filter', 'sorted', 'any', 'all', 'min', 'max', 'sum',
+ 'open', 'repr', 'abs', 'round', 'hash', 'id', 'callable', 'iter', 'next',
+ 'vars', 'dir', 'getattr', 'setattr', 'hasattr', 'delattr',
+]);
+
+// JavaScript/TypeScript-specific builtins
+const JS_BUILTINS = new Set([
+ ...SHARED_BUILTINS,
'console', 'log', 'warn', 'error', 'debug', 'info',
- 'module', 'exports', 'undefined', 'null', 'true', 'false',
- 'if', 'for', 'while', 'return', 'new', 'this', 'self',
+ 'module', 'exports',
'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean', 'JSON',
'Math', 'Date', 'Error', 'Map', 'Set', 'Symbol',
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
@@ -175,6 +194,20 @@ const BUILTINS = new Set([
'require', 'fetch', 'parseInt', 'parseFloat', 'isNaN', 'isFinite',
]);
+// Per-language BUILTINS lookup — falls back to shared for languages without a
+// specific set (e.g. Java, Go, Rust) so they only skip obvious non-calls.
+function builtinsForLanguage(lang: SupportedLanguages): Set<string> {
+ switch (lang) {
+ case SupportedLanguages.Python:
+ return PYTHON_BUILTINS;
+ case SupportedLanguages.JavaScript:
+ case SupportedLanguages.TypeScript:
+ return JS_BUILTINS;
+ default:
+ return SHARED_BUILTINS;
+ }
+}
+
/** Returns true if a grammar is installed for the given file's language. */
export function isGrammarSupported(filePath: string): boolean {
const language = languageFromPath(filePath);
@@ -207,6 +240,45 @@ function getCachedQuery(
return query;
}
+// ---------------------------------------------------------------------------
+// Rust: cfg macro unwrapping
+// ---------------------------------------------------------------------------
+
+/**
+ * Blanks out feature-gating macro wrappers in Rust source so that the items
+ * inside become visible to tree-sitter as top-level declarations.
+ *
+ * Replaces `cfg_rt! { ... }` (and similar) with the body contents in-place,
+ * preserving every character position and line number so that entity line
+ * numbers remain accurate.
+ */
+function unwrapRustCfgMacros(source: string): string {
+ const re = /\bcfg_(?:rt_multi_thread|not_rt|rt|io|time|sync|net|fs|process|signal)!\s*\{/g;
+ const chars = source.split('');
+ let m: RegExpExecArray | null;
+ while ((m = re.exec(source)) !== null) {
+ const openBrace = m.index + m[0].length - 1; // position of the `{`
+ // Find matching closing brace by counting depth
+ let depth = 0;
+ let closeBrace = -1;
+ for (let i = openBrace; i < source.length; i++) {
+ if (source[i] === '{') depth++;
+ else if (source[i] === '}') {
+ depth--;
+ if (depth === 0) { closeBrace = i; break; }
+ }
+ }
+ if (closeBrace === -1) continue;
+ // Blank out everything from start of macro name up to and including `{`
+ for (let i = m.index; i <= openBrace; i++) {
+ if (chars[i] !== '\n') chars[i] = ' ';
+ }
+ // Blank out the matching closing `}`
+ chars[closeBrace] = ' ';
+ }
+ return chars.join('');
+}
+
// ---------------------------------------------------------------------------
// Main parse function
// ---------------------------------------------------------------------------
@@ -226,7 +298,24 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
try {
const parser = getParser();
parser.setLanguage(grammar);
- const tree = parser.parse(source, undefined, { bufferSize: source.length + 1 });
+ // tree-sitter-java cannot parse array-type annotations on varargs params
+ // (e.g. `@Nullable Object @Nullable ... args`). The second annotation causes
+ // error recovery to truncate the enclosing class_declaration, orphaning all
+ // subsequent methods. Strip any @Annotation immediately before `...` in-memory
+ // so the class body parses correctly.
+ let parseSource = language === SupportedLanguages.Java
+ ? source.replace(/@\w+\s*(?=\.\.\.)/g, '')
+ : source;
+
+ // Rust: unwrap feature-gating macros (cfg_rt! { ... }, cfg_io! { ... }, etc.)
+ // These macros are transparent pass-throughs — their bodies contain normal items
+ // that tree-sitter cannot see because they are parsed as raw token_tree nodes.
+ // We blank out the macro call and matching closing brace in-place (preserving
+ // character positions and line numbers) so the inner items become top-level.
+ if (language === SupportedLanguages.Rust) {
+ parseSource = unwrapRustCfgMacros(parseSource);
+ }
+ const tree = parser.parse(parseSource, undefined, { bufferSize: parseSource.length + 1 });
const cacheKey = isTsx ? 'tsx' as const : language;
const query = getCachedQuery(cacheKey, grammar, queries);
const matches = query.matches(tree.rootNode);
@@ -259,6 +348,10 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
const seenCalls = new Map<string, Set<string>>();
// Track seen type references per enclosing class/file to avoid duplicate REFERENCES edges
const seenRefs = new Map<string, Set<string>>();
+ // Python: map function name → (param name → declared type) for typed-parameter qualifier substitution
+ const paramTypeMap = new Map<string, Map<string, string>>();
+ // Python: map function name → (variable name → assigned type) for untyped-param qualifier substitution
+ const assignTypeMap = new Map<string, Map<string, string>>();
// --- First pass: collect definitions ---
for (const match of matches) {
@@ -280,8 +373,20 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
const startByte = defNode.startIndex;
const endByte = defNode.endIndex;
- // Containment: file CONTAINS or class CONTAINS
+ // Containment: file CONTAINS or class CONTAINS.
+ // For Go methods the receiver type IS the container — methods are defined
+ // outside the struct body so findEnclosing() always returns null for them.
+ // The receiver.type capture (emitted by the Go method queries) overrides this.
const enclosing = findEnclosing(classRanges, lineStart, name);
+ const receiverCapture = match.captures.find((c: any) => c.name === 'receiver.type');
+ // heritageClassCapture is set by the Go interface method query, where @heritage.class
+ // captures the interface name and serves as the container (like receiver.type for structs).
+ const heritageClassCapture = match.captures.find((c: any) => c.name === 'heritage.class');
+ const effectiveContainer = (receiverCapture && kind === 'method')
+ ? receiverCapture.node.text
+ : (heritageClassCapture && kind === 'method')
+ ? heritageClassCapture.node.text
+ : (enclosing ?? undefined);
entities.push({
name,
@@ -289,7 +394,7 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
lineStart,
lineEnd,
language,
- container: enclosing ?? undefined,
+ container: effectiveContainer,
});
pendingChunks.push({
@@ -307,8 +412,8 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
classRanges.push({ name, start: lineStart, end: lineEnd });
}
- if (enclosing) {
- relationships.push({ srcName: enclosing, dstName: name, predicate: 'CONTAINS' });
+ if (effectiveContainer) {
+ relationships.push({ srcName: effectiveContainer, dstName: name, predicate: 'CONTAINS' });
} else {
relationships.push({ srcName: fileName, dstName: name, predicate: 'CONTAINS' });
}
@@ -343,6 +448,42 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
});
continue;
}
+
+ // Python typed parameters: build paramTypeMap for qualifier substitution in the second pass.
+ // Maps function name → (param name → declared type) so that e.g. `query: Query` lets us
+ // rewrite `query.filter(...)` → `Query.filter` when building effectiveCallee.
+ if (language === SupportedLanguages.Python) {
+ const typedParamScope = match.captures.find((c: any) => c.name === '_typed_param_scope');
+ const typedParamName = match.captures.find((c: any) => c.name === '_typed_param_name');
+ const typedParamType = match.captures.find((c: any) => c.name === '_typed_param_type');
+ if (typedParamScope && typedParamName && typedParamType) {
+ const funcName = typedParamScope.node.childForFieldName?.('name')?.text as string | undefined;
+ if (funcName) {
+ if (!paramTypeMap.has(funcName)) paramTypeMap.set(funcName, new Map());
+ paramTypeMap.get(funcName)!.set(typedParamName.node.text, typedParamType.node.text);
+ }
+ continue;
+ }
+
+ // Assignment tracking: x = SomeClass() or x = Model.objects.method()
+ const assignScope = match.captures.find((c: any) => c.name === '_assign_scope');
+ const assignLhs = match.captures.find((c: any) => c.name === '_assign_lhs');
+ const assignRhsType = match.captures.find((c: any) => c.name === '_assign_rhs_type');
+ if (assignScope && assignLhs && assignRhsType) {
+ // Only track PascalCase RHS names (constructors by convention).
+ // Lowercase function calls like `select(...)` or `create_engine(...)` are skipped
+ // to avoid cross-module false edges (e.g. orm.query → select.where in SQLAlchemy).
+ const rhsName = assignRhsType.node.text;
+ if (/^[A-Z]/.test(rhsName)) {
+ const funcName = assignScope.node.childForFieldName?.('name')?.text as string | undefined;
+ if (funcName) {
+ if (!assignTypeMap.has(funcName)) assignTypeMap.set(funcName, new Map());
+ assignTypeMap.get(funcName)!.set(assignLhs.node.text, rhsName);
+ }
+ }
+ continue;
+ }
+ }
}
// --- Second pass: calls and imports ---
@@ -408,7 +549,17 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
const callName = match.captures.find((c: any) => c.name === 'call.name');
if (callName) {
const callee = callName.node.text;
- if (!callee || BUILTINS.has(callee) || callee.length <= 1) continue;
+ if (!callee || callee.length <= 1) continue;
+
+ // If a _qualifier capture is present (field_expression / stable_identifier
+ // patterns like NodeKind.Decision, or Python attribute calls like
+ // Session.execute), emit the fully qualified name so that resolution can use
+ // the qualifier to break ties between same-named symbols in different files.
+ // BUILTINS filtering is skipped for attribute calls: method names like
+ // `filter` or `map` are Python builtins when called bare, but are valid
+ // user-defined method calls when invoked as `query.filter(...)`.
+ const qualifierCapture = match.captures.find((c: any) => c.name === '_qualifier');
+ if (builtinsForLanguage(language).has(callee) && !qualifierCapture) continue;
// Find enclosing function/method for the call; fall back to enclosing class
// (e.g. calls in val/lazy val body at class level) before falling back to file.
@@ -421,14 +572,34 @@ export function parseFile(filePath: string, source: string): FileParseResult | n
if (!seenCalls.has(scope)) seenCalls.set(scope, new Set());
const seen = seenCalls.get(scope)!;
- // If a _qualifier capture is present (field_expression / stable_identifier
- // patterns like NodeKind.Decision), emit the fully qualified name so that
- // resolution can use the qualifier to break ties between same-named symbols
- // in different files (e.g. NodeKind.Decision vs SourceType.Decision).
- const qualifierCapture = match.captures.find((c: any) => c.name === '_qualifier');
- const effectiveCallee = qualifierCapture
- ? `${qualifierCapture.node.text}.${callee}`
- : callee;
+ const effectiveCallee = (() => {
+ if (!qualifierCapture) return callee;
+ let qualifier = qualifierCapture.node.text;
+ // Python: 'self'/'cls' always refers to the enclosing class — substitute it
+ // so the edge reads 'Query.filter' instead of 'self.filter', enabling
+ // same-file resolution without type inference.
+ if (language === SupportedLanguages.Python && (qualifier === 'self' || qualifier === 'cls')) {
+ const enclosingClass = findEnclosing(classRanges, callLine, '');
+ if (enclosingClass) qualifier = enclosingClass;
+ } else if (qualifier === 'this') {
+ // JS/TS: 'this' inside a class method refers to the enclosing class.
+ // Substitute so e.g. `this.save()` → `Document.save` instead of `this.save`.
+ const enclosingClass = findEnclosing(classRanges, callLine, '');
+ if (enclosingClass) qualifier = enclosingClass;
+ } else if (language === SupportedLanguages.Python) {
+ // Typed-parameter substitution: if the qualifier is a param with a declared type,
+ // use the type name so e.g. `query.filter(...)` → `Query.filter`.
+ // Also check assignTypeMap for variables assigned from constructor/ORM calls.
+ const funcName = findEnclosingFunction(entities, callLine);
+ if (funcName) {
+ const typeForParam = paramTypeMap.get(funcName)?.get(qualifier);
+ const typeForAssign = assignTypeMap.get(funcName)?.get(qualifier);
+ if (typeForParam) qualifier = typeForParam;
+ else if (typeForAssign) qualifier = typeForAssign;
+ }
+ }
+ return `${qualifier}.${callee}`;
+ })();
if (!seen.has(effectiveCallee)) {
seen.add(effectiveCallee);
@@ -563,7 +734,17 @@ function bestQKey(
* - Unambiguous class method: dstQualifiedKey === 'ClassName.method'
* - Ambiguous (two entities share the same plain name): edge not emitted
*/
-export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
+export function resolveEdges(results: FileParseResult[], stats?: {
+ importLookups: number; transitiveLookups: number; globalFallbacks: number;
+ globalCandidateTotal: number; resolvedImport: number; resolvedTransitive: number;
+ resolvedGlobal: number; resolvedQualifier: number; skippedSameFile: number; skippedAmbiguous: number;
+}): ResolvedEdge[] {
+ // Provide a default no-op stats bag when caller passes none (backward compat).
+ if (!stats) stats = {
+ importLookups: 0, transitiveLookups: 0, globalFallbacks: 0,
+ globalCandidateTotal: 0, resolvedImport: 0, resolvedTransitive: 0,
+ resolvedGlobal: 0, resolvedQualifier: 0, skippedSameFile: 0, skippedAmbiguous: 0,
+ };
// fileQKeys: filePath → (plainName → qualifiedKeys[])
// Mirrors the entityQKey computation in buildPatch so nodeIds match exactly.
const fileQKeys = new Map<string, Map<string, string[]>>();
@@ -598,6 +779,12 @@ export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
}
}
+ // fileLanguage: filePath → SupportedLanguages (fast language lookup without re-calling languageFromPath)
+ const fileLanguage = new Map<string, SupportedLanguages>();
+ for (const r of results) {
+ fileLanguage.set(r.filePath, r.language);
+ }
+
// stemToFiles: basename-without-extension → filePath[]
// Matches the last path segment of an import to files in the batch.
const stemToFiles = new Map<string, string[]>();
@@ -640,6 +827,22 @@ export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
}
}
+ // goPkgDirToFiles: Go package directory name → filePath[]
+ // In Go, the last segment of an import path IS the package directory name.
+ // e.g. import "go.etcd.io/etcd/server/etcdserver" is stripped to modName "etcdserver"
+ // by the import processor; this index maps that name to all .go files in
+ // any directory named "etcdserver" within the ingested batch.
+ const goPkgDirToFiles = new Map<string, string[]>();
+ for (const r of results) {
+ if (nodePath.extname(r.filePath) !== '.go') continue;
+ const dirName = nodePath.basename(nodePath.dirname(r.filePath));
+ const list = goPkgDirToFiles.get(dirName) ?? [];
+ if (!list.includes(r.filePath)) list.push(r.filePath);
+ goPkgDirToFiles.set(dirName, list);
+ }
+
+ // ── Helpers ────────────────────────────────────────────────────────
+
/** Resolve a module name to matching file paths in the batch. */
function modNameToFiles(modName: string, excludeFp: string): string[] {
const fps: string[] = [];
@@ -649,7 +852,7 @@ export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
if (stripped && stripped !== modName) candidates.push(stripped);
// Strip file extensions so "explain.js" resolves to the "explain" stem
// (TS/JS ESM imports use .js extensions that map to .ts source files)
- const noExt = modName.replace(/\.(js|ts|mjs|cjs|jsx|tsx|py|scala|java)$/, '');
+ const noExt = modName.replace(/\.(js|ts|mjs|cjs|jsx|tsx|py|scala|java|c|cc|cpp|cxx|h|hh|hpp|hxx)$/, '');
if (noExt !== modName && noExt && !candidates.includes(noExt)) candidates.push(noExt);
// For dotted paths (Scala/Java: 'ix.memory.model.Edge'), also try last segment
const lastDot = modName.lastIndexOf('.');
@@ -669,13 +872,125 @@ export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
for (const fp of packageToFiles.get(modName) ?? []) {
if (fp !== excludeFp && !fps.includes(fp)) fps.push(fp);
}
+ // Go package directory resolution: "etcdserver" → all .go files in .../etcdserver/
+ // The last segment of a Go import path is the package directory name, not a file stem.
+ for (const fp of goPkgDirToFiles.get(modName) ?? []) {
+ if (fp !== excludeFp && !fps.includes(fp)) fps.push(fp);
+ }
return fps;
}
+ function tokenizeSymbolParts(value: string): string[] {
+ return value
+ .replace(/([a-z\d])([A-Z])/g, '$1 $2')
+ .replace(/[^a-zA-Z0-9]+/g, ' ')
+ .toLowerCase()
+ .split(/\s+/)
+ .filter(Boolean);
+ }
+
+ const GENERIC_RESOLUTION_TOKENS = new Set([
+ 'run', 'job', 'file', 'files', 'table', 'tables', 'output', 'outputs',
+ 'input', 'inputs', 'background',
+ ]);
+
+ function candidateStem(filePath: string): string {
+ return nodePath.basename(filePath, nodePath.extname(filePath)).toLowerCase();
+ }
+
+ function pickCallerAlignedCandidate(
+ matches: string[],
+ srcName: string,
+ dstName: string,
+ ): { chosen: string | null; best: Array<{ fp: string; overlap: number }> } | null {
+ if (matches.length === 0) return null;
+ const srcTokens = new Set(
+ tokenizeSymbolParts(srcName).filter(token => !GENERIC_RESOLUTION_TOKENS.has(token)),
+ );
+ const overlapScores = matches.map(fp => {
+ const qKeys = fileQKeys.get(fp)?.get(dstName) ?? [];
+ const candidateTokens = new Set<string>(tokenizeSymbolParts(candidateStem(fp)));
+ for (const qKey of qKeys) {
+ for (const token of tokenizeSymbolParts(qKey)) candidateTokens.add(token);
+ }
+ let overlap = 0;
+ for (const token of candidateTokens) {
+ if (!GENERIC_RESOLUTION_TOKENS.has(token) && srcTokens.has(token)) overlap++;
+ }
+ return { fp, overlap };
+ });
+ const maxOverlap = Math.max(...overlapScores.map(x => x.overlap));
+ if (maxOverlap <= 0) return null;
+ const bestMatches = overlapScores.filter(x => x.overlap === maxOverlap);
+ return {
+ chosen: bestMatches.length === 1 ? bestMatches[0].fp : null,
+ best: bestMatches,
+ };
+ }
+
+ function narrowCCandidates(
+ matches: string[],
+ srcFilePath: string,
+ srcLanguage: SupportedLanguages,
+ srcName: string,
+ dstName: string,
+ ): string[] {
+ if (matches.length <= 1) return matches;
+
+ // C# partial class narrowing: multiple files may define the same class via
+ // partial class (e.g. JsonReader.cs + JsonReader.Async.cs both define JsonReader).
+ // Prefer the canonical file whose stem exactly matches the destination class name
+ // over variant files that have additional dot-segments in the stem.
+ if (srcLanguage === SupportedLanguages.CSharp) {
+ const dstNameLower = dstName.toLowerCase();
+ const canonicalMatches = matches.filter(fp => candidateStem(fp) === dstNameLower);
+ if (canonicalMatches.length === 1) return canonicalMatches;
+ }
+
+ if (srcLanguage !== SupportedLanguages.C && srcLanguage !== SupportedLanguages.CPlusPlus) return matches;
+
+ let narrowed = matches;
+ const implExts = ['.c', '.cpp', '.cc', '.cxx'];
+ const implMatches = narrowed.filter(fp => implExts.some(ext => fp.endsWith(ext)));
+ if (implMatches.length === 1) narrowed = implMatches;
+
+ if (narrowed.length <= 1) return narrowed;
+
+ const srcParts = srcFilePath.replace(/\\/g, '/').split('/');
+ const withProximity = narrowed.map(fp => {
+ const fpParts = fp.replace(/\\/g, '/').split('/');
+ let common = 0;
+ while (common < srcParts.length && common < fpParts.length && srcParts[common] === fpParts[common]) {
+ common++;
+ }
+ return { fp, common };
+ });
+ const maxCommon = Math.max(...withProximity.map(x => x.common));
+ const proximityMatches = withProximity.filter(x => x.common === maxCommon).map(x => x.fp);
+ if (proximityMatches.length === 1) return proximityMatches;
+
+ const callerAligned = pickCallerAlignedCandidate(narrowed, srcName, dstName);
+ if (callerAligned?.chosen) return [callerAligned.chosen];
+
+ const callerAlignedCandidates = pickCallerAlignedCandidate(matches, srcName, dstName);
+ if (callerAlignedCandidates?.best) {
+ const implAlignedMatches = callerAlignedCandidates.best
+ .map(match => match.fp)
+ .filter(fp => ['.c', '.cpp', '.cc', '.cxx'].some(ext => fp.endsWith(ext)));
+ if (implAlignedMatches.length === 1) return implAlignedMatches;
+ }
+
+ return narrowed;
+ }
+
+ // ── Main resolution loop ───────────────────────────────────────────
+
+
const resolved: ResolvedEdge[] = [];
for (const result of results) {
const srcFilePath = result.filePath;
+ const srcLanguage = result.language;
const srcSymbols = fileHasSymbol.get(srcFilePath)!;
// Build the set of file paths this file explicitly imports.
@@ -779,44 +1094,57 @@ export function resolveEdges(results: FileParseResult[]): ResolvedEdge[] {
for (const fp of importedFilePaths) {
if (fileHasSymbol.get(fp)?.has(dstName)) importMatches.push(fp);
}
+ const narrowedImportMatches = narrowCCandidates(importMatches, srcFilePath, srcLanguage, srcName, dstName);
- if (importMatches.length === 1) {
- const fp = importMatches[0];
+ if (narrowedImportMatches.length === 1) {
+ const fp = narrowedImportMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null) continue; // ambiguous — do not emit bad nodeId
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.9 });
continue;
}
- if (importMatches.length > 1) continue; // ambiguous file — do not emit
-
// Tier 2.5: transitive import-scoped (confidence 0.8) — one re-export hop away
const transitiveMatches: string[] = [];
for (const fp of transitiveFilePaths) {
if (fileHasSymbol.get(fp)?.has(dstName)) transitiveMatches.push(fp);
}
+ const narrowedTransitiveMatches = narrowCCandidates(transitiveMatches, srcFilePath, srcLanguage, srcName, dstName);
- if (transitiveMatches.length === 1) {
- const fp = transitiveMatches[0];
+ if (narrowedTransitiveMatches.length === 1) {
+ const fp = narrowedTransitiveMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null) continue;
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.8 });
continue;
}
- if (transitiveMatches.length > 1) continue; // ambiguous — do not emit
+ // Tier 3: global fallback (confidence 0.5) — uses inverted symbol index
+ // instead of scanning all files.
+ stats.globalFallbacks++;
+ const candidates = symbolToFiles.get(dstName) ?? [];
+ let globalMatches = candidates.filter(fp => fp !== srcFilePath && fileLanguage.get(fp) === srcLanguage);
+ const importHint = pickCallerAlignedCandidate(importMatches, srcName, dstName)?.chosen
+ ?? pickCallerAlignedCandidate(transitiveMatches, srcName, dstName)?.chosen;
+ if (importHint) {
+ const hintedStem = candidateStem(importHint);
+ const stemMatches = globalMatches.filter(fp => candidateStem(fp) === hintedStem);
+ if (stemMatches.length > 0) globalMatches = stemMatches;
+ }
+ stats.globalCandidateTotal += globalMatches.length;
- // Tier 3: global fallback (confidence 0.5) — exactly one other file defines it
- // Only match files in the same language as the caller to avoid cross-language false positives.
- const srcLanguage = result.language;
- const globalMatches = (symbolToFiles.get(dstName) ?? [])
- .filter(fp => fp !== srcFilePath && languageFromPath(fp) === srcLanguage);
+ const resolvedMatches = narrowCCandidates(globalMatches, srcFilePath, srcLanguage, srcName, dstName);
- if (globalMatches.length === 1) {
- const fp = globalMatches[0];
+ if (resolvedMatches.length === 1) {
+ const fp = resolvedMatches[0];
const dstQualifiedKey = bestQKey(fileQKeys, fp, dstName);
if (dstQualifiedKey === null) continue; // ambiguous — do not emit bad nodeId
resolved.push({ srcFilePath, srcName, dstFilePath: fp, dstName, dstQualifiedKey, predicate: rel.predicate, confidence: 0.5 });
+ stats.resolvedGlobal++;
+ continue;
+ }
+ if (narrowedImportMatches.length > 1 || narrowedTransitiveMatches.length > 1 || resolvedMatches.length > 1) {
+ stats.skippedAmbiguous++;
}
- // 0 or >1 global matches — leave as dangling edge, do not emit
+ // 0 or >1 matches after all tiers — leave as dangling edge, do not emit
}
}
diff --git a/core-ingestion/src/patch-builder.ts b/core-ingestion/src/patch-builder.ts
index d06f6553..df704395 100644
--- a/core-ingestion/src/patch-builder.ts
+++ b/core-ingestion/src/patch-builder.ts
@@ -47,11 +47,11 @@ function sourceType(filePath: string): string {
}
export function extractorName(): string {
- return `tree-sitter/1.13`;
+ return `tree-sitter/1.18`;
}
/** Previous extractor versions — their patches are superseded when re-ingesting. */
-export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.12', 'tree-sitter/1.11', 'tree-sitter/1.10', 'tree-sitter/1.9', 'tree-sitter/1.8', 'tree-sitter/1.7', 'tree-sitter/1.6', 'tree-sitter/1.5', 'tree-sitter/1.4', 'tree-sitter/1.3', 'tree-sitter/1.2', 'tree-sitter/1.1'];
+export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.17', 'tree-sitter/1.16', 'tree-sitter/1.15', 'tree-sitter/1.14', 'tree-sitter/1.13', 'tree-sitter/1.12', 'tree-sitter/1.11', 'tree-sitter/1.10', 'tree-sitter/1.9', 'tree-sitter/1.8', 'tree-sitter/1.7', 'tree-sitter/1.6', 'tree-sitter/1.5', 'tree-sitter/1.4', 'tree-sitter/1.3', 'tree-sitter/1.2', 'tree-sitter/1.1'];
/** Compute a patchId for a (filePath, sourceHash, extractorVersion) triple. */
function computePatchId(filePath: string, sourceHash: string, extractor: string): string {
@@ -96,9 +96,14 @@ export function buildPatch(
// For ambiguous names (appear multiple times), falls back to the plain name
// so that the edge still points to *something* deterministic.
function resolveKey(name: string, container?: string): string {
- const keys = nameToQKeys.get(name);
- if (!keys || keys.length === 1) return keys?.[0] ?? name;
- // More than one entity with this name — try to pick by container
+ const rawKeys = nameToQKeys.get(name);
+ if (!rawKeys) return name;
+ // Deduplicate: @overload in Python (and similar patterns in other languages)
+ // produces multiple definitions with identical qualified keys. A Set collapses
+ // these so we don't mistake three `Session.execute` overloads for ambiguity.
+ const keys = [...new Set(rawKeys)];
+ if (keys.length === 1) return keys[0];
+ // More than one distinct entity with this name — try to pick by container
if (container) {
const qualified = `${container}.${name}`;
if (keys.includes(qualified)) return qualified;
@@ -268,13 +273,13 @@ export function buildPatchWithResolution(
resolvedEdges: ResolvedEdge[],
previousSourceHash?: string,
): GraphPatchPayload {
- // Build lookup: `${predicate}:${dstName}` → { dstFilePath, dstQualifiedKey }
+ // Build lookup: `${srcName}:${predicate}:${dstName}` → { dstFilePath, dstQualifiedKey }
// Callers should pass only edges for this file (pre-grouped) for best performance,
// but we still tolerate the full array for backward compatibility.
const edgeResolution = new Map<string, { dstFilePath: string; dstQualifiedKey: string }>();
for (const edge of resolvedEdges) {
if (edge.srcFilePath !== result.filePath) continue;
- edgeResolution.set(`${edge.predicate}:${edge.dstName}`, {
+ edgeResolution.set(`${edge.srcName}:${edge.predicate}:${edge.dstName}`, {
dstFilePath: edge.dstFilePath,
dstQualifiedKey: edge.dstQualifiedKey,
});
@@ -296,8 +301,10 @@ export function buildPatchWithResolution(
}
function resolveKey(name: string, container?: string): string {
- const keys = nameToQKeys.get(name);
- if (!keys || keys.length === 1) return keys?.[0] ?? name;
+ const rawKeys = nameToQKeys.get(name);
+ if (!rawKeys) return name;
+ const keys = [...new Set(rawKeys)]; // deduplicate — @overload produces identical qks
+ if (keys.length === 1) return keys[0];
if (container) {
const qualified = `${container}.${name}`;
if (keys.includes(qualified)) return qualified;
@@ -395,7 +402,7 @@ export function buildPatchWithResolution(
// For cross-file resolved edges (CALLS, EXTENDS), use the defining file's nodeId
let dstNodeId: string;
- const resolutionKey = `${r.predicate}:${r.dstName}`;
+ const resolutionKey = `${r.srcName}:${r.predicate}:${r.dstName}`;
if (edgeResolution.has(resolutionKey)) {
const { dstFilePath, dstQualifiedKey } = edgeResolution.get(resolutionKey)!;
dstNodeId = nodeId(dstFilePath, dstQualifiedKey);
diff --git a/core-ingestion/src/queries.ts b/core-ingestion/src/queries.ts
index 26acae33..e2d204f9 100644
--- a/core-ingestion/src/queries.ts
+++ b/core-ingestion/src/queries.ts
@@ -63,6 +63,13 @@ export const TYPESCRIPT_QUERIES = `
function: (member_expression
property: (property_identifier) @call.name)) @call
+; this.method() — capture this as qualifier so index.ts can substitute the enclosing class.
+; Analogous to Python's self/cls substitution.
+(call_expression
+ function: (member_expression
+ object: (this) @_qualifier
+ property: (property_identifier) @call.name)) @call
+
; Constructor calls: new Foo()
(new_expression
constructor: (identifier) @call.name) @call
@@ -168,6 +175,13 @@ export const JAVASCRIPT_QUERIES = `
function: (member_expression
property: (property_identifier) @call.name)) @call
+; this.method() — capture this as qualifier so index.ts can substitute the enclosing class.
+; Analogous to Python's self/cls substitution.
+(call_expression
+ function: (member_expression
+ object: (this) @_qualifier
+ property: (property_identifier) @call.name)) @call
+
; Constructor calls: new Foo()
(new_expression
constructor: (identifier) @call.name) @call
@@ -209,6 +223,37 @@ export const PYTHON_QUERIES = `
function: (attribute
attribute: (identifier) @call.name)) @call
+; Attribute calls with object captured as qualifier so Tier-1b resolution can use
+; class/module name to break ties (e.g. Session.execute → resolves to Session in
+; the importing file). Emitted alongside the bare-name pattern above so that
+; bare-name global fallback still fires when qualifier resolution fails.
+(call
+ function: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier) @call.name)) @call
+
+; Django ORM manager pattern: Model.objects.method(...)
+; Unwinds the intermediate accessor (objects/related_manager/etc.) and captures
+; the model class as qualifier, e.g. User.objects.filter(...) → CALLS User.filter.
+; This creates cross-file edges between view/form code and model definitions.
+(call
+ function: (attribute
+ object: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier))
+ attribute: (identifier) @call.name)) @call
+
+; Chained call pattern: qualifier.method1(...).method2(...)
+; Propagates the qualifier from the inner call to the outer, e.g.
+; User.filter(...).order_by(...) → CALLS User.order_by.
+(call
+ function: (attribute
+ object: (call
+ function: (attribute
+ object: (identifier) @_qualifier
+ attribute: (identifier)))
+ attribute: (identifier) @call.name)) @call
+
; Heritage queries - Python class inheritance
(class_definition
name: (identifier) @heritage.class
@@ -218,6 +263,45 @@ export const PYTHON_QUERIES = `
; Type references — captures types used in type annotations / hints
(typed_parameter type: (type (identifier) @reference.type))
(typed_default_parameter type: (type (identifier) @reference.type))
+
+; Typed parameters: capture name + type together so qualifier substitution can
+; map a local variable name to its declared class (e.g. query: Query → 'query' → 'Query').
+(function_definition
+ parameters: (parameters
+ (typed_parameter
+ (identifier) @_typed_param_name
+ type: (type (identifier) @_typed_param_type)))) @_typed_param_scope
+
+(function_definition
+ parameters: (parameters
+ (typed_default_parameter
+ (identifier) @_typed_param_name
+ type: (type (identifier) @_typed_param_type)))) @_typed_param_scope
+
+; Assignment tracking: x = SomeClass() or x = SomeClass(args)
+; Maps local variable name → constructor type for untyped-parameter qualifier substitution.
+; Only PascalCase RHS names are tracked in TypeScript (constructor convention).
+(function_definition
+ body: (block
+ (expression_statement
+ (assignment
+ left: (identifier) @_assign_lhs
+ right: (call
+ function: (identifier) @_assign_rhs_type))))) @_assign_scope
+
+; Assignment tracking: x = Model.objects.method()
+; Captures the outermost identifier (model class) for ORM manager patterns.
+(function_definition
+ body: (block
+ (expression_statement
+ (assignment
+ left: (identifier) @_assign_lhs
+ right: (call
+ function: (attribute
+ object: (attribute
+ object: (identifier) @_assign_rhs_type
+ attribute: (identifier))
+ attribute: (identifier))))))) @_assign_scope
`;
// Java queries - works with tree-sitter-java
@@ -242,14 +326,30 @@ export const JAVA_QUERIES = `
; Constructor calls: new Foo()
(object_creation_expression type: (type_identifier) @call.name) @call
-; Heritage - extends class
+; Heritage - extends class (plain: extends Foo)
(class_declaration name: (identifier) @heritage.class
(superclass (type_identifier) @heritage.extends)) @heritage
-; Heritage - implements interfaces
+; Heritage - extends class with generics (extends Foo<T>)
+(class_declaration name: (identifier) @heritage.class
+ (superclass (generic_type (type_identifier) @heritage.extends))) @heritage
+
+; Heritage - implements interfaces (plain: implements Foo)
(class_declaration name: (identifier) @heritage.class
(super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
+; Heritage - implements interfaces with generics (implements Foo<T>)
+(class_declaration name: (identifier) @heritage.class
+ (super_interfaces (type_list (generic_type (type_identifier) @heritage.implements)))) @heritage.impl
+
+; Heritage - interface extends interfaces (plain: extends Foo)
+(interface_declaration name: (identifier) @heritage.class
+ (extends_interfaces (type_list (type_identifier) @heritage.extends))) @heritage
+
+; Heritage - interface extends interfaces with generics (extends Foo<T>)
+(interface_declaration name: (identifier) @heritage.class
+ (extends_interfaces (type_list (generic_type (type_identifier) @heritage.extends)))) @heritage
+
; Type references — captures types used in field/param/return-type positions
(field_declaration type: (type_identifier) @reference.type)
(formal_parameter type: (type_identifier) @reference.type)
@@ -271,8 +371,9 @@ export const C_QUERIES = `
(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
; Structs, Unions, Enums, Typedefs
-(struct_specifier name: (type_identifier) @name) @definition.struct
-(union_specifier name: (type_identifier) @name) @definition.union
+; Only match struct/union with a body to avoid treating forward declarations as definitions
+(struct_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.struct
+(union_specifier name: (type_identifier) @name body: (field_declaration_list)) @definition.union
(enum_specifier name: (type_identifier) @name) @definition.enum
(type_definition declarator: (type_identifier) @name) @definition.typedef
@@ -290,34 +391,86 @@ export const C_QUERIES = `
; Type references — captures types used in declaration/parameter positions
(declaration type: (type_identifier) @reference.type)
(parameter_declaration type: (type_identifier) @reference.type)
+; struct_specifier forms: e.g. "const struct Curl_protocol foo = {...}"
+(declaration type: (struct_specifier name: (type_identifier) @reference.type))
+(parameter_declaration type: (struct_specifier name: (type_identifier) @reference.type))
`;
// Go queries - works with tree-sitter-go
export const GO_QUERIES = `
-; Functions & Methods
+; Functions
(function_declaration name: (identifier) @name) @definition.function
-(method_declaration name: (field_identifier) @name) @definition.method
+
+; Methods — non-pointer receiver: func (r ReceiverType) Name(...)
+; The receiver.type capture lets the parser set container = ReceiverType so that
+; qualifiedKey becomes "ReceiverType.Name" instead of bare "Name".
+(method_declaration
+ receiver: (parameter_list (parameter_declaration
+ type: (type_identifier) @receiver.type))
+ name: (field_identifier) @name) @definition.method
+
+; Methods — pointer receiver: func (r *ReceiverType) Name(...)
+(method_declaration
+ receiver: (parameter_list (parameter_declaration
+ type: (pointer_type (type_identifier) @receiver.type)))
+ name: (field_identifier) @name) @definition.method
; Types
(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
+; Interface method signatures — emits each method inside an interface_type as a method entity.
+; @heritage.class = interface name (used as container in index.ts via heritageClassCapture).
+; node type is method_elem in tree-sitter-go v0.21+.
+(type_declaration
+ (type_spec
+ name: (type_identifier) @heritage.class
+ type: (interface_type
+ (method_elem
+ name: (field_identifier) @name)))) @definition.method
+
; Imports
(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
-; Struct embedding (anonymous fields = inheritance)
+; Struct embedding — value: type Foo struct { Bar }
+; NOTE: no @definition.* capture here — if it were present, defCapture fires first and
+; the heritage block is never reached (early-exit in the first pass).
+; The . anchors require the type_identifier to be the FIRST and ONLY named child of
+; field_declaration, distinguishing anonymous embedded fields from named fields like:
+; w Writer (named field — field_identifier_list precedes type, not matched)
+(type_declaration
+ (type_spec
+ name: (type_identifier) @heritage.class
+ type: (struct_type
+ (field_declaration_list
+ (field_declaration .
+ (type_identifier) @heritage.extends .)))))
+
+; Struct embedding — pointer: type Foo struct { *Bar }
+; The . anchor requires pointer_type to be the first named child (anonymous embedded).
(type_declaration
(type_spec
name: (type_identifier) @heritage.class
type: (struct_type
(field_declaration_list
- (field_declaration
- type: (type_identifier) @heritage.extends))))) @definition.struct
+ (field_declaration .
+ (pointer_type (type_identifier) @heritage.extends) .)))))
; Calls
(call_expression function: (identifier) @call.name) @call
-(call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
+; Qualified calls: pkg.Func() or localVar.Method() where the operand is a simple
+; identifier — capture it as @_qualifier so cross-file resolution uses the fully
+; qualified name "scrape.NewManager" instead of bare "NewManager", preventing
+; ambiguous same-named symbols in different packages from being collapsed.
+(call_expression function: (selector_expression
+ operand: (identifier) @_qualifier
+ field: (field_identifier) @call.name)) @call
+; Chained/complex calls: a.b.Method(), call().Method(), index[i].Method() — the
+; operand is not a simple identifier, so emit without qualifier (bare method name).
+(call_expression function: (selector_expression
+ operand: (selector_expression)
+ field: (field_identifier) @call.name)) @call
; Struct literal construction: User{Name: "Alice"}
(composite_literal type: (type_identifier) @call.name) @call
@@ -328,6 +481,12 @@ export const GO_QUERIES = `
; Return types: in tree-sitter-go, return type is a direct type_identifier child of function/method
(function_declaration result: (type_identifier) @reference.type)
(method_declaration result: (type_identifier) @reference.type)
+
+; Pointer-type variants: e.g. opts *Options, func(*Options) *Result
+(field_declaration type: (pointer_type (type_identifier) @reference.type))
+(parameter_declaration type: (pointer_type (type_identifier) @reference.type))
+(function_declaration result: (pointer_type (type_identifier) @reference.type))
+(method_declaration result: (pointer_type (type_identifier) @reference.type))
`;
// C++ queries - works with tree-sitter-cpp
@@ -461,8 +620,8 @@ export const CSHARP_QUERIES = `
; Type references — captures types used in field/param/return-type positions
(parameter type: (identifier) @reference.type)
(variable_declaration type: (identifier) @reference.type)
-(field_declaration type: (identifier) @reference.type)
-(method_declaration return_type: (identifier) @reference.type)
+(field_declaration (variable_declaration type: (identifier) @reference.type))
+(method_declaration returns: (identifier) @reference.type)
`;
// Rust queries - works with tree-sitter-rust
@@ -488,7 +647,9 @@ export const RUST_QUERIES = `
; Calls
(call_expression function: (identifier) @call.name) @call
(call_expression function: (field_expression field: (field_identifier) @call.name)) @call
-(call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
+(call_expression function: (scoped_identifier
+ path: (identifier) @_qualifier
+ name: (identifier) @call.name)) @call
(call_expression function: (generic_function function: (identifier) @call.name)) @call
; Struct literal construction: User { name: value }
@@ -499,6 +660,31 @@ export const RUST_QUERIES = `
(parameter pattern: (_) type: (type_identifier) @reference.type)
(function_item return_type: (type_identifier) @reference.type)
+; Wrapped type references — &Type, &mut Type
+(field_declaration type: (reference_type (type_identifier) @reference.type))
+(parameter pattern: (_) type: (reference_type (type_identifier) @reference.type))
+(function_item return_type: (reference_type (type_identifier) @reference.type))
+
+; Generic wrapper types — Box<Type>, Arc<Type>, Vec<Type>, Option<Type>, Result<Type,_>, etc.
+; Capture the type argument (inner type), not the wrapper name.
+(field_declaration type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+(function_item return_type: (generic_type type_arguments: (type_arguments (type_identifier) @reference.type)))
+
+; impl Trait in parameter / return positions
+(parameter pattern: (_) type: (abstract_type (type_identifier) @reference.type))
+(function_item return_type: (abstract_type (type_identifier) @reference.type))
+
+; dyn Trait — trait objects (direct: fn foo(x: dyn Trait) or field: x: dyn Trait)
+(field_declaration type: (dynamic_type (type_identifier) @reference.type))
+(parameter pattern: (_) type: (dynamic_type (type_identifier) @reference.type))
+(function_item return_type: (dynamic_type (type_identifier) @reference.type))
+
+; dyn Trait nested inside generic wrapper — Box<dyn Trait>, Arc<dyn Trait>, etc.
+(field_declaration type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+(parameter pattern: (_) type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+(function_item return_type: (generic_type type_arguments: (type_arguments (dynamic_type (type_identifier) @reference.type))))
+
; Heritage (trait implementation) — all combinations of concrete/generic trait × concrete/generic type
(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
diff --git a/core-ingestion/src/role-classifier.ts b/core-ingestion/src/role-classifier.ts
index 01bdb093..4232c4a2 100644
--- a/core-ingestion/src/role-classifier.ts
+++ b/core-ingestion/src/role-classifier.ts
@@ -19,12 +19,14 @@ const TEST_PATH_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [
{ pattern: /[/\\]src[/\\]test[/\\]/i, signal: 'path:src/test/' },
{ pattern: /[/\\]test[/\\]unit[/\\]/i, signal: 'path:test/unit/' },
{ pattern: /[/\\]test[/\\]integration[/\\]/i,signal: 'path:test/integration/' },
+ // C#/.NET: directories named Foo.Tests or Foo.Test (e.g. Newtonsoft.Json.Tests/)
+ { pattern: /[/\\][^/\\]*\.tests?[/\\]/i, signal: 'path:.Tests/' },
];
const TEST_FILE_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [
{ pattern: /\.test\.[^.]+$/i, signal: 'filename:.test.' },
{ pattern: /\.spec\.[^.]+$/i, signal: 'filename:.spec.' },
- { pattern: /Test\.[^.]+$/, signal: 'filename:Test.' },
+ { pattern: /Tests?\.[^.]+$/, signal: 'filename:Test(s).' }, // matches Test.cs and Tests.cs
{ pattern: /Spec\.[^.]+$/, signal: 'filename:Spec.' },
{ pattern: /_test\.[^.]+$/i, signal: 'filename:_test.' },
{ pattern: /_spec\.[^.]+$/i, signal: 'filename:_spec.' },
@@ -45,6 +47,10 @@ const TEST_IMPORT_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [
{ pattern: /"testing"/, signal: 'import:go_testing' },
{ pattern: /require\s+['"]rspec['"]/, signal: 'import:rspec' },
{ pattern: /require\s+['"]minitest['"]/, signal: 'import:minitest' },
+ // C#/.NET test frameworks
+ { pattern: /using\s+NUnit\.Framework/, signal: 'import:nunit' },
+ { pattern: /using\s+Xunit/, signal: 'import:xunit' },
+ { pattern: /using\s+Microsoft\.VisualStudio\.TestTools\.UnitTesting/, signal: 'import:mstest' },
];
const FIXTURE_PATH_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [
diff --git a/ix-cli/src/cli/__tests__/search-ranking.test.ts b/ix-cli/src/cli/__tests__/search-ranking.test.ts
index ecb00327..19eac811 100644
--- a/ix-cli/src/cli/__tests__/search-ranking.test.ts
+++ b/ix-cli/src/cli/__tests__/search-ranking.test.ts
@@ -1,4 +1,5 @@
-import { describe, it, expect } from "vitest";
+import { describe, it, expect, vi } from "vitest";
+import { resolveEntityFull } from "../resolve.js";
/**
* Verify that search ranking correctly incorporates backend _search_weight.
@@ -114,3 +115,72 @@ describe("search ranking with backend weight", () => {
expect(r3.matchSource).toBe("resolver");
});
});
+
+describe("resolveEntityFull --path hard exclusion", () => {
+ it("excludes out-of-scope candidates even on exact name match", async () => {
+ // Simulates Bug 1: etcd has 'Notifier' but prometheus does not.
+ // With --path prometheus, the etcd candidate must be excluded entirely.
+ const etcdNotifier = {
+ id: "etcd-notifier-id",
+ name: "Notifier",
+ kind: "class",
+ provenance: { sourceUri: "etcd/pkg/notify/notify.go" },
+ };
+ const mockClient = {
+ search: vi.fn().mockResolvedValue([etcdNotifier]),
+ } as any;
+
+ const result = await resolveEntityFull(mockClient, "Notifier", ["class"], { path: "prometheus" });
+
+ expect(result.resolved).toBe(false);
+ if (!result.resolved) {
+ expect(result.ambiguous).toBe(false);
+ }
+ });
+
+ it("resolves when the only candidate matches the path filter", async () => {
+ const promNotifier = {
+ id: "prom-notifier-id",
+ name: "Notifier",
+ kind: "class",
+ provenance: { sourceUri: "prometheus/notifier/notifier.go" },
+ };
+ const mockClient = {
+ search: vi.fn().mockResolvedValue([promNotifier]),
+ } as any;
+
+ const result = await resolveEntityFull(mockClient, "Notifier", ["class"], { path: "prometheus" });
+
+ expect(result.resolved).toBe(true);
+ if (result.resolved) {
+ expect(result.entity.id).toBe("prom-notifier-id");
+ }
+ });
+
+ it("prefers in-scope candidate over higher-scored out-of-scope candidate", async () => {
+ // Both repos have 'Manager'; only the prometheus one should be returned.
+ const etcdManager = {
+ id: "etcd-manager-id",
+ name: "Manager",
+ kind: "class",
+ provenance: { sourceUri: "etcd/raft/manager.go" },
+ };
+ const promManager = {
+ id: "prom-manager-id",
+ name: "Manager",
+ kind: "class",
+ provenance: { sourceUri: "prometheus/notifier/manager.go" },
+ };
+ const mockClient = {
+ search: vi.fn().mockResolvedValue([etcdManager, promManager]),
+ } as any;
+
+ const result = await resolveEntityFull(mockClient, "Manager", ["class"], { path: "prometheus" });
+
+ // etcdManager is excluded by the path filter; only promManager survives → single candidate → resolved
+ expect(result.resolved).toBe(true);
+ if (result.resolved) {
+ expect(result.entity.id).toBe("prom-manager-id");
+ }
+ });
+});
diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.ts
index e4d1ea2a..8769f524 100644
--- a/ix-cli/src/cli/commands/ingest.ts
+++ b/ix-cli/src/cli/commands/ingest.ts
@@ -31,6 +31,33 @@ const SUPPORTED_EXTENSIONS = new Set([
'.scala', '.sc',
]);
+// ---------------------------------------------------------------------------
+// Language filter helpers
+// ---------------------------------------------------------------------------
+
+/** Normalise user-supplied language names to their canonical enum values. */
+const LANG_ALIASES: Record<string, string> = {
+ 'c++': 'cpp',
+ 'cplusplus': 'cpp',
+ 'c#': 'csharp',
+ 'cs': 'csharp',
+ 'js': 'javascript',
+ 'ts': 'typescript',
+ 'py': 'python',
+ 'rb': 'ruby',
+ 'rs': 'rust',
+ 'kt': 'kotlin',
+};
+
+function parseLangs(raw: string): Set<string> {
+ return new Set(
+ raw.split(',')
+ .map(s => s.trim().toLowerCase())
+ .map(s => LANG_ALIASES[s] ?? s)
+ .filter(Boolean),
+ );
+}
+
const IGNORE_DIRS = new Set([
'node_modules', '.git', 'dist', 'build', 'target', '.next',
'.cache', '__pycache__', '.ix', '.claude', '.gitnexus',
@@ -137,10 +164,11 @@ export function registerIngestCommand(program: Command): void {
.option('--format <fmt>', 'Output format (text|json)', 'text')
.option('--root <dir>', 'Workspace root directory')
.option('--debug', 'Show phase timing breakdown', false)
- .addHelpText('after', '\nExamples:\n ix ingest ./src\n ix ingest --path ./src --force\n ix ingest --github owner/repo\n ix ingest --github owner/repo --since 2026-01-01 --limit 20 --format json\n ix ingest --github owner/repo --token ghp_xxxx')
+ .option('--lang <langs>', 'Comma-separated languages to include (e.g. cpp,c or typescript). Aliases: c++=cpp, c#=csharp, py=python, ts=typescript, js=javascript')
+ .addHelpText('after', '\nExamples:\n ix ingest ./src\n ix ingest --path ./src --force\n ix ingest --path ./rocksdb --lang cpp,c\n ix ingest --github owner/repo\n ix ingest --github owner/repo --since 2026-01-01 --limit 20 --format json\n ix ingest --github owner/repo --token ghp_xxxx')
.action(async (positionalPath: string | undefined, opts: {
path?: string; recursive?: boolean; force?: boolean; github?: string; token?: string;
- since?: string; limit: string; format: string; root?: string; debug?: boolean;
+ since?: string; limit: string; format: string; root?: string; debug?: boolean; lang?: string;
}) => {
const effectivePath = positionalPath ?? opts.path;
if (opts.github) {
@@ -160,11 +188,15 @@ export function registerIngestCommand(program: Command): void {
export async function ingestFiles(
path: string,
- opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean; printSummary?: boolean }
+ opts: { recursive?: boolean; force?: boolean; format: string; root?: string; debug?: boolean; printSummary?: boolean; lang?: string }
): Promise<void> {
const debug = opts.debug || process.env.IX_DEBUG === '1';
const trueStart = performance.now();
+ const [{ parseFile, resolveEdges, isGrammarSupported }, { buildPatchWithResolution }, { languageFromPath }] = await loadIngestionModules();
+ const moduleLoadMs = Math.round(performance.now() - trueStart);
+
+
const resolvedPath = nodePath.isAbsolute(path)
? path
: nodePath.resolve(resolveWorkspaceRoot(opts.root), path);
@@ -207,6 +239,14 @@ export async function ingestFiles(
try {
// Phase: discover files
+ const langFilter = opts.lang ? parseLangs(opts.lang) : null;
+ const supportsFile = (fileName: string): boolean => {
+ if (!isGrammarSupported(fileName)) return false;
+ if (!langFilter) return true;
+ const lang = languageFromPath(fileName);
+ return lang !== null && langFilter.has(lang);
+ };
+
const stat = fs.statSync(resolvedPath);
const filePaths: string[] = stat.isFile()
? (SUPPORTED_EXTENSIONS.has(nodePath.extname(resolvedPath)) ? [resolvedPath] : [])
diff --git a/ix-cli/src/cli/resolve.ts b/ix-cli/src/cli/resolve.ts
index f70c711d..3582fff0 100644
--- a/ix-cli/src/cli/resolve.ts
+++ b/ix-cli/src/cli/resolve.ts
@@ -84,7 +84,11 @@ export function scoreCandidate(
if (opts?.path) {
const pathLower = opts.path.toLowerCase();
if (sourceUri.includes(pathLower)) {
- score -= 4; // strong path preference
+ // Specificity bonus: a longer/more specific filter string gives a larger
+ // score reduction, breaking ties when many entities share the same short
+ // path prefix (e.g. 8 structs named Handle all under "tokio/").
+ const specificityRatio = pathLower.length / Math.max(sourceUri.length, 1);
+ score -= 4 + Math.round(specificityRatio * 6); // bonus from 4 to 10
}
}
@@ -101,7 +105,7 @@ export async function resolveEntity(
client: IxClient,
symbol: string,
preferredKinds: string[],
- opts?: { kind?: string; path?: string; pick?: number; includeTests?: boolean; testsOnly?: boolean }
+ opts?: { kind?: string; path?: string; pick?: number; includeTests?: boolean; testsOnly?: boolean; searchLimit?: number }
): Promise<ResolvedEntity | null> {
const result = await resolveEntityFull(client, symbol, preferredKinds, opts);
if (result.resolved) return result.entity;
@@ -122,10 +126,10 @@ export async function resolveEntityFull(
client: IxClient,
symbol: string,
preferredKinds: string[],
- opts?: { kind?: string; path?: string; pick?: number; includeTests?: boolean; testsOnly?: boolean }
+ opts?: { kind?: string; path?: string; pick?: number; includeTests?: boolean; testsOnly?: boolean; searchLimit?: number }
): Promise<ResolveResult> {
const kindFilter = opts?.kind;
- const nodes = await client.search(symbol, { limit: 20, kind: kindFilter, nameOnly: true });
+ const nodes = await client.search(symbol, { limit: opts?.searchLimit ?? 20, kind: kindFilter, nameOnly: true });
if (nodes.length === 0) {
stderr(`No entity found matching "${symbol}".`);
@@ -133,14 +137,38 @@ export async function resolveEntityFull(
}
// Apply role filter before scoring
- const { filtered: filteredNodes, hiddenTestCount } = applyRoleFilter(nodes, opts ?? {});
+ const { filtered: roleFiltered, hiddenTestCount } = applyRoleFilter(nodes, opts ?? {});
+
+ // Hard path filter: when --path is provided, exclude candidates whose sourceUri does not
+ // contain the filter string. If no candidates survive, return "not found" rather than
+ // falling back to cross-repo results.
+ const filteredNodes = opts?.path
+ ? roleFiltered.filter((n: any) => {
+ const uri = (n.provenance?.sourceUri ?? n.provenance?.source_uri ?? "").toLowerCase();
+ return uri.includes(opts.path!.toLowerCase());
+ })
+ : roleFiltered;
+
+ if (opts?.path && filteredNodes.length === 0) {
+ stderr(`No entity named "${symbol}" found in paths matching "${opts.path}".`);
+ return { resolved: false, ambiguous: false, hiddenTestCount };
+ }
// ── Phase 1: Exact-name candidates ──────────────────────────────────
const symbolLower = symbol.toLowerCase();
- const exactName = filteredNodes.filter((n: any) => {
- const name = (n.name || n.attrs?.name || "").toLowerCase();
- return name === symbolLower;
+ // Prefer case-sensitive exact matches. Fall back to case-insensitive only if none found.
+ // This prevents e.g. 'Apply' (capital A) from matching lowercase 'apply' module import
+ // aliases before finding the actual 'Apply' method entities.
+ const exactCaseName = filteredNodes.filter((n: any) => {
+ const name = (n.name || n.attrs?.name || "");
+ return name === symbol;
});
+ const exactName = exactCaseName.length > 0
+ ? exactCaseName
+ : filteredNodes.filter((n: any) => {
+ const name = (n.name || n.attrs?.name || "").toLowerCase();
+ return name === symbolLower;
+ });
// Score exact-name candidates
if (exactName.length > 0) {
@@ -230,6 +258,17 @@ function pickBest(
return { resolved: true, entity: nodeToResolved(best.node, symbol, resolutionMode(best, opts)) };
}
+ // If the best candidate ranks strictly higher in the kind preference list than all
+ // other top-tier candidates, auto-pick it — the preference list is the tiebreaker.
+ const topTierKindRanks = topTier.map(s => {
+ const idx = preferredKinds.indexOf((s.node.kind || "").toLowerCase());
+ return idx >= 0 ? idx : preferredKinds.length;
+ });
+ const bestKindRank = topTierKindRanks[0];
+ if (topTier.length > 1 && topTierKindRanks.every((r, i) => i === 0 || r > bestKindRank)) {
+ return { resolved: true, entity: nodeToResolved(best.node, symbol, "preferred-kind") };
+ }
+
// If best is a container kind and second is a method/function, prefer the container
const bestKind = (best.node.kind || "").toLowerCase();
const secondKind = (second.node.kind || "").toLowerCase();
@@ -250,7 +289,7 @@ function pickBest(
// Genuinely ambiguous — return only structurally relevant candidates
const ambiguousCandidates = unique
.filter(s => s.score <= topScore + 5) // only candidates within range
- .slice(0, 5);
+ .slice(0, 8);
return {
resolved: false,
@@ -316,7 +355,7 @@ function buildAmbiguous(nodes: any[], scores?: number[]): AmbiguousResult {
const seen = new Set<string>();
const candidates: AmbiguousResult["candidates"] = [];
let rank = 0;
- for (let i = 0; i < nodes.length && i < 5; i++) {
+ for (let i = 0; i < nodes.length && i < 8; i++) {
const node = nodes[i] as any;
if (seen.has(node.id)) continue;
seen.add(node.id);
@@ -368,6 +407,35 @@ export function isRawId(s: string): boolean {
|| /^[0-9a-f]{32,}$/i.test(s);
}
+// ── Scoped symbol parsing (e.g. C++ ClassName::methodName) ────────────────
+
+/**
+ * Convert a CamelCase or PascalCase identifier to snake_case.
+ * Used to derive a file path hint from a C++/Rust class name.
+ * Examples: "CompactionJob" → "compaction_job", "DBImpl" → "db_impl"
+ */
+function camelToSnake(s: string): string {
+ return s
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
+ .replace(/([a-z\d])([A-Z])/g, '$1_$2')
+ .toLowerCase();
+}
+
+/**
+ * Parse a scoped symbol like "ClassName::methodName" (C++/Rust/PHP style).
+ * Returns the class and method parts, or null if no `::` is present.
+ * Uses the *last* `::` so that nested scopes like `ns::Class::method` resolve
+ * to `{ className: "ns::Class", methodName: "method" }`.
+ */
+function parseScopedSymbol(symbol: string): { className: string; methodName: string } | null {
+ const idx = symbol.lastIndexOf('::');
+ if (idx < 1) return null;
+ const className = symbol.slice(0, idx);
+ const methodName = symbol.slice(idx + 2);
+ if (!className || !methodName) return null;
+ return { className, methodName };
+}
+
// ── File-first resolution ─────────────────────────────────────────────────
/** Common file extensions that signal the target is file-like, not a symbol name. */
@@ -425,8 +493,56 @@ export async function resolveFileOrEntity(
// Fall through to symbol resolution
}
+ // 2.5 Scoped symbol (e.g. "CompactionJob::Run", "ns::Class::method")
+ const scoped = parseScopedSymbol(target);
+ if (scoped) {
+ // Phase A: resolve the class entity to obtain its actual source file path.
+ // This gives a precise path hint rather than a guess from snake_case conversion.
+ // We suppress stderr during this lookup to avoid confusing "not found" noise.
+ const shortClassName = scoped.className.split('::').pop()!;
+ const classEntity = await resolveEntity(
+ client,
+ shortClassName,
+ ['class', 'interface', 'struct', 'trait', 'object', 'function'],
+ { ...opts, kind: opts?.kind ? undefined : undefined }, // no kind constraint for class lookup
+ );
+
+ // Determine the best path hint: prefer the actual file path from phase A,
+ // fall back to snake_case conversion of the class name.
+ let pathHint: string;
+ if (classEntity?.path) {
+ // Extract basename without extension (e.g. "/db/flush_job.h" → "flush_job")
+ const basename = classEntity.path.replace(/\\/g, '/').split('/').pop() ?? '';
+ pathHint = basename.replace(/\.[^.]+$/, '').toLowerCase();
+ } else {
+ // Fallback: CamelCase → snake_case (e.g. "CompactionJob" → "compaction_job")
+ pathHint = camelToSnake(shortClassName);
+ }
+
+ // Phase B: find the method, boosting candidates in the class's source file.
+ // Use pathHint (derived from the class entity's actual source file) as the
+ // path constraint — it is always more specific than the user's broad --path
+ // workspace filter (e.g. "rocksdb"), so it takes priority.
+ // Use a higher search limit so that methods in the correct file are not
+ // pushed out by unrelated Run/Execute methods in other classes.
+ // We deliberately do NOT force kind=method because some parsers classify
+ // class methods as kind "function".
+ const scopedOpts = {
+ ...opts,
+ path: pathHint, // always use the class-derived hint, not opts?.path
+ searchLimit: 50,
+ };
+ const entity = await resolveEntity(client, scoped.methodName, ['method', 'function'], scopedOpts);
+ if (entity) {
+ // Rewrite the display name to show the full scoped form
+ return { ...entity, name: `${scoped.className}::${scoped.methodName}` };
+ }
+ // Not found — return null (don't fall through to a literal "Foo::Bar" search)
+ return null;
+ }
+
// 3. Symbol resolution (handles all entity kinds)
- const allKinds = ["file", "class", "object", "trait", "interface", "module", "function", "method"];
+ const allKinds = ["file", "class", "object", "trait", "interface", "module", "method", "function"];
return resolveEntity(client, target, allKinds, opts);
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/BulkWriteApi.scala b/memory-layer/src/main/scala/ix/memory/db/BulkWriteApi.scala
index d0c51ae0..9c213812 100644
--- a/memory-layer/src/main/scala/ix/memory/db/BulkWriteApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/BulkWriteApi.scala
@@ -44,7 +44,18 @@ class BulkWriteApi(client: ArangoClient) {
Option(doc.get("logical_id")).map(_.toString)
}
+ // Collect source URIs so we can tombstone ALL old nodes for each file.
+ // This is needed when a re-ingest changes an entity's qualified key (e.g.
+ // a method gains a container, shifting its nodeId). Tombstoning only by
+ // logical_id would leave the old orphaned entity alive.
+ // Include both slash variants so that nodes stored with backslash paths
+ // (Windows) are also matched when re-ingesting with forward-slash paths.
+ val sourceUris = fileBatches.map(_.filePath).distinct.flatMap { p =>
+ Seq(p, p.replace('\\', '/'), p.replace('/', '\\'))
+ }.distinct
+
for {
+ _ <- tombstoneNodesBySourceUri(sourceUris, newRev)
_ <- tombstoneExistingNodes(logicalIds, newRev)
_ <- retireOldClaims(fileBatches, newRev)
_ <- withRetry(client.bulkInsert("nodes", allNodes))
@@ -55,6 +66,30 @@ class BulkWriteApi(client: ArangoClient) {
} yield CommitResult(Rev(newRev), CommitStatus.Ok)
}
+ /** Tombstone every live node whose provenance.source_uri matches one of the given paths.
+ * Called before inserting new nodes so that stale entities (whose nodeId changed because
+ * they gained or lost a container) are cleaned up even though they share no logical_id
+ * with the incoming replacements.
+ */
+ private def tombstoneNodesBySourceUri(sourceUris: Vector[String], newRev: Long): IO[Unit] = {
+ if (sourceUris.isEmpty) IO.unit
+ else {
+ val uriList = new java.util.ArrayList[String](sourceUris.size)
+ sourceUris.foreach(uriList.add)
+ client.execute(
+ """FOR n IN nodes
+ | FILTER n.provenance.source_uri IN @uris
+ | AND n.deleted_rev == null
+ | UPDATE n WITH { deleted_rev: @rev, updated_at: @now } IN nodes""".stripMargin,
+ Map(
+ "uris" -> uriList.asInstanceOf[AnyRef],
+ "rev" -> Long.box(newRev).asInstanceOf[AnyRef],
+ "now" -> Instant.now().toString.asInstanceOf[AnyRef]
+ )
+ )
+ }
+ }
+
private def tombstoneExistingNodes(logicalIds: Vector[String], newRev: Long): IO[Unit] = {
if (logicalIds.isEmpty) IO.unit
else {
diff --git a/memory-layer/src/main/scala/ix/memory/map/MapService.scala b/memory-layer/src/main/scala/ix/memory/map/MapService.scala
index f1c5c96a..09bec74d 100644
--- a/memory-layer/src/main/scala/ix/memory/map/MapService.scala
+++ b/memory-layer/src/main/scala/ix/memory/map/MapService.scala
@@ -283,17 +283,56 @@ class MapService(
val mySegs = dirSegs(myPaths)
val otherSegs = dirSegs(otherPaths)
- val exclusive = (mySegs -- otherSegs).filterNot(LabelNoiseTokens.contains)
-
- // Prefer shorter tokens (more likely to be a meaningful module name).
- // Fallback: rank by size — largest keeps the clean label, smaller ones get "(2)", "(3)", etc.
- val suffix = exclusive.toVector.sortBy(s => (s.length, s)).headOption
- .map(s => s" / ${s.capitalize}")
- .getOrElse {
- val rank = group.sortBy(-_.memberFiles.size).indexWhere(_.id == r.id) + 1
- if (rank <= 1) "" else s" ($rank)"
+ val minExclCoverage = math.max(2, r.memberFiles.size * 0.20).toInt
+ val exclusive = (mySegs -- otherSegs)
+ .filterNot(LabelNoiseTokens.contains)
+ // Only use a segment as a discriminator if it covers ≥20% of the cluster's files.
+ // This prevents a low-frequency deep segment (e.g. "dummy" in 7/45 files) from
+ // winning over segments that actually characterise the majority of the cluster.
+ .filter { seg =>
+ myPaths.count(p =>
+ p.split("[/\\\\]").dropRight(1).exists(_.equalsIgnoreCase(seg))
+ ) >= minExclCoverage
}
- r.copy(label = r.label + suffix)
+
+ // Prefer shorter tokens (more likely to be a meaningful module name)
+ exclusive.toVector.sortBy(s => (s.length, s)).headOption match {
+ case Some(seg) =>
+ r.copy(label = r.label + s" / ${seg.capitalize}")
+ case None =>
+ // No exclusive directory found (cross-cutting clusters in the same label group
+ // have already claimed all of our directory segments).
+ // Fall back to the dominant directory within THIS cluster as a full label
+ // replacement — not a suffix — so we don't collide with the parent system name.
+ // Strip the common absolute prefix and apply depth weighting (same as inferLabel
+ // Strategy 2) so that deeper, more specific directory segments score higher.
+ val strippedPaths = myPaths.toSeq.map { p =>
+ val segs = p.split("[/\\\\]")
+ if (commonPfxLen > 0 && commonPfxLen < segs.length) segs.drop(commonPfxLen)
+ else segs
+ }
+ val dirsWithDepth: Seq[(Int, String)] = strippedPaths.flatMap { segs =>
+ segs.dropRight(1).zipWithIndex
+ .filterNot { case (s, _) => LabelNoiseTokens.contains(s.toLowerCase) || s.isEmpty }
+ .map { case (s, i) => (i, s) }
+ }
+ val maxD = dirsWithDepth.map(_._1).maxOption.getOrElse(1).toDouble.max(1.0)
+ val candidateSegments = dirsWithDepth.groupBy(_._2)
+ // Skip the base label itself — we need what distinguishes this cluster *within*
+ // the label group, not the project/package name that all siblings share.
+ .filterNot { case (seg, _) => seg.equalsIgnoreCase(r.label) }
+
+ // Score all candidate segments by frequency × depth-weight.
+ // No coverage floor here — depth-weighting already favours specific segments,
+ // and imposing a 20% minimum causes large spread-out clusters to fall back to
+ // the useless "(Nf)" label when files are spread across many subdirectories.
+ val scored = candidateSegments
+ .map { case (seg, entries) =>
+ seg -> entries.length * (1.0 + entries.map(_._1 / maxD).sum / entries.length)
+ }
+ val dominant = scored.maxByOption(_._2).map(_._1.capitalize)
+ r.copy(label = dominant.getOrElse(r.label + s" (${r.memberFiles.size}f)"))
+ }
case None => r
}
}