Skip to content

coverage: ast-grep reports mixed carrying a Rust-specific caveat #106

Closed

Description

@JordanCoin

Split out of #105 review — cosmetic, not a correctness bug, deliberately not held against that PR.

What happens

scanner/astgrep.go marks the ast-grep source mixed with the Rust caveat whenever any analyzed file is Rust:

source := analysis.Source{Name: "ast-grep", Status: analysis.SourceAuthoritative}
for _, fileAnalysis := range analyses {
    if DetectLanguage(fileAnalysis.Path) == "rust" {
        source.Status = analysis.SourceMixed
        source.Detail = rustCoverageNote
        break
    }
}

On a two-crate Cargo workspace that produces:

{"name": "ast-grep",       "status": "mixed",         "detail": "Rust macro-generated, string-routed, and #[path] module edges may be unresolved"}
{"name": "cargo-metadata", "status": "authoritative"}
{"name": "rust-cargo",     "status": "mixed",         "detail": "Rust macro-generated, string-routed, and #[path] module edges may be unresolved"}

Why it's wrong

ast-grep's extraction isn't degraded — it found what it found. The caveat (macro-generated, #[path], string-routed edges) describes a Rust resolution gap, which is rust-cargo's concern. Conflating "which tool ran" with "which language has resolution gaps" has two consequences:

  1. On a Go + Rust monorepo, the Go analysis is reported as degraded too, even though nothing about the Go extraction is partial.
  2. It's the direct cause of coverage: Rust caveat prints twice in the CLI coverage line #107 — the same sentence lands on two sources and prints twice.

Suggested fix

Leave ast-grep as authoritative and let only rust-cargo carry the Rust caveat. The source list then reads as what each tool actually contributed, and the duplicate note disappears at the same time.

A third site does the same thing: scanner/types.go in newDepsProject sets coverage.Sources[0].Detail = rustCoverageNote on the ast-grep source (kept "for the determinism and Rust-coverage tests").

Reproduce

Cargo workspace with two crates where app uses helper from a #[cfg(test)] block, then:

codemap --json --deps <workspace> | jq .coverage

Activity

  1. JordanCoin commented on Aug 8, 2026

    @JordanCoin
    OwnerAuthor

    Cross-ref: filed #111 for the underlying design issue — coverage is reported at scan granularity but consumed at query granularity, which is why this keeps surfacing. This issue is still worth fixing on its own; #111 is the reason it recurs.

    Also reclassifying: I filed this as cosmetic assuming a human reader. If the consumer is an agent parsing coverage.sources[] / coverage.notes[], a duplicated note is a malformed payload and a misattributed source is wrong data — not a presentation nit.

  2. JordanCoin commented on Aug 8, 2026

    @JordanCoin
    OwnerAuthor

    Fixed by #108 (d1e8a13), verified on merged main with a two-crate Cargo workspace:

    • ast-grep now reports authoritative; only rust-cargo carries the Rust caveat.
    • The coverage line prints the caveat once.
    • No regression: a Go-only repo still reports complete with a single authoritative source.

    The underlying granularity issue stays open as #111 — coverage is still reported per-scan rather than per-query, which is why a Go file in a mixed repo still reads partial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions