Repository navigation
fix: prevent silent CI passes on missing/partial data (#101, #108, #116) - #148
Conversation
73bfcd9 to
a3968c6
Compare
em-redhat
left a comment
There was a problem hiding this comment.
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
*intchange is consistently applied acrosscrapStepResult,ReportSummary,compactSummary, andThresholdResult.Actual intPtrduplication resolved — removed fromthreshold_test.go, added tothreshold.goproduction codethresholdSetproperly propagated — threaded throughselfCheckParams→crapParamsgenerateCoverProfilecall site updated — caller passesopts.StderrcheckZeroResultGateis well-designed — correctly skips when CRAP step errored, checksTotalFunctionsinstead of score count, handles nil payload- Test updates for
*intare 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
*intsemantics matching the existingThresholdConfigpattern cmd.Flags().Changed()for intent detection matching the existingMaxCrapload *intpattern ingaze report- Extracted
validateReportParamsreducingrunReportcomplexity checkZeroResultGateas 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):
- File an issue to align
gaze crapGazeCRAPload threshold behavior withgaze report(close the asymmetry gap) - Add minimal profile header validation to
recoverPartialProfile - Verify task 4.3's E2E test actually validates the
null/unavailable case
| return fmt.Errorf("CRAPload %d exceeds maximum %d", | ||
| rpt.Summary.CRAPload, maxCrapload) | ||
| } | ||
| // When GazeCRAPload is nil, skip the check silently. gaze crap |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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.
| } | ||
| return profilePath, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
[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. |
There was a problem hiding this comment.
[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)
a3968c6 to
bac8ee2
Compare
Summary
Fixes three CI gate integrity bugs where "could not analyze" was silently
reported as a passing result.
Bug fixes
Bug:
crapdiscards the coverage profile and aborts whengo testexits non-zero #101:generateCoverProfilenow preserves partial coverage profileswhen
go testexits non-zero but wrote usable data — warns instead ofaborting. Extracted
recoverPartialProfilehelper.Bug:
report --max-gaze-craploadalways PASSES when GazeCRAP is unavailable #108: ChangedcrapStepResult.GazeCRAPload,ReportSummary.GazeCRAPload,compactSummary.GazeCRAPloadfromintto*intacross the report pipeline,preserving the nil/unavailable signal from
crap.Summary. ChangedThresholdResult.Actualfromintto*int.EvaluateThresholdsnowfails when
--max-gaze-craploadis set but GazeCRAP data is unavailable.Bug: Empty / zero-result runs exit 0 and read as a CI "pass" #116: Added zero-result gate failure in
runCrap(cmd/gaze/main.go)and
Run()(internal/aireport/runner.go). Gate commands exit non-zerowhen zero functions are analyzed and threshold flags were explicitly provided.
Added
TotalFunctionsfield for precise zero-result detection. Usescmd.Flags().Changed()for threshold intent detection.Breaking change
gaze_craploadingaze report --format=jsonoutput changes from0tonullwhen GazeCRAP is unavailable. This aligns withgaze crap --format=jsonwhich already emits
null.Testing
go test -race -count=1 -short ./...Closes #101, #108, #116