Skip to content

feat(prr): add --min-severity flag to audit and review - #38

Merged
andreujuanc merged 5 commits into
masterfrom
feat/min-finding-level
May 28, 2026
Merged

andreujuanc merged 5 commits into
masterfrom
feat/min-finding-level

Conversation

@andreujuanc

@andreujuanc andreujuanc commented May 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • New --min-severity=<critical|high|medium|low|nit> flag on prr audit and prr review.
  • Drops Phase 3 deep-review findings below the threshold before recheck and every later phase (synthesis, persistence, reporting). The user pays no recheck/synthesis cost for findings they've chosen to ignore.
  • TUI surfaces a "PARTIAL — filtered to severity ≥ X" banner on the Review tab (both findings view and clean-PR placeholder) so a filtered run can't masquerade as a full one, with a hint to press A for a fresh full run.

Context

  • Threaded through audit.Options.MinSeverity, review.PRReviewOptions.MinSeverity, and review.CoreOptions.MinSeverity. Persisted on state.ReviewMeta.MinSeverity so the marker survives TUI restart.
  • Shared parser + filter live in internal/review/execute.go. Severity ladder is package-private; AllSeverities() returns a copy (mirrors ai.AllCategorySlugs pattern). FilterByMinSeverity always allocates so callers can't accidentally alias the input.
  • Empty / unset = no filtering (preserves today's behavior). Unknown severities and the empty string rank as nit, matching severityRank. Invalid values fail fast at the CLI boundary with a clear error listing valid levels.
  • Tests: round-trip in internal/state, parse + filter + aliasing contract in internal/review, partial banner rendering in internal/ui.

Filter deep-review findings below a severity threshold before recheck
and all later phases run, so the user pays no recheck/synthesis cost for
findings they've chosen to ignore. Supported on both `prr audit` and
`prr review` as --min-finding-level=<critical|high|medium|low|nit>.
Matches the existing `DeepFinding.Severity` field and the rest of the
codebase's vocabulary (severityRank, severityOrder). The shorter name
also fits the established help-text column so the flag aligns with
its peers instead of overflowing.
Mirrors the category-list pattern (ai.AllCategorySlugs): keeps the
canonical severity ladder package-private and exposes read access via
AllSeverities, which returns a fresh copy so external callers can't
mutate the shared slice.

FilterByMinSeverity now always allocates the returned slice, so the
empty-min path no longer aliases the caller's input. Added an
aliasing-mutation assertion so the contract is regression-tested.
Adds the active --min-severity threshold to audit.Result,
review.PRReviewResult/CoreResult, and state.ReviewMeta. Headless JSON
output now carries the marker, and reopening the TUI exposes it via
state.LastReview.MinSeverity so the Review tab can render a
"partial run" badge and offer a re-run without the filter.

Pure plumbing — no TUI rendering yet. JSON uses `min_severity,omitempty`
so older state files round-trip unchanged.
Adds a "PARTIAL — filtered to severity ≥ X" banner to the Review tab,
mirroring the existing STALE banner's visual vocabulary. Shows up in
both the findings view and the clean-PR placeholder (so a "clean"
verdict produced from a filtered run no longer looks unconditionally
clean). Hint line tells the user to press A for a fresh full run.

Threads LastReview.MinSeverity through renderStructuredReview from
all three call sites in model.go. Test coverage: empty minSeverity
hides the banner; non-empty shows it with the threshold and hint;
STALE + PARTIAL coexist when both apply.
@andreujuanc
andreujuanc force-pushed the feat/min-finding-level branch from f55fa0a to 4f5aa2c Compare May 28, 2026 18:25
@andreujuanc andreujuanc changed the title feat(prr): add --min-finding-level to audit and review feat(prr): add --min-severity flag to audit and review May 28, 2026
@andreujuanc
andreujuanc merged commit 03e6ac2 into master May 28, 2026
2 checks passed
@andreujuanc
andreujuanc deleted the feat/min-finding-level branch May 28, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant