Class: RosettAi::Composition::ConflictDetector
- Inherits:
-
Object
- Object
- RosettAi::Composition::ConflictDetector
- Defined in:
- lib/rosett_ai/composition/conflict_detector.rb
Overview
Detects rule ID collisions across behaviour files. When two behaviours define the same rule ID at the same scope and priority, this is a conflict that must be reported.
Instance Method Summary collapse
-
#detect(rules) ⇒ Array<String>
Detects rule ID collisions in a list of annotated rules.
-
#security_override?(existing, candidate) ⇒ Boolean
Checks if a security-domain rule would be overridden by a non-security rule.
Instance Method Details
#detect(rules) ⇒ Array<String>
Detects rule ID collisions in a list of annotated rules.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rosett_ai/composition/conflict_detector.rb', line 16 def detect(rules) conflicts = [] seen = {} rules.each do |rule| rule_id = rule[:id] key = rule_id.to_s if seen.key?(key) existing = seen[key] conflicts << format_conflict(rule_id, existing, rule) else seen[key] = rule end end conflicts end |
#security_override?(existing, candidate) ⇒ Boolean
Checks if a security-domain rule would be overridden by a non-security rule. This is never allowed.
41 42 43 |
# File 'lib/rosett_ai/composition/conflict_detector.rb', line 41 def security_override?(existing, candidate) existing[:domain] == 'security' && candidate[:domain] != 'security' end |