Skip to content

fix: reconcile absolute-path baselines with module-relative report paths - #345

Merged
jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/baseline-absolute-path-compat
Nov 15, 2026
Merged

jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/baseline-absolute-path-compat

Conversation

@jflowers

Copy link
Copy Markdown
Collaborator

Summary

Fixes #330 — gaze crap --baseline mis-matching historical absolute-path baselines (pre-relativization, e.g. v1.9.x) against current module-relative report paths. Same function was reported as both removed and new, and unchanged scores above new_function_threshold falsely failed the gate (regressions: 0 became meaningless).

  • New internal/crap/baseline_compat.go: ReconcileBaselinePaths(baseline *Report, moduleDir, baselineRoot string) (ReconciliationStats, error) — deterministic, no-I/O, in-place normalization. Empty/non-absolute paths untouched; absolute paths rewritten via filepath.Rel(moduleDir, …) then opt-in --baseline-root; ..-prefixed escapes rejected so sibling dirs never conflate; unreconcilable entries return *BaselinePathError.
  • CLI: new --baseline-root string flag (no .gaze.yaml key — historical machine state, not config) threaded runCrap → resolveBaselineAndCompare → loadAndCompare; incompatibility now fails before any comparison output with actionable diagnostic (baseline path, count, example, regenerate command + --baseline-root remediation) in both explicit and auto-detected modes.
  • Two stderr-only signals (never stdout/JSON): normalization notice when Normalized > 0, and zero-match warning when both sides non-empty but 0 functions match (wrong --baseline-root / cross-OS / rewritten codebase). JSON schema, thresholds, score semantics unchanged.

Closes #330.

What Was Built

