feat(findings): accepted risk, a who/when/why history, strict status values #350

Merged
sharang merged 1 commits from feat/finding-triage into main 2026-09-23 15:03:27 +00:00
Owner

Pilot P1, item J (triage). Stacked on #349.

What

  • New status accepted_risk ("Risiko akzeptiert"). Setting it requires a non-empty reason, otherwise 422.
  • History: every status change a person makes pushes {status, by, at, reason} onto Finding.status_history (serde default, so old rows read fine). The detail page lists it newest first. Choosing "Risiko akzeptieren" opens a reason field before anything is saved.
  • Strict values: UpdateStatusRequest.status and BulkUpdateStatusRequest.status are FindingStatus, so an unknown value is 422. Before, any string was stored, and every later read of that finding failed to decode. A status change on a missing finding is 404, where it used to be a silent 200.
  • Evidence:
    • OSCAL observations carry a status prop;
    • an accepted risk remains a not-satisfied finding against its control, marked as decided on;
    • the MCP findings summary counts accepted_risk.
  • Dashboard:
    • label and icon for the new status;
    • the bulk bar leaves out "accepted risk", which needs a reason per finding;
    • format_time is shared from the i18n module.

Verification

  • Unit tests:
    • an accepted risk needs a reason;
    • the update document records user and reason;
    • wontfix and dismissed are refused;
    • the OSCAL accepted-risk prop.
    • The existing DTO tests used the invalid "dismissed" and "x"; they are updated.
    • 395 agent lib tests, 72 core lib tests and 40 dashboard lib tests pass.
  • Integration (MongoDB): status_changes_are_validated_and_recorded
    • unknown status → 422;
    • accepted risk without a reason → 422;
    • triaged → 200;
    • accepted risk with a reason → 200;
    • missing finding → 404;
    • the stored history has two entries by dev-user with the reason.
    • It runs in parallel with the manual-findings test.
  • clippy with the CI flags (agent, mcp, dashboard server/web); fmt.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Pilot P1, item J (triage). **Stacked on #349.** ## What - **New status `accepted_risk`** ("Risiko akzeptiert"). Setting it requires a non-empty `reason`, otherwise 422. - **History:** every status change a person makes pushes `{status, by, at, reason}` onto `Finding.status_history` (serde default, so old rows read fine). The detail page lists it newest first. Choosing "Risiko akzeptieren" opens a reason field before anything is saved. - **Strict values:** `UpdateStatusRequest.status` and `BulkUpdateStatusRequest.status` are `FindingStatus`, so an unknown value is **422**. Before, any string was stored, and every later read of that finding failed to decode. A status change on a missing finding is **404**, where it used to be a silent 200. - **Evidence:** - OSCAL observations carry a `status` prop; - an accepted risk remains a not-satisfied finding against its control, marked as decided on; - the MCP findings summary counts `accepted_risk`. - **Dashboard:** - label and icon for the new status; - the bulk bar leaves out "accepted risk", which needs a reason per finding; - `format_time` is shared from the i18n module. ## Verification - **Unit tests:** - an accepted risk needs a reason; - the update document records user and reason; - `wontfix` and `dismissed` are refused; - the OSCAL accepted-risk prop. - The existing DTO tests used the invalid `"dismissed"` and `"x"`; they are updated. - 395 agent lib tests, 72 core lib tests and 40 dashboard lib tests pass. - **Integration (MongoDB):** `status_changes_are_validated_and_recorded` - unknown status → 422; - accepted risk without a reason → 422; - triaged → 200; - accepted risk with a reason → 200; - missing finding → 404; - the stored history has two entries by `dev-user` with the reason. - It runs in parallel with the manual-findings test. - clippy with the CI flags (agent, mcp, dashboard `server`/`web`); fmt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang changed target branch from feat/manual-findings to main 2026-09-23 14:46:42 +00:00
sharang added 1 commit 2026-09-23 14:46:42 +00:00
feat(findings): accepted risk, a who/when/why history, strict status values
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
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 6m6s
c465dbab4e
- New status `accepted_risk`. Setting it requires a reason (422 without).
- Every status change a person makes is pushed onto the finding's
  `status_history` with the user, the time and the reason; the detail
  page lists it, and accepting a risk asks for the reason first.
- The status is typed in the API: an unknown value such as `dismissed` is
  refused with 422. It used to be stored as free text and then broke
  every later read of the finding. A status change on a finding that
  does not exist is a 404.
- OSCAL observations carry the finding's status: an accepted risk stays a
  finding against its control, marked as decided on. The MCP findings
  summary counts accepted risks.
- The bulk bar leaves out "accepted risk", which needs a reason per
  finding; format_time moves into the i18n module and is shared.

Tests: the reason rule, the recorded change, refusal of an unknown
status, the OSCAL status prop, and an integration test (MongoDB) of
422 / 422 / 200 / 200 / 404 and the stored history.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/finding-triage from ab35864d9a to c465dbab4e 2026-09-23 14:46:42 +00:00 Compare
sharang merged commit 32bdada66b into main 2026-09-23 15:03:27 +00:00
Sign in to join this conversation.