Repository navigation
fix: reconcile absolute-path baselines with module-relative report paths - #345
Conversation
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
left a comment
There was a problem hiding this comment.
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.
- 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. - LOW —
cmd/gaze/main_test.go:1443: the normalization-notice suppression assertion is vacuous — the fixture cannot produce the notice it suppresses. - LOW —
cmd/gaze/main.go:962: the defensive non-BaselinePathErrorwrap 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.
Summary
Fixes #330 —
gaze crap --baselinemis-matching historical absolute-path baselines (pre-relativization, e.g. v1.9.x) against current module-relative report paths. Same function was reported as bothremovedandnew, and unchanged scores abovenew_function_thresholdfalsely failed the gate (regressions: 0became meaningless).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 viafilepath.Rel(moduleDir, …)then opt-in--baseline-root;..-prefixed escapes rejected so sibling dirs never conflate; unreconcilable entries return*BaselinePathError.--baseline-root stringflag (no.gaze.yamlkey — historical machine state, not config) threadedrunCrap → resolveBaselineAndCompare → loadAndCompare; incompatibility now fails before any comparison output with actionable diagnostic (baseline path, count, example, regenerate command +--baseline-rootremediation) in both explicit and auto-detected modes.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.How to Verify
Expected: 13 files changed, 100% line coverage in
internal/crap/baseline_compat.go,TestEmbeddedAssetsMatchSourcestill green, JSON stdout untouched.How to Demo
Key Files
internal/crap/baseline_compat.go— reconciliation coreinternal/crap/baseline_compat_test.go— D7 matrix + 5 epic regression casescmd/gaze/main.go+cmd/gaze/main_test.go—--baseline-rootflag threading, stderr signalsdocs/reference/cli/crap.md— flag table + Baseline path compatibility sectiondocs/guides/ci-integration.md— migration tableREADME.md,AGENTS.mdopenspec/changes/baseline-absolute-path-compat/— proposal/design/spec/tasks +.openspec.yaml(originating_issue: 330)Known Issues (from review-council — 3 LOW advisories)
BaselinePathErrorbranch inloadAndCompareunreachable — kept as defense-in-depth without doc comment.Diff: 13 files changed, 1653 insertions(+), 11 deletions(-) · Commit:
7965494ahead ofupstream/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-bytrailer.