feat(commons): add ADR-064 rule set schema types and validation #2409
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
cbumb
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 readsruleSetsyet. node-drainer and fault-remediation adopt it in later issues.New package
commons/pkg/rulesetRuleSet: shared fieldsname,enabled,priorityandmatch(all/anyCEL rules onHealthEventorNode). A component embeds it and adds its outcome key (drain,remediation). An omittedenableddefaults totrue, as ADR-064 specifies.StopandOutcome: each outcome embeds the sharedstopfield and defines its ownValidate().Validate: rejects bad or duplicate names, an invalidmatch, 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 underruleSets, for exampleruleSets.drainin the fault-remediation config. It ignores keys outsideruleSets, so a rolling upgrade keeps working.Changes to existing packages
configmanager.LoadTOMLConfigWithMetadatareturns the decode metadata.LoadTOMLConfigis unchanged.celrule.CheckBooleanExpressiontype-checks an expression at startup. It acceptsdyn, so field reads such asnode.spec.unschedulablekeep 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
ruleSetsissue, which is the first caller ofCheckUndecoded.Type of Change
Component(s) Affected
commonsshared library)Testing
Checklist
<!-- 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 -->