feat(findings): say why a finding needs review — AI false alarm or AI unsure (#954) #958

Merged
sharang merged 1 commits from feat/954-review-reason into main 2026-11-10 13:49:34 +00:00
Owner

What changed

"Zu prüfen" now says which case put a finding there:

  • "KI: wohl Fehlalarm" / "AI: likely false alarm": the LLM triage dismissed it.
  • "KI: unsicher" / "AI: unsure": the triage confirmed it, but with confidence below the threshold.

Where it shows:

  • Findings list: the status badge shows the reason instead of the plain status. Hovering it shows the AI's rationale.

  • Finding page: the header and the triage card show the reason. The card already shows the rationale. For a likely false alarm there are two one-click actions, offered only to roles that may change a status (use_can_write, the same check as the status card):

    • "Fehlalarm bestätigen" sets false_positive, with the AI's rationale as the reason in the status history.
    • "Doch prüfen" sets triaged, the status the triage itself gives a confirmed finding.

    Both go through the existing PATCH /api/v1/findings/{id}/status. The API handler is unchanged.

The actions are offered only for the false-alarm case. They confirm or reject the AI's guess, and an "unsure" verdict makes no guess. For those findings the existing status buttons decide.

The actions are on the finding page only. The list has bulk actions but no per-row actions, so I added none there.

Data model

There is no new stored field and no migration. The reason comes from data each finding already stores:

  • status == needs_review
  • triage_action
  • confidence

Code:

  • compliance-core: new ReviewReason { LikelyFalseAlarm, Unsure }, ReviewReason::of_verdict(action, confidence) and Finding::review_reason(). These are additive (an enum, constants, one method). Finding's serialized form is unchanged.
  • The triage's confidence threshold (3.0) and its action markers (dismiss, skipped, control_not_confirmed) move to core constants. The agent's SKIPPED_ACTION is now an alias of the core constant.
  • apply_action in llm/triage.rs now decides through ReviewReason::of_verdict, so the triage and the label cannot drift apart.

Old findings get the label as well: they already store the verdict.

The label falls back to the plain "Zu prüfen" when:

  • the triage skipped the finding;
  • the control check set it to review (control_not_confirmed; that path keeps the model's earlier confidence, so it is excluded explicitly);
  • no confidence is stored;
  • a later scan judged an earlier needs_review finding again and the model is now sure it is real. The finding store updates the triage fields of such a row but not its status, so the label follows the latest verdict.

The wire status needs_review is unchanged, so the API, MCP, issue sync (issue_sync.rs, issue_creation.rs ISSUE_STATUSES) and the nightly harness are untouched.

Not in this PR

  • Status filter "KI: wohl Fehlalarm" (item 4): skipped. The list's status filter goes straight into a Mongo equality, so a filter on the reason needs a new query parameter through the DTO, the handler and the dashboard query. That is more than trivial. #950's "KI: wohl Fehlalarm" bucket needs the same server-side match: status: "needs_review", triage_action: "dismiss".

How tested

  • compliance-core unit tests for review_reason:

    • dismiss;
    • confidence 2.9 vs 3.0;
    • an unknown action counts as confirm;
    • skipped, control_not_confirmed and no confidence give no reason;
    • a status other than needs_review gives no reason;
    • downgrade and upgrade give no reason.
  • compliance-agent: apply_verdict stores a reason that review_reason() reads back, for:

    • dismiss;
    • low confidence;
    • a test-code path that halves the confidence;
    • a confident confirm, which has no reason.

    llm::triage (49), controls:: (38) and finding_store (8) tests pass.

  • compliance-dashboard texts: DE and EN labels, and the fallback to the plain status.

  • The brief asked for a serde test of a new field. There is no new field, so that test does not apply.

  • cargo fmt --all --check passes.

  • Clippy with -D warnings is clean for:

    • compliance-core;
    • compliance-agent;
    • compliance-dashboard, with --features server and with --features web;
    • compliance-mcp.

Closes #954

🤖 Generated with Claude Code

## What changed "Zu prüfen" now says which case put a finding there: - **"KI: wohl Fehlalarm"** / "AI: likely false alarm": the LLM triage dismissed it. - **"KI: unsicher"** / "AI: unsure": the triage confirmed it, but with confidence below the threshold. Where it shows: - **Findings list:** the status badge shows the reason instead of the plain status. Hovering it shows the AI's rationale. - **Finding page:** the header and the triage card show the reason. The card already shows the rationale. For a likely false alarm there are two one-click actions, offered only to roles that may change a status (`use_can_write`, the same check as the status card): - **"Fehlalarm bestätigen"** sets `false_positive`, with the AI's rationale as the reason in the status history. - **"Doch prüfen"** sets `triaged`, the status the triage itself gives a confirmed finding. Both go through the existing `PATCH /api/v1/findings/{id}/status`. The API handler is unchanged. The actions are offered only for the false-alarm case. They confirm or reject the AI's guess, and an "unsure" verdict makes no guess. For those findings the existing status buttons decide. The actions are on the finding page only. The list has bulk actions but no per-row actions, so I added none there. ## Data model There is **no new stored field and no migration.** The reason comes from data each finding already stores: - `status == needs_review` - `triage_action` - `confidence` Code: - `compliance-core`: new `ReviewReason { LikelyFalseAlarm, Unsure }`, `ReviewReason::of_verdict(action, confidence)` and `Finding::review_reason()`. These are additive (an enum, constants, one method). `Finding`'s serialized form is unchanged. - The triage's confidence threshold (3.0) and its action markers (`dismiss`, `skipped`, `control_not_confirmed`) move to core constants. The agent's `SKIPPED_ACTION` is now an alias of the core constant. - `apply_action` in `llm/triage.rs` now decides through `ReviewReason::of_verdict`, so the triage and the label cannot drift apart. **Old findings** get the label as well: they already store the verdict. The label falls back to the plain "Zu prüfen" when: - the triage skipped the finding; - the control check set it to review (`control_not_confirmed`; that path keeps the model's earlier confidence, so it is excluded explicitly); - no confidence is stored; - a later scan judged an earlier `needs_review` finding again and the model is now sure it is real. The finding store updates the triage fields of such a row but not its status, so the label follows the latest verdict. The **wire status `needs_review` is unchanged**, so the API, MCP, issue sync (`issue_sync.rs`, `issue_creation.rs` ISSUE_STATUSES) and the nightly harness are untouched. ## Not in this PR - **Status filter "KI: wohl Fehlalarm" (item 4):** skipped. The list's `status` filter goes straight into a Mongo equality, so a filter on the reason needs a new query parameter through the DTO, the handler and the dashboard query. That is more than trivial. #950's "KI: wohl Fehlalarm" bucket needs the same server-side match: `status: "needs_review", triage_action: "dismiss"`. ## How tested - `compliance-core` unit tests for `review_reason`: - dismiss; - confidence 2.9 vs 3.0; - an unknown action counts as confirm; - skipped, `control_not_confirmed` and no confidence give no reason; - a status other than `needs_review` gives no reason; - downgrade and upgrade give no reason. - `compliance-agent`: `apply_verdict` stores a reason that `review_reason()` reads back, for: - dismiss; - low confidence; - a test-code path that halves the confidence; - a confident confirm, which has no reason. `llm::triage` (49), `controls::` (38) and `finding_store` (8) tests pass. - `compliance-dashboard` texts: DE and EN labels, and the fallback to the plain status. - The brief asked for a serde test of a new field. There is no new field, so that test does not apply. - `cargo fmt --all --check` passes. - Clippy with `-D warnings` is clean for: - `compliance-core`; - `compliance-agent`; - `compliance-dashboard`, with `--features server` and with `--features web`; - `compliance-mcp`. Closes #954 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-10 10:48:22 +00:00
feat(findings): say why a finding needs review — AI false alarm or AI unsure (#954)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m5s
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 17m45s
0e9077181c
"Zu prüfen" now says which of the two cases put it there: the LLM triage
dismissed the finding as a likely false alarm ("KI: wohl Fehlalarm"), or it
confirmed it with too little confidence ("KI: unsicher"). The reason is read
from the verdict already stored on the finding (triage_action, confidence),
so findings from before this change get it too; the wire status stays
needs_review.

- core: ReviewReason, ReviewReason::of_verdict and Finding::review_reason;
  the triage's confidence threshold and its action markers move to core.
- agent: apply_action decides through ReviewReason::of_verdict, so the
  triage and the label cannot drift apart.
- dashboard: the list and the finding page show the reason instead of the
  bare status, the list with the AI's rationale on hover; the finding page
  confirms ("Fehlalarm bestätigen", false positive with the rationale as
  reason) or rejects ("Doch prüfen", triaged) the AI's guess in one click,
  for roles that may change a status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit ef9c578948 into main 2026-11-10 13:49:34 +00:00
Sign in to join this conversation.