Documentation

Docs / Reference

ADR 0067 - Java, C# and Dart best-effort tier

Status: Accepted (delegated review, 2026-11-16) Date: 2026-11-16

Task: the T021 task record (internal) (claim contract, open points O1-O14); counts: the T021 task record (internal). Written in the investigation; implementation steps add implementation notes. Where an open point is still undecided, this ADR records its provisional default.

Context

Milestone M2 (item 6) of the project plan moves the Java/C#/Dart best-effort tier into v1 (developer decision 2026-11-09): bundled grammars through the existing WASM build, checksum and licence pipeline, and structural extraction of files, types, functions and imports labelled best_effort, without calls, cross-file symbol resolution, build files or frameworks. ADR 0002 chose upstream tree-sitter in WASM through wasitter/wazero without cgo; ADR 0006 defines shared compilation, isolated workers and the compilation cache namespace; ADR 0007 owns the CI build of non-upstream modules and recorded that the C# and Dart modules (CI run C, 37428985231) load and match their goldens; ADR 0008 and ADR 0028 registered the current seven production modules by copying audited spike assets. The scanner already labels .java files java, .cs files c_sharp and .dart files dart, all with precision: "best_effort", and emits them as file nodes only.

Options considered

Grammar assets

Recovered trees

Import resolution

