Skip to content

Filter and group findings in the shared driver layer #430

Description

@e54-bot

Follow-up to #429. Wave 1 of the agent/CLI experience work.

Problem

Findings are returned and rendered whole. There is no way to ask for a subset, and repeats are not collapsed.

Measured with wright 0.2.41 on tests/fixtures/workshop/real-world/overpy-cake.ws:

  • 10 findings, but only 2 distinct messages: 9x repeated-value with identical text, 1x min-wait-loop.
  • Text mode prints 44 lines, each finding carrying its own source-context line. On this fixture the quoted Workshop lines run past 200 columns, so the wrapped output for two real problems fills a screen.
  • --format json returns all 10 with no way to request only errors, only one rule, or only one file.

The agent operations have the same shape: findings, lint, and costEstimate take no request fields and always return everything. In a fix loop, an agent re-reads the full set every turn to find the one finding it is working on, and a large project's findings compete with the source it is editing for context budget.

This is one defect with two symptoms. Humans cannot read the output and agents cannot afford it, because both consume the same unfiltered driver result.

Scope

Add finding selection in wright-driver so the CLI and the agent contract share one implementation and one semantics.

Selection dimensions:

  • severity (at or above a threshold)
  • rule id
  • source file
  • maximum count

Surfaces:

Text-mode grouping:

  • Consecutive findings sharing a rule id and message collapse into one entry that lists its locations, instead of repeating the message and a source-context line per occurrence.
  • The verdict line keeps reporting the true total, so collapsing never understates the result.

Truncation must be visible:

  • When a maximum count drops findings, the result states how many were withheld, in both text and JSON. A truncated result is never presented as complete.

Non-goals

  • Changing which findings the analyzer produces, or any rule's semantics.
  • The fixed rule-metadata payload in the lint envelope. Separate issue; it is a contract decision, not a filtering one.
  • Lint suggestions or fixes.
  • A config file for default selection. That belongs with project configuration.
  • Changing analyze's existing ranking and bounded-report behaviour.

Constraints

  • Selection belongs in wright-driver, not in the CLI renderer. A filter the CLI applies after the fact cannot serve the agent contract, and two implementations will drift.
  • Additive only on wright-agent/v1: no operation removed or renamed, no field's type or meaning changed. See docs/agent-contract.md versioning.
  • Exit codes stay driven by the true highest severity present, not by what survives selection. Filtering a result must not turn a failing project into exit 0. This is the main correctness hazard in this issue.
  • Output rules in docs/cli/presentation.md are unchanged: one envelope on stdout in JSON mode, no ANSI or progress in plain/CI/JSON rendering.

Acceptance criteria

  • Findings can be selected by severity threshold, rule id, source file, and maximum count, through both the CLI and the agent contract.
  • For each dimension, the CLI and agent paths return the same selected set for the same input and selection. A test compares the two paths.
  • Omitting every selection option reproduces current output byte-for-byte in JSON mode. A test asserts this against the existing expectations.
  • Selecting severity=error on overpy-cake.ws, whose findings are all warnings and info, yields an empty finding set and the unchanged non-zero-warning verdict and exit code. A test asserts the exit code is not affected by selection.
  • A maximum count that withholds findings reports the withheld count in text and JSON. A test asserts the count is present and correct.
  • Text mode collapses overpy-cake.ws's 9 identical repeated-value findings into one entry listing 9 locations, while the verdict still reports 10 findings total. A test asserts both.
  • An unknown rule id in a selection is a usage error, not a silent empty result.
  • capabilities still advertises wright-agent/v1 and every previously advertised operation; existing schema compatibility tests pass unchanged.
  • docs/cli/lint.md, docs/cli/presentation.md, and docs/agent-contract.md describe the selection options and the collapse behaviour.
  • Ablation: making exit codes depend on the selected set instead of the full set makes the exit-code test fail.

Dependencies / ownership

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions