codemap icon indicating copy to clipboard operation
codemap copied to clipboard

coverage is reported at scan granularity but consumed at query granularity

Open JordanCoin opened this issue 3 months ago • 0 comments

Design issue behind #106/#107, worth separating because the fix is a contract change rather than a relabel.

The mismatch

Coverage today is a property of the whole scan: "this repo contains Rust, therefore partial." But callers consume codemap one query at a time — --importers <file>, get_importers, blast radius for a specific path.

So in a Go + Rust monorepo:

$ codemap --importers config/config.go
⚠️  HUB FILE: config/config.go
   Imported by 22 files
Coverage: partial — Rust macro-generated, string-routed, and #[path] module edges may be unresolved

That caveat is true about the repo and useless about the answer. Nothing in config/config.go's import graph is affected by Rust macro expansion. A caller can't tell whether the gap touches this result or some unrelated crate three directories away.

Why it matters more as a primitive than as a CLI

A human skims the caveat and moves on. An agent has to make a decision: do I trust this blast-radius list enough to skip a manual check? If coverage is partial on essentially every query in any polyglot repo, the honest answer is always "maybe", and callers learn to ignore the field entirely. A signal that's always on is the same as no signal — and it's worse than none here, because it was added specifically to be trusted.

Suggested direction

Make coverage answer the question the caller actually asked:

  1. Per-result coverage — when answering for file X, report only the gaps that could affect X's edges (its language, its resolver, the manifests in play). A Go file in a mixed repo should read complete.
  2. Scan-level coverage stays as a rollup — still useful for --deps over a whole project, still the right shape for DepsProject.Coverage.
  3. Per-edge provenance where cheap — which resolver produced each edge (cargo-metadata, js-workspace, fuzzy). That also makes "why does codemap think A imports B?" answerable, which is currently guesswork.

Relationship to the open issues

  • #106 (ast-grep mislabeled mixed with a Rust caveat) is the sharpest instance: an unrelated source gets tagged degraded because Rust exists somewhere in the tree. Fixing #106 narrows the blast radius of the mislabel but does not fix the granularity.
  • #107 (duplicate note) is downstream of #106.

Both are worth fixing on their own; this issue is the reason they keep recurring.

Reclassification note

#106 and #107 were filed as cosmetic on the assumption the reader is human. If the consumer is an agent parsing coverage.sources[] and coverage.notes[], a duplicated note is a malformed payload and a misattributed source is wrong data. Suggest treating them as data defects rather than presentation nits.

JordanCoin avatar Aug 08 '26 15:08 JordanCoin