Decision

  1. Grammars: option A. Register the audited Java and C# modules byte for byte from spike/parsing/grammars/, and the Dart module byte for byte from its reviewed Grammar assets artifact:

    Language Source pin ABI Module SHA-256 Bytes Toolchain
    Java tree-sitter/tree-sitter-java v0.23.5 14 bdafeee7af6963461de9498f22f9e0a1893a2196bb410f20941a55fab0e24e88 641,890 wasitter v0.1.0 release, Zig 0.15.2
    C# tree-sitter/tree-sitter-c-sharp v0.23.5 15 9075c0442ff28ddd2d0c368994aad2b26de4d79f08df5a22383290ef46208bcf 5,572,871 run C, WASI SDK 25.0 clang 19.1.5 (external scanner)
    Dart UserNobody14/tree-sitter-dart 0038280b774b65c1b89ba7fec50624d8baed9fe1 (2026-10-18; developer decision O1 (b)) 15 ff84ee67832448ba4187f05adb9c991c3bbd7e1fc4e8f5761f94c6daa22e302b 1,441,929 Grammar assets run 43909359868, WASI SDK 25.0 clang 19.1.5 (external scanner), as run C

    All three are MIT-licensed (Dart: MIT source text, ISC package metadata, handled as in ADR 0007). The production loader verifies each digest before compilation. This amends ADR 0006's asset list and moves the compilation cache namespace to wasitter-0.1.0-assets-v4; the runtime stays wasitter v0.1.0 / wazero v1.10.1; no cgo, download or installation. The aggregate extractor version is bumped once the extractors land. Java's grant is already in THIRD_PARTY_NOTICES.txt; c_sharp-LICENSES.txt, dart-LICENSES.txt and the two build records are copied with the modules. Dart follows option B (developer decision O1, 2026-11-16): the superseded audited pin be07cf7 (module 5812b5b4..., 1,398,462 B) is not registered; the 0038280 module is built by the grammar CI workflow and reviewed per ADR 0007 before it is copied in (done in T021-B1, see the implementation notes).

  2. Recovered trees: option A (row BE-2). The file keeps its file node and the existing syntax_error warning, which already marks it as a knowledge gap. Parse and extractor failures stay per-file diagnostics. Known clean misparses of the pinned Dart grammar on Dart 3.13 concise constructors are refused by guard rows DA-G1 and DA-G2. (With 0038280 the DA-G1 misparse no longer occurs and the DA-G2 shape is an ambiguity rather than a misparse; whether B4 keeps both guards is open, see the implementation notes.)

  3. Structure. Level-4 symbol nodes, contained by their nearest emitted lexical owner:

    Language Types (kind) Callables (kind) Not emitted
    Java class, interface, enum, record, @interface (annotation); nested and local types methods and annotation elements (method), constructors and compact constructors (constructor), Java 25 program-level methods anonymous-class and enum-constant bodies, fields, initializers, enum constants, record components, modules
    C# class, struct, interface, record (record struct: attribute struct), enum; partial attribute methods, destructors, operators (method), constructors (constructor), local functions (function), properties and indexers (property) delegates, events, fields, enum members, accessors, lambdas
    Dart class (incl. mixin class, mixin applications), mixin, extension (anonymous: extension on <T>), extension type, enum top-level functions, getters and setters (function), members (method, setters named x=), constructors (constructor, unnamed new), local functions (function) typedefs, variables, enum values, function expressions

    Spans are the declaration node (Java and C#: modifiers, annotations and attributes included, doc comments excluded); Dart members and top-level functions run from their preceding annotations to the end of the sibling function_body, or to the ; of a bodyless declaration. Java packages and C# namespaces are not owners. Java/C# overload sets append @overload(<parameter types>); C# explicit interface implementations append @<interface>; repeated names use the house @2/@3 rule.

  4. Imports: option A. Java JV-I2-I4 resolve to the one file declaring the fully qualified type name; ambiguous names give ambiguous_import; undeclared names under a repository package give unresolved_import; others are java: externals. C# usings never resolve to files: usings of repository namespaces produce nothing, others are dotnet: externals. Dart: dart: externals; relative URIs and own-package package: URIs resolve to scanned files (unresolved_import when missing); other repository packages produce nothing; unknown packages are pub: externals; every conditional alternative is followed without evaluation; part is an imports edge, part of none. The only build-file read is the top-level name: of scanned pubspec.yaml files.

  5. Precision labels. Files keep precision: "best_effort"; nodes follow T020's representation if it adds one, otherwise carry none. T020 must not label these languages precise.

  6. Contract v1, the storage schema, the store interface, dependencies and the server/web are unchanged.

Consequences

Known gaps

Implementation notes

T021-B1 (grammar registration, partial). Java and C# are registered: wasitter-java.wasm, wasitter-c_sharp.wasm, c_sharp-LICENSES.txt and c_sharp-build.json copied byte for byte from spike/parsing/grammars/ into internal/parse/grammars/, their digests added to SHA256SUMS and the loader's checksums map, and the compilation cache namespace moved to wasitter-0.1.0-assets-v4. This amends ADR 0006's asset list and cache namespace (as ADR 0028 did for v3). internal/index supported() is unchanged, so neither language is parsed during indexing yet.

Binary size with Java and C# only (CGO_ENABLED=0 go build ./cmd/graphvein, Go 1.27.1, against b8af787): linux/amd64 53,764,627 to 59,981,395 B (+6,216,768); windows/amd64 54,091,776 to 60,307,968 B (+6,216,192); darwin/arm64 51,699,970 to 57,974,594 B (+6,274,624). The two modules total 6,214,761 B.

T021-B1 (Dart). The manifest's Dart row moved to 0038280 with the developer-supplied source archive digest 7d9f51b4ff20756a21935ce69a2386e6db1e2fda325835d41790e745270e0db8 (LICENSE at 0038280 is identical to grammars/dart-LICENSE.txt; grammars/NOTICES.md follows the pin). Grammar assets run 43909359868 (commit 062c52c) built the four CI grammars. Artifact review per ADR 0007: sha256sum -c SHA256SUMS passes for every file; --check-paths finds no host path in any module; the HTML, Angular and C# modules are byte-identical to the run C copies in spike/parsing/grammars/ (Angular and C# also to the production copies), so the pipeline is unchanged; manifest.yaml, NOTICES.md, UPSTREAM_NOTICES.txt, LLVM-LICENSE.txt and WASI-SDK-NOTICES.txt equal the committed files; dart-build.json records the new source digest, ABI 15 and the same toolchain fields as run C. dart-LICENSES.txt (the MIT LICENSE and the nested tree_sitter/LICENSE) is byte-identical to the be07cf7 run C copy. wasitter-dart.wasm (1,441,929 B, SHA-256 ff84ee67...e302b), dart-LICENSES.txt and dart-build.json are copied byte for byte into internal/parse/grammars/ and registered in SHA256SUMS and the loader's checksums map, in set v4.

Probes against the built module (TestDartModernConstructorShapes): every Dart 3.12/3.13 form parses without ERROR or MISSING. Primary constructors are a primary_constructor field on class_definition / enum_declaration (named ones carry a name field, class const P(...) a const_builtin); class Empty; is a bodiless class_definition; the primary constructor body this : ...; is a primary_constructor_body_signature. new named(); is a constructor_signature with an anonymous new token and one name field, so the DA-G1 shape (function_signature returning new) no longer occurs; it differs from the classic Classic(); only by that token. new(); / const new(); have no name at all. factory make() is still a factory_constructor_signature with one identifier, the same shape as the unnamed factory Classic(): DA-G2's form is now valid Dart 3.13 that only a comparison with the enclosing type's name can tell apart. Neither is a silent misparse any more, but both are silent shape ambiguities for an extractor written against be07cf7. Classic const C.c() now exposes its identifiers as name fields (they were plain children). The localsend re-census is identical to the be07cf7 census (see the T021 task record (internal)).

Binary size with Java, C# and Dart (CGO_ENABLED=0 go build -buildvcs=false ./cmd/graphvein, Go 1.27.1, both sides built the same way, against b8af787): linux/amd64 53,764,243 to 61,428,627 B (+7,664,384, within the 7.7 MB gate); windows/amd64 54,093,824 to 61,753,344 B (+7,659,520); darwin/arm64 51,699,970 to 59,427,682 B (+7,727,712). The three modules total 7,656,690 B.

T021-B2 (shared kit and Java). internal/lang/besteffort holds the shared rules: BE-2 over the detached tree (Recovered: an ERROR node or a named zero-width node) plus Refuse, which the indexer also applies when only the parser's syntax flag is set (an unnamed MISSING token is dropped from the detached tree); the declaration forest with BE-4 containment, BE-6 overload and BE-5 repeated-name naming; the type-text and span helpers; and the claim-contract table type. internal/lang/java implements rows JV-*; its per-file payload is the new optional facts.BestEffortFacts (version 1: refused flag, package, importable type paths, import directives as written), so linking re-resolves every importer from the cache. The aggregate extractor version is extractors-38 (main held extractors-37; the number is re-checked at merge). Java joins supported(); C# and Dart do not yet. Choices made where the contract was silent, all recorded in docs/lang/best-effort.md: a receiver parameter is not part of the BE-6 type list (it is not part of a Java signature); a compact canonical constructor takes the record header's types; JV-T6 also covers local classes in lambdas and initializers below a type (javac agrees); JV-I7 applies when the imported type name or any dotted prefix of it is a scanned package; a type declared only in a refused file is invisible to resolution (T021-B3 closes the consequence with row BE-8, below). The javac oracle (scripts/oracle/java_decls.sh) agrees on kind, owner path, start and end for 43 of 43 fixture declarations, 4,279 of 4,279 on spring-modulith and 12,719 of 12,719 on commons-lang; the row counts on both corpora equal the investigation's inventory.

T021-B3 (C#, and the shared row BE-8). Precision fix first: B2 let a type declared only in a refused (BE-2) file fall through to a java: external, labelling a repository type as an external dependency. New shared row BE-8 (besteffort.Hidden, besteffort.HiddenImport): while the repository has a file of the language that is refused (BE-2) or has no valid payload because parsing or extraction failed (BE-3), an import or using that would otherwise be external (JV-I8, CS-I2) is an unresolved_import warning naming a hidden file, with no external node and no edge. There is no JDK/BCL allowlist, since a hidden file could declare anything. The Java fixture (two BE-2 files) loses its four java: externals and five import edges to five warnings; a second root, testdata/fixtures/java-best-effort-external/, keeps JV-I8 covered.

internal/lang/csharp implements rows CS-*. The payload gains C# fields (Namespaces, GlobalTypes; per using Alias, Scope, Prefixes) in the same facts.BestEffortFacts version 1; besteffort.Decl gains Suffix for C# discriminators (@IFoo, @static, `N), which are part of the segment that BE-6 groups by. C# joins supported(); extractors-38 is unchanged on this branch (one bump per merge). Contract changes, all refusals (no new claim), recorded in docs/lang/best-effort.md and for the developer's review:

eShop census (real extractor and linker, scratch; not an oracle): every symbol row equals the investigation's inventory (2,458 symbols); CS-I1 402 (+1, the nested-type alias above), CS-I3 10 (from the investigation's CS-I2), BE-8 499 (all remaining would-be CS-I2, since eShop has two BE-2 files), CS-I2 0, CS-G1 0. No C# oracle (O13 (a)).

T021-B4 (Dart, and the BE-8 refinement). BE-8 first (decision, precision-safe): a refused file now hides only the names its raw text proves it can declare (besteffort.Scope, Occurrences, Hider, Hiding; java.RefusedScope, csharp.RefusedScope; the payload's Scoped/Scopes, absent in older payloads, which keeps them hiding everything). The scan counts every whole-word keyword, in comments and strings too, so it only over-matches. Java: every package <name> found hides names equal to or under it; no occurrence means the unnamed package, whose types no import can name (JLS 7.5; javac 21 rejects import C;, import C.D;, import C.*; and import static C.m; for a class C in the unnamed package, checked in scratch), so such a file hides nothing. C#: only when every namespace keyword is a file-scoped declaration (namespace X;: at most one per file, before every type, never with a block namespace; CS8954-CS8956, not compiler-checked here) does it hide just names equal to, under or a dotted prefix of X; otherwise any name, as before. A \u escape in the text, or a failed file, proves nothing. The Java fixture's refused files now hide only com.acme.secret.Vault, so its JV-I8 externals return; the C# fixture's refused file-scoped Broken.cs hides only Shop.Hidden names, so its CS-I2 externals return; a new root testdata/fixtures/csharp-best-effort-hidden/ keeps the block-namespace case. eShop: 0 of the 499 BE-8 warnings return (its gRPC Basket.cs has a block namespace; MauiProgram.cs's file-scoped eShop.ClientApp hides none of them on its own).

internal/lang/dart implements rows DA-* for the 0038280 grammar, replacing the investigation's DA-G1/DA-G2 guards (written for be07cf7) as decided in T021-B1's open point, option (b): DA-C2 claims constructor_signature / constant_constructor_signature with the anonymous new token (unnamed new without a name field, else named), DA-C3 claims a factory with no identifier (new) or with one identifier that differs from the enclosing type's name (named); DA-C1 keeps the classic forms but requires the first identifier to equal the type's name. The fixture covers the token check (new named()) and the name comparison (factory make() against factory Classic()). Precision stop S2 found while probing: 0038280 parses an untyped method (foo();, foo() {}) without an error as a constructor_signature named foo; the rewritten DA-G1 refuses every constructor signature whose name does not match (subtree skipped), and DA-G2 does the same for factories (not valid Dart). Other choices recorded in docs/lang/best-effort.md: DA-S includes a top-level external keyword (a program token outside the signature) and extends a bodyless top-level signature over its ;; anonymous extensions keep one space between two word characters of the on-type (extension on void Function()); DA-I4 also covers an unknown pubspec name (a package: URI that could name it claims nothing and no pub: external is emitted); self-imports give no edge; query, fragment, adjacent-string and triple-quoted URIs are DA-I8. BE-8 does not apply to Dart. The payload gains BestEffortImport.Directive; dart.PackageNames reads each scanned pubspec.yaml's first unindented name: line at link time. Dart joins bestEffort() (so supported(), the cache check and BE-2 apply); extractors-38 is unchanged on this branch. localsend census (real extractor and linker, scratch; not an oracle): every row equals the investigation's inventory, and the 34,221 declarations equal the investigation's prototype after its naming (constructors new, setters =), except 6,346 bodyless spans that now include their ; (DA-S), 7 anonymous-extension names (the investigation kept only the first word of the on-type) and 5 repeated local functions that BE-5 numbers. No Dart oracle (O13 (a)).

T021-B5 (corpora, gates, and BE-8 for block-namespace C# files). BE-8 first (decision, B4's open point option (b), precision-safe): a refused C# file with block namespaces (or a mix), or without any namespace keyword, now gets a Global scope (besteffort.Scope.Global, payload BestEffortFacts.Global, omitted when false so older payloads stay hide-all): it hides plain usings equal to, under or a dotted prefix of a namespace name found lexically (a nested block's composite name is under its outer name) and every static and alias using, which may name a global-namespace type. The rule rests on ECMA-334 §7.8.1 (a plain using's name shall refer to a namespace; CS0138) and §14.2-14.3 (only namespace declarations declare namespaces; other members are in the global namespace); no compiler was run. A \u escape, a verbatim name after namespace and failed files still hide everything. eShop: CS-I2 0 to 495, BE-8 499 to 4 (its four alias usings). Corpora: scripts/cloud-corpus.sh pins spring-modulith, eShop, localsend and commons-lang (O13); GRAPHVEIN_BESTEFFORT_CENSUS_CORPUS-gated census tests per language equal the inventory; TestJavaDeclsOracleCorpora (GRAPHVEIN_JAVA_ORACLE_CORPUS) runs the javac oracle on both Java corpora: 4,279 and 12,719 declarations, 0 disagreements. Gates against the merge base a2979584: the 23 existing corpora's snapshots and SQLite sizes are identical apart from the version string; Langflow, kaneo, umami and seerr fresh and warm medians are within 10 %; the self-index adds only the Java, C# and Dart files' records. Binary growth on linux/amd64 is +7,876,270 B (the three modules plus about 0.2 MB of extractor code), above the 7.7 MB gate read as 7,700,000 B and below it read as 7.7 MiB (open point in the T021 task record (internal)). localsend's generated Dart is 78 % of its nodes and 73 % of its store (O9 (a) kept).

T021-F1 (review fixes). Two contract changes chosen after the T021 review (the T021 task record (internal)). C#: new row CS-I4 (option (b)). A using that CS-I1 and CS-I3 do not match, and that has a proper dotted prefix of two or more segments which is a declared namespace or a prefix of one, is an unresolved_import warning naming that prefix. It is no longer a dotnet: external. The repository may declare that namespace outside .cs files: Razor components get theirs from the project's root namespace and folder (eShop's using eShop.WebApp.Components;), and .proto files and source generators add theirs at build time. CS-I4 takes precedence over BE-8. On eShop, 33 of the 146 dotnet: nodes become warnings (95 usings; 3,644 to 3,611 nodes, 3,193 to 3,098 edges, 18 to 113 diagnostics). Java's JV-I7 already covers the case where a declared package encloses the name (Known gaps). Dart: DA-C1, DA-C2 and DA-G1 now look at the token before new. With a . before it, C.new() and const C.new() are the unnamed constructor C.new (DA-C1), the identity C() gets; Other.new() is refused (DA-G1). Only a new without a . before it is the concise form (DA-C2). Before this change C.new() was named C.C. The binary size gate was raised to 8.0 MB (8,000,000 B): the investigation's 7.7 MB estimate covered the grammar modules only and left out about 212 KB of extractor code, and no part of the contract could be dropped. Growth at the F1 head is in the T021 task record (internal).

Review notes (2026-11-16)

Accepted after delegated review on 2026-11-16.

Report a problem with this pageSource: docs/adr/0067-java-csharp-dart-best-effort.md