accuracy(Kotlin): measure import graph accuracy and close gaps below 90%
Part of #237.
Starting estimate: near 0% recall. This is an unmeasured guess.
Measure
Run codemap on real Kotlin repositories at pinned commits and compare it to ground truth.
- Suggested ground truth: Compiler output or a symbol-reference sample.
- Report: recall, precision, and whether the coverage status was honest for each file.
Likely gaps to check
same-package references, top-level functions, imports mapping to files.
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.
Kotlin: file-to-file import graph measurement (#253)
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)
- ktorio/ktor @ b7809b1eb47ec68cbb9c78a52a23880caca710cd (2435 Kotlin source files)
- InsertKoinIO/koin @ d486a5e8748f90db43f939e227083f2bd2c47c12 (505 Kotlin source files)
Method
- Sample: 30 files per repo, seeded random sample (Python
random.Random(42).sampleover sorted tracked files; notshuf), 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.jsononlylist includes the language extension in every repo (not hiding it). - (a) fully qualified import mapped to path by convention (Java/Kotlin/Scala
a.b.Ctoa/b/C.<ext>with prefix walk; C# namespace to directory suffix; ElixirFoo.BarBaztofoo/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 |
|---|---|---|---|---|---|
| k-ktor | 2435 | 103 | 2 | 2% | 30/30 |
| k-koin | 505 | 124 | 40 | 32% | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| k-ktor | 103 | 2 | 2% | 0 | 100 | 97% | 210 | 32% | 48 | 47% | 101 |
| k-koin | 124 | 40 | 32% | 1 | 71 | 57% | 158 | 31% | 40 | 32% | 17 |
What blocks 90%
- Kotlin already resolves some edges: koin 40 of 124 (32%), ktor 2 of 103 (2%), the 40 matching exactly the (a) count for koin. Cause not investigated (inference: an existing generic import-to-path pass).
- Blocker 1 (koin: 53 of 124 G edges): imports of top-level functions/properties (
import org.koin.dsl.module) have no type to match and no file named for them. Needs a top-level symbol index. Medium. - Blocker 2 (ktor): multiplatform source sets (
common/jvm/posixwith the same FQN in several files,expect/actual) give 1-to-many targets; wildcard imports (73 of 103 G edges via package wildcard). Needs package-scoped resolution. Medium. - Name-only (b) is noisy: 210 and 158 false edges in 30 files. Unique-only halves recall.
- 90% reachable: with package-scoped type + top-level symbol index. Fix size: medium.
Scripts:
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.