codemap icon indicating copy to clipboard operation
codemap copied to clipboard

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

Open JordanCoin opened this issue 1 month ago • 1 comments

Part of #237.

Starting estimate: 70-85% recall. This is an unmeasured guess.

Measure

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

  • Suggested ground truth: clang -MM with compile_commands.json.
  • Report: recall, precision, and whether the coverage status was honest for each file.

Likely gaps to check

include directories known only to the build system, generated headers, modules.

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

C++ import-graph accuracy (#243)

codemap 4.6.3. Samples, not full-repo numbers. 60 files per repo, seeded (random.seed(42)), .cc/.h/.cpp/.inc.

Repo SHA Shape
google/leveldb bb74ef739973a70ca9f0d90788a1da89b788c0ad include/leveldb/ public headers, db/ table/ util/ port/ (build: include_directories(. include))
abseil/abseil-cpp 4ce33a3b8a55d727ccb50d4134f869d1689039f2 single absl/ tree rooted at repo root (-I.), 1612 files, many std-named headers (utility, memory, type_traits)

Method: ground truth = clang -E -H -w -std=c++17 -I<dirs> direct includes inside the repo (leveldb -I. -Iinclude; abseil -I.). Same caveats as the C report: clang -H hides guard-deduplicated direct includes, so every codemap edge absent from truth was checked against the file's textual #include lines resolved by same-dir/-I rules. Only host (macOS) active branches are in truth.

Repo sample truth edges codemap edges recall not in clang truth textually valid precision (valid / codemap) coverage_status
leveldb 60 159 200 159/159 = 100% 41 41 200/200 = 100% complete 60/60
abseil-cpp 60 167 362 163/167 = 97.6% 199 152 (163+152)/362 = 87.0% complete 60/60

Honesty: abseil has 4 misses and 47 false positives, all reported complete. The misses are the worst case (miss under complete).

Root causes, ranked by edges

  1. 47 false-positive edges (abseil): #include <utility>, <memory>, <type_traits>, <variant>, <optional>, <any>, <algorithm> resolve to project files absl/utility/utility.h, absl/memory/memory.h, absl/meta/type_traits.h, absl/types/variant.h, absl/types/optional.h, absl/types/any.h, absl/algorithm/algorithm.h. Example: absl/strings/str_replace.h:44 #include <utility> -> absl/utility/utility.h. 15 of 47 inspected by name; all were this pattern, the remaining 32 were not individually checked. Code: scanner/filegraph.go:1026 trySuffixMatch appends resolver extensions (.h) to the extensionless std name and suffix-matches. Fix: small (skip extensionless angle includes unless an exact extensionless file exists).
  2. 4 lost edges (abseil): absl/debugging/symbolize_darwin.inc is not treated as a source file (no .inc language mapping found in scanner/*.go or sg-rules), so its four includes (raw_logging.h, demangle.h, numbers.h, str_cat.h) are dropped, while --importers still says coverage_status: complete. Fix: small for mapping, but the honesty issue is separate: unknown-language files should not be complete.
  3. Not an error: leveldb's 41 and abseil's 152 "extras" are real includes hidden from clang -H by include guards (or inactive #if branches). leveldb and its public include/leveldb/ layout resolved perfectly.

Scripts: local scratch dir/lang/scripts/cmp2.py, an.py. Raw: local scratch dir/lang/out/{leveldb,abseil-cpp}.json.


Measured with codemap 4.6.3. Sampled numbers are samples, not a census.

JordanCoin avatar Nov 01 '26 11:11 JordanCoin