Repository navigation
Description
Context
During an extended session using gaze crap --format=json output to drive automated quality improvement (decomposing Q4 functions, adding contract assertions for Q3, reducing GazeCRAPload from 12 to 0), several patterns emerged where the gaze output could have accelerated the workflow if it provided more actionable detail upfront.
This issue captures observations from the perspective of an AI agent consuming gaze output to plan and execute code improvements.
Observations
1. GazeCRAP quadrant lacks the "why" for each function
The CRAP JSON output includes quadrant labels (Q1-Q4) but not the actionable fix category. By the end of the session I had learned:
- Q4 with high contract coverage = needs decomposition (not more tests)
- Q4 with low contract coverage = needs tests AND decomposition
- Q3 = needs contract-level assertions (has line coverage but tests don't verify observable behavior)
An agent consuming the JSON has to infer this from the combination of quadrant, contract_coverage, line_coverage, and complexity. A fix_strategy field (e.g., "decompose", "add_tests", "add_assertions", "decompose_and_test") would eliminate one round of analysis.
2. No way to distinguish "assertion gap" from "coverage gap" in quality output
gaze quality reports contract coverage percentage, but an agent can't tell whether a function at 50% contract coverage needs:
- More test functions (coverage gap), or
- More assertions in existing tests (assertion gap)
The WriteStepSummary case was instructive: 94% line coverage, 0% contract coverage. The tests executed the function but asserted almost nothing about its observable behavior. An agent that only sees "0% contract coverage" would waste time writing new test functions when the fix is adding assertions to existing ones.
A field like assertion_density (assertions per test function) or has_tests_without_assertions: true would help agents skip the wrong fix strategy.
3. CRAP output doesn't surface the extracted-helper opportunity
When planning decomposition, the most useful signal is "which groups of branches form a cohesive unit that can be extracted." The agent has to read the source code and identify these manually. Gaze already computes cyclomatic complexity per function — it could potentially identify "complexity clusters" within a function (e.g., "lines 45-67 contain 5 branches related to file I/O" vs "lines 70-90 contain 4 branches related to validation").
This is a harder problem and may not be worth solving in gaze itself — just noting that it was the most time-consuming part of the decomposition workflow.
4. gaze crap and gaze quality are separate commands but the agent always needs both
Every planning decision required both CRAP data (complexity, line coverage, quadrant) and quality data (contract coverage, assertion mapping). Running them separately and correlating by function name is wasteful. gaze report --format=json provides both, but it also runs classification and docscan which aren't needed for the "reduce GazeCRAPload" use case.
A gaze crap --with-quality flag or a lightweight combined mode would reduce the two-command pattern to one.
5. The "fix priority" is implicit, not explicit
The agent had to learn the priority ordering through experience:
- Q4 with CRAP > 100 (adapter Format methods) — highest impact
- Q4 with CRAP 40-70 (pipeline orchestrators) — high impact
- Q4 with complexity > 15 (decomposition targets) — medium impact
- Q3 with 0% contract coverage (assertion gaps) — lower impact but easy wins
A sorted recommended_actions list in the JSON output — ordered by expected GazeCRAPload reduction — would let agents work in optimal order from the start instead of discovering it iteratively.
Suggested Enhancements (in priority order)
fix_strategyfield on GazeCRAP scores — one of:decompose,add_tests,add_assertions,decompose_and_test- Combined crap+quality mode —
gaze crap --with-qualityto avoid running two commands recommended_actionslist — sorted by expected impact, with function name, current quadrant, and fix strategy- Assertion density metric — distinguish "no tests" from "tests without assertions"
Non-suggestions
- Automated decomposition hints (complexity cluster detection) — interesting but likely too complex for gaze's scope
- Auto-fix generation — out of scope for a static analysis tool
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
- StatusShow more project fieldsNo status
Activity
feat: add FixStrategy field to CRAP scores for actionable remediation…
feat: add FixStrategy field to CRAP scores for actionable remediation…
jflowers commentedon Mar 15, 2026
PR #49 addressed suggestion 1:
fix_strategyfield on each CRAPload score (decompose,add_tests,add_assertions,decompose_and_test) plusfix_strategy_countson Summary.Still open (suggestions 2-4):
gaze crap --with-quality) — agents still need to run two commands and correlate by function namerecommended_actionssorted list — priority ordering by expected GazeCRAPload reductionKeeping this issue open for the remaining items.
feat: add recommended_actions list and assertion_count to JSON output
feat: add recommended_actions list and assertion_count to JSON output
feat: add recommended_actions list and assertion_count to JSON output