← Back to Pull requests

feat(commons): evaluate rule sets in order of priority #2537

Closed
unknown closed this pull request without merging on Nov 26, 2026 03:24 UTC
View on GitHub
unknown unknown commented on Nov 25, 2026 00:40 UTC
Author

Summary

Fixes #2210. Part of #1903. Design: ADR-064, section "Rule set evaluation".

Adds rule set evaluation to commons/pkg/ruleset. Nothing calls it yet.

  • Compile drops disabled rule sets, compiles the CEL rules once, and orders the rule sets by priority, highest first. Equal priorities keep the order of the configuration.

  • Evaluate returns the first rule set that matches, or no match. The rule sets after the winner are not evaluated.

  • An error in a rule set before the winner returns an EvaluationError that names the rule set, and no winner. The caller then uses neither a later rule set nor its default.

  • all and any give the same result whatever the order of their rules, as && and || do in CEL. A rule that does not match decides all, and a rule that matches decides any, even when another rule in the list fails.

  • The caller passes the event and the Node in Input. A rule whose input is missing fails with ErrMissingInput.

  • To evaluate a group first, such as the node-drainer stop rule sets, the caller compiles each group into its own evaluator and evaluates them in order.
  • The second commit logs each Node rule evaluation in celrule at debug instead of info, because it now runs for each rule set on each event.

    Type of Change


  • 🐛 Bug fix

  • ✨ New feature

  • 💥 Breaking change

  • 📚 Documentation

  • 🔧 Refactoring

  • 🔨 Build/CI
  • Component(s) Affected


  • Health Monitor

  • Core Service

  • Fault Management

  • Janitor

  • Deployment/Config

  • API/Interface

  • Preflight

  • Plugins

  • Documentation/CI

  • New Component

  • Multiple Components

  • Other
  • Testing


  • Tests pass locally

  • Manual testing completed

  • No breaking changes (or documented)
  • Checklist


  • Self-review completed

  • Documentation updated (if needed)

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

    Summary by CodeRabbit

    New Features
    Rule sets can now be compiled and evaluated to select the first matching result, considering higher-priority rules first and preserving configuration order for ties. Disabled rule sets are skipped.
    Evaluation reports errors when a rule set fails before a match and identifies when a required input is missing. For combined rules, all and any conditions follow their expected match behavior even when other conditions error.
    A selected rule set retains its configured outcome.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 336 lines (+252 / -84) across 4 files Reviewer: cbumb Review duration: 1604m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 336 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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
    Diff Size diff_size
    0.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2537"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 42.2% (MEDIUM) · Higher = larger blast radius
    42.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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 18.3% · Safe to merge
    18.3%