pub struct ResolutionRule {
pub id: String,
pub playbook_id: String,
pub target_class: TargetClass,
pub priority: u32,
pub merge_strategy: MergeStrategy,
pub description: String,
pub min_confidence: f64,
pub min_score: u32,
pub require_unknown_vendor: bool,
pub vendors: Vec<VendorRuleMatch>,
}Expand description
Single codified rule mapping vendor patterns to a playbook.
Rules are ordered by priority (lower numbers win). When two
rules both match a crate::vendor_classifier::VendorClassification
the resolver picks the lowest-priority rule, then applies its
merge_strategy to combine any
remaining rules into a single decision.
§Example
use stygian_charon::vendor_resolver::{MergeStrategy, ResolutionRule, VendorRuleMatch};
use stygian_charon::types::TargetClass;
use stygian_charon::vendor_classifier::VendorId;
let rule = ResolutionRule {
id: "tier2-hostile".to_string(),
playbook_id: "tier2-hostile".to_string(),
target_class: TargetClass::HighSecurity,
priority: 0,
merge_strategy: MergeStrategy::StrongestVendor,
description: "Hostile anti-bot vendors".to_string(),
min_confidence: 0.60,
min_score: 5,
require_unknown_vendor: false,
vendors: vec![VendorRuleMatch {
vendor: VendorId::DataDome,
weight: 10,
}],
};
assert!(rule.validate().is_ok());Fields§
§id: StringStable rule id ("tier2-hostile", "tier1-js-cloudflare",
etc.). Required, non-empty, unique within a resolver bundle.
playbook_id: StringPlaybook id the rule resolves to. Empty string means the
Manual strategy marker should be returned instead.
target_class: TargetClassTarget class the resolved playbook maps to.
priority: u32Priority (lower wins). The baseline rules use 0
(tier2-hostile), 10 (tier1-js-cloudflare), 100
(tier1-static), and 1000 (default-manual).
merge_strategy: MergeStrategyMerge strategy used when this rule fires alongside other matching rules.
description: StringHuman-readable description for operator logs.
min_confidence: f64Minimum classifier confidence the top vendor must cross for
the rule to fire. Must be in [0.0, 1.0].
min_score: u32Minimum classifier score the top vendor must reach for the
rule to fire. Must be > 0 (or 0 for the catch-all
default-manual rule).
require_unknown_vendor: boolWhen true, the rule only fires when the classifier reports
VendorId::Unknown. Used by the tier1-static rule so
benign unknown classifications do not accidentally swallow
single-signal low-confidence matches.
vendors: Vec<VendorRuleMatch>Vendors that trigger the rule.
Implementations§
Source§impl ResolutionRule
impl ResolutionRule
Sourcepub fn validate(&self) -> Result<(), VendorResolverError>
pub fn validate(&self) -> Result<(), VendorResolverError>
Validate the rule’s internal consistency. Reports the first failing field with a structured error that includes both the rule id and the field path.
§Errors
Returns VendorResolverError on the first inconsistency.
The error embeds the rule id, the field path, and
the bad value so operators can locate the offending
TOML line without re-running the loader.
Sourcepub fn vendors_by_id(&self) -> BTreeMap<VendorId, &VendorRuleMatch>
pub fn vendors_by_id(&self) -> BTreeMap<VendorId, &VendorRuleMatch>
Vendor list indexed by VendorId for fast lookup.
Trait Implementations§
Source§impl Clone for ResolutionRule
impl Clone for ResolutionRule
Source§fn clone(&self) -> ResolutionRule
fn clone(&self) -> ResolutionRule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more