Skip to content

gaze report: agent-facing improvements for automated quality improvement workflows #48

Closed

Description

@jflowers

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:

  1. Q4 with CRAP > 100 (adapter Format methods) — highest impact
  2. Q4 with CRAP 40-70 (pipeline orchestrators) — high impact
  3. Q4 with complexity > 15 (decomposition targets) — medium impact
  4. 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)

  1. fix_strategy field on GazeCRAP scores — one of: decompose, add_tests, add_assertions, decompose_and_test
  2. Combined crap+quality mode — gaze crap --with-quality to avoid running two commands
  3. recommended_actions list — sorted by expected impact, with function name, current quadrant, and fix strategy
  4. 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

Activity

  1. added
    enhancement
    on Mar 15, 2026
  2. jflowers commented on Mar 15, 2026

    @jflowers
    CollaboratorAuthor

    PR #49 addressed suggestion 1: fix_strategy field on each CRAPload score (decompose, add_tests, add_assertions, decompose_and_test) plus fix_strategy_counts on Summary.

    Still open (suggestions 2-4):

    • 2. Combined crap+quality mode (gaze crap --with-quality) — agents still need to run two commands and correlate by function name
    • 3. recommended_actions sorted list — priority ordering by expected GazeCRAPload reduction
    • 4. Assertion density metric — distinguish "no tests" from "tests without assertions"

    Keeping this issue open for the remaining items.

  3. added this to the v1.5.0 milestone on Mar 15, 2026
  4. added 2 commits that reference this issue on Mar 19, 2026
    6497388
    263f6ae
  5. moved this from Todo to In Progress in Gaze Roadmapon Mar 19, 2026
  6. moved this from In Progress to Done in Gaze Roadmapon Mar 19, 2026
  7. added a commit that references this issue on Mar 19, 2026
    81db53a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions