Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
feat(ingest): bump B — batch-independent resolution, persisted symbol table, extraction depth, dependent re-resolve; extractor 1.29 (#764)
Ian Hock26f497ca1bb6
diff --git a/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap b/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snapindex aa81b928..1a8ee633 100644--- a/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap+++ b/core-ingestion/src/__tests__/__snapshots__/parseFile.test.ts.snap@@ -537,6 +537,28 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"name": "CheckResult","startByte": 654,},+ {+ "chunkKind": "class",+ "container": undefined,+ "contentHash": "a73c66f5052aa408",+ "endByte": 782,+ "language": "typescript",+ "lineEnd": 20,+ "lineStart": 20,+ "name": "CheckStatus",+ "startByte": 738,+ },+ {+ "chunkKind": "class",+ "container": undefined,+ "contentHash": "1ce85fb2228bdf6c",+ "endByte": 823,+ "language": "typescript",+ "lineEnd": 22,+ "lineStart": 22,+ "name": "Loader",+ "startByte": 784,+ },{"chunkKind": "function","container": undefined,@@ -632,6 +654,24 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"name": "CheckResult","packageScope": undefined,},+ {+ "container": undefined,+ "kind": "class",+ "language": "typescript",+ "lineEnd": 20,+ "lineStart": 20,+ "name": "CheckStatus",+ "packageScope": undefined,+ },+ {+ "container": undefined,+ "kind": "class",+ "language": "typescript",+ "lineEnd": 22,+ "lineStart": 22,+ "name": "Loader",+ "packageScope": undefined,+ },{"container": undefined,"kind": "function",@@ -739,6 +779,16 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "CONTAINS","srcName": "sample-command.ts",},+ {+ "dstName": "CheckStatus",+ "predicate": "CONTAINS",+ "srcName": "sample-command.ts",+ },+ {+ "dstName": "Loader",+ "predicate": "CONTAINS",+ "srcName": "sample-command.ts",+ },{"dstName": "runChecks","predicate": "CONTAINS",@@ -786,6 +836,11 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "IMPORTS","srcName": "sample-command.ts",},+ {+ "dstName": "CheckResult",+ "predicate": "REFERENCES",+ "srcName": "runChecks",+ },{"dstName": "push","predicate": "CALLS",@@ -797,6 +852,11 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "CALLS","srcName": "runChecks",},+ {+ "dstName": "CheckResult",+ "predicate": "REFERENCES",+ "srcName": "runOne",+ },{"dstName": "join","predicate": "CALLS",@@ -808,6 +868,11 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "CALLS","srcName": "runOne",},+ {+ "dstName": "CheckResult",+ "predicate": "REFERENCES",+ "srcName": "statusOf",+ },{"dstName": "CheckStatus","predicate": "REFERENCES",@@ -823,6 +888,16 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "CALLS","srcName": "statusOf",},+ {+ "dstName": "Loader",+ "predicate": "REFERENCES",+ "srcName": "CheckRunner",+ },+ {+ "dstName": "Loader",+ "predicate": "REFERENCES",+ "srcName": "CheckRunner.constructor",+ },{"dstName": "loader","predicate": "CALLS",@@ -833,6 +908,11 @@ exports[`parseFile snapshots > snapshots a TypeScript command module 1`] = `"predicate": "CALLS","srcName": "CheckRunner.load",},+ {+ "dstName": "CheckResult",+ "predicate": "REFERENCES",+ "srcName": "CheckRunner.describe",+ },{"bareCall": true,"dstName": "statusOf",diff --git a/core-ingestion/src/__tests__/extraction-depth.test.ts b/core-ingestion/src/__tests__/extraction-depth.test.tsnew file mode 100644index 00000000..e84e7312--- /dev/null+++ b/core-ingestion/src/__tests__/extraction-depth.test.ts@@ -0,0 +1,159 @@+// Copyright 2026 Ix Infrastructure Inc.++import { describe, expect, it } from 'vitest';++import { parseFile } from '../index.js';+import { buildPatchWithResolution } from '../patch-builder.js';+import { classifyFileRole } from '../role-classifier.js';++/**+ * Extraction depth: what the parser used to leave out of a TypeScript file,+ * parse errors it said nothing about, and file roles it got wrong.+ */++const SAMPLE = `import { Base } from './base';+export type Alias = { a: number };+export enum Color { Red, Green }+export abstract class Shape extends Base<Alias> {+ abstract area(): number;+ draw = () => 1;+}+export namespace NS {+ export function inner() { return 1; }+}+export function over(a: string): string;+export function over(a: number): number;+export function over(a: any): any { return a; }+export class K extends NS.Deep {}+export function uses(c: Color, p: Promise<Alias>, xs: Alias[], m: Alias | null, mm: Map<string, Alias>): void {+ const z = p as unknown as Alias;+}+`;++describe('TypeScript extraction', () => {+ for (const file of ['/repo/sample.ts', '/repo/sample.tsx']) {+ it(`type aliases, enums, abstract classes, namespaces and their members are nodes (${file.slice(-3)})`, () => {+ const r = parseFile(file, SAMPLE)!;+ const byName = new Map(r.entities.map(e => [e.name, e]));+ for (const name of ['Alias', 'Color', 'Shape', 'NS', 'area', 'draw', 'inner', 'over', 'K', 'uses']) {+ expect(byName.has(name), name).toBe(true);+ }+ expect(byName.get('area')!.container).toBe('Shape');+ expect(byName.get('draw')!.container).toBe('Shape');+ });++ it(`extends and type positions produce edges (${file.slice(-3)})`, () => {+ const rels = parseFile(file, SAMPLE)!.relationships;+ expect(rels).toContainEqual({ srcName: 'Shape', dstName: 'Base', predicate: 'EXTENDS' });+ expect(rels).toContainEqual({ srcName: 'K', dstName: 'NS.Deep', predicate: 'EXTENDS' });+ // Promise<Alias>, Alias[], Alias | null, Map<string, Alias>, `as Alias`: one edge.+ expect(rels).toContainEqual({ srcName: 'uses', dstName: 'Alias', predicate: 'REFERENCES' });+ expect(rels).toContainEqual({ srcName: 'uses', dstName: 'Color', predicate: 'REFERENCES' });+ // `extends Base<Alias>`+ expect(rels.some(rel => rel.predicate === 'REFERENCES' && rel.dstName === 'Alias' && rel.srcName.startsWith('Shape'))).toBe(true);+ // Builtins stay out.+ expect(rels.some(rel => rel.dstName === 'Promise' || rel.dstName === 'Map')).toBe(false);+ });+ }+});++describe('TypeScript overloads', () => {+ it('are one function, spanning the implementation', () => {+ const r = parseFile('/repo/over.ts', [+ 'export function over(a: string): string;',+ 'export function over(a: number): number;',+ 'export function over(a: any): any {',+ ' return a;',+ '}',+ ].join('\n'))!;+ const over = r.entities.filter(e => e.name === 'over');+ expect(over.map(e => [e.lineStart, e.lineEnd])).toEqual([[3, 5]]);+ expect(r.chunks.filter(c => c.name === 'over').map(c => [c.lineStart, c.lineEnd])).toEqual([[3, 5]]);+ });++ it('without an implementation (declare, .d.ts) are one function at the first signature', () => {+ const r = parseFile('/repo/over.d.ts', [+ 'export declare function over(a: string): string;',+ 'export declare function over(a: number): number;',+ ].join('\n'))!;+ expect(r.entities.filter(e => e.name === 'over').map(e => e.lineStart)).toEqual([1]);+ });+});++describe('parse errors', () => {+ it('flags a file tree-sitter had to recover, and puts it on the file node', () => {+ const broken = parseFile('/repo/broken.ts', 'export function ok() { return 1; }\nexport function bad( {\n')!;+ expect(broken.hasParseErrors).toBe(true);+ const fileNode = buildPatchWithResolution(broken, 'h', 'ws', []).ops+ .find(op => op.type === 'UpsertNode' && op.kind === 'file') as { attrs: Record<string, unknown> };+ expect(fileNode.attrs.parse_errors).toBe(true);+ });++ it('says nothing about a clean file', () => {+ const clean = parseFile('/repo/clean.ts', 'export function ok() { return 1; }\n')!;+ expect('hasParseErrors' in clean).toBe(false);+ const fileNode = buildPatchWithResolution(clean, 'h', 'ws', []).ops+ .find(op => op.type === 'UpsertNode' && op.kind === 'file') as { attrs: Record<string, unknown> };+ expect('parse_errors' in fileNode.attrs).toBe(false);+ });+});++describe('Java varargs annotations are blanked, not deleted', () => {+ it('keeps byte offsets after the annotation', () => {+ const source = [+ 'package com.example;',+ 'public final class P {',+ ' public static void check(@Nullable Object @Nullable ... args) {}',+ ' public static void after() {}',+ '}',+ '',+ ].join('\n');+ const r = parseFile('/repo/P.java', source)!;+ const chunk = r.chunks.find(c => c.name === 'after')!;+ expect(source.slice(chunk.startByte, chunk.endByte)).toContain('void after()');+ });+});++describe('file roles on workspace-relative paths', () => {+ const role = (path: string, source?: string) => classifyFileRole(path, source).role;++ it('root-level directories count', () => {+ expect(role('tests/test_models.py')).toBe('test');+ expect(role('tests/helpers.py')).toBe('test');+ expect(role('src/tests/helpers.py')).toBe('test');+ expect(role('vendor/lib/x.go')).toBe('external');+ expect(role('fixtures/data.json')).toBe('fixture');+ expect(role('scripts/release.sh')).toBe('tooling');+ expect(role('test/fixtures/user.json')).toBe('fixture');+ });++ it('pytest conventions are tests', () => {+ expect(role('pkg/test_models.py')).toBe('test');+ expect(role('conftest.py')).toBe('test');+ });++ it('no longer misfires', () => {+ expect(role('src/config.ts', 'if (env === "testing") {}')).toBe('production');+ expect(role('pkg/api/PodSpec.go')).toBe('production');+ expect(role('api/spec/openapi.yaml')).toBe('production');+ expect(role('src/audio/resample.py')).toBe('production');+ expect(role('src/db/seed.ts')).toBe('production');+ expect(role('src/audio/SampleRate.java')).toBe('production');+ expect(role('src/tools/search.ts')).toBe('tooling');+ });++ it('still catches what it should', () => {+ expect(role('pkg/x/x_test.go', 'package x\n\nimport "testing"\n')).toBe('test');+ expect(role('pkg/x/util.go', 'package x\n\nimport (\n "fmt"\n "testing"\n)\n')).toBe('test');+ expect(role('src/test/scala/FooSpec.scala')).toBe('test');+ expect(role('src/FakeClock.java')).toBe('fixture');+ expect(role('src/Stubborn.java')).toBe('production');+ expect(role('spec/models/user_spec.rb')).toBe('test');+ });++ it('reports only the winning bucket\'s signals', () => {+ const r = classifyFileRole('test/fixtures/user.json');+ expect(r.role).toBe('fixture');+ expect(r.role_signals).toEqual(['path:fixtures/']);+ });+});diff --git a/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts b/core-ingestion/src/__tests__/patchBuilder.resolution.test.tsindex f0f131ab..28c36f59 100644--- a/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts+++ b/core-ingestion/src/__tests__/patchBuilder.resolution.test.ts@@ -555,4 +555,19 @@ describe('colliding edge ids (#554)', () => {expect(edge.id).toBe(deterministicId('/repo/plain.ts:alpha:beta:CALLS'));});++ it('salts the patch id, and only the patch id, with a resolution hash (IN-11)', () => {+ const result = fileResult('src/a.ts', SupportedLanguages.TypeScript, [entity('alpha', SupportedLanguages.TypeScript)], []);+ const plain = buildPatchWithResolution(result, 'hash', 'ws', []);+ const salted = buildPatchWithResolution(result, 'hash', 'ws', [], undefined, undefined, 'abc123');+ const again = buildPatchWithResolution(result, 'hash', 'ws', [], undefined, undefined, 'abc123');+ const other = buildPatchWithResolution(result, 'hash', 'ws', [], undefined, undefined, 'def456');++ expect(salted.patchId).not.toBe(plain.patchId);+ expect(again.patchId).toBe(salted.patchId);+ expect(other.patchId).not.toBe(salted.patchId);+ expect(salted.ops).toEqual(plain.ops);+ expect(salted.source).toEqual(plain.source);+ expect(salted.replaces).toEqual(plain.replaces);+ });});diff --git a/core-ingestion/src/__tests__/resolveEdges.batching.test.ts b/core-ingestion/src/__tests__/resolveEdges.batching.test.tsnew file mode 100644index 00000000..31c2f43e--- /dev/null+++ b/core-ingestion/src/__tests__/resolveEdges.batching.test.ts@@ -0,0 +1,194 @@+// Copyright 2026 Ix Infrastructure Inc.++import { readdirSync, readFileSync, statSync } from 'node:fs';+import path from 'node:path';++import fc from 'fast-check';+import { describe, expect, it } from 'vitest';++import {+ buildGlobalResolutionIndex,+ parseFile,+ resolveEdges,+ summarizeParseResult,+ type FileParseResult,+ type ResolvedEdge,+} from '../index.js';++/**+ * Resolution must not depend on how the files are batched. The CLI resolves a+ * repository in streaming batches (and an edit as a batch of one) against a+ * whole-repository index; whatever the partition and order, the union of the+ * batches' edges must equal one call over every file. It did not: a target+ * file's language, imports, and (outside JS/TS, PHP, R, SAS and Go) its symbols+ * were read from the batch, so edges were lost, invented, or changed with the+ * file order.+ */++const key = (e: ResolvedEdge) =>+ [e.srcFilePath, e.srcName, e.predicate, e.dstName, e.dstFilePath, e.dstQualifiedKey, e.confidence].join('\0');++function indexOf(results: FileParseResult[]) {+ return buildGlobalResolutionIndex(+ results.map((r) => r.filePath),+ undefined,+ undefined,+ new Map(results.map((r) => [r.filePath, summarizeParseResult(r)])),+ );+}++function batched(results: FileParseResult[], batchOf: number[], index: ReturnType<typeof indexOf>): Set<string> {+ const batches = new Map<number, FileParseResult[]>();+ results.forEach((r, i) => {+ const b = batchOf[i] ?? 0;+ const list = batches.get(b) ?? [];+ list.push(r);+ batches.set(b, list);+ });+ const out = new Set<string>();+ for (const batch of batches.values()) for (const e of resolveEdges(batch, undefined, index)) out.add(key(e));+ return out;+}++/** A small repository whose edges need every kind of cross-file lookup. */+const MIXED: Array<[string, string]> = [+ ['pkg/__init__.py', 'from pkg.util import helper\n'],+ ['pkg/util.py', 'def helper():\n return 1\n\ndef scale(x):\n return x * helper()\n'],+ ['pkg/service.py', 'from pkg.util import helper, scale\n\nclass Service:\n def run(self):\n return scale(helper())\n'],+ ['pkg/app.py', 'from pkg import helper\nfrom pkg.service import Service\n\ndef main():\n return Service().run() + helper()\n'],+ ['pkg/lonely.py', 'def only_here():\n return 2\n'],+ ['pkg/caller.py', 'def go():\n return only_here()\n'],+ ['src/com/ex/Util.java', 'package com.ex;\n\npublic class Util {\n public static int helper() { return 1; }\n}\n'],+ ['src/com/ex/Service.java', 'package com.ex;\n\nimport com.ex.Util;\n\npublic class Service {\n public int run() { return Util.helper(); }\n}\n'],+ ['src/com/ex/App.java', 'package com.ex;\n\npublic class App {\n public int main() { return new Service().run() + Util.helper(); }\n}\n'],+ ['web/math.ts', 'export function add(a: number, b: number) { return a + b; }\n'],+ ['web/index.ts', "export { add } from './math';\n"],+ ['web/calc.ts', "import { add } from './index';\nexport function total() { return add(1, 2); }\n"],+ ['web/report.ts', "import { total } from './calc';\nexport class Report { sum() { return total(); } }\n"],+];++const mixed = MIXED.map(([file, src]) => parseFile(file, src)).filter((r): r is FileParseResult => r !== null);++function ownSources(): FileParseResult[] {+ const dir = path.resolve(import.meta.dirname, '..');+ return readdirSync(dir)+ .filter((f) => f.endsWith('.ts') && statSync(path.join(dir, f)).isFile())+ .sort()+ .map((f) => parseFile(`core-ingestion/src/${f}`, readFileSync(path.join(dir, f), 'utf8'), { budgetMs: 0 }))+ .filter((r): r is FileParseResult => r !== null);+}++describe('resolveEdges is independent of batching', () => {+ it('the mixed repository resolves cross-file edges in every language', () => {+ const edges = resolveEdges(mixed, undefined, indexOf(mixed));+ const langs = new Set(edges.filter((e) => e.predicate !== 'IMPORTS').map((e) => path.extname(e.srcFilePath)));+ expect([...langs].sort()).toEqual(['.java', '.py', '.ts']);+ });++ for (const [name, corpus] of [['mixed fixture', mixed], ['this package', ownSources()]] as const) {+ it(`any partition and order of ${name} gives the edges of one call`, () => {+ const index = indexOf(corpus);+ const whole = new Set(resolveEdges(corpus, undefined, index).map(key));+ expect(whole.size).toBeGreaterThan(0);+ fc.assert(+ fc.property(+ fc.array(fc.nat(3), { minLength: corpus.length, maxLength: corpus.length }),+ fc.boolean(),+ (batchOf, reverse) => {+ const files = reverse ? [...corpus].reverse() : corpus;+ const order = reverse ? [...batchOf].reverse() : batchOf;+ expect(batched(files, order, index)).toEqual(whole);+ },+ ),+ { numRuns: 25, seed: 20261003 },+ );+ });+ }++ it('a batch of one sees the whole repository', () => {+ const index = indexOf(mixed);+ const whole = new Set(resolveEdges(mixed, undefined, index).map(key));+ expect(batched(mixed, mixed.map((_, i) => i), index)).toEqual(whole);+ });+});++describe('resolveEdges scales with the repository', () => {+ /** `n` Python modules, each calling a helper in another and a dotted member. */+ function synthetic(n: number): FileParseResult[] {+ const out: FileParseResult[] = [];+ for (let i = 0; i < n; i++) {+ const next = (i + 1) % n;+ const src = `from pkg.m${next} import f${next}\n\nclass C${i}:\n def m(self):\n return 1\n\ndef f${i}():\n return f${next}() + C${next}.m(None)\n`;+ const r = parseFile(`pkg/m${i}.py`, src);+ if (r) out.push(r);+ }+ return out;+ }++ it('doubling the files keeps the time well under quadratic', () => {+ // Best of seven on sizes large enough that one scheduler hiccup can't swing+ // the ratio. Doubling measures ~2.2x locally but sits right at 3x on CI+ // runners; quadratic would be ~4x, so 3.5x still catches it.+ const time = (results: FileParseResult[]) => {+ const index = indexOf(results);+ return Math.min(...Array.from({ length: 7 }, () => {+ const t = performance.now();+ resolveEdges(results, undefined, index);+ return performance.now() - t;+ }));+ };+ const small = synthetic(2000);+ const large = synthetic(4000);+ time(small); // warm up+ time(large);+ expect(time(large) / time(small)).toBeLessThan(3.5);+ }, 60_000);+});++describe('resolveEdges against a summarized index', () => {+ it('an index built from summaries alone resolves like one built with the paths too', () => {+ const summariesOnly = buildGlobalResolutionIndex(+ [],+ undefined,+ undefined,+ new Map(mixed.map((r) => [r.filePath, summarizeParseResult(r)])),+ );+ const whole = new Set(resolveEdges(mixed, undefined, indexOf(mixed)).map(key));+ expect(batched(mixed, mixed.map((_, i) => i), summariesOnly)).toEqual(whole);+ });++ it('resolving a batch leaves the index as it was', () => {+ const indexed = mixed.filter((r) => r.filePath !== 'web/calc.ts');+ const index = indexOf(indexed);+ const snapshot = (i: ReturnType<typeof indexOf>) => JSON.stringify(+ [i.stemToFiles, i.dirToIndexFiles, i.packageToFiles, i.goPkgDirToFiles, i.goPkgPathToFiles].map((m) => [...m]),+ );+ const before = snapshot(index);+ // Not in the index, and its stem and directory collide with files that are.+ const extra = [parseFile('web/index/index.ts', "export const x = 1;\n")!, parseFile('src/com/ex/Extra.java', 'package com.ex;\npublic class Extra {}\n')!];+ resolveEdges([...extra, mixed.find((r) => r.filePath === 'web/calc.ts')!], undefined, index);+ expect(snapshot(index)).toBe(before);+ });++ it('a one-file batch costs time linear in the repository, not in a common stem squared', () => {+ // Every file is an `index.ts`: one stem list as long as the repository.+ function repo(n: number) {+ const results: FileParseResult[] = [];+ for (let i = 0; i < n; i++) {+ const r = parseFile(`p${i}/index.ts`, `export function f${i}() { return 1; }\n`);+ if (r) results.push(r);+ }+ return { results, index: indexOf(results) };+ }+ const time = ({ results, index }: ReturnType<typeof repo>) => Math.min(...[0, 1, 2].map(() => {+ const t = performance.now();+ resolveEdges([results[0]], undefined, index);+ return performance.now() - t;+ }));+ const small = repo(3000);+ const large = repo(12000);+ time(small); // warm up+ // 4x the files: linear is ~4x, the old per-call de-dup was ~16x.+ expect(time(large) / time(small)).toBeLessThan(8);+ });+});diff --git a/core-ingestion/src/index.ts b/core-ingestion/src/index.tsindex 99ccc30e..e7a0fde3 100644--- a/core-ingestion/src/index.ts+++ b/core-ingestion/src/index.ts@@ -153,6 +153,8 @@ import { SupportedLanguages, languageFromPath } from './languages.js';import { LANGUAGE_QUERIES } from './queries.js';import { classifyFileRole } from './role-classifier.js';import type { RoleClassification } from './role-classifier.js';+import { summarySignature, type FileSummary } from './symbol-index.js';+export type { FileSummary } from './symbol-index.js';// ---------------------------------------------------------------------------// Public types@@ -276,6 +278,12 @@ export interface FileParseResult {* Absent for non-PHP files and for PHP files in the global namespace.*/phpNamespaceBlocks?: number;+ /**+ * The tree has ERROR or MISSING nodes: tree-sitter recovered, and whatever+ * sat in the broken region may be missing from `entities`. Absent when the+ * file parsed cleanly.+ */+ hasParseErrors?: true;fileRole: RoleClassification;}@@ -349,6 +357,12 @@ const TYPE_BUILTINS = new Set([// TypeScript / JavaScript'string', 'number', 'boolean', 'void', 'null', 'undefined', 'any', 'never','unknown', 'object', 'bigint', 'symbol',+ // TypeScript utility types, now that generic arguments, arrays and unions+ // are referenced too. Only names no other language uses for its own types:+ // this set is shared, and `Buffer` or `Error` are real types elsewhere.+ 'Record', 'Partial', 'Required', 'Readonly', 'ReadonlyArray', 'Pick', 'Omit',+ 'Exclude', 'Extract', 'NonNullable', 'ReturnType', 'Parameters', 'InstanceType',+ 'Awaited', 'PromiseLike', 'WeakMap', 'WeakSet',// Java / Kotlin / Scala'String', 'Integer', 'Long', 'Double', 'Float', 'Boolean', 'Byte', 'Short','Character', 'Object', 'Void', 'Int', 'Unit', 'Any', 'AnyVal', 'AnyRef',@@ -2538,9 +2552,10 @@ export function parseFile(filePath: string, source: string, opts: ParseFileOptio// (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.+ // so the class body parses correctly. Blanked with spaces, not deleted, so+ // every later byte offset and column still matches the file on disk.let parseSource = language === SupportedLanguages.Java- ? source.replace(/@\w+\s*(?=\.\.\.)/g, '')+ ? source.replace(/@\w+\s*(?=\.\.\.)/g, m => ' '.repeat(m.length)): source;// Rust: unwrap feature-gating macros (cfg_rt! { ... }, cfg_io! { ... }, etc.)@@ -2679,6 +2694,28 @@ export function parseFile(filePath: string, source: string, opts: ParseFileOptio? collectPhpNamespaces(tree.rootNode): { spans: [], blocks: 0 };+ // TypeScript overloads: `function f(a: string): string;` lines above the+ // implementation are signatures of the same function. They become one+ // entity, spanning the implementation -- or the first signature where there+ // is none (`declare function`, a .d.ts) -- not one entity per line, which+ // gave the function node the span of its first signature.+ const overloadKey = (defNode: any, name: string): string => {+ let scope = defNode.parent;+ while (scope && (scope.type === 'export_statement' || scope.type === 'ambient_declaration')) scope = scope.parent;+ return `${scope?.startIndex ?? -1}:${name}`;+ };+ const implementedOverloads = new Set<string>();+ if (language === SupportedLanguages.TypeScript) {+ for (const match of pass1Matches) {+ const def = match.captures.find((c: any) => c.name === 'definition.function')?.node;+ const name = match.captures.find((c: any) => c.name === 'name')?.node.text;+ if (def && name && (def.type === 'function_declaration' || def.type === 'generator_function_declaration')) {+ implementedOverloads.add(overloadKey(def, name));+ }+ }+ }+ const seenSignatures = new Set<string>();+// --- First pass: collect definitions ---for (const match of pass1Matches) {checkBudget();@@ -2712,6 +2749,12 @@ export function parseFile(filePath: string, source: string, opts: ParseFileOptio: rawName;if (!name || name.length === 0) continue;+ if (defCapture.node.type === 'function_signature') {+ const key = overloadKey(defCapture.node, name);+ if (implementedOverloads.has(key) || seenSignatures.has(key)) continue;+ seenSignatures.add(key);+ }+// SAS module entities (DATA/PROC steps, PROC SQL CREATE) need extra// shaping so they reflect real data artifacts rather than parser noise.if (language === SupportedLanguages.SAS && kind === 'module') {@@ -3456,6 +3499,8 @@ export function parseFile(filePath: string, source: string, opts: ParseFileOptio// file. A key that is present-but-undefined still serializes, which would// rewrite every checked-in parseFile snapshot for no behavioural reason....(phpNamespaces.blocks > 0 ? { phpNamespaceBlocks: phpNamespaces.blocks } : {}),+ // Absent unless true, for the same reason.+ ...(tree.rootNode.hasError ? { hasParseErrors: true as const } : {}),fileRole: classifyFileRole(filePath, source),};} catch (e) {@@ -3542,6 +3587,53 @@ function ambiguousPhpTypeNames(entities: ParsedEntity[]): Set<string> {return new Set([...counts].filter(([, count]) => count > 1).map(([name]) => name));}+/**+ * What resolution needs from a file it resolves TO (see `FileSummary`). The+ * same rules `resolveEdges` applies to a batch file, so a file looks the same+ * to resolution whether it is in the batch or only in the index.+ */+export function summarizeParseResult(r: FileParseResult): FileSummary {+ const qkeys: Array<[string, string]> = [];+ for (const e of r.entities) {+ if (e.kind === 'file' || e.kind === 'module') continue;+ qkeys.push([e.name, qualifiedKey(e)]);+ }+ const exportPublicNames = r.exportPublicNames?.map((n): [string, string] => [n.public, n.local]);+ let phpTypes: Array<[string, string]> | undefined;+ if (r.language === SupportedLanguages.PHP) {+ const ambiguous = ambiguousPhpTypeNames(r.entities);+ phpTypes = [];+ for (const e of r.entities) {+ const fqcn = phpTypeFqcn(e);+ if (fqcn && !ambiguous.has(e.name.toLowerCase())) phpTypes.push([fqcn, e.name]);+ }+ }+ const imports: FileSummary['imports'] = [];+ const refs = new Set<string>();+ for (const rel of r.relationships) {+ if (rel.predicate === 'IMPORTS') {+ imports.push({+ dstName: rel.dstName,+ ...(typeof rel.importRaw === 'string' ? { importRaw: rel.importRaw } : {}),+ ...(rel.importVia ? { importVia: rel.importVia } : {}),+ });+ } else if (rel.predicate === 'CALLS' || rel.predicate === 'REFERENCES' || rel.predicate === 'EXTENDS') {+ refs.add(rel.dstName);+ }+ }+ const summary = {+ filePath: r.filePath,+ language: r.language,+ entityCount: r.entities.length,+ qkeys,+ ...(exportPublicNames ? { exportPublicNames } : {}),+ imports,+ ...(phpTypes ? { phpTypes } : {}),+ refs: [...refs].sort(),+ };+ return { ...summary, sig: summarySignature(summary) };+}+/*** Given a file's qualified-key map and a plain callee name, return the single* unambiguous qualified key, or null if the name maps to 0 or >1 entities.@@ -3591,6 +3683,23 @@ export interface GlobalResolutionIndex {goPkgDirToFiles: Map<string, string[]>;goPkgPathToFiles: Map<string, string[]>;phpFqcnToTypes?: Map<string, Array<{ filePath: string; typeName: string }>>;+ /**+ * Per-file summaries, every language, when the caller supplied them. With+ * them `resolveEdges` sees every target file exactly as it would if the file+ * were in the batch, so the batching does not change the result.+ */+ summaries?: Map<string, FileSummary>;+}++/** `name -> qualified keys`, in entity order: what `resolveEdges` and buildPatch key on. */+function qkeyMapOf(summary: FileSummary): Map<string, string[]> {+ const map = new Map<string, string[]>();+ for (const [name, qk] of summary.qkeys) {+ const list = map.get(name) ?? [];+ list.push(qk);+ map.set(name, list);+ }+ return map;}/**@@ -3609,6 +3718,10 @@ export function buildGlobalResolutionIndex(// Absent an entry, each block falls back to parsing here, so callers that do// not have a pool (tests, library use) behave exactly as before.preParsed?: Map<string, FileParseResult>,+ // Summaries of any files, any language (see FileSummary). A summarized file's+ // symbols come from its summary, not from the per-language blocks below,+ // which then only serve callers that have no summaries.+ summaries?: Map<string, FileSummary>,): GlobalResolutionIndex {const stemToFiles = new Map<string, string[]>();const dirToIndexFiles = new Map<string, string[]>();@@ -3617,7 +3730,12 @@ export function buildGlobalResolutionIndex(const goPkgPathToFiles = new Map<string, string[]>();const phpFqcnToTypes = new Map<string, Array<{ filePath: string; typeName: string }>>();- for (const fp of filePaths) {+ // A summarized file is indexed by path too, so `resolveEdges` can rely on+ // the index's path maps holding every file it has a summary for.+ const indexPaths = summaries+ ? [...new Set([...filePaths, ...summaries.keys()])]+ : filePaths;+ for (const fp of indexPaths) {const ext = nodePath.extname(fp);const stem = nodePath.basename(fp, ext);@@ -3815,15 +3933,39 @@ export function buildGlobalResolutionIndex(}}- for (const [fp, symbols] of fileHasSymbol) {- for (const sym of symbols) {- const list = symbolToFiles.get(sym) ?? [];- list.push(fp);- symbolToFiles.set(sym, list);+ }++ if (summaries) {+ for (const [fp, summary] of summaries) {+ const qkMap = qkeyMapOf(summary);+ fileQKeys.set(fp, qkMap);+ fileHasSymbol.set(fp, new Set(qkMap.keys()));+ if (summary.exportPublicNames) filePublicNames.set(fp, new Map(summary.exportPublicNames));+ else filePublicNames.delete(fp);+ }+ // PHP types for summarized files come from their summaries alone.+ for (const [fqcn, entries] of phpFqcnToTypes) {+ phpFqcnToTypes.set(fqcn, entries.filter(entry => !summaries.has(entry.filePath)));+ }+ for (const [fp, summary] of summaries) {+ for (const [fqcn, typeName] of summary.phpTypes ?? []) {+ const entries = phpFqcnToTypes.get(fqcn) ?? [];+ if (!entries.some(entry => entry.filePath === fp && entry.typeName === typeName)) {+ entries.push({ filePath: fp, typeName });+ }+ phpFqcnToTypes.set(fqcn, entries);}}}+ for (const [fp, symbols] of fileHasSymbol) {+ for (const sym of symbols) {+ const list = symbolToFiles.get(sym) ?? [];+ list.push(fp);+ symbolToFiles.set(sym, list);+ }+ }+return {fileHasSymbol,fileQKeys,@@ -3835,6 +3977,7 @@ export function buildGlobalResolutionIndex(goPkgDirToFiles,goPkgPathToFiles,phpFqcnToTypes,+ ...(summaries ? { summaries } : {}),};}@@ -3998,6 +4141,21 @@ export function resolveEdges(globalCandidateTotal: 0, resolvedImport: 0, resolvedTransitive: 0,resolvedGlobal: 0, resolvedQualifier: 0, skippedSameFile: 0, skippedAmbiguous: 0,};+ // Every file this call can resolve TO: the index's summaries with the batch's+ // own laid over them. Everything below that describes a target file -- its+ // symbols, exports, language, imports -- is derived from this and never from+ // `results`, so a batch resolves exactly as the whole repository would+ // (IN-09). `results` is only the set of files whose edges are resolved.+ // Files the index knows only through its older per-language maps (a caller+ // that passed no summaries) keep those entries.+ const batchSummaries = results.map(summarizeParseResult);+ const summaries = new Map<string, FileSummary>(globalIndex?.summaries ?? []);+ for (const s of batchSummaries) summaries.set(s.filePath, s);+ // The index's maps already hold every file it has a summary for (its symbol+ // maps from the summaries, its path maps from paths and summaries alike), so+ // only the batch's own summaries are laid over them below. Redoing the whole+ // index here cost every call O(repository), and the path maps' de-dup made+ // it quadratic in the size of a common stem (`index`, `__init__`).// Renamed-import call resolution (Z): a call to a renamed local binding (`import// { format as fmt }; fmt()`) should resolve as the provider's public symbol// (`format`), so in-repo AND co-ingest resolution link it to the real definition.@@ -4080,11 +4238,10 @@ export function resolveEdges(}}}- for (const r of results) {- const srcRepo = repoOf(r.filePath);+ for (const s of summaries.values()) {+ const srcRepo = repoOf(s.filePath);if (srcRepo === undefined) continue;- for (const rel of r.relationships) {- if (rel.predicate !== 'IMPORTS') continue;+ for (const rel of s.imports) {// Prefer the raw specifier when the parser preserved it: a relative import// (./x, ../x) is intra-repo by construction and can NEVER denote another// repo's package, so packageOf rejects it and it seeds no cross-repo dep.@@ -4156,12 +4313,12 @@ export function resolveEdges(const better = (a: [number, number, string], b: [number, number, string]) =>a[0] !== b[0] ? a[0] < b[0] : a[1] !== b[1] ? a[1] < b[1] : a[2] < b[2];const bestScore = new Map<string, [number, number, string]>();- for (const r of results) {- const repo = repoOf(r.filePath);+ for (const filePath of summaries.keys()) {+ const repo = repoOf(filePath);if (repo === undefined) continue;- const s = entryScore(r.filePath);+ const s = entryScore(filePath);const cur = bestScore.get(repo);- if (!cur || better(s, cur)) { bestScore.set(repo, s); entryFileOf.set(repo, r.filePath); }+ if (!cur || better(s, cur)) { bestScore.set(repo, s); entryFileOf.set(repo, filePath); }}}// fileQKeys: seed from global index (cross-batch files), then batch entries override.@@ -4169,27 +4326,14 @@ export function resolveEdges(const fileQKeys = globalIndex? new Map<string, Map<string, string[]>>(globalIndex.fileQKeys): new Map<string, Map<string, string[]>>();- for (const r of results) {- const qkMap = new Map<string, string[]>();- for (const e of r.entities) {- if (e.kind === 'file' || e.kind === 'module') continue;- const qk = qualifiedKey(e);- const list = qkMap.get(e.name) ?? [];- list.push(qk);- qkMap.set(e.name, list);- }- fileQKeys.set(r.filePath, qkMap); // overrides global entry if present- }+ for (const s of batchSummaries) fileQKeys.set(s.filePath, qkeyMapOf(s)); // overrides the index's own entryconst filePublicNames = globalIndex? new Map<string, Map<string, string>>(globalIndex.filePublicNames ?? []): new Map<string, Map<string, string>>();- for (const r of results) {- if (r.exportPublicNames) {- filePublicNames.set(r.filePath, new Map(r.exportPublicNames.map(name => [name.public, name.local])));- } else {- filePublicNames.delete(r.filePath);- }+ for (const s of batchSummaries) {+ if (s.exportPublicNames) filePublicNames.set(s.filePath, new Map(s.exportPublicNames));+ else filePublicNames.delete(s.filePath);}// fileHasSymbol: rebuilt from merged fileQKeys so per-batch overrides take effect.@@ -4198,27 +4342,23 @@ export function resolveEdges(fileHasSymbol.set(fp, new Set(qkMap.keys()));}+ // Index entries for files that have no summary, then every summarized file's+ // own types, in summary order.const phpFqcnToTypes = new Map<string, Array<{ filePath: string; typeName: string }>>();for (const [fqcn, entries] of globalIndex?.phpFqcnToTypes ?? []) {- phpFqcnToTypes.set(fqcn, [...entries]);+ const unsummarized = entries.filter(entry => !summaries.has(entry.filePath));+ if (unsummarized.length > 0) phpFqcnToTypes.set(fqcn, unsummarized);}- for (const result of results) {- if (result.language !== SupportedLanguages.PHP) continue;- const ambiguousTypes = ambiguousPhpTypeNames(result.entities);- for (const entity of result.entities) {- const fqcn = phpTypeFqcn(entity);- if (!fqcn || ambiguousTypes.has(entity.name.toLowerCase())) continue;+ for (const s of summaries.values()) {+ for (const [fqcn, typeName] of s.phpTypes ?? []) {const entries = phpFqcnToTypes.get(fqcn) ?? [];- if (!entries.some(entry => entry.filePath === result.filePath && entry.typeName === entity.name)) {- entries.push({ filePath: result.filePath, typeName: entity.name });+ if (!entries.some(entry => entry.filePath === s.filePath && entry.typeName === typeName)) {+ entries.push({ filePath: s.filePath, typeName });}phpFqcnToTypes.set(fqcn, entries);}}- // resultsByPath: O(1) lookup replacing results.find() in transitive import loop- const resultsByPath = new Map<string, FileParseResult>(results.map(r => [r.filePath, r]));-// symbolToFiles: rebuilt from merged fileHasSymbol (not seeded directly — per-batch// overrides can change which files define a symbol).const symbolToFiles = new Map<string, string[]>();@@ -4232,33 +4372,45 @@ export function resolveEdges(// 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);+ for (const s of summaries.values()) fileLanguage.set(s.filePath, s.language);++ // "A.b" -> files whose qualified keys include it. The qualifier fallback+ // asked every file in the batch per dotted call; this answers it once.+ const qualifiedToFiles = new Map<string, string[]>();+ for (const [fp, qkMap] of fileQKeys) {+ for (const keys of qkMap.values()) {+ for (const qk of new Set(keys)) {+ const list = qualifiedToFiles.get(qk) ?? [];+ list.push(fp);+ qualifiedToFiles.set(qk, list);+ }+ }}+ // Add `fp` under `key` without touching the index's own array: the maps are+ // shallow copies, and pushing into a shared list leaked one batch's files+ // into the index every later batch resolves against.+ const addPath = (map: Map<string, string[]>, key: string, fp: string): void => {+ const list = map.get(key);+ if (!list) map.set(key, [fp]);+ else if (!list.includes(fp)) map.set(key, [...list, fp]);+ };+// stemToFiles: seed from global index, then add batch entries.const stemToFiles = globalIndex? new Map<string, string[]>(globalIndex.stemToFiles): new Map<string, string[]>();- for (const r of results) {- const stem = nodePath.basename(r.filePath, nodePath.extname(r.filePath));- const list = stemToFiles.get(stem) ?? [];- if (!list.includes(r.filePath)) list.push(r.filePath);- stemToFiles.set(stem, list);+ for (const r of batchSummaries) {+ addPath(stemToFiles, nodePath.basename(r.filePath, nodePath.extname(r.filePath)), r.filePath);}// dirToIndexFiles: seed from global index, then add batch entries.const dirToIndexFiles = globalIndex? new Map<string, string[]>(globalIndex.dirToIndexFiles): new Map<string, string[]>();- for (const r of results) {+ for (const r of batchSummaries) {const stem = nodePath.basename(r.filePath, nodePath.extname(r.filePath));- if (stem === 'index') {- const dirName = nodePath.basename(nodePath.dirname(r.filePath));- const list = dirToIndexFiles.get(dirName) ?? [];- if (!list.includes(r.filePath)) list.push(r.filePath);- dirToIndexFiles.set(dirName, list);- }+ if (stem === 'index') addPath(dirToIndexFiles, nodePath.basename(nodePath.dirname(r.filePath)), r.filePath);}// Relative imports must be resolved against the importing file's directory.@@ -4287,17 +4439,14 @@ export function resolveEdges(const packageToFiles = globalIndex? new Map<string, string[]>(globalIndex.packageToFiles): new Map<string, string[]>();- for (const r of results) {+ for (const r of batchSummaries) {const ext = nodePath.extname(r.filePath);if (ext !== '.scala' && ext !== '.java') continue;const dir = nodePath.dirname(r.filePath);const parts = dir.split(/[/\\]/);const maxDepth = Math.min(8, parts.length);for (let i = parts.length - 1; i >= parts.length - maxDepth; i--) {- const pkg = parts.slice(i).join('.');- const list = packageToFiles.get(pkg) ?? [];- if (!list.includes(r.filePath)) list.push(r.filePath);- packageToFiles.set(pkg, list);+ addPath(packageToFiles, parts.slice(i).join('.'), r.filePath);}}@@ -4308,19 +4457,13 @@ export function resolveEdges(const goPkgPathToFiles = globalIndex? new Map<string, string[]>(globalIndex.goPkgPathToFiles): new Map<string, string[]>();- for (const r of results) {+ for (const r of batchSummaries) {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);+ addPath(goPkgDirToFiles, nodePath.basename(nodePath.dirname(r.filePath)), r.filePath);const parts = nodePath.dirname(r.filePath).replace(/\\/g, '/').split('/').filter(Boolean);const maxDepth = Math.min(8, parts.length);for (let i = parts.length - 1; i >= parts.length - maxDepth; i--) {- const pkgPath = parts.slice(i).join('/');- const pkgList = goPkgPathToFiles.get(pkgPath) ?? [];- if (!pkgList.includes(r.filePath)) pkgList.push(r.filePath);- goPkgPathToFiles.set(pkgPath, pkgList);+ addPath(goPkgPathToFiles, parts.slice(i).join('/'), r.filePath);}}@@ -4408,18 +4551,18 @@ export function resolveEdges(if (exactStemMatch.length === 1) return exactStemMatch[0];const ranked = [...pool].sort((a, b) => {- const aResult = resultsByPath.get(a);- const bResult = resultsByPath.get(b);- const aImports = aResult?.relationships.filter(rel => rel.predicate === 'IMPORTS').length ?? 0;- const bImports = bResult?.relationships.filter(rel => rel.predicate === 'IMPORTS').length ?? 0;+ const aSummary = summaries.get(a);+ const bSummary = summaries.get(b);+ const aImports = aSummary?.imports.length ?? 0;+ const bImports = bSummary?.imports.length ?? 0;if (aImports !== bImports) return bImports - aImports;- // Fall back to global index entity count for cross-batch files (not in resultsByPath).- // fileQKeys is seeded from buildGlobalResolutionIndex which pre-scans exported- // types/functions via regex, so substantive files like instance.go score higher- // than package-doc stubs like doc.go (which only has the package name).- const aEntities = aResult?.entities.length ?? fileQKeys.get(a)?.size ?? 0;- const bEntities = bResult?.entities.length ?? fileQKeys.get(b)?.size ?? 0;+ // Fall back to the index's symbol count for a file with no summary.+ // fileQKeys is seeded from buildGlobalResolutionIndex, so substantive+ // files like instance.go score higher than package-doc stubs like doc.go+ // (which only has the package name).+ const aEntities = aSummary?.entityCount ?? fileQKeys.get(a)?.size ?? 0;+ const bEntities = bSummary?.entityCount ?? fileQKeys.get(b)?.size ?? 0;if (aEntities !== bEntities) return bEntities - aEntities;return a.localeCompare(b);@@ -4749,6 +4892,20 @@ export function resolveEdges(// ── Main resolution loop ───────────────────────────────────────────+ /**+ * The files of `pool` that define `name`, in `pool` order -- what a loop over+ * the pool asking `fileHasSymbol` returns, but walking whichever side is+ * smaller. A source file's import set grows with the repository (a common+ * stem matches more files), and walking it once per call made resolution+ * quadratic.+ */+ function definersIn(pool: Set<string>, order: Map<string, number>, name: string): string[] {+ const definers = symbolToFiles.get(name);+ if (!definers) return [];+ if (definers.length >= pool.size) return [...pool].filter(fp => fileHasSymbol.get(fp)?.has(name));+ return definers.filter(fp => pool.has(fp)).sort((a, b) => order.get(a)! - order.get(b)!);+ }+function fileDefinesQualifiedMember(filePath: string, qualifierPart: string, memberPart: string): boolean {const qks = fileQKeys.get(filePath)?.get(memberPart) ?? [];return qks.includes(`${qualifierPart}.${memberPart}`);@@ -4818,15 +4975,19 @@ export function resolveEdges(// Handles re-exports: baz.ts → index.ts (re-exports from bar.ts) → bar.tsconst transitiveFilePaths = new Set<string>();for (const fp of importedFilePaths) {- const fpResult = resultsByPath.get(fp);- if (!fpResult) continue;- for (const rel of fpResult.relationships) {- if (rel.predicate !== 'IMPORTS' || rel.importVia === 'helper') continue;- for (const transitiveFp of resolveImportTargets(fp, fpResult.language, rel.dstName, rel.importRaw)) {+ const fpSummary = summaries.get(fp);+ if (!fpSummary) continue;+ for (const rel of fpSummary.imports) {+ if (rel.importVia === 'helper') continue;+ for (const transitiveFp of resolveImportTargets(fp, fpSummary.language, rel.dstName, rel.importRaw)) {if (!importedFilePaths.has(transitiveFp)) transitiveFilePaths.add(transitiveFp);}}}+ // Position of each file in the two sets, so `definersIn` can return its+ // matches in set order without walking the whole set per relationship.+ const importedOrder = new Map([...importedFilePaths].map((fp, i) => [fp, i]));+ const transitiveOrder = new Map([...transitiveFilePaths].map((fp, i) => [fp, i]));for (const rel of result.relationships) {if (rel.predicate !== 'CALLS' && rel.predicate !== 'EXTENDS' && rel.predicate !== 'REFERENCES' && rel.predicate !== 'IMPORTS') continue;@@ -5116,7 +5277,7 @@ export function resolveEdges(if (memberPart && qualifierPart) {const elixirAliasedModule = srcLanguage === SupportedLanguages.Elixir ? result.importAliases?.[qualifierPart]: undefined;const aliasedImportMatches = srcLanguage === SupportedLanguages.Go ? resolveImportQualifierTargets(srcFilePath, srcLanguage, result.importAliases?.[qualifierPart] ?? '')- : elixirAliasedModule ? results.map(r => r.filePath).filter(fp => fp !== srcFilePath && fileHasSymbol.get(fp)?.has(elixirAliasedModule))+ : elixirAliasedModule ? (symbolToFiles.get(elixirAliasedModule) ?? []).filter(fp => fp !== srcFilePath): [];// Try import-scoped qualifier firstconst qualifierSearchPool = aliasedImportMatches.length > 0@@ -5155,11 +5316,11 @@ export function resolveEdges(stats.skippedAmbiguous++;continue;}- const qualGlobalMatches = results- .map(r => r.filePath)+ // Every file that defines `qualifier.member` -- the whole index, not+ // just this batch (a lookup, where it was a scan per call).+ const qualGlobalMatches = (qualifiedToFiles.get(`${qualifierPart}.${memberPart}`) ?? []).filter(fp => fp !== srcFilePath- && importLanguageCompatible(srcLanguage, fileLanguage.get(fp) ?? languageFromPath(fp))- && fileDefinesQualifiedMember(fp, qualifierPart, memberPart));+ && importLanguageCompatible(srcLanguage, fileLanguage.get(fp) ?? languageFromPath(fp)));if (qualGlobalMatches.length === 1) {const qfp = qualGlobalMatches[0];if (fileHasSymbol.get(qfp)?.has(memberPart)) {@@ -5174,10 +5335,7 @@ export function resolveEdges(}// Tier 2: import-scoped (confidence 0.9)- const importMatches: string[] = [];- for (const fp of importedFilePaths) {- if (fileHasSymbol.get(fp)?.has(dstName) && reachable(fp)) importMatches.push(fp);- }+ const importMatches = definersIn(importedFilePaths, importedOrder, dstName).filter(reachable);const narrowedImportMatches = narrowByRepoDeps(narrowCCandidates(importMatches, srcFilePath, srcLanguage, srcName, dstName), srcFilePath);if (narrowedImportMatches.length === 1) {@@ -5202,10 +5360,7 @@ export function resolveEdges(continue;}// 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) && reachable(fp)) transitiveMatches.push(fp);- }+ const transitiveMatches = definersIn(transitiveFilePaths, transitiveOrder, dstName).filter(reachable);const narrowedTransitiveMatches = narrowByRepoDeps(narrowCCandidates(transitiveMatches, srcFilePath, srcLanguage, srcName, dstName), srcFilePath);if (narrowedTransitiveMatches.length === 1) {diff --git a/core-ingestion/src/patch-builder.ts b/core-ingestion/src/patch-builder.tsindex 204ee0de..5985209a 100644--- a/core-ingestion/src/patch-builder.ts+++ b/core-ingestion/src/patch-builder.ts@@ -136,7 +136,10 @@ function deduplicateUpsertEdges(ops: PatchOp[]): PatchOp[] {* 1.27: Python, Rust and PHP bare calls no longer resolve to another file's* class member. 1.28: no edge is written without a node at both ends (calls* that resolve nowhere go on their caller as `unresolved_calls`), and- * cross-file edges carry `confidence` and `tier`.+ * cross-file edges carry `confidence` and `tier`. 1.29: cross-file resolution+ * no longer depends on how files are split into batches, TypeScript gaps+ * (overload signatures, generic type references) are extracted, and files+ * carry `parse_errors` and their role.** `ix map` skips files whose mtime or source hash is unchanged, which would* keep the old extractor's edges on them, so the ingest baseline records this@@ -154,11 +157,11 @@ export function patchActor(): string {}export function extractorName(): string {- return `tree-sitter/1.28`;+ return `tree-sitter/1.29`;}/** Previous extractor versions — their patches are superseded when re-ingesting. */-export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.27', 'tree-sitter/1.26', 'tree-sitter/1.25', 'tree-sitter/1.24', 'tree-sitter/1.23', 'tree-sitter/1.22', 'tree-sitter/1.21', 'tree-sitter/1.20', 'tree-sitter/1.19', 'tree-sitter/1.18', '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'];+export const PREVIOUS_EXTRACTORS = ['tree-sitter/1.28', 'tree-sitter/1.27', 'tree-sitter/1.26', 'tree-sitter/1.25', 'tree-sitter/1.24', 'tree-sitter/1.23', 'tree-sitter/1.22', 'tree-sitter/1.21', 'tree-sitter/1.20', 'tree-sitter/1.19', 'tree-sitter/1.18', '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'];/** Patch ids that may own the active graph entities for a stored source hash. */export function sourcePatchIdCandidates(@@ -317,7 +320,7 @@ export function buildPatch(if (!seenNodeIds.has(id)) {seenNodeIds.add(id);const roleAttrs = e.kind === 'file'- ? { role: result.fileRole.role, role_confidence: result.fileRole.role_confidence, role_signals: result.fileRole.role_signals }+ ? { role: result.fileRole.role, role_confidence: result.fileRole.role_confidence, role_signals: result.fileRole.role_signals, ...(result.hasParseErrors ? { parse_errors: true } : {}) }: { role: result.fileRole.role, role_source: 'inherited_from_file' };ops.push({type: 'UpsertNode',@@ -565,6 +568,13 @@ export function buildPatchWithResolution(resolvedEdges: ResolvedEdge[],previousSourceHash?: string,multiRepo?: MultiRepoContext,+ /**+ * Set when an unchanged file is re-sent because what its edges resolve to+ * changed elsewhere (IN-11): a hash of its new resolution. The patch id must+ * differ from the one its unchanged bytes already have, or the backend+ * answers `Idempotent` and keeps the old edges.+ */+ resolutionSalt?: string,): GraphPatchPayload {// Build lookup: `${srcName}:${predicate}:${dstName}` → { dstFilePath, dstQualifiedKey }// Callers should pass only edges for this file (pre-grouped) for best performance,@@ -647,7 +657,7 @@ export function buildPatchWithResolution(if (!seenNodeIds2.has(id)) {seenNodeIds2.add(id);const roleAttrs = e.kind === 'file'- ? { role: result.fileRole.role, role_confidence: result.fileRole.role_confidence, role_signals: result.fileRole.role_signals }+ ? { role: result.fileRole.role, role_confidence: result.fileRole.role_confidence, role_signals: result.fileRole.role_signals, ...(result.hasParseErrors ? { parse_errors: true } : {}) }: { role: result.fileRole.role, role_source: 'inherited_from_file' };ops.push({type: 'UpsertNode',@@ -899,7 +909,7 @@ export function buildPatchWithResolution(}const extractor = extractorName();- const patchId = computePatchId(filePath, sourceHash, extractor);+ const patchId = computePatchId(filePath, sourceHash, resolutionSalt ? `${extractor}#r${resolutionSalt}` : extractor);const previousPatchId = previousSourceHash? computePatchId(filePath, previousSourceHash, extractor): legacyPatchId(filePath, sourceHash);diff --git a/core-ingestion/src/queries.ts b/core-ingestion/src/queries.tsindex 2cb64836..9534d57a 100644--- a/core-ingestion/src/queries.ts+++ b/core-ingestion/src/queries.ts@@ -15,9 +15,35 @@ export const TYPESCRIPT_QUERIES = `(class_declarationname: (type_identifier) @name) @definition.class+(abstract_class_declaration+ name: (type_identifier) @name) @definition.class+(interface_declarationname: (type_identifier) @name) @definition.interface+; Type aliases and enums are often a TypeScript codebase's central vocabulary.+(type_alias_declaration+ name: (type_identifier) @name) @definition.type++(enum_declaration+ name: (identifier) @name) @definition.enum++; namespace NS { ... }+(internal_module+ name: (identifier) @name) @definition.namespace++(abstract_method_signature+ name: (property_identifier) @name) @definition.method++; A class field holding a function is a method in all but syntax: draw = () => ...+(public_field_definition+ name: (property_identifier) @name+ value: [(arrow_function) (function_expression)]) @definition.method++; Overload signatures: \`function f(a: string): string;\` above the implementation.+(function_signature+ name: (identifier) @name) @definition.function+(function_declarationname: (identifier) @name) @definition.function@@ -106,12 +132,24 @@ export const TYPESCRIPT_QUERIES = `(new_expressionconstructor: (identifier) @call.name) @call-; Heritage queries - class extends+; Heritage queries - class extends, plain or abstract, a bare name or ns.Base(class_declarationname: (type_identifier) @heritage.class(class_heritage(extends_clause- value: (identifier) @heritage.extends))) @heritage+ value: [(identifier) (member_expression)] @heritage.extends))) @heritage++(abstract_class_declaration+ name: (type_identifier) @heritage.class+ (class_heritage+ (extends_clause+ value: [(identifier) (member_expression)] @heritage.extends))) @heritage++(abstract_class_declaration+ name: (type_identifier) @heritage.class+ (class_heritage+ (implements_clause+ (type_identifier) @heritage.implements))) @heritage.impl; Heritage queries - class implements interface(class_declaration@@ -126,8 +164,18 @@ export const TYPESCRIPT_QUERIES = `(extends_type_clause(type_identifier) @heritage.extends)) @heritage-; Type references — captures types used in annotations/parameters/return types+; Type references — captures types used in annotations/parameters/return types,+; and inside the type forms they compose: Promise<Foo>, Foo[], Foo | null,+; Foo & Bar, \`x as Foo\`, \`extends Base<Foo>\`, \`type T = Foo\`. Duplicates+; per enclosing definition are dropped in index.ts.(type_annotation (type_identifier) @reference.type)+(generic_type name: (type_identifier) @reference.type)+(type_arguments (type_identifier) @reference.type)+(array_type (type_identifier) @reference.type)+(union_type (type_identifier) @reference.type)+(intersection_type (type_identifier) @reference.type)+(as_expression (type_identifier) @reference.type)+(type_alias_declaration value: (type_identifier) @reference.type)`;// JavaScript queries - works with tree-sitter-javascriptdiff --git a/core-ingestion/src/role-classifier.ts b/core-ingestion/src/role-classifier.tsindex ceac4028..65333297 100644--- a/core-ingestion/src/role-classifier.ts+++ b/core-ingestion/src/role-classifier.ts@@ -29,11 +29,19 @@ const TEST_FILE_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [{ pattern: /\.test\.[^.]+$/i, signal: 'filename:.test.' },{ pattern: /\.spec\.[^.]+$/i, signal: 'filename:.spec.' },{ pattern: /Tests?\.[^.]+$/, signal: 'filename:Test(s).' }, // matches Test.cs and Tests.cs- { pattern: /Spec\.[^.]+$/, signal: 'filename:Spec.' },+ // FooSpec is a test only where the test frameworks name them so (ScalaTest,+ // Spock, Kotest). Elsewhere `PodSpec.go` and `OpenApiSpec.ts` are code.+ { pattern: /Spec\.(?:scala|groovy|kt|kts)$/, signal: 'filename:Spec.' },{ pattern: /_test\.[^.]+$/i, signal: 'filename:_test.' },{ pattern: /_spec\.[^.]+$/i, signal: 'filename:_spec.' },+ // pytest's conventions+ { pattern: /^test_[^/\\]*\.py$/, signal: 'filename:test_*.py' },+ { pattern: /^conftest\.py$/, signal: 'filename:conftest.py' },];+/** Data and docs: a `spec/` directory holding these is an API spec, not tests. */+const DATA_FILE = /\.(?:ya?ml|json|toml|md|txt|xml|proto|graphql)$/i;+const TEST_IMPORT_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [{ pattern: /from ['"](?:jest|vitest|mocha|chai|sinon|jasmine|@testing-library)/, signal: 'import:js_test_framework' },{ pattern: /require\(['"](?:jest|vitest|mocha|chai|sinon|jasmine)['"]\)/, signal: 'import:js_test_framework_require' },@@ -46,7 +54,8 @@ const TEST_IMPORT_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [{ pattern: /import\s+org\.scalatest/, signal: 'import:scalatest' },{ pattern: /import\s+munit/, signal: 'import:munit' },{ pattern: /import\s+zio\.test/, signal: 'import:zio_test' },- { pattern: /"testing"/, signal: 'import:go_testing' },+ // Go's "testing" is checked separately, and only for .go files: the string+ // alone matched `=== "testing"` in any language.{ pattern: /require\s+['"]rspec['"]/, signal: 'import:rspec' },{ pattern: /require\s+['"]minitest['"]/, signal: 'import:minitest' },// C#/.NET test frameworks@@ -62,13 +71,17 @@ const FIXTURE_PATH_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [{ pattern: /[/\\]testdata[/\\]/i, signal: 'path:testdata/' },];+// Whole words only -- separated by `.`, `_`, `-` or the ends of the name, or+// a CamelCase prefix for test doubles (`FakeClock.java`). As substrings they+// caught `resample.py`, `SampleRate.java` and `seed.ts`, and a fixture's+// symbols are hidden by default. `seed` is gone: a seed script is code.const FIXTURE_FILE_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [- { pattern: /fixture/i, signal: 'filename:fixture' },+ { pattern: /(?:^|[._-])fixtures?(?:[._-]|$)/i, signal: 'filename:fixture' },{ pattern: /\.mock\.[^.]+$/i, signal: 'filename:.mock.' },- { pattern: /stub/i, signal: 'filename:stub' },- { pattern: /fake/i, signal: 'filename:fake' },- { pattern: /sample/i, signal: 'filename:sample' },- { pattern: /seed/i, signal: 'filename:seed' },+ // No `i` flag: it would let `^Stub[A-Z]` match "Stubborn".+ { pattern: /(?:^|[._-])(?:stubs?|Stubs?|STUBS?)(?:[._-]|$)|^Stub[A-Z]/, signal: 'filename:stub' },+ { pattern: /(?:^|[._-])(?:fakes?|Fakes?|FAKES?)(?:[._-]|$)|^Fake[A-Z]/, signal: 'filename:fake' },+ { pattern: /(?:^|[._-])samples?(?:[._-]|$)/i, signal: 'filename:sample' },];const GENERATED_PATH_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [@@ -124,76 +137,77 @@ const TOOLING_FILE_PATTERNS: Array<{ pattern: RegExp; signal: string }> = [// Main classifier// ---------------------------------------------------------------------------+/** A Go file that imports the standard `testing` package. */+const GO_TESTING_IMPORT = /^import\s*(?:\([^)]*"testing"|"testing")/m;+export function classifyFileRole(filePath: string, source?: string): RoleClassification {- const normalizedPath = filePath.replace(/\\/g, '/');+ // Always with a leading `/`: the directory patterns need a separator before+ // the name, and the CLI passes workspace-relative paths, so a root-level+ // `tests/`, `vendor/` or `scripts/` never matched.+ const normalizedPath = `/${filePath.replace(/\\/g, '/').replace(/^\/+/, '')}`;const fileName = nodePath.basename(filePath);- const signals: string[] = [];+ const isDataFile = DATA_FILE.test(fileName);++ /** First matching pattern of `table` against `subject`, adding `weight` to `bucket`. */+ const buckets = new Map<EntityRole, { score: number; signals: string[] }>();+ const add = (+ bucket: EntityRole,+ table: Array<{ pattern: RegExp; signal: string }>,+ subject: string,+ weight: number,+ skip?: (signal: string) => boolean,+ ): void => {+ for (const { pattern, signal } of table) {+ if (skip?.(signal) || !pattern.test(subject)) continue;+ const b = buckets.get(bucket) ?? { score: 0, signals: [] };+ b.score += weight;+ b.signals.push(signal);+ buckets.set(bucket, b);+ return;+ }+ };// --- Test ---- let testScore = 0;- for (const { pattern, signal } of TEST_PATH_PATTERNS) {- if (pattern.test(normalizedPath)) { testScore += 0.8; signals.push(signal); break; }- }- for (const { pattern, signal } of TEST_FILE_PATTERNS) {- if (pattern.test(fileName)) { testScore += 0.9; signals.push(signal); break; }- }+ add('test', TEST_PATH_PATTERNS, normalizedPath, 0.8, signal => signal === 'path:spec/' && isDataFile);+ add('test', TEST_FILE_PATTERNS, fileName, 0.9);if (source) {- for (const { pattern, signal } of TEST_IMPORT_PATTERNS) {- if (pattern.test(source)) { testScore += 0.5; signals.push(signal); break; }- }+ const imports = fileName.endsWith('.go')+ ? [...TEST_IMPORT_PATTERNS, { pattern: GO_TESTING_IMPORT, signal: 'import:go_testing' }]+ : TEST_IMPORT_PATTERNS;+ add('test', imports, source, 0.5);}// --- Fixture ---- let fixtureScore = 0;- for (const { pattern, signal } of FIXTURE_PATH_PATTERNS) {- if (pattern.test(normalizedPath)) { fixtureScore += 0.8; signals.push(signal); break; }- }- for (const { pattern, signal } of FIXTURE_FILE_PATTERNS) {- if (pattern.test(fileName)) { fixtureScore += 0.6; signals.push(signal); break; }- }+ add('fixture', FIXTURE_PATH_PATTERNS, normalizedPath, 0.8);+ add('fixture', FIXTURE_FILE_PATTERNS, fileName, 0.6);// --- Generated ---- let generatedScore = 0;- for (const { pattern, signal } of GENERATED_PATH_PATTERNS) {- if (pattern.test(normalizedPath)) { generatedScore += 0.7; signals.push(signal); break; }- }- if (source) {- for (const { pattern, signal } of GENERATED_SOURCE_PATTERNS) {- if (pattern.test(source)) { generatedScore += 0.9; signals.push(signal); break; }- }- }+ add('generated', GENERATED_PATH_PATTERNS, normalizedPath, 0.7);+ if (source) add('generated', GENERATED_SOURCE_PATTERNS, source, 0.9);// --- External ---- let externalScore = 0;- for (const { pattern, signal } of EXTERNAL_PATH_PATTERNS) {- if (pattern.test(normalizedPath)) { externalScore += 0.9; signals.push(signal); break; }- }+ add('external', EXTERNAL_PATH_PATTERNS, normalizedPath, 0.9);// --- Tooling ---- let toolingScore = 0;- for (const { pattern, signal } of TOOLING_PATH_PATTERNS) {- if (pattern.test(normalizedPath)) { toolingScore += 0.6; signals.push(signal); break; }- }- for (const { pattern, signal } of TOOLING_FILE_PATTERNS) {- if (pattern.test(fileName)) { toolingScore += 0.7; signals.push(signal); break; }- }+ add('tooling', TOOLING_PATH_PATTERNS, normalizedPath, 0.6);+ add('tooling', TOOLING_FILE_PATTERNS, fileName, 0.7);// --- Pick winner ---- const scores: Array<[EntityRole, number]> = [- ['test', testScore],- ['fixture', fixtureScore],- ['generated', generatedScore],- ['external', externalScore],- ['tooling', toolingScore],- ];- scores.sort((a, b) => b[1] - a[1]);- const [topRole, topScore] = scores[0];-- if (topScore >= 0.5) {+ // On a tie the more specific bucket wins: `test/fixtures/x.json` is a+ // fixture, though both directories now match from the root.+ const order: EntityRole[] = ['fixture', 'test', 'generated', 'external', 'tooling'];+ let top: { role: EntityRole; score: number; signals: string[] } | undefined;+ for (const role of order) {+ const b = buckets.get(role);+ if (b && (!top || b.score > top.score)) top = { role, ...b };+ }++ if (top && top.score >= 0.5) {return {- role: topRole,- role_confidence: parseFloat(Math.min(topScore, 1.0).toFixed(2)),- role_signals: signals,+ role: top.role,+ role_confidence: parseFloat(Math.min(top.score, 1.0).toFixed(2)),+ // The winner's reasons only; another bucket's signals explain nothing.+ role_signals: top.signals,};}diff --git a/core-ingestion/src/symbol-index.ts b/core-ingestion/src/symbol-index.tsnew file mode 100644index 00000000..80988335--- /dev/null+++ b/core-ingestion/src/symbol-index.ts@@ -0,0 +1,45 @@+// Copyright 2026 Ix Infrastructure Inc.++import * as crypto from 'node:crypto';++import type { SupportedLanguages } from './languages.js';++/**+ * Everything `resolveEdges` needs to know about a file when it is the TARGET+ * of a resolution rather than the file being resolved: what it defines, what+ * it exports, what it imports. Small enough to keep for a whole repository, so+ * a batch of changed files can be resolved against all the others without+ * parsing them (IN-09), and later persisted beside the ingest baseline (IN-10).+ *+ * Built by `summarizeParseResult` in `index.ts`. A batch file's summary and the+ * one in the index for the same content are identical, which is what makes+ * resolution independent of how the files are batched.+ */+export interface FileSummary {+ filePath: string;+ language: SupportedLanguages;+ /** Entities, file node included -- only the count is used (Go package anchors). */+ entityCount: number;+ /** `[name, qualifiedKey]` per entity other than the file and module nodes, in source order. */+ qkeys: Array<[string, string]>;+ /** `[public, local]` export names (JS/TS), when the file has any. */+ exportPublicNames?: Array<[string, string]>;+ /** The file's IMPORTS relationships, as the import resolver reads them. */+ imports: Array<{ dstName: string; importRaw?: string; importVia?: string }>;+ /** `[fqcn, typeName]` for unambiguous PHP types. */+ phpTypes?: Array<[string, string]>;+ /** Sorted unique names this file calls, references or extends (for IN-11). */+ refs: string[];+ /** Hash of what other files can resolve to here: qualified keys, exports, PHP types. */+ sig: string;+}++/** The part of a summary other files depend on, hashed. */+export function summarySignature(s: Pick<FileSummary, 'qkeys' | 'exportPublicNames' | 'phpTypes'>): string {+ const canonical = JSON.stringify([+ [...s.qkeys].map(([n, q]) => `${n}\0${q}`).sort(),+ [...(s.exportPublicNames ?? [])].map(([p, l]) => `${p}\0${l}`).sort(),+ [...(s.phpTypes ?? [])].map(([f, t]) => `${f}\0${t}`).sort(),+ ]);+ return crypto.createHash('sha256').update(canonical).digest('hex').slice(0, 32);+}diff --git a/ix-cli/src/cli/__tests__/ingest-dependents.test.ts b/ix-cli/src/cli/__tests__/ingest-dependents.test.tsnew file mode 100644index 00000000..47b0c92a--- /dev/null+++ b/ix-cli/src/cli/__tests__/ingest-dependents.test.ts@@ -0,0 +1,165 @@+// Copyright 2026 Ix Infrastructure Inc.++import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { execFileSync } from "node:child_process";++import { ingestFiles } from "../commands/ingest.js";+import { FakeBackend } from "./helpers/fake-backend.js";++// Two parse workers, as in ingest-equivalence.test.ts.+vi.mock("node:os", async (importOriginal) => {+ const actual = await importOriginal<typeof import("node:os")>();+ return { ...actual, cpus: () => actual.cpus().slice(0, 3) };+});++/**+ * IN-11 cases the edit fixture cannot express: a file's exported names stay+ * the same but what they bind to changes -- an export alias pointed at another+ * local, a re-export moved to another module. The callers did not change, so+ * only the dependents pass can re-bind them.+ *+ * Each step writes files (null deletes) and runs an incremental map against+ * one fake backend; the CALLS edges left live must equal a fresh map's.+ */+type Files = Record<string, string | null>;+/** Files to write, and patch-source substrings the backend refuses during this map. */+type Step = Files | { files: Files; poison: string[] };++const ENV_KEYS = ["HOME", "USERPROFILE", "IX_ENDPOINT", "IX_LOCK_DIR", "IX_HOME", "IX_DEBUG"] as const;++async function liveVsFresh(steps: Step[], predicate: string): Promise<{ live: string[]; fresh: string[] }> {+ const root = realpathSync.native(mkdtempSync(join(tmpdir(), "ix-deps-")));+ const repo = join(root, "repo");+ mkdirSync(repo);+ execFileSync("git", ["init", "-q"], { cwd: repo, stdio: "ignore" });+ const backends: FakeBackend[] = [];+ let homes = 0;+ const start = async (): Promise<[FakeBackend, string, string]> => {+ const backend = new FakeBackend({ semantics: "head" });+ backends.push(backend);+ const home = join(root, `home${++homes}`);+ mkdirSync(home);+ return [backend, home, await backend.start()];+ };+ const map = (home: string, endpoint: string) => {+ process.env.HOME = home;+ process.env.USERPROFILE = home;+ process.env.IX_ENDPOINT = endpoint;+ process.env.IX_LOCK_DIR = join(home, "locks");+ return ingestFiles(repo, { recursive: true, format: "json", printSummary: false, suppressOutput: true, mapMode: true });+ };+ const edges = (backend: FakeBackend): string[] =>+ backend.graphSignature().edges+ .filter((line) => line.endsWith(` ${predicate}`))+ .map((line) => {+ const [, src, dst] = line.split(" ");+ // The target's id too: `x.foo` and `y.foo` share a name.+ return `${backend.nodeName(src!)} -> ${backend.nodeName(dst!)} ${dst}`;+ })+ .sort();+ try {+ const [backend, home, endpoint] = await start();+ for (const step of steps) {+ const files = "files" in step && typeof step.files === "object" ? (step.files as Files) : (step as Files);+ backend.poison = "poison" in step && Array.isArray(step.poison) ? step.poison : [];+ for (const [p, text] of Object.entries(files)) {+ const abs = join(repo, p);+ if (text === null) rmSync(abs);+ else {+ mkdirSync(dirname(abs), { recursive: true });+ writeFileSync(abs, text, "utf8");+ }+ }+ execFileSync("git", ["add", "-A"], { cwd: repo, stdio: "ignore" });+ await map(home, endpoint);+ }+ backend.poison = [];+ const [freshBackend, freshHome, freshEndpoint] = await start();+ await map(freshHome, freshEndpoint);+ return { live: edges(backend), fresh: edges(freshBackend) };+ } finally {+ for (const b of backends) await b.stop();+ rmSync(root, { recursive: true, force: true });+ }+}++describe("dependents re-bind when a name's target changes (IN-11)", () => {+ vi.setConfig({ testTimeout: 120_000 });+ const saved: Record<string, string | undefined> = {};+ beforeAll(() => {+ for (const k of ENV_KEYS) {+ saved[k] = process.env[k];+ delete process.env[k];+ }+ });+ afterAll(() => {+ for (const [k, v] of Object.entries(saved)) {+ if (v === undefined) delete process.env[k];+ else process.env[k] = v;+ }+ });++ const caller = "import { foo } from './barrel';\nexport function go(): number { return foo(); }\n";++ it("an export alias pointed at another local re-binds its callers", async () => {+ const barrel = (local: string) =>+ `function a(): number { return 1; }\nfunction b(): number { return 2; }\nexport { ${local} as foo };\n`;+ const { live, fresh } = await liveVsFresh(+ [{ "web/barrel.ts": barrel("a"), "web/caller.ts": caller }, { "web/barrel.ts": barrel("b") }],+ "CALLS",+ );+ expect(fresh.map((e) => e.split(" ").slice(0, 3).join(" "))).toEqual(["go[function] -> b[function]"]);+ expect(live).toEqual(fresh);+ });++ it("a re-export moved to another module re-binds its callers", async () => {+ // CALLS only: the barrel's own retired IMPORTS edge is IN-04's (#808).+ const { live, fresh } = await liveVsFresh(+ [+ {+ "web/x.ts": "export function foo(): number { return 1; }\n",+ "web/y.ts": "export function foo(): number { return 2; }\n",+ "web/barrel.ts": "export { foo } from './x';\n",+ "web/caller.ts": caller,+ },+ { "web/barrel.ts": "export { foo } from './y';\n" },+ ],+ "CALLS",+ );+ expect(live).toEqual(fresh);+ });++ // A run that fails to send what it found leaves it for the next run: the+ // renamed file itself, or a caller it re-resolved.+ const math = (name: string) => `export function ${name}(): number { return 1; }\n`;+ const callsFoo = "import { foo } from './math';\nexport function go(): number { return foo(); }\n";++ it("a renamed file whose commit failed still re-binds its callers when it lands", async () => {+ const { live, fresh } = await liveVsFresh(+ [+ { "web/math.ts": math("bar"), "web/caller.ts": callsFoo },+ { files: { "web/math.ts": math("foo") }, poison: ["web/math.ts"] },+ {},+ ],+ "CALLS",+ );+ expect(fresh.map((e) => e.split(" ").slice(0, 3).join(" "))).toEqual(["go[function] -> foo[function]"]);+ expect(live).toEqual(fresh);+ });++ it("a caller whose re-send failed is re-sent by the next run", async () => {+ const { live, fresh } = await liveVsFresh(+ [+ { "web/math.ts": math("bar"), "web/caller.ts": callsFoo },+ { files: { "web/math.ts": math("foo") }, poison: ["web/caller.ts"] },+ {},+ ],+ "CALLS",+ );+ expect(fresh.map((e) => e.split(" ").slice(0, 3).join(" "))).toEqual(["go[function] -> foo[function]"]);+ expect(live).toEqual(fresh);+ });+});diff --git a/ix-cli/src/cli/__tests__/ingest-discovery.test.ts b/ix-cli/src/cli/__tests__/ingest-discovery.test.tsindex b146bd9a..dc81a0de 100644--- a/ix-cli/src/cli/__tests__/ingest-discovery.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-discovery.test.ts@@ -12,7 +12,6 @@ import {isSupportedSourceFile,discoverIngestFilePaths,isWithinDiscoveryRoot,- needsIndexPrescan,tryGitLsFiles,} from '../commands/ingest.js';@@ -81,17 +80,6 @@ describe('dedupeDiscoveredFilePaths', () => {expect(isWithinDiscoveryRoot(root, join('/repo', '..shared', 'app.ts'))).toBe(false);expect(isWithinDiscoveryRoot(root, join(root, '..shared', 'app.ts'))).toBe(true);});-- it('pre-scans every language whose index is parser-derived', () => {- for (const filePath of [- 'src/Service.php',- 'src/helper.js', 'src/helper.jsx', 'src/helper.mjs', 'src/helper.cjs',- 'src/helper.ts', 'src/helper.tsx',- ]) {- expect(needsIndexPrescan(filePath)).toBe(true);- }- expect(needsIndexPrescan('src/service.py')).toBe(false);- });});describe('discovery symlink containment', () => {diff --git a/ix-cli/src/cli/__tests__/ingest-equivalence.test.ts b/ix-cli/src/cli/__tests__/ingest-equivalence.test.tsindex df47bb61..2ae31c56 100644--- a/ix-cli/src/cli/__tests__/ingest-equivalence.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-equivalence.test.ts@@ -234,10 +234,11 @@ describe("incremental ix map equals a fresh map (fake backend)", () => {await runSequence("head", [edit("editBody", "web/calc.ts"), edit("addFunction", "web/report.ts")]);});- // F-03. An edited Python or Java file is resolved against the batch of- // changed files alone, so its cross-file CALLS are re-pointed at phantom- // module nodes or dropped. TypeScript is spared by the index prescan.- it.fails("IN-10: a body edit to a Python or Java file keeps its cross-file edges", async () => {+ // F-03. Before IN-09/IN-10 an edited Python or Java file was resolved+ // against the batch of changed files alone, so its cross-file CALLS were+ // re-pointed at phantom module nodes or dropped. It now resolves against the+ // symbol table, in every language.+ it("IN-10: a body edit to a Python or Java file keeps its cross-file edges", async () => {await runSequence("head", [edit("editBody", "pkg/app.py"), edit("editBody", "src/com/ex/App.java")]);});@@ -255,12 +256,18 @@ describe("incremental ix map equals a fresh map (fake backend)", () => {});});- // The index prescan holds no Python or Java symbols, so an added file in- // either language still takes the whole-repository pass: resolved alone, its- // cross-file calls would point at a module node or at nothing.- it("IN-01: an added Python or Java file keeps its cross-file calls", async () => {- await runSequence("head", [edit("addFile", undefined, 0)], { langs: ["py"] });- await runSequence("head", [edit("addFile", undefined, 1)], { langs: ["java"] });+ // The persisted symbol table gives the index every language's symbols, so an+ // added Python or Java file takes the incremental path too: one patch, and+ // its cross-file calls resolve as a fresh map resolves them.+ it("IN-01/IN-10: an added Python or Java file sends one patch and keeps its cross-file calls", async () => {+ const onePatch = (world: World) => {+ const sent = world.backend.requests+ .filter((r) => r.path === "/v1/patches/bulk" || r.path === "/v1/patch")+ .reduce((sum, r) => sum + r.patches, 0);+ expect(sent, "patches on the wire").toBe(1);+ };+ await runSequence("head", [edit("addFile", undefined, 0)], { langs: ["py"], check: onePatch });+ await runSequence("head", [edit("addFile", undefined, 1)], { langs: ["java"], check: onePatch });});// F-04. Dropping the file's last import removes a node, the patch carries a@@ -276,18 +283,28 @@ describe("incremental ix map equals a fresh map (fake backend)", () => {});// F-03. Files that call a renamed or deleted function are unchanged, so- // nothing re-resolves them. Their edges go when the name goes, and when it- // comes back -- renamed back, or the file restored -- they never return.- // (A plain rename now passes: since IN-08 an unresolved call writes no edge,- // fresh or incremental, so the rename back is what shows the defect.)- it.fails("IN-11: a called function renamed and renamed back re-binds its callers", async () => {+ // nothing re-resolved them: their edges went when the name went, and when it+ // came back -- renamed back, or the file restored -- they never returned.+ // The run now re-resolves the files that refer to a changed name.+ it("IN-11: a called function renamed and renamed back re-binds its callers", async () => {await runSequence("head", [edit("renameFunction", "web/math.ts", 0), { kind: "revert", a: 0, b: 0 }]);});- it.fails("IN-11: restoring a deleted file re-binds its callers", async () => {+ it("IN-11: restoring a deleted file re-binds its callers", async () => {await runSequence("head", [edit("deleteThenRestore", "web/math.ts")]);});+ it("IN-11: a re-map with nothing renamed re-sends no caller", async () => {+ await runSequence("head", [edit("editBody", "web/math.ts")], {+ check: (world) => {+ const sent = world.backend.requests+ .filter((r) => r.path === "/v1/patches/bulk" || r.path === "/v1/patch")+ .reduce((sum, r) => sum + r.patches, 0);+ expect(sent, "only the edited file").toBe(1);+ },+ });+ });+it("a revert and a delete-then-restore re-apply, on a backend with BEW-03", async () => {await runSequence("head", [edit("addFunction", "web/main.ts"), { kind: "revert", a: 0, b: 0 }]);await runSequence("head", [edit("deleteThenRestore", "web/main.ts")]);@@ -305,9 +322,9 @@ describe("incremental ix map equals a fresh map (fake backend)", () => {await property("head", ["editBody", "addFunction", "addCall", "addFile"], ["ts"]);});- // The acceptance gate for the F-03 chain: IN-04, IN-10 and IN-11. The last- // of them to land deletes this marker.- it.fails("IN-11: random edit sequences of every kind", async () => {+ // The acceptance gate for the F-03 chain: IN-04, IN-10 and IN-11. All+ // three have landed, so it is no longer marked.+ it("IN-11: random edit sequences of every kind", async () => {await property("head", EDIT_KINDS);});});diff --git a/ix-cli/src/cli/__tests__/ingest-extractor-bump.test.ts b/ix-cli/src/cli/__tests__/ingest-extractor-bump.test.tsindex f3be581f..388977ca 100644--- a/ix-cli/src/cli/__tests__/ingest-extractor-bump.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-extractor-bump.test.ts@@ -54,8 +54,12 @@ vi.mock("../commands/ingestion-loader.js", async (importOriginal) => {}}patch.ops.push(...dangling);- // The id 1.27 gave this file and content: the first previous extractor.- patch.patchId = patchBuilder.sourcePatchIdCandidates(parsed.filePath, hash, workspaceId)[1];+ // The id 1.27 gave this file and content. Candidates are the current+ // extractor's id followed by PREVIOUS_EXTRACTORS' in order, so look+ // 1.27 up rather than assume it is the first previous one.+ patch.patchId = patchBuilder.sourcePatchIdCandidates(parsed.filePath, hash, workspaceId)[+ (patchBuilder as unknown as { PREVIOUS_EXTRACTORS: string[] }).PREVIOUS_EXTRACTORS.indexOf(OLD_EXTRACTOR) + 1+ ];return patch;},};diff --git a/ix-cli/src/cli/__tests__/ingest-files.test.ts b/ix-cli/src/cli/__tests__/ingest-files.test.tsindex bc6293b9..37248988 100644--- a/ix-cli/src/cli/__tests__/ingest-files.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-files.test.ts@@ -8,7 +8,7 @@ import { execFileSync } from "node:child_process";import { ingestFiles, ingestPathSingleFlight } from "../commands/ingest.js";import { acquireMapLock, takeMapRerun } from "../single-flight.js";-import { ingestMtimeCachePath, ingestRebuildPath, loadConfig } from "../config.js";+import { ingestMtimeCachePath, ingestRebuildPath, ingestSymbolsPath, loadConfig } from "../config.js";import { workspaceIdForPath } from "../system.js";import { FakeBackend } from "./helpers/fake-backend.js";import { runWithSignal } from "../../client/run-signal.js";@@ -803,6 +803,23 @@ describe("ingestFiles against a fake backend", () => {expect(summary.filesDiscovered).toBe(17);});+ it("adding one Python file sends one patch", async () => {+ // Until IN-10 a new file outside the index-prescan languages forced the+ // whole-repository pass. The symbol table covers every language, so a+ // new Python file takes the incremental path like a TypeScript one.+ await incremental();+ writeFileSync(join(repo, "src", "added.py"), "def added():\n return 1\n", "utf8");+ stage();+ backend.resetRequests();++ const summary = await incremental();++ expect(backend.acceptedPatches(), "patches on the wire").toBe(1);+ expect(backend.commitCount).toBe(1);+ expect(summary.filesSkippedAsUnchanged).toBe(16);+ expect(summary.filesDiscovered).toBe(17);+ });+it("an empty file that gains content sends one patch", async () => {writeFileSync(join(repo, "src", "empty.ts"), "", "utf8");stage();@@ -1129,6 +1146,17 @@ describe("ingestFiles against a fake backend", () => {});});+ it("counts files tree-sitter parsed with errors, and still ingests them", async () => {+ fixture(2);+ writeFileSync(join(repo, "src", "broken.ts"), "export function ok() { return 1; }\nexport function bad( {\n", "utf8");+ execFileSync("git", ["add", "-A"], { cwd: repo, stdio: "ignore" });++ const summary = await run();++ expect(summary.filesWithParseErrors).toBe(1);+ expect(backend.acceptedPatches()).toBe(3);+ });+it("counts a file over the size limit in the summary, so ix map can say so", async () => {fixture(2);writeFileSync(join(repo, "src", "huge.ts"), `export const big = "${"x".repeat(1024 * 1024 + 10)}";\n`, "utf8");@@ -1476,6 +1504,61 @@ describe("ingestFiles against a fake backend", () => {expect(edges()).toEqual(full);});+ it("does not resolve a scoped run against a stale symbol-table entry for a file outside the scope", async () => {+ // The table is trusted for a file the baseline calls mtime-clean, but a+ // scoped run never stats the files outside its scope, so it vouched for an+ // edited `lib/b.ts` with the symbols it had before the edit.+ // Real commit semantics, so the incremental run has hashes to compare.+ backend.semantics = "head";+ mkdirSync(join(repo, "src"), { recursive: true });+ mkdirSync(join(repo, "lib"), { recursive: true });+ writeFileSync(join(repo, "lib", "b.ts"), "export function helper(): number { return 1; }\n", "utf8");+ writeFileSync(join(repo, "src", "a.ts"), "import { helper } from '../lib/b';\nexport function caller(): number { return helper(); }\n", "utf8");+ execFileSync("git", ["init", "-q"], { cwd: repo, stdio: "ignore" });+ execFileSync("git", ["add", "-A"], { cwd: repo, stdio: "ignore" });+ const edges = () => (backend.lastOps.get("src/a.ts") ?? [])+ .filter(op => op.type === "UpsertEdge")+ .map(op => `${String(op.predicate)} ${String(op.dst)}`)+ .sort();++ await ingestFiles(repo, quiet);+ const resolved = edges();++ // `helper` is gone from lib/b.ts; a.ts still calls it. Only src/ is re-mapped.+ writeFileSync(join(repo, "lib", "b.ts"), "export function renamed(): number { return 1; }\n", "utf8");+ writeFileSync(join(repo, "src", "a.ts"), "import { helper } from '../lib/b';\nexport function caller(): number { return helper() + 1; }\n", "utf8");+ backend.lastOps.clear();+ await ingestFiles(join(repo, "src"), quiet);+ const scoped = edges();++ // What a fresh map of the edited workspace says about a.ts.+ backend.lastOps.clear();+ await ingestFiles(repo, { ...quiet, force: true });+ const fresh = edges();++ expect(resolved, "the fixture's call resolved to lib/b.ts at first").not.toEqual(fresh);+ expect(scoped).toEqual(fresh);+ });++ it("keeps other languages' symbol-table entries on a --lang run", async () => {+ // The table was pruned to the run's resolution paths, which `--lang`+ // filters, so every other language was dropped and re-parsed next map.+ mkdirSync(join(repo, "src"), { recursive: true });+ writeFileSync(join(repo, "src", "a.ts"), "export function a(): number { return 1; }\n", "utf8");+ writeFileSync(join(repo, "src", "b.py"), "def b():\n return 1\n", "utf8");+ execFileSync("git", ["init", "-q"], { cwd: repo, stdio: "ignore" });+ execFileSync("git", ["add", "-A"], { cwd: repo, stdio: "ignore" });+ const tableFiles = () =>+ Object.keys((JSON.parse(readFileSync(ingestSymbolsPath(repo), "utf8")) as { files: Record<string, unknown> }).files).sort();++ await ingestFiles(repo, quiet);+ expect(tableFiles()).toEqual(["src/a.ts", "src/b.py"]);++ writeFileSync(join(repo, "src", "b.py"), "def b():\n return 2\n", "utf8");+ await ingestFiles(repo, { ...quiet, lang: "py" });+ expect(tableFiles()).toEqual(["src/a.ts", "src/b.py"]);+ });+it("writes no baseline from a subdirectory run when the workspace has none", async () => {// One written from `src/` alone would report the whole graph complete.fixture(2);diff --git a/ix-cli/src/cli/__tests__/ingest-symbols.test.ts b/ix-cli/src/cli/__tests__/ingest-symbols.test.tsnew file mode 100644index 00000000..28ce15eb--- /dev/null+++ b/ix-cli/src/cli/__tests__/ingest-symbols.test.ts@@ -0,0 +1,113 @@+// Copyright 2026 Ix Infrastructure Inc.++import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";++import { ingestSymbolsPath } from "../config.js";+import {+ changedNames, definedNames, findDependents, importsChanged, loadIngestSymbols, resolutionHash, saveIngestSymbols, type SymbolEntry,+} from "../ingest-symbols.js";++describe("ingest symbol table", () => {+ let home: string;+ const root = "/work/repo";+ const entry = (filePath: string): SymbolEntry => ({ hash: "h1", summary: { filePath, qkeys: [["f", "f"]] } });++ beforeEach(() => {+ home = mkdtempSync(join(tmpdir(), "ix-symbols-"));+ process.env.IX_HOME = home;+ });+ afterEach(() => {+ delete process.env.IX_HOME;+ rmSync(home, { recursive: true, force: true });+ });++ it("round-trips, and leaves no temp file behind", () => {+ saveIngestSymbols(root, "tree-sitter/1.29", new Map([["a.py", entry("a.py")]]));+ expect(loadIngestSymbols(root, "tree-sitter/1.29").get("a.py")).toEqual(entry("a.py"));+ expect(readdirSync(home).filter((f) => f.endsWith(".tmp"))).toEqual([]);+ });++ it("is empty for another extractor or another root", () => {+ saveIngestSymbols(root, "tree-sitter/1.29", new Map([["a.py", entry("a.py")]]));+ expect(loadIngestSymbols(root, "tree-sitter/1.30").size).toBe(0);+ writeFileSync(ingestSymbolsPath("/other"), JSON.stringify({ version: 1, root, extractor: "tree-sitter/1.29", files: {} }));+ expect(loadIngestSymbols("/other", "tree-sitter/1.29").size).toBe(0);+ });++ it("is empty when missing or unreadable, and drops malformed entries", () => {+ expect(loadIngestSymbols(root, "x").size).toBe(0);+ writeFileSync(ingestSymbolsPath(root), "{not json");+ expect(loadIngestSymbols(root, "x").size).toBe(0);+ writeFileSync(ingestSymbolsPath(root), JSON.stringify({+ version: 1, root, extractor: "x", files: { "a.py": entry("a.py"), "b.py": { hash: 3 }, "c.py": { hash: "h", summary: {} } },+ }));+ expect([...loadIngestSymbols(root, "x").keys()]).toEqual(["a.py"]);+ expect(existsSync(ingestSymbolsPath(root))).toBe(true);+ });++ it("keeps a resolution hash across a save", () => {+ saveIngestSymbols(root, "x", new Map([["a.py", { ...entry("a.py"), res: "r1" }]]));+ expect(loadIngestSymbols(root, "x").get("a.py")?.res).toBe("r1");+ });+});++describe("dependents (IN-11)", () => {+ const summary = (filePath: string, fields: Record<string, unknown>) => ({ filePath, ...fields });+ const entry = (s: ReturnType<typeof summary>): SymbolEntry => ({ hash: "h", summary: s });++ it("changes no names when the signature is the same, and the symmetric difference otherwise", () => {+ const before = summary("m.ts", { sig: "s1", qkeys: [["add", "add"], ["sub", "sub"]] });+ expect(changedNames(before, summary("m.ts", { sig: "s1", qkeys: [["add", "add"], ["sub", "sub"]] }))).toEqual(new Set());+ const after = summary("m.ts", { sig: "s2", qkeys: [["add", "add"], ["minus", "minus"]], exportPublicNames: [["default", "add"]] });+ expect(changedNames(before, after)).toEqual(new Set(["sub", "minus", "default"]));+ // Added or deleted: every name it defines.+ expect(changedNames(undefined, before)).toEqual(new Set(["add", "sub"]));+ expect(changedNames(before, undefined)).toEqual(new Set(["add", "sub"]));+ expect(definedNames(summary("p.php", { phpTypes: [["App\\Foo", "Foo"]] }))).toEqual(new Set(["App\\Foo", "Foo"]));+ });++ it("finds files that refer to a changed name, by whole name or by segment, or import a path that came or went", () => {+ const table = new Map<string, SymbolEntry>([+ ["main.ts", entry(summary("main.ts", { refs: ["sub"], imports: [{ dstName: "./math", importRaw: "./math" }] }))],+ ["obj.ts", entry(summary("obj.ts", { refs: ["calc.sub"] }))],+ ["mod.py", entry(summary("mod.py", { refs: ["Mod::sub"] }))],+ ["other.ts", entry(summary("other.ts", { refs: ["mul"], imports: [{ dstName: "./util" }] }))],+ ["uses-new.ts", entry(summary("uses-new.ts", { refs: [], imports: [{ dstName: "./added", importRaw: "./added" }] }))],+ ["math.ts", entry(summary("math.ts", { refs: ["sub"] }))],+ ]);+ expect(findDependents(table, new Set(["sub"]), [], new Set(["math.ts"]))).toEqual(["main.ts", "mod.py", "obj.ts"]);+ expect(findDependents(table, new Set(), ["web/added.ts"], new Set())).toEqual(["uses-new.ts"]);+ expect(findDependents(table, new Set(), ["pkg/util/index.ts"], new Set())).toEqual(["other.ts"]);+ expect(findDependents(table, new Set(), [], new Set())).toEqual([]);+ });++ it("counts a name whose binding moved, and an import change, though no name came or went", () => {+ const was = summary("b.ts", { sig: "s1", exportPublicNames: [["foo", "a"]], imports: [{ dstName: "x", importRaw: "./x" }] });+ const now = summary("b.ts", { sig: "s2", exportPublicNames: [["foo", "b"]], imports: [{ dstName: "y", importRaw: "./y" }] });+ expect(changedNames(was, now)).toEqual(new Set(["foo"]));+ expect(importsChanged(was, now)).toBe(true);+ expect(importsChanged(was, { ...was })).toBe(false);+ // An added or deleted file is a changed path already.+ expect(importsChanged(undefined, now)).toBe(false);+ });++ it("matches an import by path segment, not by substring", () => {+ const table = new Map<string, SymbolEntry>([+ ["uses-a.ts", entry(summary("uses-a.ts", { refs: [], imports: [{ importRaw: "./a.js" }] }))],+ ["uses-data.ts", entry(summary("uses-data.ts", { refs: [], imports: [{ importRaw: "./data" }] }))],+ ["uses-pkg-a.py", entry(summary("uses-pkg-a.py", { refs: [], imports: [{ importRaw: "pkg.a" }] }))],+ ]);+ expect(findDependents(table, new Set(), ["web/a.ts"], new Set())).toEqual(["uses-a.ts", "uses-pkg-a.py"]);+ });++ it("hashes a patch's edges and their targets, in any order, and nothing else", () => {+ const a = { type: "UpsertEdge", id: "e1", dst: "n1" };+ const b = { type: "UpsertEdge", id: "e2", dst: "n2" };+ const node = { type: "UpsertNode", id: "n9" };+ expect(resolutionHash([a, b, node])).toBe(resolutionHash([b, a]));+ expect(resolutionHash([a, b])).not.toBe(resolutionHash([a, { ...b, dst: "n3" }]));+ });+});diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex d76ad8a0..976171a5 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -28,6 +28,10 @@ import { parseGitHubRepo, fetchGitHubData } from '../github/fetch.js';import { loadIngestionModules } from './ingestion-loader.js';import { declaredPackageDirs } from '../package-dirs.js';import { ensureWorkspaceIdState, workspaceStateFor } from '../bootstrap.js';+import {+ changedNames, findDependents, importsChanged, loadIngestSymbols, resolutionHash, saveIngestSymbols,+ type StoredSummary, type SymbolEntry,+} from '../ingest-symbols.js';import { detectSystem, repoWorkspaceIdFor, lookupPackage, readPackageNames, readPackageDeps } from '../system.js';import { CLIENT_EXPECTED_SCHEMA_VERSION } from '../backend-status.js';import { admitStitchWaiting, connectionNeverEstablished, type StitchRefusal } from '../stitch-guard.js';@@ -64,20 +68,6 @@ import { createLimiter, type Limiter } from "../tree-walk.js";export { isSupportedSourceFile, tryGitLsFiles, walkFiles } from '../file-discovery.js';-// Extensions whose source text must be pre-read so buildGlobalResolutionIndex can-// extract cross-batch symbols before the streaming parse loop. Go uses a fast-// regex scan; PHP, JavaScript, TypeScript, SAS and R are parsed, so their-// cross-batch indexes are derived from the parser's definition entities and-// cannot drift from what the in-batch path extracts.-const INDEX_PRESCAN_EXTENSIONS = new Set([- '.go', '.php', '.r', '.sas',- '.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx',-]);--export function needsIndexPrescan(filePath: string): boolean {- return INDEX_PRESCAN_EXTENSIONS.has(nodePath.extname(filePath).toLowerCase());-}-// ---------------------------------------------------------------------------// Language filter helpers// ---------------------------------------------------------------------------@@ -1324,6 +1314,12 @@ export interface IngestFilesSummary {* something must not claim the graph is where it was.*/graphUnchanged: boolean;+ /**+ * Files tree-sitter parsed with ERROR or MISSING nodes. They are in the+ * graph, but whatever sat in the broken region may not be. Not counted in+ * `parseErrors`, which is files that produced nothing.+ */+ filesWithParseErrors: number;/*** Files skipped because their parse ran past the per-file budget* (IX_PARSE_BUDGET_MS, default 10 s), workspace-relative. A subset of the@@ -1992,45 +1988,6 @@ export async function ingestFiles(- /**- * Parse the prescan sources on the worker pool.- *- * buildGlobalResolutionIndex derives PHP/JS/TS/R/SAS indexes from real parse- * results rather than a regex, so they cannot drift from what the in-batch- * path extracts — the right call, but it means the index costs one parse per- * prescanned file. Done inside the index that is a synchronous main-thread- * loop, and .ts is not a rare extension: on a TypeScript repo it is most of- * the files, and an incremental map pays it for every unchanged file too.- *- * The pool is already running for the streaming loop below, so parse there- * instead and hand the results over. Only extensions whose index is- * parser-derived are worth the round trip; Go is a regex scan inside the- * index and needs nothing here.- */- const PARSER_DERIVED_PRESCAN = new Set(['.php', '.r', '.sas', '.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx']);- const preParsePrescanSources = async (relSources: Map<string, string>): Promise<Map<string, any>> => {- const targets = [...relSources.keys()].filter(- fp => PARSER_DERIVED_PRESCAN.has(nodePath.extname(fp).toLowerCase()),- );- const preParsed = new Map<string, any>();- if (targets.length === 0) return preParsed;- const PRESCAN_PARSE_CHUNK = 500;- for (let i = 0; i < targets.length; i += PRESCAN_PARSE_CHUNK) {- const chunk = targets.slice(i, i + PRESCAN_PARSE_CHUNK);- const parsed = await Promise.all(- // `false`: this prescan is best-effort by construction -- the caller- // drops nulls, and every file here is read and parsed again by the- // streaming loop below. A loss here is not a file the RUN lost, and- // counting it as one refused the stitch and withheld the baseline over- // files that were all present.- chunk.map(fp => ensureParsePool(targets.length).parse(fp, relSources.get(fp)!, false).catch(() => null)),- );- for (let j = 0; j < chunk.length; j++) {- if (parsed[j]) preParsed.set(chunk[j], parsed[j]);- }- }- return preParsed;- };let progressPhase = 'Scanning';let progressCurrent = 0;@@ -2081,6 +2038,8 @@ export async function ingestFiles(const committedRel = new Set<string>();const settledAbs = new Set<string>();const unparsedRel = new Set<string>();+ /** Files that parsed with ERROR or MISSING nodes: indexed, but possibly incompletely. */+ let filesWithParseErrors = 0;// What `graphUnchanged` is computed from, beside the counters above. Each is// a way this run can have written to the graph, or have found it not where// the last run left it, without a patch being counted.@@ -2516,6 +2475,141 @@ export async function ingestFiles(type ParsedFile = { filePath: string; parsed: any; hash: string; previousHash: string | undefined };let resolveEdgesFn: Function | null = null;let buildPatchFn: Function | null = null;++ // ── Symbol table ─────────────────────────────────────────────────────+ // What every file defines, exports and imports, kept between runs (see+ // `ingest-symbols.ts`). The resolution index is built from it, so an edit+ // parses only the files that changed, in any language, and still resolves+ // against all the others.+ // Loaded on first use: a run with nothing to parse never reads it, and on a+ // large repository it is tens of megabytes of JSON.+ let loadedSymbolTable: Map<string, SymbolEntry> | undefined;+ const symbolTable = (): Map<string, SymbolEntry> =>+ (loadedSymbolTable ??= loadIngestSymbols(projectRoot, currentExtractor));+ let symbolTableChanged = false;+ /** sha256 of each file this run has read, by absolute path. */+ const currentHashes = new Map<string, string>();+ const mtimeChangedSet = new Set(mtimeChangedPaths);+ let summarize: ((parsed: any) => StoredSummary) | null = null;+ /** Record what a parse in this run learned about a file, for the next run. */+ const noteSummary = (relFilePath: string, hash: string, parsed: any, mtime: number | undefined): void => {+ if (!summarize || !parsed) return;+ const table = symbolTable();+ const before = table.get(relFilePath);+ if (!summaryBeforeRun.has(relFilePath)) summaryBeforeRun.set(relFilePath, before?.summary);+ // The resolution hash describes the patch built from these bytes; it is+ // kept until that patch is built again (noteResolution).+ const res = before?.hash === hash ? before.res : undefined;+ table.set(relFilePath, {+ hash, summary: summarize(parsed), ...(mtime !== undefined ? { mtime } : {}), ...(res !== undefined ? { res } : {}),+ });+ symbolTableChanged = true;+ };+ /**+ * What each file this run parsed defined before the run, by relative path+ * (undefined: a file the table did not have). Compared with its new+ * summary to find the names that changed (IN-11).+ */+ const summaryBeforeRun = new Map<string, StoredSummary | undefined>();+ /** Record what a file's patch resolved to, so a later run can tell whether re-resolving it changes anything. */+ const noteResolution = (relFilePath: string, patch: GraphPatchPayload): void => {+ const entry = symbolTable().get(relFilePath);+ if (!entry) return;+ const res = resolutionHash(patch.ops);+ if (entry.res !== res) {+ entry.res = res;+ symbolTableChanged = true;+ }+ };+ /** The file's mtime now: from this run's stat loop, or a stat for a file outside it. */+ const mtimeNow = (absFilePath: string): number | undefined => {+ const known = currentMtimes.get(absFilePath);+ if (known !== undefined) return known;+ try { return fs.statSync(absFilePath).mtimeMs; } catch { return undefined; }+ };+ /**+ * An entry still describes its file: the same bytes, or (with a baseline)+ * a file that is mtime-clean AND still has the mtime the entry was read at.+ * The baseline alone is not enough: the table is saved after it and can be+ * older (a failed save, a run killed in between), and a scoped run does not+ * stat the files outside its scope, so they never look changed.+ */+ const tableEntryValid = (absFilePath: string, entry: SymbolEntry | undefined, trustMtime: boolean): boolean => {+ if (!entry) return false;+ const hash = currentHashes.get(absFilePath);+ if (hash !== undefined) {+ if (entry.hash !== hash) return false;+ // Same bytes under a new mtime (a touch, a checkout): record the new+ // one, or the entry fails the mtime check on every run from now on.+ const mtime = currentMtimes.get(absFilePath);+ if (mtime !== undefined && entry.mtime !== mtime) {+ entry.mtime = mtime;+ symbolTableChanged = true;+ }+ return true;+ }+ if (!trustMtime || mtimeChangedSet.has(absFilePath) || entry.mtime === undefined) return false;+ return mtimeNow(absFilePath) === entry.mtime;+ };++ /**+ * The resolution index over every file edges may resolve to, from the+ * table where it is still valid. A file it lacks is read and parsed here+ * for its summary only -- unless the streaming loop is about to parse it+ * in a single chunk, where the batch's own summary takes precedence in+ * `resolveEdges` anyway. Across several chunks an earlier chunk would see+ * a later one's stale entry, so then every file without a valid entry is+ * summarized first (for a first map, that is one extra parse of the repo).+ *+ * `trustMtime` is false on Path B, where there is no baseline to trust.+ */+ const buildResolutionIndex = async (+ ingestion: { summarizeParseResult: (parsed: any) => StoredSummary; buildGlobalResolutionIndex: Function },+ parsedInStream: Set<string>,+ singleChunk: boolean,+ trustMtime: boolean,+ ): Promise<any> => {+ summarize = ingestion.summarizeParseResult;+ const summaries = new Map<string, StoredSummary>();+ const missing: string[] = [];+ for (const abs of resolutionPaths) {+ const rel = toWorkspaceRelative(abs);+ const entry = symbolTable().get(rel);+ if (tableEntryValid(abs, entry, trustMtime)) {+ summaries.set(rel, entry!.summary);+ continue;+ }+ if (singleChunk && parsedInStream.has(abs)) continue;+ // A scoped run reads nothing outside its scope.+ if (scopedRun && !inScope(abs)) continue;+ missing.push(abs);+ }+ const SUMMARY_CHUNK = 500;+ for (let i = 0; i < missing.length; i += SUMMARY_CHUNK) {+ const chunk = missing.slice(i, i + SUMMARY_CHUNK);+ // Stat'd before the read, so a file that changes in between is+ // recorded with its older mtime and re-read next time.+ const mtimes = chunk.map(mtimeNow);+ const bytes = await Promise.all(chunk.map(fp => fs.promises.readFile(fp).catch(() => null)));+ const parsed = await Promise.all(chunk.map((fp, j) => {+ const b = bytes[j];+ if (!b || b.length === 0 || b.length > MAX_FILE_BYTES) return null;+ // `false`: a loss here is not a file the run lost -- see `ParsePool.parse`.+ return ensureParsePool(missing.length).parse(toWorkspaceRelative(fp), b.toString('utf-8'), false).catch(() => null);+ }));+ for (let j = 0; j < chunk.length; j++) {+ const b = bytes[j];+ if (!b) continue;+ const hash = sha256(b);+ currentHashes.set(chunk[j], hash);+ const rel = toWorkspaceRelative(chunk[j]);+ noteSummary(rel, hash, parsed[j], mtimes[j]);+ const entry = symbolTable().get(rel);+ if (entry && entry.hash === hash) summaries.set(rel, entry.summary);+ }+ }+ return ingestion.buildGlobalResolutionIndex(resolutionPaths.map(toWorkspaceRelative), undefined, undefined, summaries);+ };let globalIndex: any = undefined;// Larger chunks for big repos: fewer resolve+commit cycles, better edge resolution per batch.@@ -3350,6 +3444,7 @@ export async function ingestFiles();}if (mapMode) patch = stripMapModeOps(patch);+ noteResolution(p.filePath, patch);// source.uri (workspace-relative) and source.workspaceId are set// inside buildPatch; the backend stores both as opaque attributes.return makePreparedPatch(patch, j + 1, p.filePath, previousHash !== undefined || isForced(p.filePath));@@ -3482,17 +3577,13 @@ export async function ingestFiles(// `mtimeCache` is empty after --force, a workspace migration or the DB-reset// guard above, so those still take Path B.//- // Only for files whose cross-file references Path A can resolve, though.- // Path A resolves the changed files as one batch against `globalIndex`, and- // that index holds the symbols of the prescan languages only (Go, PHP, R,- // SAS, JS/TS). A new Python or Java file resolved that way binds its calls- // to itself alone, so they point at a module node or at nothing; the- // whole-repository pass resolves them. Those files keep that pass until the- // persisted symbol table (IN-10) covers every language.- const unknownToBackend = mtimeChangedPaths.filter(fp => !knownHashes.has(fp));- const hasBaseline = previousBaseline !== null && mtimeCache.size > 0- && unknownToBackend.every(needsIndexPrescan);- if ((hasBaseline || knownHashes.size > 0 || mtimeChangedPaths.length === 0) && !opts.force) {+ // A new file in any language takes it: Path A resolves the changed files+ // against `globalIndex`, which the persisted symbol table gives every+ // language's symbols, so a new Python or Java file binds its cross-file+ // calls as a whole-repository pass would.+ const hasBaseline = previousBaseline !== null && mtimeCache.size > 0;+ const incrementalRun = (hasBaseline || knownHashes.size > 0 || mtimeChangedPaths.length === 0) && !opts.force;+ if (incrementalRun) {// Path A: has baseline or all mtime-clean → pre-scan to detect changes before loading modules.// If nothing changed, module load is skipped entirely. A file with no// backend hash is new: it is parsed and sent with no reconcile.@@ -3501,6 +3592,7 @@ export async function ingestFiles(try {const bytes = fs.readFileSync(filePath);const hash = sha256(bytes);+ currentHashes.set(filePath, hash);if (!forceReingestPaths.has(filePath) && knownHashes.get(filePath) === hash) {filesSkipped++;filesSkippedAsUnchanged++;@@ -3550,36 +3642,17 @@ export async function ingestFiles(progressTotal = parseable.length;progressCurrent = 0;- // Build global resolution index from all repo file paths (not just changed files)- // so cross-batch imports resolve correctly even in streaming per-chunk mode.- // Reuse bytes already read into changedPaths (on first install = all files, zero extra reads).- // Only async-read Go/R files that were mtime-clean and therefore not in changedPaths.+ // The resolution index over every file, from the symbol table: only+ // the changed files are parsed (below), plus any file the table lacks.{- const sources = new Map<string, string>();- const changedSet = new Set(changedPaths.map(c => c.filePath));- for (const { filePath, bytes } of changedPaths) {- if (needsIndexPrescan(filePath)) sources.set(filePath, bytes.toString('utf-8'));- }- const remainingIndexFiles = filePaths.filter(fp => needsIndexPrescan(fp) && !changedSet.has(fp));- const INDEX_READ_CONCURRENCY = 2000;- for (let i = 0; i < remainingIndexFiles.length; i += INDEX_READ_CONCURRENCY) {- const batch = remainingIndexFiles.slice(i, i + INDEX_READ_CONCURRENCY);- const texts = await Promise.all(batch.map(fp => fs.promises.readFile(fp, 'utf-8').catch(() => null)));- for (let j = 0; j < batch.length; j++) {- if (texts[j] != null) sources.set(batch[j], texts[j]!);- }- }- // Global resolution index is keyed on workspace-relative paths so- // that edge resolution matches the relative paths we pass into- // parseFile.- const relSources = new Map<string, string>();- for (const [abs, text] of sources) relSources.set(toWorkspaceRelative(abs), text);- const relFilePaths = resolutionPaths.map(toWorkspaceRelative);- const preParsed = await preParsePrescanSources(relSources);- globalIndex = (ingestion.buildGlobalResolutionIndex as Function)(relFilePaths, relSources, preParsed);- sources.clear();- relSources.clear();- preParsed.clear();+ const indexStart = performance.now();+ globalIndex = await buildResolutionIndex(+ ingestion,+ new Set(parseable.map(p => p.absFilePath)),+ parseable.length <= PARSE_STREAM_CHUNK,+ true,+ );+ timings.goIndexMs = Math.round(performance.now() - indexStart);}let pendingFlush: Promise<void> = Promise.resolve();@@ -3599,6 +3672,8 @@ export async function ingestFiles(if (!parsed) { filesSkipped++; filesSkippedUnparsed++; unparsedRel.add(chunk[j].filePath); continue; }entitiesParsed += parsed.entities.length;batch.push({ filePath: chunk[j].filePath, parsed, hash: chunk[j].hash, previousHash: chunk[j].previousHash });+ noteSummary(chunk[j].filePath, chunk[j].hash, parsed, currentMtimes.get(chunk[j].absFilePath));+ if (parsed.hasParseErrors) filesWithParseErrors++;}await pendingFlush;pendingFlush = flushBatch(batch);@@ -3616,7 +3691,7 @@ export async function ingestFiles(// loop recorded did not actually happen, and leaving them counted would// refuse the stitch on a run that parsed every file. (Adding one file to// a mapped repo used to land here whatever its language; the baseline- // check above keeps prescan-language additions on Path A now.)+ // check above keeps additions in every language on Path A now.)filesSkipped -= filesSkippedAsUnchanged;filesSkippedAsUnchanged = 0;const moduleStart = performance.now();@@ -3631,23 +3706,14 @@ export async function ingestFiles(// Index keys are workspace-relative to match the relative paths we pass// into parseFile below.{- const goIndexStart = performance.now();- const sources = new Map<string, string>();- const indexFiles = filePaths.filter(fp => needsIndexPrescan(fp));- const INDEX_READ_CONCURRENCY = 2000;- for (let i = 0; i < indexFiles.length; i += INDEX_READ_CONCURRENCY) {- const batch = indexFiles.slice(i, i + INDEX_READ_CONCURRENCY);- const texts = await Promise.all(batch.map(fp => fs.promises.readFile(fp, 'utf-8').catch(() => null)));- for (let j = 0; j < batch.length; j++) {- if (texts[j] != null) sources.set(toWorkspaceRelative(batch[j]), texts[j]!);- }- }- const relFilePaths = resolutionPaths.map(toWorkspaceRelative);- const preParsed = await preParsePrescanSources(sources);- globalIndex = ingestion.buildGlobalResolutionIndex(relFilePaths, sources, preParsed);- sources.clear();- preParsed.clear();- timings.goIndexMs = Math.round(performance.now() - goIndexStart);+ const indexStart = performance.now();+ globalIndex = await buildResolutionIndex(+ ingestion,+ new Set(filePaths),+ filePaths.length <= PARSE_STREAM_CHUNK,+ false,+ );+ timings.goIndexMs = Math.round(performance.now() - indexStart);}progressPhase = 'Parsing';@@ -3733,6 +3799,7 @@ export async function ingestFiles(await fh.close();}const hash = sha256(bytes);+ currentHashes.set(absFilePath, hash);if (!opts.force && !forceReingestPaths.has(absFilePath) && knownHashes.get(absFilePath) === hash) {filesSkipped++;filesSkippedAsUnchanged++;@@ -3768,6 +3835,8 @@ export async function ingestFiles(if (!parsed) { filesSkipped++; filesSkippedUnparsed++; unparsedRel.add(f.filePath); continue; }entitiesParsed += parsed.entities.length;batch.push({ filePath: f.filePath, parsed, hash: f.hash, previousHash: f.previousHash });+ noteSummary(f.filePath, f.hash, parsed, currentMtimes.get(chunk[j]));+ if (parsed.hasParseErrors) filesWithParseErrors++;}await pendingFlushB;pendingFlushB = flushBatch(batch);@@ -3866,6 +3935,110 @@ export async function ingestFiles(}}+ // ── Dependents (IN-11) ──────────────────────────────────────────────+ // An unchanged file whose calls resolve to a name that was renamed,+ // removed or added elsewhere keeps its old edges until it is re-sent:+ // callers of a renamed function point at the old node, and when the name+ // comes back -- renamed back, the file restored -- nothing re-binds them.+ // The table says which names changed and which files refer to them; those+ // files are re-parsed and re-resolved, and sent only when their resolution+ // actually differs, under a patch id salted with it (an unsalted re-send of+ // unchanged bytes is a replay the backend answers `Idempotent`).+ //+ // Path A only: Path B parses and resolves every file anyway.+ const deletedRel = deletedPaths.map(toWorkspaceRelative);+ // Left pending by an earlier run whose re-send did not land.+ const pendingRel = incrementalRun ? [...symbolTable()].filter(([, e]) => e.pending).map(([rel]) => rel) : [];+ if (incrementalRun && (summaryBeforeRun.size > 0 || deletedRel.length > 0 || pendingRel.length > 0)) {+ const table = symbolTable();+ const names = new Set<string>();+ // Paths whose importers may resolve differently: files that appeared,+ // and files that changed what they import (a re-export moved).+ const pathsChanged: string[] = [];+ for (const [rel, before] of summaryBeforeRun) {+ const after = table.get(rel)?.summary;+ for (const n of changedNames(before, after)) names.add(n);+ if (before === undefined || importsChanged(before, after)) pathsChanged.push(rel);+ }+ for (const rel of deletedRel) {+ for (const n of changedNames(table.get(rel)?.summary, undefined)) names.add(n);+ }+ const absByRel = new Map(resolutionPaths.map(abs => [toWorkspaceRelative(abs), abs] as const));+ const exclude = new Set<string>([...summaryBeforeRun.keys(), ...deletedRel]);+ for (const rel of table.keys()) if (!absByRel.has(rel)) exclude.add(rel);+ const found = findDependents(table, names, [...pathsChanged, ...deletedRel], exclude);+ const dependents = [...new Set([...found, ...pendingRel.filter(rel => !exclude.has(rel))])].sort()+ // A scoped run reads nothing outside its scope.+ .filter(rel => inScope(absByRel.get(rel)!));+ // Until each lands or proves unneeded: a re-send that fails, or a file+ // that cannot be read now, is picked up again by the next run.+ for (const rel of dependents) {+ const entry = table.get(rel);+ if (entry && !entry.pending) {+ entry.pending = true;+ symbolTableChanged = true;+ }+ }+ if (debug && dependents.length > 0) {+ process.stderr.write(`\n [dependents] ${names.size} name(s) changed; re-resolving ${dependents.length} file(s)\n`);+ }+ if (dependents.length > 0) {+ const [ingestion, patchBuilder] = await loadIngestionModules();+ resolveEdgesFn ??= ingestion.resolveEdges;+ buildPatchFn ??= patchBuilder.buildPatchWithResolution;+ // Over the files as they are now: the changed files' new summaries in,+ // the deleted files out.+ globalIndex = await buildResolutionIndex(ingestion, new Set(), false, true);+ const reread = await Promise.all(dependents.map(async rel => {+ const bytes = await fs.promises.readFile(absByRel.get(rel)!).catch(() => null);+ if (!bytes || bytes.length === 0 || bytes.length > MAX_FILE_BYTES) return null;+ const parsed = await ensureParsePool(dependents.length).parse(rel, bytes.toString('utf-8'), false).catch(() => null);+ return parsed ? { filePath: rel, parsed, hash: sha256(bytes), previousHash: undefined } as ParsedFile : null;+ }));+ const batch = reread.filter((f): f is ParsedFile => f !== null);+ const edges = resolveEdgesFn!(batch.map(f => f.parsed), resolveStats, globalIndex, resolveOpts) as any[];+ const edgesByFile = new Map<string, any[]>();+ for (const edge of edges) {+ let arr = edgesByFile.get(edge.srcFilePath);+ if (!arr) { arr = []; edgesByFile.set(edge.srcFilePath, arr); }+ arr.push(edge);+ }+ const resent: PreparedPatch[] = [];+ const pendingRes = new Map<string, string>();+ for (const { filePath: rel, parsed: p, hash } of batch) {+ const entry = table.get(rel);+ const build = (salt?: string): GraphPatchPayload => {+ const patch = buildPatchFn!(p, hash, fileWorkspaceId(rel), edgesByFile.get(rel) ?? emptyEdges, undefined, fileMultiRepo(rel), salt);+ return mapMode ? stripMapModeOps(patch) : patch;+ };+ const res = resolutionHash(build().ops);+ // Equal: re-resolving changes nothing this file says. A different+ // hash, or none recorded, and it is re-sent.+ if (entry?.res === res && entry.hash === hash) {+ delete entry.pending;+ continue;+ }+ resent.push(makePreparedPatch(build(res.slice(0, 12)), resent.length + 1, rel, false));+ pendingRes.set(rel, res);+ }+ if (debug) process.stderr.write(`\n [dependents] ${resent.length} of ${batch.length} resolve differently; re-sending them\n`);+ if (resent.length > 0) {+ filesChanged += resent.length;+ await commitPreparedPatches(resent, resent.length, {+ onCommitted: item => {+ const entry = table.get(item.filePath);+ const res = pendingRes.get(item.filePath);+ if (entry && res !== undefined) {+ entry.res = res;+ delete entry.pending;+ symbolTableChanged = true;+ }+ },+ });+ }+ }+ }+const committed = performance.now();if (debug && baseRevRetries > 0) {process.stderr.write(`\n [base-rev race] ${baseRevRetries} commit(s) re-sent after another writer moved the rev\n`);@@ -3957,6 +4130,16 @@ export async function ingestFiles(runClean ? baselineExtractor : (previousBaseline?.extractor ?? baselineExtractor),{ replayedFiles, pendingFiles, parseTimeouts },);+ // The symbol table describes files, not the graph, so it is kept whether or+ // not every commit landed -- pruned to the files that still exist. A+ // `--lang` run's resolution paths hold its languages only; the files it+ // left out still exist and keep their entries, as they keep their baseline.+ if (symbolTableChanged) {+ const existing = new Set([...resolutionPaths, ...langExcluded].map(toWorkspaceRelative));+ const table = symbolTable();+ for (const rel of [...table.keys()]) if (!existing.has(rel)) table.delete(rel);+ saveIngestSymbols(projectRoot, currentExtractor, table);+ }if (rebuildProgress !== null) {// Finished: the baseline now records the new extractor. Otherwise keep// what landed, so the next run resumes from here.@@ -4229,6 +4412,7 @@ export async function ingestFiles(stitchErrors,stitchSkipped,stitchSkippedRule,+ filesWithParseErrors,parseTimeouts: timedOutParses(),graphUnchanged:opts.force !== true &&@@ -4310,6 +4494,7 @@ export async function ingestFiles(filesSkipped,idempotentPatches,replayedChanges: summary.replayedChanges,+ filesWithParseErrors,entitiesParsed,latestRev,// `unchanged` is the files we ASSUMED unchanged, not every skip. It used@@ -4379,6 +4564,7 @@ export async function ingestFiles(if (replayedChanges.size > 0) console.log(` ${chalk.yellow('not applied:')} ${replayedChanges.size} ${chalk.dim('(see the warning above)')}`);if (tooLarge > 0) console.log(` ${chalk.dim('skipped too large:')} ${tooLarge}`);if (minifiedLikely > 0) console.log(` ${chalk.dim('skipped minified:')} ${minifiedLikely}`);+ if (filesWithParseErrors > 0) console.log(` ${chalk.yellow("parsed with errors:")} ${filesWithParseErrors} ${chalk.dim("(tree-sitter recovered; parts may be missing)")}`);if (summary.parseTimeouts.length > 0) console.log(` ${chalk.yellow("skipped parse timeout:")} ${summary.parseTimeouts.length} ${chalk.dim(`(${summary.parseTimeouts.join(", ")})`)}`);// Not dimmed like the others: these were dropped because the repo pointed// at files outside itself, which is worth a look rather than a shrug.diff --git a/ix-cli/src/cli/commands/ingestion-loader.ts b/ix-cli/src/cli/commands/ingestion-loader.tsindex 8e12fae7..1e7015a7 100644--- a/ix-cli/src/cli/commands/ingestion-loader.ts+++ b/ix-cli/src/cli/commands/ingestion-loader.ts@@ -7,7 +7,13 @@ type IngestionModule = {parseFile: (filePath: string, source: string) => any;resolveEdges: (results: any[], stats?: any, globalIndex?: any) => any[];isGrammarSupported: (filePath: string) => boolean;- buildGlobalResolutionIndex: (filePaths: string[], sources?: Map<string, string>, preParsed?: Map<string, any>) => any;+ buildGlobalResolutionIndex: (+ filePaths: string[],+ sources?: Map<string, string>,+ preParsed?: Map<string, any>,+ summaries?: Map<string, any>,+ ) => any;+ summarizeParseResult: (parsed: any) => { filePath: string; [key: string]: unknown };};type PatchBuilderModule = {diff --git a/ix-cli/src/cli/config.ts b/ix-cli/src/cli/config.tsindex df612972..cf788040 100644--- a/ix-cli/src/cli/config.ts+++ b/ix-cli/src/cli/config.ts@@ -43,6 +43,15 @@ export function ingestRebuildPath(projectRoot: string): string {return join(ixHome(), `ingest_rebuild_${key}.json`);}+/**+ * Path to the per-file symbol summaries an incremental map resolves against+ * (see `ingest-symbols.ts`). Cleared with the mtime cache.+ */+export function ingestSymbolsPath(projectRoot: string): string {+ const key = rootKey(projectRoot);+ return join(ixHome(), `ingest_symbols_${key}.json`);+}+/** Path to the architecture-map completion marker for one project root. */export function mapBaselinePath(projectRoot: string): string {const key = rootKey(projectRoot);@@ -135,6 +144,7 @@ export function clearMapBaseline(projectRoot: string): void {export function clearIngestMtimeCache(projectRoot: string): void {try { rmSync(ingestMtimeCachePath(projectRoot), { force: true }); } catch { /* non-critical */ }try { rmSync(ingestRebuildPath(projectRoot), { force: true }); } catch { /* non-critical */ }+ try { rmSync(ingestSymbolsPath(projectRoot), { force: true }); } catch { /* non-critical */ }clearMapBaseline(projectRoot);}diff --git a/ix-cli/src/cli/ingest-symbols.ts b/ix-cli/src/cli/ingest-symbols.tsnew file mode 100644index 00000000..9ac155d5--- /dev/null+++ b/ix-cli/src/cli/ingest-symbols.ts@@ -0,0 +1,251 @@+// Copyright 2026 Ix Infrastructure Inc.++import { createHash } from "node:crypto";+import * as fs from "node:fs";+import * as path from "node:path";+import { ingestSymbolsPath } from "./config.js";++/**+ * The symbol table an incremental `ix map` resolves against.+ *+ * Resolving a changed file needs to know what every OTHER file defines,+ * exports and imports. Without a record of that, every run re-read and+ * re-parsed the whole repository's JS/TS, PHP, R and SAS just to build the+ * index -- and knew nothing at all about Python, Java and the rest, so an edit+ * to one of those resolved its calls against itself alone and lost its+ * cross-file edges. This keeps one `FileSummary` (core-ingestion's+ * `summarizeParseResult`) per file, keyed by workspace-relative path, beside+ * the ingest baseline.+ *+ * An entry is usable when its file is unchanged since the last run (mtime-clean+ * in the baseline) or its content hash matches, and only for the extractor that+ * wrote it.+ */++/** Bump when the stored shape changes; an older table is ignored, not migrated. */+const TABLE_VERSION = 1;++/** What core-ingestion's `FileSummary` looks like from here: opaque except for the path. */+export interface StoredSummary {+ filePath: string;+ [key: string]: unknown;+}++export interface SymbolEntry {+ /** sha256 of the file the summary describes. */+ hash: string;+ /**+ * The file's mtime when it was read for this summary, stat'd before the read.+ * An entry is trusted without reading its file only while the file still has+ * this mtime: the baseline's mtimes say nothing about this table, which is+ * saved separately and can be older, and a scoped run never stats the files+ * outside its scope.+ */+ mtime?: number;+ summary: StoredSummary;+ /**+ * What the file's patch resolved its edges to, recorded when the patch is+ * built from these bytes: a hash of its edge ids and their targets+ * (`resolutionHash`). A re-resolution's re-send records it only once it lands. An unchanged file is+ * re-sent when names it uses change elsewhere, and only if this differs.+ */+ res?: string;+ /**+ * Picked for re-resolution (a name it uses changed) and not yet sent. Set+ * before the re-send and cleared when it lands or turns out unneeded, so a+ * failed re-send is retried by the next run rather than forgotten: by then+ * nothing it depends on looks changed any more.+ */+ pending?: true;+}++/**+ * A hash of a patch's edges and where they point. Same bytes resolved against+ * the same names gives the same value, so it changes exactly when something+ * the file refers to moved, appeared or went away.+ */+export function resolutionHash(ops: ReadonlyArray<{ type?: unknown; id?: unknown; dst?: unknown }>): string {+ const pairs = ops+ .filter(op => op.type === "UpsertEdge")+ .map(op => `${String(op.id)}>${String(op.dst)}`)+ .sort();+ return createHash("sha256").update(pairs.join("\n")).digest("hex");+}++interface SerializedSymbolTable {+ version: number;+ root: string;+ extractor: string;+ files: Record<string, SymbolEntry>;+}++/** The table for `projectRoot` and `extractor`, or an empty one. */+export function loadIngestSymbols(projectRoot: string, extractor: string): Map<string, SymbolEntry> {+ try {+ const data = JSON.parse(fs.readFileSync(ingestSymbolsPath(projectRoot), "utf-8")) as SerializedSymbolTable;+ if (data.version !== TABLE_VERSION || data.root !== projectRoot || data.extractor !== extractor) return new Map();+ if (!data.files || typeof data.files !== "object") return new Map();+ const table = new Map<string, SymbolEntry>();+ for (const [rel, entry] of Object.entries(data.files)) {+ if (typeof entry?.hash === "string" && entry.summary && typeof entry.summary.filePath === "string") {+ table.set(rel, entry);+ }+ }+ return table;+ } catch {+ return new Map();+ }+}++/**+ * Write the table via a temp file and a rename, so a process killed mid-write+ * leaves the previous table rather than a truncated one.+ */+export function saveIngestSymbols(projectRoot: string, extractor: string, table: Map<string, SymbolEntry>): void {+ try {+ const target = ingestSymbolsPath(projectRoot);+ fs.mkdirSync(path.dirname(target), { recursive: true });+ const data: SerializedSymbolTable = {+ version: TABLE_VERSION,+ root: projectRoot,+ extractor,+ files: Object.fromEntries(table),+ };+ const tmp = `${target}.${process.pid}.tmp`;+ fs.writeFileSync(tmp, JSON.stringify(data));+ fs.renameSync(tmp, target);+ } catch {+ // An optimization: losing it costs the next run a parse of what it lacks.+ }+}++// ── Dependents (IN-11) ──────────────────────────────────────────────────+// A file that did not change can still need re-sending: a call it makes may+// now resolve somewhere else, or nowhere, because a name it uses was added,+// renamed or removed in another file. The table knows what every file defines+// and refers to, so the run can find those files without reading the rest.++type SummaryFields = {+ qkeys?: Array<[string, string]>;+ exportPublicNames?: Array<[string, string]>;+ phpTypes?: Array<[string, string]>;+ refs?: string[];+ imports?: Array<{ dstName?: string; importRaw?: string }>;+ sig?: string;+};++/** The names other files can resolve to in a summary. */+export function definedNames(summary: StoredSummary | undefined): Set<string> {+ const names = new Set<string>();+ if (!summary) return names;+ const s = summary as SummaryFields;+ for (const [name, qkey] of s.qkeys ?? []) { names.add(name); names.add(qkey); }+ for (const [publicName] of s.exportPublicNames ?? []) names.add(publicName);+ for (const [fqcn, typeName] of s.phpTypes ?? []) { names.add(fqcn); names.add(typeName); }+ return names;+}++/**+ * What other files can bind to in a summary, as `key -> name`: one key per+ * entity name and qualified key, per `[public, local]` export pair and per PHP+ * type. The key carries what the name resolves to, so `export { a as foo }`+ * becoming `export { b as foo }` changes a key although no name came or went.+ */+function bindings(summary: StoredSummary | undefined): Map<string, string[]> {+ const out = new Map<string, string[]>();+ if (!summary) return out;+ const s = summary as SummaryFields;+ for (const [name, qkey] of s.qkeys ?? []) out.set(`q\0${name}\0${qkey}`, [name, qkey]);+ for (const [publicName, local] of s.exportPublicNames ?? []) out.set(`e\0${publicName}\0${local}`, [publicName]);+ for (const [fqcn, typeName] of s.phpTypes ?? []) out.set(`p\0${fqcn}\0${typeName}`, [fqcn, typeName]);+ return out;+}++/**+ * Names whose binding differs before and after: defined in one but not the+ * other, or now pointing at something else. None when the signature is the same.+ */+export function changedNames(before: StoredSummary | undefined, after: StoredSummary | undefined): Set<string> {+ const b = before as SummaryFields | undefined;+ const a = after as SummaryFields | undefined;+ if (b?.sig !== undefined && b.sig === a?.sig) return new Set();+ const was = bindings(before);+ const now = bindings(after);+ const out = new Set<string>();+ for (const [key, names] of was) if (!now.has(key)) for (const n of names) out.add(n);+ for (const [key, names] of now) if (!was.has(key)) for (const n of names) out.add(n);+ return out;+}++/**+ * Whether a file's imports differ before and after. A file that re-exports+ * (`export { foo } from './x'`, a Python `__init__`) passes names through its+ * imports, which its signature does not cover: when they change, files that+ * import it may resolve differently, so it counts as a path that changed.+ */+export function importsChanged(before: StoredSummary | undefined, after: StoredSummary | undefined): boolean {+ if (!before || !after) return false;+ const key = (s: StoredSummary) =>+ JSON.stringify(((s as SummaryFields).imports ?? []).map(i => `${i.dstName ?? ""}\0${i.importRaw ?? ""}`).sort());+ return key(before) !== key(after);+}++/** The stem an import of `relPath` would name: `math` for `web/math.ts`, `web` for `web/index.ts`. */+function importStem(relPath: string): string {+ const posix = relPath.replace(/\\/g, "/");+ const stem = path.posix.basename(posix).replace(/\.[^.]+$/, "");+ if (stem === "index" || stem === "__init__" || stem === "mod") return path.posix.basename(path.posix.dirname(posix));+ return stem;+}++const REF_SEPARATOR = /::|->|[.#\\]/;++/** The segments of an import specifier: `./math.js` -> `math`, `js`; `pkg.util` -> `pkg`, `util`. */+function importSegments(spec: string): string[] {+ return spec.split(/[/\\.:]+/).filter(Boolean);+}++/**+ * Files in `table` that may resolve differently now: a name they refer to is in+ * `names` (also by its first or last segment, for `obj.method` and `Mod::f`), or+ * an import of theirs names the stem of a path in `paths` (a file that appeared,+ * went away, or changed what it imports). Files in `exclude` -- the ones the+ * run already sent -- are left out. Over-matching costs a parse; the resolution hash then decides whether+ * anything is sent.+ */+export function findDependents(+ table: ReadonlyMap<string, SymbolEntry>,+ names: ReadonlySet<string>,+ paths: Iterable<string>,+ exclude: ReadonlySet<string>,+): string[] {+ const stems = new Set<string>();+ for (const p of paths) {+ const stem = importStem(p);+ if (stem.length > 0 && stem !== ".") stems.add(stem);+ }+ if (names.size === 0 && stems.size === 0) return [];+ const out: string[] = [];+ for (const [rel, entry] of table) {+ if (exclude.has(rel)) continue;+ const s = entry.summary as SummaryFields;+ const byName = names.size > 0 && (s.refs ?? []).some(ref => {+ if (names.has(ref)) return true;+ // Most refs are plain names; splitting each costs more than the rest of the scan.+ if (!REF_SEPARATOR.test(ref)) return false;+ const parts = ref.split(/::|->|\.|#|\\/).filter(Boolean);+ return parts.length > 1 && (names.has(parts[0]) || names.has(parts[parts.length - 1]));+ });+ // By path segment, not substring: an added `a.ts` must not match every+ // import with an "a" in it.+ const byImport = !byName && stems.size > 0 && (s.imports ?? []).some(imp => {+ const spec = imp.importRaw ?? imp.dstName ?? "";+ for (const stem of stems) {+ if (spec.includes(stem) && importSegments(spec).includes(stem)) return true;+ }+ return false;+ });+ if (byName || byImport) out.push(rel);+ }+ return out.sort();+}diff --git a/ix-cli/test/e2e/scenarios.e2e.ts b/ix-cli/test/e2e/scenarios.e2e.tsindex f6fba73c..74079b30 100644--- a/ix-cli/test/e2e/scenarios.e2e.ts+++ b/ix-cli/test/e2e/scenarios.e2e.ts@@ -26,7 +26,6 @@ import {map,resetBackend,expectSameGraph,- failsUntil,signature,} from "./harness.js";@@ -55,25 +54,25 @@ function edit(co: Checkout, rel: string, change: (text: string) => string): voidconst replaceAll = (from: string, to: string) => (text: string) => text.split(from).join(to);describe("revert to earlier content", () => {- it(- "[fails until BEW-03] A -> B -> A equals A",- failsUntil(["BEW-03"], async () => {- const co = checkout("polyglot");- map(env, co);- const a = await signature(env, co);-- edit(- co,- "app/pricing.py",- (t) => t + "\n\ndef surcharge(amount):\n return add_tax(amount) + 100\n",- );- map(env, co);- edit(co, "app/pricing.py", (t) => t.slice(0, t.indexOf("\n\ndef surcharge")));- map(env, co);-- expectSameGraph("A->B->A", await signature(env, co), a);- }),- );+ // Was [fails until BEW-03]. BEW-03 is in the pinned backend; what was left+ // was the edited Python file's cross-file calls, resolved against itself+ // alone until the persisted symbol table (IN-10).+ it("A -> B -> A equals A", async () => {+ const co = checkout("polyglot");+ map(env, co);+ const a = await signature(env, co);++ edit(+ co,+ "app/pricing.py",+ (t) => t + "\n\ndef surcharge(amount):\n return add_tax(amount) + 100\n",+ );+ map(env, co);+ edit(co, "app/pricing.py", (t) => t.slice(0, t.indexOf("\n\ndef surcharge")));+ map(env, co);++ expectSameGraph("A->B->A", await signature(env, co), a);+ });// Marked [fails until BEW-03] until tree-sitter/1.28. All that was left of// the renamed state was edges with no live node at either end: the renamed@@ -93,50 +92,50 @@ describe("revert to earlier content", () => {expectSameGraph("rename and back", await signature(env, co), a);});- it(- "[fails until BEW-03, IN-04] delete a file and restore it equals the original",- failsUntil(["BEW-03", "IN-04"], async () => {- const co = checkout("polyglot");- map(env, co);- const a = await signature(env, co);-- rmSync(join(co.dir, "app/pricing.py"));- map(env, co);- git(co.dir, "checkout", "--", "app/pricing.py");- map(env, co);-- expectSameGraph("delete and restore", await signature(env, co), a);- }),- );-- it(- "[fails until BEW-03, IN-04, IN-10] branch round trip equals the starting branch",- failsUntil(["BEW-03", "IN-04", "IN-10"], async () => {- const co = checkout("polyglot");- git(co.dir, "checkout", "-q", "-b", "feature");- edit(co, "app/services.py", replaceAll("def charge(", "def charge_order("));- edit(co, "app/services.py", replaceAll("service.charge(", "service.charge_order("));- edit(co, "web/src/cart.ts", replaceAll("summary()", "describe()"));- edit(co, "web/src/index.ts", replaceAll("cart.summary()", "cart.describe()"));- rmSync(join(co.dir, "app/events.py"));- writeFileSync(- join(co.dir, "app/audit.py"),- "from app.utils import slugify\n\n\ndef audit_key(name):\n return slugify(name)\n",- );- git(co.dir, "add", "-A");- git(co.dir, "commit", "-q", "-m", "feature");- git(co.dir, "checkout", "-q", "main");-- map(env, co);- const main = await signature(env, co);- git(co.dir, "checkout", "-q", "feature");- map(env, co);- git(co.dir, "checkout", "-q", "main");- map(env, co);-- expectSameGraph("branch round trip", await signature(env, co), main);- }),- );+ // Was failsUntil BEW-03/IN-04(/IN-10). What was left was callers of the+ // deleted or renamed file's names: unchanged, so nothing re-resolved them.+ // IN-11 re-resolves the files that refer to a changed name.+ it("delete a file and restore it equals the original", async () => {+ const co = checkout("polyglot");+ map(env, co);+ const a = await signature(env, co);++ rmSync(join(co.dir, "app/pricing.py"));+ map(env, co);+ git(co.dir, "checkout", "--", "app/pricing.py");+ map(env, co);++ expectSameGraph("delete and restore", await signature(env, co), a);+ });++ // Was failsUntil BEW-03/IN-04(/IN-10). What was left was callers of the+ // deleted or renamed file's names: unchanged, so nothing re-resolved them.+ // IN-11 re-resolves the files that refer to a changed name.+ it("branch round trip equals the starting branch", async () => {+ const co = checkout("polyglot");+ git(co.dir, "checkout", "-q", "-b", "feature");+ edit(co, "app/services.py", replaceAll("def charge(", "def charge_order("));+ edit(co, "app/services.py", replaceAll("service.charge(", "service.charge_order("));+ edit(co, "web/src/cart.ts", replaceAll("summary()", "describe()"));+ edit(co, "web/src/index.ts", replaceAll("cart.summary()", "cart.describe()"));+ rmSync(join(co.dir, "app/events.py"));+ writeFileSync(+ join(co.dir, "app/audit.py"),+ "from app.utils import slugify\n\n\ndef audit_key(name):\n return slugify(name)\n",+ );+ git(co.dir, "add", "-A");+ git(co.dir, "commit", "-q", "-m", "feature");+ git(co.dir, "checkout", "-q", "main");++ map(env, co);+ const main = await signature(env, co);+ git(co.dir, "checkout", "-q", "feature");+ map(env, co);+ git(co.dir, "checkout", "-q", "main");+ map(env, co);++ expectSameGraph("branch round trip", await signature(env, co), main);+ });});describe("two workspaces in one backend", () => {@@ -156,18 +155,15 @@ describe("two workspaces in one backend", () => {});describe("incremental equals fresh", () => {- it(- "[fails until IN-10] edit one Python file",- failsUntil(["IN-10"], async () => {- const co = checkout("polyglot");- map(env, co);- edit(co, "app/services.py", (t) => t + "\n# edited\n");- map(env, co);- const incremental = await signature(env, co);-- expectSameGraph("python edit", incremental, await freshSignature(env, co));- }),- );+ it("edit one Python file", async () => {+ const co = checkout("polyglot");+ map(env, co);+ edit(co, "app/services.py", (t) => t + "\n# edited\n");+ map(env, co);+ const incremental = await signature(env, co);++ expectSameGraph("python edit", incremental, await freshSignature(env, co));+ });it("edit one TypeScript file", async () => {const co = checkout("polyglot");@@ -179,20 +175,18 @@ describe("incremental equals fresh", () => {expectSameGraph("typescript edit", incremental, await freshSignature(env, co));});- it(- "[fails until IN-04, IN-10] rename a file",- failsUntil(["IN-04", "IN-10"], async () => {- const co = checkout("polyglot");- map(env, co);- renameSync(join(co.dir, "app/events.py"), join(co.dir, "app/bus.py"));- for (const f of ["app/services.py", "app/api.py"])- edit(co, f, replaceAll("from app.events import", "from app.bus import"));- map(env, co);- const incremental = await signature(env, co);-- expectSameGraph("file rename", incremental, await freshSignature(env, co));- }),- );+ // Was [fails until IN-04, IN-10]. Both have landed.+ it("rename a file", async () => {+ const co = checkout("polyglot");+ map(env, co);+ renameSync(join(co.dir, "app/events.py"), join(co.dir, "app/bus.py"));+ for (const f of ["app/services.py", "app/api.py"])+ edit(co, f, replaceAll("from app.events import", "from app.bus import"));+ map(env, co);+ const incremental = await signature(env, co);++ expectSameGraph("file rename", incremental, await freshSignature(env, co));+ });it("add a file", async () => {const co = checkout("polyglot");