← Back to Pull requests

CNV-80463: add alert rule preview API #1331

Open
unknown opened this pull request with 239 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 06, 2026 14:15 UTC
Author

Summary

Adds POST /api/v1/alerting/rules/preview for dry-run create or
update without persisting changes.

Preview shares planning logic with execute paths
(plan_create_user_defined.go, plan_create_platform.go,
plan_update.go) and returns a multi-resource change plan
(resources[], desiredRule, writable, optional managedBy).

Preview API

  • Create preview: alertingRule + optional prometheusRule

  • Update preview: ruleId + at least one of labels,

  • alertingRuleEnabled, or classification
  • Response includes per-resource changes[] and full desiredObject

  • for UI review
  • Works on externally managed resources (writable: false with

  • managedBy)

    Tests

  • Unit: preview handler and planning paths

  • Unit: platform preview/execute writable parity

  • E2E: preview no-persistence checks for create and update

  • E2E RBAC: anonymous / namespace-scoped / cluster-admin for

  • /rules/preview create and update

    Test plan

  • go test ./pkg/management/... ./internal/managementrouter/...

  • go build -tags e2e ./test/e2e/...

  • CI on this PR
  • Signed-off-by: Shirly Radco <sradco@redhat.com>
    Co-authored-by: AI Assistant <noreply@cursor.com>

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added alert-rule previews for creating and updating rules. Previews show the desired rule, affected resources, and add, replace, or remove changes without saving them.
    Preview results indicate whether changes are writable and identify GitOps- or operator-managed rules that cannot be changed through the API.
    API operations now document bearer-token authentication.

    Documentation
    Documented preview requests, responses, and access requirements.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 239 lines (+179 / -60) across 2 files Reviewer: PeterYurkovich Review duration: 77221m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 239 lines diff across 2 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.328
    Real PR Conversation Timeline
    1 comments
    "Review active on #1331"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.2% (MEDIUM) · Higher = larger blast radius
    44.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.5% · Safe to merge
    24.5%