Baseline path compatibility for gaze crap --baseline (issue #330): historical absolute-path baselines saved by older Gaze now reconcile against current module-relative report paths. Incompatible baselines fail loudly with remediation; module-relative baselines (normal case) are byte-identical. All five epic-mandated regression scenarios (#337) covered, plus D7 boundary matrix, mixed-baseline test, and 11 CLI tests including Cobra flag registration.

Baseline path compatibility for gaze crap --baseline (issue #330): historical absolute-path baselines saved by older Gaze versions now reconcile against current module-relative report paths instead of falsely failing the gate. New internal/crap/baseline_compat.go adds ReconcileBaselinePaths — deterministic, no-I/O, in-place normalization [...] Docs: CLI reference, CI integration guide, README; website issue unbound-force/website#415.

How to Verify

go build ./cmd/gaze
go test -race -count=1 -short ./...
go vet ./...   # via golangci-lint in CI
# Manual: same-checkout reconciliation (no flag)
gaze crap --format=json --coverprofile=coverage.out --baseline=.gaze/baseline.json ./... > /tmp/cur.json
# Manual: relocated checkout
gaze crap --baseline-root /home/alice/gaze --coverprofile=coverage.out ./...

Expected: 13 files changed, 100% line coverage in internal/crap/baseline_compat.go, TestEmbeddedAssetsMatchSource still green, JSON stdout untouched.

How to Demo

gh pr view --repo unbound-force/gaze --json url,title,headRefName
gh pr checks --repo unbound-force/gaze <PR#>

Key Files

  • internal/crap/baseline_compat.go — reconciliation core
  • internal/crap/baseline_compat_test.go — D7 matrix + 5 epic regression cases
  • cmd/gaze/main.go + cmd/gaze/main_test.go — --baseline-root flag threading, stderr signals
  • docs/reference/cli/crap.md — flag table + Baseline path compatibility section
  • docs/guides/ci-integration.md — migration table
  • README.md, AGENTS.md
  • openspec/changes/baseline-absolute-path-compat/ — proposal/design/spec/tasks + .openspec.yaml (originating_issue: 330)

Known Issues (from review-council — 3 LOW advisories)

  1. Incompatible-baseline tests assert stdout empty on error — trivial, kept intentional.
  2. flag-set-plus-no-baseline-file combo structurally covered but unexecuted — not worth a dedicated fixture.
  3. Defensive non-BaselinePathError branch in loadAndCompare unreachable — kept as defense-in-depth without doc comment.

Diff: 13 files changed, 1653 insertions(+), 11 deletions(-) · Commit: 7965494 ahead of upstream/main (0 behind) · Website docs: unbound-force/website#415

🤖 Assisted by Muse Spark (rits/meta-models/Muse-Spark-Open-816B-A42B-NVFP4) — see commit Assisted-by trailer.

Historical baselines saved with absolute paths (pre-relativization) were
keyed literally against current module-relative report paths, causing the
same function to appear as both removed and new and triggering false gate
failures for unchanged scores above the new-function threshold.

- Add internal/crap/baseline_compat.go: ReconcileBaselinePaths rewrites
  absolute baseline paths via filepath.Rel against moduleDir then
  --baseline-root, rejecting escapes ("../"-prefixed), returning
  *BaselinePathError for unreconcilable entries; module-relative paths
  untouched
- Thread --baseline-root flag through CLI (runCrap → resolveBaselineAndCompare
  → loadAndCompare) for relocated checkouts; auto-detected incompatibility
  now fails with actionable diagnostic instead of silent skip
- Surface two stderr-only signals (never stdout/JSON): normalization notice
  and zero-match warning (both-sides-non-empty guard)
- Cover D7 boundary matrix, five epic regression scenarios, mixed-baseline
  partial rewrite, and 11 CLI tests (flag registration, inertness, error
  wrapping) at 100% line coverage; update CLI reference, CI guide, README

Closes unbound-force#330

Assisted-by: Muse-Spark-Open-816B-A42B-NVFP4
Generated with AI assistance (Muse-Spark-Open-816B-A42B-NVFP4)

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by /uf.review-pr (AI-assisted).

Council verdict: APPROVE WITH ADVISORIES — 7/7 reviewer runs succeeded (adversary, architect, curator, entropy, gaze-testing, guard: APPROVE; testing: APPROVE WITH ADVISORIES). No CRITICAL or HIGH findings.

Summary

This PR fixes #330 by reconciling historical absolute-path baselines against current module-relative report paths: a new pure ReconcileBaselinePaths in internal/crap/baseline_compat.go, an opt-in --baseline-root flag for relocated checkouts, and a hard-error diagnostic (with regenerate / --baseline-root remediations) for unreconcilable baselines in both explicit and auto-detected modes. Thresholds, score semantics, exit directions, and the comparison JSON schema are unchanged; diagnostics are stderr-only. All six CI checks pass on the head commit (7965494).

Findings (3 advisories: 1 MEDIUM, 2 LOW)

All findings come from the testing persona; the code paths they describe behave correctly today — these are test-hardening gaps, not defects.

  1. MEDIUM — cmd/gaze/main_test.go:1403: incompatible-baseline tests assert only the returned error; nothing enforces spec R4's "fail before any comparison output is written" clause on the error path.
  2. LOW — cmd/gaze/main_test.go:1443: the normalization-notice suppression assertion is vacuous — the fixture cannot produce the notice it suppresses.
  3. LOW — cmd/gaze/main.go:962: the defensive non-BaselinePathError wrap branch is unreachable and unvalidated.

Spec alignment

The delta spec (openspec/changes/baseline-absolute-path-compat/) is implemented faithfully: all five epic-mandated regression scenarios (#337) have named tests, the D7 boundary matrix is present, and the deliberate deviation (auto-detected incompatible baseline as a hard error) is documented in the proposal. 100% line coverage on baseline_compat.go is claimed against the ≥90% spec floor.

CI

All 6 checks PASS on 7965494: Unit + Integration (Go 1.24/1.25), E2E (Go 1.24/1.25), MegaLinter, Gaze AI Report.

Comment thread cmd/gaze/main_test.go Resolved
Comment thread cmd/gaze/main_test.go Resolved
Comment thread cmd/gaze/main.go Resolved
@jflowers
jflowers merged commit 0dfd948 into unbound-force:main Nov 15, 2026
6 checks passed
@jflowers
jflowers deleted the opsx/baseline-absolute-path-compat branch November 15, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: absolute-path baselines mismatch relative report paths

2 participants