codemap icon indicating copy to clipboard operation
codemap copied to clipboard

accuracy(Java): measure import graph accuracy and close gaps below 90%

Open JordanCoin opened this issue 1 month ago • 1 comments

Part of #237.

Starting estimate: near 0% recall. This is an unmeasured guess.

Measure

Run codemap on real Java repositories at pinned commits and compare it to ground truth.

  • Suggested ground truth: jdeps or javac -verbose.
  • Report: recall, precision, and whether the coverage status was honest for each file.

Likely gaps to check

same-package references, imports naming classes that map to files, wildcards.

Done when

  • Repositories, commits, method and numbers are recorded here.
  • Each miss has a root cause.
  • Recall is at or above 90%, or the remaining gap is one codemap cannot close and its coverage status says so.

JordanCoin avatar Nov 01 '26 11:11 JordanCoin

Java: file-to-file import graph measurement (#252)

Predictions below are predictions from a throwaway script, not measurements of a shipped resolver. Current-graph numbers are measured with codemap 4.6.3.

Repos (shallow clones)

  • google/gson @ 57731049da3e415be3d5d34db1ca3b80f3c73810 (264 Java source files)
  • apache/commons-lang @ b8726053b685e80ea27f10a09fbb53f6022be46e (630 Java source files)

Method

  • Sample: 30 files per repo, seeded random sample (Python random.Random(42).sample over sorted tracked files; not shuf), tests included.
  • Ground truth G: NOT hand-built for all 300 files. G is a script-built proxy: explicit imports resolved to project files via a package/namespace/module index, plus same-package (C#: same and parent namespace, used namespaces; Elixir: alias-expanded dotted module references) type-name tokens in comment- and string-stripped code. I hand-checked 3 files (oban engine_bench.exs, MediatR Mediator.cs, cats FunctionK.scala) and they looked right; G may still contain token collisions (over-count) and miss top-level function use, macros, implicits (under-count). Treat G as a sample proxy.
  • Current graph: codemap --json --importers <T> for every G target and sample file plus 40 random files; an edge S->T counts as recovered if S is listed in importers(T). .codemap/config.json only list includes the language extension in every repo (not hiding it).
  • (a) fully qualified import mapped to path by convention (Java/Kotlin/Scala a.b.C to a/b/C.<ext> with prefix walk; C# namespace to directory suffix; Elixir Foo.BarBaz to foo/bar_baz.ex).
  • (b) Swift-style: any identifier (len>=3) in the file (import lines removed, comments and strings kept, as Swift does) equal to a type declared in another file, all declarers become targets. (b-uniq) same but only names declared in exactly one file.
  • False edge = predicted edge not in G. Because G is a proxy, some false edges may be real and vice versa.

Current graph (measured)

repo files G edges current recovered recall partial on sampled files
j-gson 264 152 0 0% 30/30
j-lang 630 83 0 0% 30/30

Precision of current edges: not measured (importers queries only reveal edges into queried files; every recovered edge I could see was in G). Honesty: coverage_status was partial with a symbol-imports note on 30 of 30 sampled files in every repo, so no sampled file claimed completeness.

Predicted recovery on the same sample (prediction)

repo G (a) true (a) recall (a) false (b) true (b) recall (b) false (b) precision (b-uniq) true (b-uniq) recall (b-uniq) false
j-gson 152 101 66% 0 152 100% 73 68% 147 97% 25
j-lang 83 39 47% 0 81 98% 89 48% 69 83% 46

What blocks 90%

  • Current Java importers are empty: no codemap --importers result in either repo listed any importer (0 of 235 G edges recovered). Java gets no FQN mapping today, though (a) alone would recover about half.
  • Blocker 1 (about 40-50% of edges): same-package references need no import (gson: 53 of 152 G edges). Needs a package index (package line + top-level type names). Medium.
  • Blocker 2: explicit imports to a path convention work for Java (a) but wildcard imports (a.b.*) and static imports of nested members need a prefix walk. Small.
  • A name-only index (b) over-matches on common nouns and cross-package same-name types (commons-lang: 89 false vs 81 true). A package-scoped index (same package + imported packages) is what the proxy G does and would be near-exact for Java. Fix size: medium (package-scoped type index), small if only (a).
  • 90% reachable: yes with package-scoped index; not with (a) or (b) alone.

Scripts: (res.py, run.py, cur.py, gen.py); raw edges in out.json.


Measured with codemap 4.6.3. Ground truth here is a script-built proxy with three files hand-checked. Predicted numbers are predictions, not measurements.

JordanCoin avatar Nov 01 '26 11:11 JordanCoin