Skip to content

feat: add contract coverage reason and confidence range to CRAP scores - #63

Merged
jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:coverage-reason-guidance
Mar 16, 2026
Merged

jflowers merged 1 commit into
unbound-force:mainfrom
jflowers:coverage-reason-guidance

Conversation

@jflowers

Copy link
Copy Markdown
Collaborator

Summary

  • Add ContractCoverageReason and EffectConfidenceRange to CRAP scores
  • When 0% contract coverage is caused by classification (all effects "ambiguous"), the report explains why
  • Changed ContractCoverageFunc from bare float64 to ContractCoverageInfo struct

Problem (Issue #60)

A developer spent a full iteration adding 55 assertion fixes across 9 test files with zero improvement to contract coverage. The reason: all 24 Q3 functions had effects at confidence 78-79 (threshold 80). With total_contractual=0, adding assertions can't improve the metric. The report didn't explain this.

Solution

Before:

{"function": "LoadConversations", "contract_coverage": 0, "gaze_crap": 30}

After:

{
  "function": "LoadConversations",
  "contract_coverage": 0,
  "gaze_crap": 30,
  "contract_coverage_reason": "all_effects_ambiguous",
  "effect_confidence_range": [78, 79]
}

Text report worst-offenders now show:

1. 30.0  LoadConversations [add_assertions] (all effects ambiguous, confidence 78-79)

Changes

File What
internal/crap/crap.go Added ContractCoverageReason, EffectConfidenceRange to Score; added ContractCoverageInfo struct
internal/crap/analyze.go Changed ContractCoverageFunc type, updated computeScores
internal/crap/report.go Display reason in worst-offenders
cmd/gaze/main.go Updated buildContractCoverageFunc to compute reason from classification data
Tests 2 new reason tests, updated all callback mocks

Closes #60

When contract coverage is 0% because all effects are classified
'ambiguous', the CRAP score now explains why via ContractCoverageReason
and shows how close effects are to the threshold via
EffectConfidenceRange.

- Add ContractCoverageInfo struct replacing bare float64 in
  ContractCoverageFunc callback
- Add ContractCoverageReason and EffectConfidenceRange to Score
- Update buildContractCoverageFunc to compute reason from quality
  classification data
- Display reason in text report worst-offenders section
- 2 new tests for reason computation

Closes unbound-force#60
@jflowers jflowers added this to the v1.5.0 milestone Mar 16, 2026
@jflowers
jflowers merged commit 8cf478d into unbound-force:main Mar 16, 2026
5 checks passed
jflowers added a commit to jflowers/gaze that referenced this pull request Mar 19, 2026
ci-gaze-report: superseded by ci-gaze-report-v2
ci-gaze-report-v2: merged as PR unbound-force#69 (v1.4.5)
target-warning-guidance: merged as PR unbound-force#65
coverage-reason-guidance: merged as PR unbound-force#63
jflowers added a commit that referenced this pull request Mar 19, 2026
ci-gaze-report: superseded by ci-gaze-report-v2
ci-gaze-report-v2: merged as PR #69 (v1.4.5)
target-warning-guidance: merged as PR #65
coverage-reason-guidance: merged as PR #63
@jflowers
jflowers deleted the coverage-reason-guidance 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: No status

Development

Successfully merging this pull request may close these issues.

Classification breakdown needs 'why' guidance, not just raw data (follow-up to #42)

1 participant