Skip to content

feat(review): Apply per-rule severity overrides from config#114

Merged
mhiro2 merged 3 commits into
mainfrom
feat/review-severity-override
Apr 29, 2026
Merged

feat(review): Apply per-rule severity overrides from config#114
mhiro2 merged 3 commits into
mainfrom
feat/review-severity-override

Conversation

@mhiro2

@mhiro2 mhiro2 commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add per-rule severity overrides so projects can downgrade noisy findings or escalate the ones that matter, with overrides applied between rule evaluation and suppression so summary counts and --deny thresholds see the post-override severity.
  • Surface the override pipeline through [review.severity_overrides."<rule-id>"] in relune.toml with strict, fail-fast validation: unknown rule IDs and duplicate (including case-insensitive) config entries become usage errors at startup.

Changes

  • d098868 : feat(review): apply per-rule severity overrides from config
    • Introduce ReviewSeverityOverride in relune-core (re-exported from relune-app) and a new ReviewRequest::severity_overrides field plus builder.
    • Wire the override pipeline through relune-app::review: build a HashMap<ReviewRuleId, ReviewSeverity> (rejecting duplicates as input errors) and rewrite finding severities before suppression, summary, and deny-threshold evaluation.
    • Parse [review.severity_overrides] as a strict BTreeMap<rule_id, { severity }> table, resolve each key via ReviewRuleId::parse so unknown IDs surface as ConfigError::InvalidValue, and forward the merged list through merge_review_args.
  • 72f8547 : fix(review): map severity-override config errors to usage exit code
    • Drop the manual CliError::general wrapper in run_review so the existing From<ConfigError> for CliError mapping returns CliError::usage (exit code 2), matching the rest of the config validation surface.
    • Add CLI integration coverage for the override pipeline: a downgrade success path that asserts the JSON summary/finding severity, and a usage-error path that asserts exit code 2 plus the explanatory stderr message.
  • 80c5ffd : fix(review): reject duplicate severity override keys at config layer
    • Detect case-insensitive key collisions inside resolve_severity_overrides so duplicates are rejected as ConfigError::InvalidValue (exit code 2) instead of slipping through to the app-layer duplicate guard (exit code 1).
    • Add matching config unit and CLI integration tests for the duplicate path so the behaviour stays pinned.

mhiro2 added 2 commits April 29, 2026 22:20
Add `[review.severity_overrides."<rule-id>"]` to `relune.toml` so noisy
rules can be downgraded and rules the project cares about can be
escalated without changing the rule code itself. The overrides are
applied in `relune-app::review` between rule evaluation and summary
aggregation, so the post-override severity flows through both the
JSON `summary` and the `--deny` threshold check.

Unknown rule IDs in TOML now fail-fast as a usage error during the
config merge, and duplicate `rule_id` entries on a directly built
`ReviewRequest` are rejected as `AppError::Input` to keep behavior
consistent with the strict TOML schema.

`ReviewSeverityOverride` is added to `relune-core` (alongside
`ReviewRuleMetadata`) as the single serialization shape shared by the
CLI, future WASM bindings, and the playground.
Drop the manual `CliError::general` wrapper in `run_review` so the existing
`From<ConfigError> for CliError` mapping (which returns `CliError::usage`)
applies. Unknown rule_ids in `[review.severity_overrides]` now exit with code
2, matching the rest of the config validation surface.

Add CLI integration coverage for the override pipeline: a downgrade success
path that asserts the JSON summary/finding severity, and a usage-error path
that asserts exit code 2 plus the explanatory stderr message.
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown

Schema review

Tip

✅ No risk findings — schema changes look safe to merge.

`ReviewRuleId::parse` is case-insensitive, so two TOML keys like
`risk/fk-without-index` and `RISK/FK-WITHOUT-INDEX` previously slipped past
`resolve_severity_overrides` and only failed inside the app layer's duplicate
guard, surfacing as a generic exit code 1. Detect the collision in the config
resolver instead so it raises a `ConfigError::InvalidValue` and maps to the
usage exit code 2 like the rest of the override validation surface.

Add a config-level unit test plus a CLI integration test that pin the
behaviour for case-insensitive duplicates.
@mhiro2 mhiro2 self-assigned this Apr 29, 2026
@mhiro2 mhiro2 added the enhancement New feature or request label Apr 29, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report

main (436955f) #114 (e21fb92) +/-
Coverage 94.7% 94.7% +0.0%
Test Execution Time 1m34s 1m32s -2s
Details
  |                     | main (436955f) | #114 (e21fb92) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          94.7% |          94.7% | +0.0% |
  |   Files             |             81 |             81 |     0 |
  |   Lines             |          36858 |          37109 |  +251 |
+ |   Covered           |          34912 |          35161 |  +249 |
+ | Test Execution Time |          1m34s |          1m32s |   -2s |

Code coverage of files in pull request scope (94.0% → 94.4%)

Files Coverage +/- Status
crates/relune-app/src/lib.rs 96.2% 0.0% modified
crates/relune-app/src/request.rs 81.2% +0.2% modified
crates/relune-app/src/usecases/review.rs 95.5% +0.9% modified
crates/relune-cli/src/commands/review.rs 92.3% +0.1% modified
crates/relune-cli/src/config.rs 96.4% +0.2% modified
crates/relune-core/src/review.rs 94.7% +0.2% modified

Reported by octocov

@mhiro2
mhiro2 merged commit 117a6fd into main Apr 29, 2026
6 checks passed
@mhiro2
mhiro2 deleted the feat/review-severity-override branch April 29, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant