← Back to Pull requests

feat(commons): add ADR-064 rule set schema types and validation #2409

Closed
unknown closed this pull request without merging on Nov 18, 2026 10:53 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 01:49 UTC
Author

Summary

Closes #2209. Part of [ADR-064](docs/designs/064-node-and-device-selection.md).

Adds the shared rule set schema and its validation in commons/pkg/ruleset. No component reads ruleSets yet. node-drainer and fault-remediation adopt it in later issues.

New package commons/pkg/ruleset

  • RuleSet: shared fields name, enabled, priority and match (all / any CEL rules on HealthEvent or Node). A component embeds it and adds its outcome key (drain, remediation). An omitted enabled defaults to true, as ADR-064 specifies.

  • Stop and Outcome: each outcome embeds the shared stop field and defines its own Validate().

  • Validate: rejects bad or duplicate names, an invalid match, an unknown kind, a non-boolean or broken expression, and a missing or invalid outcome. It checks disabled rule sets too, and returns all errors together.

  • CheckUndecoded: names unknown keys under ruleSets, for example ruleSets.drain in the fault-remediation config. It ignores keys outside ruleSets, so a rolling upgrade keeps working.
  • Changes to existing packages

  • configmanager.LoadTOMLConfigWithMetadata returns the decode metadata. LoadTOMLConfig is unchanged.

  • celrule.CheckBooleanExpression type-checks an expression at startup. It accepts dyn, so field reads such as node.spec.unschedulable keep working, as they do in fault-quarantine. Fault-quarantine behaviour is unchanged.
  • Not in this PR
    node-drainer keeps discarding the decode metadata until the node-drainer ruleSets issue, which is the first caller of CheckUndecoded.

    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 (commons shared library)
  • 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
    Added support for defining and validating rule sets with names, priorities, match conditions, and outcomes.
    Rule expressions are checked for valid syntax and boolean-compatible results, with errors identifying the affected rule or configuration.
    Configuration loading can now report unrecognized TOML keys, including unknown fields within rule sets.
    * Rule sets without an explicit enabled setting default to enabled; explicitly configured settings are preserved.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 368 lines (+276 / -92) across 4 files Reviewer: cbumb Review duration: 3423m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 368 lines diff across 4 files
    0.43
    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.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2409"
    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.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    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.5% · Safe to merge
    18.5%