* test(conformance): compare TypeScript resolution with compiler declarations * test(typescript): compare fixture declarations and runtime dispatch * test(typescript): compare namespace and generic dispatch fixtures with tsc * fix(typescript): resolve qualified types and nested generic references * test(typescript): run CLI, embedding and workspace fixtures in conformance * fix(typescript): compare JSX member bindings and callable declarations * test(bench): pin compiler-verified property declaration positions * test(typescript): exercise parser cache and graph publication in conformance * test(typescript): run graph publication and recovery fixtures in conformance * fix(typescript): select member overloads from bound call results * bench(typescript): pin the verified overload resolver source tree * test(typescript): compare property accesses and migrate mixed fixtures * test(typescript): require FTS and correct conformance run instructions * fix(typescript): attribute constrained and aliased types to their declarations * test(bench): verify graph and capture changes for TypeScript aliases * test(typescript): move MCP and embedding fixtures into native conformance * test(typescript): check callback signatures and concrete targets against the compiler * test(conformance): verify callback types and migrate TypeScript product fixtures * fix(typescript): propagate the selected overload return to receiver calls * test(conformance): compare callback assignments and preserve class-expression coverage * test(bench): pin the verified overload resolver tree for parse reuse * test(conformance): compare overloaded callbacks and migrate rename and workspace fixtures * fix(typescript): preserve distinct local classes and chained overload return types * test(conformance): cover dirty snapshot reuse and graph rename in the native runner * test(conformance): release the database when fixture setup fails * test(conformance): run TypeScript watcher and shared-store fixtures natively * test(conformance): verify embedding identity and cache reuse in the native runner * test(conformance): move shared-store checkout fixtures into TypeScript jobs * test(bench): pin cold and resumed graphs for the local-class resolver * test(conformance): compare block-shadowed property reads with TypeScript * test(conformance): exercise TypeScript WAL recovery and Git directory handling natively * fix(ingestion): count receiver ownership suppressions once after replay * test(conformance): exercise TypeScript source edits during cold and cached resolution * test(conformance): stage only bundled dependencies for the installed CLI fixture * test(conformance): verify cold and incremental TypeScript file reuse in the native suite * test(conformance): exercise mixed-language embedding chunk reuse and source ranges * fix(typescript): qualify class graph identities by their namespace * test(conformance): move mixed worker persistence and filesystem fixtures to Node * test(cache): verify namespace owner identities across all reuse phases * test(conformance): exercise all 38 POSIX atomic publication cases in the native job * Move TypeScript graph, heap and scenario fixtures to native conformance * Resolve inherited TypeScript overloads and verify transitive interface methods * Compare TypeScript method keys and move wiki and embedding fixtures to conformance * Run TypeScript-backed rename, benchmark and scenario fixtures in native conformance * Compare class type parameters with TypeScript and preserve literal constraints * Fix conformance lint, formatting and rename fixture file handling * Pin both verified cache trials for literal type parameters * Run embedding recovery and control-flow fixtures in TypeScript conformance * Check TypeScript local function identities and repository fixtures in conformance * Compile shared TypeScript callable query patterns once per worker * Verify the Java wildcard graph includes the field declaration column * Pin verified file reuse results for the consolidated TypeScript query * Compare generator, closure and shadowing fixtures with the TypeScript compiler * Run incremental database fixtures in TypeScript conformance on their original platforms * Limit receiver replay to files with call-result consumers and resolve TypeScript overloads in declaration order * Bind TypeScript ambient declarations in their project and reject named imports from declaration scripts * Verify compiler capture, graph and file reuse baselines for the scoped resolver Two real-corpus runs agree across all five reuse phases. The TypeScript ingestion workload retains its call targets on all three sizes. Method-declaration graphs add only the source columns of the Dart and Kotlin properties. The migrated private-field fixture contributes the one additional array push reported by both runtimes. * Shard the Linux TypeScript product tests and require coverage from both runners * Run full-text opt-out lifecycle fixtures in native TypeScript conformance * Verify actual CLI exits, repeated skill output and shared-store analysis * Match TypeScript inheritance order, declared generic defaults and interface method identities * Trace callable arguments through TypeScript constructors and conditional expressions * Give anonymous TypeScript signatures their own generic scope * Move parser drain and analysis lifecycle fixtures into native conformance * Verify TypeScript reference and capture changes against frozen benchmark corpora * Move TypeScript incremental analysis and external config fixtures to conformance * Skip interface identity and callable-flow work for ordinary TypeScript values * Check TypeScript overload declarations and migrate fixture-backed product coverage * Resolve TypeScript script visibility, merged overloads, and immutable receivers * Record the verified TypeScript parse-cache benchmark graphs * Use TypeScript project file membership for global declarations * Match merged rest overloads and hoisted script declarations * Run TypeScript-backed indexing, worker, and rename fixtures in conformance * Move TypeScript gRPC and workspace-link fixtures to conformance * Keep runtime inference out of TypeScript compiler conformance * Keep TypeScript compiler conformance focused on static resolution * fix(typescript): preserve compiler-selected project and method bindings * test(typescript): compare callback sites with the resolved call range * test(typescript): let the compiler check namespace and ambient exports * style(test): format TypeScript conformance fixtures * test(typescript): align capture and receiver benchmarks with the compiler corpus Fingerprint all 174 capture inputs. Compared with main, these inputs add 25 call-result assignments, 19 type references and four scopes. Preserve the scaling budgets. The former duplicate Store fixture contributed one unresolved array push. Replaying both revisions on the current corpus yields exactly the same 20 TypeScript drop sites. Restore the original receiver counts. * perf(typescript): limit overload lookup to compiler-visible bindings * Compare TypeScript module ownership, defaults, and tuple bindings with the compiler Treat export flags as declaration metadata so identifier length cannot displace the declaration anchor. The benchmark corpus gains two reads and two calls to the two extractor helpers. All five cache scenarios keep their previous reparse counts. * Check published call locations and keep receiver replay scoped to call sites Resolve qualified heritage through its lexical namespace and honor TypeScript module detection for script globals. Index overload consumers by scope so 400 independent functions take 400 owner checks instead of 80,200. The published graph and all five real-corpus cache fingerprints remain stable. * Resolve script globals within their TypeScript projects and namespaces Follow compiler project references and source directives, share the global binding tables, and keep namespace values from resolving to unrelated types. Record the compiler-verified declaration positions in the lexical benchmark. * Resolve destructured script globals and preserve CommonJS loader targets Compare script bindings with TypeScript and forwarded CommonJS values with Node after compilation. Move capture ordering and worker parity checks to the native conformance job. Verify the iterable benchmark against the compiler-selected Value.save declaration. * Preserve TypeScript default factory exports across unrelated writes * Resolve standalone TypeScript projects and callable CommonJS exports * Match TypeScript compiler overloads, overrides, and narrowed calls * Resolve TypeScript CommonJS defaults using the project's module format * Check block-local handler bindings against the TypeScript compiler * Run TypeScript compiler conformance from one entry point * Match TypeScript on scoped enum members and tuple overloads * fix(typescript): address resolver and compiler conformance review Preserve shared overload implementation edges and exact literal member keys. Track reachable writes and namespace receiver types, honor inherited package mode, and scan shared overload bindings once. Extend compiler and graph controls for the outstanding literal, scope, and generic-parameter findings. * fix(typescript): verify module bindings and computed keys against runtime Restrict factory invalidation to reachable direct eval and preserve CommonJS wrapper binding order. Evaluate grouped numeric operands in property keys. Add runtime, compiler and scope controls. Update only the capture digests attributable to the awaited tuple marker. * fix(typescript): preserve native ESM exports around CommonJS references Use the module format to select explicit ESM exports in JavaScript and TypeScript. Check namespace keys and imported call targets against Node for .mjs, .mts, .js and .ts, with executable CommonJS controls. * fix(ingestion): preserve JavaScript and TypeScript binding identities Honor project nullability during overload selection and distinguish lexical loop callables. Preserve empty TypeScript method names and signatures through database publication. Track CommonJS wrapper identity across reassignment and grouping. Resolve JavaScript numeric property keys under the owning package format and refresh the affected index rows after a manifest change. * fix(ingestion): restore compiler-proven graph edges and CI parity Correct ESM package scope, CommonJS wrapper evaluation, strict class keys and TypeScript overload and field resolution. Share workspace discovery across providers in the same scan. Pin the verified graph changes to the exact benchmark inputs, preserve the measured performance limits, and cover the reported cases with compiler and runtime regressions. * fix(ingestion): validate package reads and TypeScript type evidence Read package manifests through the same validated descriptor. Preserve keyof precedence, cooked template overloads, and static computed method identities. Pin the compiler-confirmed graph changes to the frozen benchmark inputs. * fix(ingestion): resolve nullable inheritance and TypeScript overloads Preserve nullable generic override targets across C#, Kotlin and Dart. Match TypeScript overloads for loose object fields and inherited instance methods on union receivers. Share the verified parse-cache graph expectations across the two source revisions. * fix(ingestion): preserve narrowed call targets and generic overrides Carry prior instanceof exclusions through direct else-if chains and respect execution order for CommonJS wrapper writes. Match scoped C# reference and global-qualified generic signatures and Kotlin nullable generic arguments. Add compiler-backed regression cases and record the verified cache graph identity. * fix(ingestion): preserve constructed overrides and guard C++ defaults Retain the scoped identity and nested arguments of nullable C# and Dart overrides. Keep earlier C++ template parameters when parser recovery truncates a comparison in the last default. Add compiler-backed positive and negative controls. * fix(ingestion): resolve Map entries and qualified nullable overrides * ci: require both compiler checks for coverage reuse * test(bench): verify resolver graph on release corpus * fix(ingestion): preserve scoped call and override identities * fix(ingestion): preserve timer handles and inherited method targets Classify host timer registrations through lexical bindings. Preserve Vue inherited method selection and C++ digit-separated template arguments. Track Babel in the parse cache, skip unnecessary generic substitution work, and verify both frozen graph corpora. * fix(ingestion): preserve module exports and method return types Keep CommonJS wrapper-only exports out of native ES modules. Resolve TypeScript literal method returns by owner and preserve rooted nullable C# generic overrides. Record exact graph equivalence for both frozen corpora. * fix(ingestion): preserve receiver and override targets Separate TypeScript static and instance lookup and retain nullable C# and Kotlin override identity. Make conformance ordering and syntax scanning explicit. Both frozen cache corpora preserve all graph rows and duplicate counts. * test(java): load graph helpers in native Node Use the conformance comparator from a native ECMAScript module. The Java contract runner imports the TypeScript graph helper directly under Node 22. * fix(csharp): resolve named tuple overrides and repair CI checks Compare C# tuple element types and labels in declaration scope and select an eligible inherited method. Cover method arity, accessibility, return conversions and closed slots. Verify raw Git path bytes and preserve Node test registration. Both frozen graph corpora match on the new source trees. * fix(ingestion): preserve CLR override identities and C++ template defaults Resolve predefined C# types in their declaring scope and compare explicit ValueTuple and Nullable return types, including array variance and long tuples. Keep C++ comparison operators intact inside template parameter defaults. Preserve point and range coordinates in the lexical benchmark. Add compiler-backed regressions and record the verified graph equivalence. * fix(ingestion): resolve default classes and namespace aliases Preserve default-class ownership through parentheses and stop at nested anonymous classes. Keep existing CommonJS exports across unrelated property writes. Resolve ambient namespace aliases by public name and preserve type-only visibility. Document receiver filtering and add regression coverage. * fix(ingestion): preserve compiler-selected bindings Filter function-local namespace accesses. Preserve Node setImmediate handles and qualified verbatim C# names. Use each TypeScript project’s optional-property rules for overload selection and verify the resulting call and read edges against the compiler. * test(bench): record frozen graph equivalence Accept the verified source trees for the two existing frozen-corpus expectations. All 1,671,468 graph rows and their multiplicities matched across ten indexing runs; all 78 negative controls rejected altered evidence. * fix(ingestion): preserve template defaults and TypeScript call targets Recover complete C++ template defaults from verified parser spans and retain their source spelling. Resolve intrinsic Set tuple iteration and matching primitive method overloads across union receivers. Add compiler-backed positive and negative controls. * fix(ingestion): address SonarCloud findings in compiler conformance Simplify resolver and conformance code, preserve compiler-selected bindings, and distinguish C++ reference overloads in the graph lookup cache. Record graph equivalence for both frozen benchmark corpora. * refactor(ingestion): simplify four resolver functions Resolve the remaining four hosted SonarCloud complexity findings. Preserve class ownership, narrowing order, tsconfig file selection, and template parameter parsing. Record the matching graph fingerprints for both frozen corpora. --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
12 KiB
Compare call resolution across tools
Use compare.mjs to check whether two tools agree on the declarations selected by calls in the same source fixture. Copy this single file into a checkout with Node.js to use the standalone command. One producer might use a compiler API and the other a language server, an indexer, or a static analyzer.
Generate one JSON report per tool for the same fixture and run the following command. It exits with status 0 on a match and prints missing and unexpected results on a mismatch.
node compare.mjs compiler.json analyzer.json
JavaScript integrations can import compareReports(expected, actual) from the same file. It throws on a mismatch or malformed input.
Report format
For example, save this fixture as main.py.
class Greeter:
def greet(self):
return 42
def entry(self):
return self.greet()
An execution trace of Greeter().entry() can record the following call to greet. An analyzer can produce the same record by inspecting the source.
{
"producer": "Example analyzer",
"sites": [
{
"file": "main.py",
"start": "6:15",
"end": "6:27",
"status": "resolved",
"target": "main.py#2:4"
}
],
"edges": [{ "from": "main.py#5:4", "to": "main.py#2:4" }]
}
- Source range. Report the entire call expression using fixture-relative paths with forward slashes. Lines start at 1. Columns count UTF-16 code units from 0. The end is exclusive. Convert byte offsets or tab-expanded columns in the producer.
- Outcome. A resolved record requires a target. Use a record such as
{"file":"main.py","start":"5:11","end":"5:18","status":"ambiguous"}for an explicit ambiguity. Producers can agree on additional status strings. For multiple observed targets, emit one record per target at the same range. - Declaration identity. Both producers must use the same string for a declaration. The Java adapter uses the fixture-relative declaration file and start position. A fully qualified symbol and signature also work. Optional
descriptiontext gives a human-readable target in diagnostics. - Graph edges. Include
edgesin both reports to compare the published caller-to-callee pairs. Use[]for an observed empty graph. Omit the field from both reports to compare sites alone.
Site records and edges are sets. Order and repeated identical observations have no effect. The reference needs at least one site or edge. Each producer should enumerate its own results over the same fixture and selection rule so missing and unexpected calls remain visible.
The GitNexus adapter uses recorded resolution outcomes and call edges with exact source spans. A caller-to-callee pair without a span contributes to the edge comparison. The comparator reports a missing site if the reference supplies a range that the analyzer cannot establish.
Add a producer
- Choose what the tools can independently observe, such as compile-time overload selection or runtime dispatch on a fixed input. Use the same source snapshot and scope on each side.
- Translate the native source ranges, declarations, and outcomes into reports. A command-line producer can write JSON using its language's standard library.
- Run the comparison and verify that changing one selected target produces a mismatch at the correct source range.
Java fixtures
To add a call-resolution case, put a self-contained Java project under gitnexus/test/fixtures/compiler-conformance/java-<case>/. Write the Java source exactly as it should be analyzed. The runner discovers the directory and sends the same source to JDK 21 and the production GitNexus ingestion pipeline. Each project gets an isolated javac task in one JVM. A single project can exercise several distinct calls on the same line.
Set JAVA_HOME to the absolute path of your JDK 21 installation and run the command from a built gitnexus/ checkout.
npm run test:conformance:java
For example, a fixture can declare pick(Object) and pick(String) and call pick("x"). Javac supplies the selected declaration and source range. CI detects a missing call, an extra call, a different target, or a disagreement about ambiguity or applicability. It compares direct call edges as well. Set implementations to the expected number of class-to-interface method pairs to compare every published METHOD_IMPLEMENTS edge with javac's Elements.overrides result.
The runner also compares source type identities, ordinary method names and counts per file, and direct inheritance between source types. For method references such as User::getName, javac records the source range and selected declaration. GitNexus publishes the caller and target as an aggregate edge, so CI compares those declarations. Projects with constructors: true also check constructor edges, including Type::new, super(...) and this(...). Put explicit constructor overloads on different declaration lines in those projects so each edge has an unambiguous target.
The fixture manifest reuses projects outside the discovery directory and pins the number of compiler sites for migrated tests. A fixture can select method families or compare only type declarations when collapsed overloads give GitNexus a different method inventory. The manifest explains which projects require compiler recovery or product checks because they contain incomplete Java, invalid source layouts, or duplicate types across module boundaries. The runner automatically includes new lang-resolution/java-* source projects. The generated matrix independently pins all 100 argument ranges across 20 overload pairs.
All Java source fixtures run through this command, including inline snippets and virtual projects. Add a Java resolution case as a fixture project so javac supplies its expected target. The resolution checks also handle partially invalid projects, cold and warm parses, and import storage. The provider checks cover parser captures and other GitNexus-specific results. The Spring checks and product checks cover framework behavior, rename, graph persistence, and mixed-language analysis. The conformance command scans Vitest source for Java fixture paths and virtual source maps. It follows literals, aliases and direct local assignments. Vitest also detects Java parsing in process and Java files submitted to the shared worker helper, including those with dynamically computed paths.
For a project with unresolved dependencies, the manifest can specify the exact javac diagnostic codes and counts in diagnostics. The comparison still checks every source declaration and source inheritance edge that javac can attribute. An added or missing diagnostic fails the run.
The Java compiler comparison is strict by default. A difference in a source range, target, rejection, or published edge fails the job and prints the fixture and the two observations. When a fixture selects method families, javac reports overload rejections for those families. Other compilation errors, such as an ambiguous type declaration, still need an exact diagnostic entry.
Each javac task uses the fixture sources, the JDK 21 platform, and an empty application classpath. GitNexus resolves wildcard imports against indexed source packages and known platform types. Adding a dependency JAR to javac's classpath can introduce another type of the same name and change its answer.
The comparison also covers calls in the selected method families that resolve to library code. For example, javac and GitNexus report java.lang.Iterable#forEach(java.util.function.Consumer) at the call site when a JDK list supplies the receiver. Source implementations of forEach contribute their declaration and a call graph edge.
Windows and macOS run node tools/compiler-conformance/java/check-products.mjs --platform from the GitNexus package. This checks rename, worker-cache persistence, the parser ABI, and projects with non-ASCII paths on each platform. The native runner fails if a selected file has no passing tests or contains a skipped case, a todo, or an empty suite.
To compare another analyzer against javac, run the following from this directory. With no method names, the standalone command includes source and library methods. Pass '*' '<init>' to include constructors. In the fixture manifest, omitting families compares method names declared by the fixture, including calls of those names on library types. Set "families": ["*"] to include every library method.
node java/javac-report.mjs /path/to/fixture find resolve count > compiler.json
node compare.mjs compiler.json analyzer.json
The standalone comparator reads sites and edges. The Java report also exposes constructors, heritage, and implementations for consumers that compare those relationships. The Java conformance job compares them with the published graph.
Each methodAccess entry identifies a source method by file, line, and column. Its isPublic field includes methods that Java makes implicitly public. Projects that compare method declarations check this flag against the graph's isExported property.
TypeScript fixtures
After npm run build, run node tools/compiler-conformance/typescript/check.mjs from gitnexus/. It runs the native controls, then compares every registered project. Pass a project directory to run the controls and compare just that project. CI invokes the same command through npm run test:conformance:typescript. Add new source projects under test/fixtures/compiler-conformance/typescript-<case>/. The runner also compares existing projects listed in typescript/projects.json.
The oracle uses the TypeScript compiler installed by the package lock. It reads the fixture's tsconfig when present. Projects without a config use strict checking and bundler module resolution. The compiler and GitNexus read the same source. For npm workspaces, the compiler gets a temporary copy with the local packages linked.
For generic classes, the runner compares each type parameter's name, constraint, and default in declaration order. It joins the parameters from GitNexus scope resolution to the published class by source location.
Each call comparison checks the source range and the selected declaration, including overloads. The runner separately compares published calls by caller, stored range and target. A class method's published identity encodes its owner, staticness and complete property name as a JSON tuple. Runtime interface-dispatch edges have their own product assertions in test/integration/resolvers/typescript.test.ts. The runner also compares graph edges for imports, named types, inheritance, overrides, and interface implementations. The declaration inventory compares named functions, classes, interfaces, and their methods in the projects listed for that check. Negative controls deliberately swap same-named targets and verify that the comparison fails.
Fixtures that exercise compiler recovery declare their expected diagnostics in typescript/diagnostics.json. For example, TypeScript 7 reports two configuration errors in the legacy baseUrl fixture. Unlisted or missing diagnostics fail the job. For a type-only import used as a constructor, the runner checks that GitNexus leaves the call unbound. Annotated receivers still have compiler-selected methods.
Three projects listed under diagnosticsOnly also pin compiler diagnostics. Their runtime graphs have separate Vitest suites in test/integration/resolvers/. typescript-callable-alternatives follows possible runtime callees, typescript-hof-callbacks attributes callbacks passed to higher-order functions, and typescript-hoc-wrapped publishes wrapper-bound functions. The default command labels these projects separately. Passing one of their directories explicitly runs the full graph comparison and reports the differences.
For a call through an identifier with an inline function-type annotation, the compiler report records the parameter declaration and its annotated signature. Calls on an unchecked receiver can have no compiler-selected declaration. The comparison records those locations separately.
To use the TypeScript producer with another analyzer, run the following from gitnexus/ using a project that passes type checking. Both reports use the format described above.
node tools/compiler-conformance/typescript/compiler-report.mjs path/to/project CALLS > compiler.json
node tools/compiler-conformance/compare.mjs compiler.json analyzer.json