Skip to content

fix: prevent silent CI passes on missing/partial data (#101, #108, #116) - #148

Merged
jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/ci-gate-integrity
Jun 22, 2026
Merged

jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:opsx/ci-gate-integrity

Conversation

@jflowers

Copy link
Copy Markdown
Collaborator

Summary

Fixes three CI gate integrity bugs where "could not analyze" was silently
reported as a passing result.

Bug fixes

Breaking change

gaze_crapload in gaze report --format=json output changes from 0 to
null when GazeCRAP is unavailable. This aligns with gaze crap --format=json
which already emits null.

Testing

  • 12 new unit tests across 4 packages
  • All 12 packages pass: go test -race -count=1 -short ./...
  • No new lint violations

Closes #101, #108, #116

@beatrizmcouto beatrizmcouto moved this to In Review 👀 in Unbound Force Planning Jun 17, 2026
@jflowers
jflowers force-pushed the opsx/ci-gate-integrity branch 2 times, most recently from 73bfcd9 to a3968c6 Compare June 17, 2026 14:34

@em-redhat em-redhat 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.

PR Review: fix: prevent silent CI passes on missing/partial data (#101, #108, #116)

Stats: +1268 / -114 across 25 files (1 commit)
CI: All 5 checks pass (Unit+Integration Go 1.24/1.25, E2E Go 1.24/1.25, MegaLinter)

What's Good

  • Spec-first workflow followed correctly — full proposal → design → specs → tasks pipeline with all tasks checked off
  • Type propagation is thorough — the *int change is consistently applied across crapStepResult, ReportSummary, compactSummary, and ThresholdResult.Actual
  • intPtr duplication resolved — removed from threshold_test.go, added to threshold.go production code
  • thresholdSet properly propagated — threaded through selfCheckParams → crapParams
  • generateCoverProfile call site updated — caller passes opts.Stderr
  • checkZeroResultGate is well-designed — correctly skips when CRAP step errored, checks TotalFunctions instead of score count, handles nil payload
  • Test updates for *int are comprehensive — all test assertions updated to handle pointer dereferencing
  • Design decisions are well-documented — D1-D4 with rationale, risks, and coverage strategy
  • Learnings captured in .uf/dewey/learnings/

Findings

See inline comments for details.

Architecture Assessment

The changes follow established project patterns well:

  • Dependency injection for testability (stderr io.Writer, analyzeFunc, thresholdSet bool)
  • Consistent *int semantics matching the existing ThresholdConfig pattern
  • cmd.Flags().Changed() for intent detection matching the existing MaxCrapload *int pattern in gaze report
  • Extracted validateReportParams reducing runReport complexity
  • checkZeroResultGate as a standalone function — testable, clear single responsibility

Verdict

Approve with comments. The PR correctly addresses three real CI gate integrity bugs with thorough type propagation, comprehensive tests, and well-documented design decisions. All CI checks pass.

Suggested follow-ups (not blocking):

  1. File an issue to align gaze crap GazeCRAPload threshold behavior with gaze report (close the asymmetry gap)
  2. Add minimal profile header validation to recoverPartialProfile
  3. Verify task 4.3's E2E test actually validates the null/unavailable case

Comment thread cmd/gaze/main.go
return fmt.Errorf("CRAPload %d exceeds maximum %d",
rpt.Summary.CRAPload, maxCrapload)
}
// When GazeCRAPload is nil, skip the check silently. gaze crap

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.

[HIGH] Behavioral asymmetry between gaze crap and gaze report on nil GazeCRAPload thresholds

When --max-gaze-crapload=5 is set and GazeCRAPload is nil:

  • gaze crap: silently skips the threshold check (passes)
  • gaze report: reports FAIL with "GazeCRAPload (unavailable)"

The design doc (D3 non-goals) explicitly defers this: "Aligning gaze crap's int-based threshold model with gaze report's *int + cmd.Flags().Changed() model — that's a separate refactoring task."

However, this technically violates the PR's own spec MODIFIED requirement which states: "Both commands MUST fail a --max-gaze-crapload threshold check" when GazeCRAP is unavailable.

Suggested follow-up: File an issue to align gaze crap GazeCRAPload threshold behavior with gaze report.

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 documented in the design artifact as a non-goal for this PR and acknowledged in the code comment at cmd/gaze/main.go:686-691. I created issue #150 to track for separate resolution.

Comment thread internal/crap/analyze.go
}
return profilePath, nil
}

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.

[MEDIUM] No validation of profile content

This only checks os.Stat for existence and non-zero size. A truncated or corrupt profile (non-empty but missing the mode: header or with incomplete lines) would be accepted as valid. Downstream cover.ParseProfiles may silently skip malformed lines, producing incomplete coverage data that appears valid.

The design doc's R2 acknowledges this risk and deems it acceptable since "the alternative (no output at all) is strictly worse." This is reasonable for the initial implementation. A minimal header check (mode: prefix on first line) would be cheap insurance.

Not blocking — flagging as a follow-up improvement.

- [x] 4.1 Run `go test -race -count=1 -short ./...` — all existing tests must pass.
- [x] 4.2 Run `golangci-lint run` — no new lint violations.
- [x] 4.3 Extend `TestSC002_GazeCRAPloadMatchBetweenCrapAndReport` to verify that both `gaze crap --format=json` and `gaze report --format=json` produce `null` (not `0`) for `gaze_crapload` when GazeCRAP is unavailable — confirm consistency between the two commands as an automated test.
- [x] 4.4 Check whether any JSON Schema definitions (e.g., in `internal/report/schema.go`) need updating to allow `null` for the `gaze_crapload` field, and update them if so.

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.

[MEDIUM] Task 4.3 marked complete but test not modified in diff

This task says TestSC002_GazeCRAPloadMatchBetweenCrapAndReport was extended to verify null vs 0 consistency — but the diff does not include any changes to that test function. The test exists on main at cmd/gaze/main_test.go:1877 but was not touched.

It's possible the existing test already covers this case through the *int type changes flowing through the pipeline (the E2E test runs the full commands). But if the intent was to add an explicit null assertion, it's missing.

, unbound-force#108, unbound-force#116)

- Preserve partial coverage profiles when go test exits non-zero
  but wrote usable data; warn instead of aborting (unbound-force#101)
- Change GazeCRAPload from int to *int across the report pipeline
  (crapStepResult, ReportSummary, compactSummary, ThresholdResult.Actual)
  so EvaluateThresholds fails when data is unavailable (unbound-force#108)
- Add zero-result gate failure in runCrap and gaze report Run() —
  gate commands exit non-zero when zero functions are analyzed
  and threshold flags were explicitly provided (unbound-force#116)
@jflowers
jflowers force-pushed the opsx/ci-gate-integrity branch from a3968c6 to bac8ee2 Compare June 22, 2026 13:16
@jflowers
jflowers merged commit a73d657 into unbound-force:main Jun 22, 2026
5 checks passed
@yvonnedevlinrh yvonnedevlinrh moved this from In Review 🏁 to Done ✔️ in Unbound Force Planning Aug 17, 2026
@jflowers
jflowers deleted the opsx/ci-gate-integrity branch November 15, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

Bug: crap discards the coverage profile and aborts when go test exits non-zero

3 participants