Skip to content

bug: absolute-path baselines mismatch relative report paths #330

Closed

Description

@marcusburghardt

Summary

gaze crap --baseline cannot match an older absolute-path baseline to current
module-relative report paths. It treats the same function as both removed and
new, and can flag unchanged historical scores as new-function violations.

Confirmed with Gaze v1.9.0 and v2.3.0, Linux amd64, Go 1.26.10. V1.9.0 is
currently selected by go install github.com/unbound-force/gaze/cmd/gaze@latest;
v2.3.0 was tested separately. No baseline or threshold was changed for either run.

Reproduction

  1. Use an existing baseline containing absolute scores[].file paths, such as
    the committed baseline in complytime/complytime-providers.

  2. Generate coverage and run a current Gaze release from the module root:

    go test -coverprofile=coverage.out ./...
    gaze crap --format=json --coverprofile=coverage.out \
      --baseline=.gaze/baseline.json ./...
  3. Inspect matching file/function entries. For example, our baseline contains
    <checkout>/cmd/openscap-provider/xccdf/arf.go:RuleResultMessage, whereas
    the current report contains
    cmd/openscap-provider/xccdf/arf.go:RuleResultMessage.

Our actual run scoped coverage and analysis to the 16 changed packages in a
provider feature branch. Both versions produced the following comparison:

{
  "regressions": 0,
  "improvements": 0,
  "new_functions": 282,
  "new_violations": 1,
  "removed_functions": 191,
  "unchanged": 0,
  "epsilon": 0.5,
  "new_function_threshold": 30,
  "new_function_gaze_crap_threshold": 30,
  "passed": false
}

The command exits 1. RuleResultMessage is reported as new_violation with
complexity 8, line coverage 0%, and CRAP 72. Its baseline entry has those exact
same values; its function body is byte-identical to the feature's merge base.
The apparent removal/new-function pair is a path-identity mismatch, not a new
function. The zero matched functions also means genuine regressions cannot be
inferred from this comparison's regressions: 0.

Cause

  • internal/crap/analyze.go converts report paths to module-relative paths
    (v1.9.0 lines 141–147; v2.3.0 lines 154–160).
  • internal/crap/compare.go
    keys scores with the literal s.File + ":" + s.Function.
  • LoadBaseline unmarshals the historical path representation without reconciling
    it with the current report. The default-branch source still has the literal key.

Expected behavior

Provide a supported, explicit compatibility/migration mechanism for historical
absolute-path baselines, or fail with an actionable incompatibility diagnostic
rather than silently treating every entry as new/removed. Preserve thresholds
and score semantics. Avoid basename/suffix-only matching that could conflate
different packages or checkout roots.

Suggested regression cases: historical absolute versus module-relative paths for
the same function; multiple files with the same basename/function; a relocated
checkout; actual new/removed functions; and an unchanged score above the new-function
threshold. The reproducing consumer baseline has not been rewritten to clear this.

Activity

  1. added a commit that references this issue on Nov 15, 2026
    0dfd948
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions