accuracy(Ruby): measure import graph accuracy and close gaps below 90%
Part of #237.
Starting estimate: 50-70% recall. This is an unmeasured guess.
Measure
Run codemap on real Ruby repositories at pinned commits and compare it to ground truth.
- Suggested ground truth: Zeitwerk eager load or a constant-reference sample.
- Report: recall, precision, and whether the coverage status was honest for each file.
Likely gaps to check
Rails and Zeitwerk autoloading, require with load path, whether coverage wrongly reads complete.
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.
codemap 4.6.3 import graph accuracy: Ruby (#244)
Repos (shallow clones, never executed):
- jekyll/jekyll @ 97c3bdc822df9d5bea4c269b29a28de5a5e29d70 (gem, 162 .rb)
- maybe-finance/maybe @ 77b5469832758d1cbee1a940f3012a1ae1c74cd3 (Rails app with Zeitwerk, 794 .rb). Chosen over mastodon (3355 files, over the cap).
Config
onlyincludesrbin both.
Methods differ per repo.
- jekyll: FULL census. GT = Ruby
Ripper.sexpwalk forrequire,require_relative,load,autoloadwith literal args (command form only;require("x")with parens is not in my GT, so GT is a slight undercount), load roots lib/, test/, repo root. Constant references are NOT counted here, so true recall is lower than shown. - maybe: SAMPLE of 40 files (seeded
shuf,sort | shuf --random-source=<(yes 240) -n 40over app/ and lib/). GT = Ripper-extracted constant refs (const, A::B, superclass) resolved by Zeitwerk naming (app/, app//concerns, lib; lexical nesting, longest prefix) + require_relative. Automated, spot-checked by reading ~5 (e.g. chats_controller.rb< ApplicationController), not read line by line. Inflection overrides (API vs Api) ignored. These are samples. Codemap edges = inverse of--importersfor every file; for maybe the importer scan covered 96 files before I stopped it, and--depsraw imports for all 38 sampled indexed files are empty, so codemap's outgoing edges from the sample are 0 (not a sampling artifact).
| repo | GT edges | codemap edges | true pos | recall | precision | coverage_status |
|---|---|---|---|---|---|---|
| jekyll (full, require/autoload only) | 121 | 78 | 71 | 58.7% | 91.0% (7 FP unverified, likely my GT gap) | complete on 155/155 |
| maybe (sample, 40 files, constants) | 72 | 0 | 0 | 0/72 = 0% | undefined (no edges) | complete on 96/96 queried |
Honesty: worst case confirmed. Every file reports complete while edges are missing. Concrete: codemap --json --importers lib/jekyll/cache.rb -> importers null, coverage_status complete, though lib/jekyll.rb autoloads it and Jekyll::Cache is used widely. Same for app/models/account.rb and family.rb in maybe.
Root causes ranked by edges lost:
- Zeitwerk/autoload constant references not modelled (72 of 72 sampled maybe edges; all models/controllers/components deps). scanner/sg-rules/ruby.yml only matches
requireandrequire_relativecalls. Example: app/controllers/chats_controller.rb:1class ChatsController < ApplicationController. Fix: large (autoload roots + constant resolution + inflections; at minimum small: reportpartialwhen a Rails/Zeitwerk app is detected). autoload :X, "path"ignored: 50 misses in jekyll (44 in lib/jekyll.rb:44+, 6 in lib/jekyll/utils.rb). Fix: small (addautoloadto ruby.yml, resolve second arg like require).- Coverage honesty:
completewhen only require forms are indexed. Fix: small (downgrade to partial for ruby when constants unresolved).
Measured with codemap 4.6.3. Sampled numbers are samples, not a census.