Skip to content

feat(driver): share finding selection across CLI and agent surfaces - #435

Merged
Teakowa merged 3 commits into
mainfrom
wright-430-finding-selection
Sep 29, 2026
Merged

Teakowa merged 3 commits into
mainfrom
wright-430-finding-selection

Conversation

@e54-bot

@e54-bot e54-bot commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements #430: finding/diagnostic selection is implemented once in
wright-driver (FindingSelection + SelectionOutcome, select.rs) and
shared by every finding surface.

  • Shared selection (severity threshold, rule id, file = resolved
    span.path, max): applied to envelope diagnostics (check, analyze,
    lint) and lint findings; wright-agent/v1 findings, lint, and
    costEstimate requests accept the same fields as flat request
    properties.
  • Verdicts are truthful: selection runs after exit/ok are computed
    on the complete set, and SelectionOutcome carries total, withheld,
    and the full set's max severity, so PASS/WARN/ERROR and the exit code can
    never be understated by a filtered view.
  • Explicit truncation: selection: {"total": N, "withheld": M} appears
    next to the filtered array in JSON; text mode prints
    ... N finding(s)/diagnostic(s) withheld (--max).
  • Text grouping: consecutive lint findings sharing rule id and message
    collapse into one entry that lists all locations (the 9×repeated-value
    cake fixture now renders as one entry with 9 --> locations).
  • Unknown --rule-id/rule is a usage error (CLI exit 2, agent
    invalid-selection), never a silent empty result.
  • Compatibility: omitting every selection option reproduces the
    previous output byte-for-byte — findings stays a bare array, and no
    selection member appears.

Schemas (wright-agent-v1, wright-check-v1), the agent contract doc, and
the CLI docs/help are updated. cost CLI flags join with the query surface
in #429, which this PR does not implement.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets --all-features — all green
  • New tests: driver unit tests for each dimension + unknown-rule error;
    CLI e2e (filtering, --max withheld counts in text+JSON, grouping of the
    cake fixture, byte-identical envelope without options, unknown id exit 2,
    and the ablation guard: check --rule-id filtering an error diagnostic
    keeps exit 1); CLI↔agent same-set equivalence test; stdio transport
    selection test
  • Verified against tests/fixtures/workshop/real-world/overpy-cake.ws
    end to end (CLI text/JSON and serve stdio)

Closes #430

Finding selection (severity threshold, rule id, file, max) is implemented
once in wright-driver and applied to envelope diagnostics and lint findings
only after the verdict and exit code are fixed on the complete set, so a
filtered view can never flip a failing project to exit 0. The CLI exposes
--severity/--rule-id/--file/--max on check, analyze, and lint; the
wright-agent/v1 findings, lint, and costEstimate requests accept the same
fields flat in the request. Truncation is reported via
selection.total/withheld, unknown rule ids are usage errors, and
consecutive identical lint findings collapse into one rendered entry
listing all locations.

Fixes #430

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the #430 acceptance criteria: shared driver-side selection, truthful verdict/exit ordering, withheld reporting, text collapsing, unknown-rule usage errors, additive wire shapes, and CLI↔agent parity coverage all check out. Two findings inline. The branch also conflicts with main after #436 (compact_lint_rules + the agent-contract wording); resolution is straightforward — keep the compact rules payload and add selection on top.

Comment thread crates/wright-driver/src/select.rs Outdated
Comment thread crates/wright-driver/src/result.rs Outdated
Resolve the lint-result overlap with #436: keep the compact per-rule id/effective-severity payload and apply finding selection on top, on both the CLI lint result and the agent lint operation.
The reported span.path spelling differs per surface — lint findings resolve root-relative while check/analyze envelope diagnostics carry the cwd-relative display path — so an exact string match silently selected nothing for the input path exactly as passed. Resolve both the file argument and each reported span.path under the session bases (invocation cwd and input root) to a canonical path; pseudo-paths keep exact-match semantics. Also correct the Envelope::selection doc: the member is emitted whenever a selection is applied, not only when it reduces the set.
@e54-bot

e54-bot commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up verification complete on 5bad6ad:

  • Both review findings are addressed — --file now selects by canonical file identity across as-passed, root-relative, cwd-relative, and absolute spellings on all surfaces (check/analyze/lint/agent findings/lint/costEstimate); the Envelope::selection rustdoc now reflects actual emission semantics.
  • Independent local re-review verified: verdict/exit computed on the full set before selection, no-selection output is byte-identical to the pre-change baseline (db42356), the feat(driver): serve compact rule metadata in the lint result #436 merge preserves compact rules metadata alongside selection, --max/collapse/unknown-rule behavior all conform to Filter and group findings in the shared driver layer #430.
  • CI run 36585859815: all checks green.

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teakowa
Teakowa merged commit efe6e8c into main Sep 29, 2026
22 checks passed
@Teakowa
Teakowa deleted the wright-430-finding-selection branch September 29, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Filter and group findings in the shared driver layer

2 participants