Class: RosettAi::Compiler::CapabilityChecker
- Inherits:
-
Object
- Object
- RosettAi::Compiler::CapabilityChecker
- Defined in:
- lib/rosett_ai/compiler/capability_checker.rb
Overview
Checks compiled output against engine capability manifest and emits warnings when the source YAML uses features the target engine does not support (e.g. sensitive filtering, rule metadata).
Called between compiler.compile and process_compiled in the CLI. With --strict, warnings become CompileErrors.
Instance Method Summary collapse
-
#check(source_dir) ⇒ Array<Hash>
Check compiled results against engine capabilities.
-
#check_summarized(source_dir) ⇒ Array<Hash>
Summarized check — groups warnings by feature type.
-
#initialize(engine_name) ⇒ CapabilityChecker
constructor
A new instance of CapabilityChecker.
Constructor Details
#initialize(engine_name) ⇒ CapabilityChecker
Returns a new instance of CapabilityChecker.
15 16 17 18 19 |
# File 'lib/rosett_ai/compiler/capability_checker.rb', line 15 def initialize(engine_name) @engine_name = engine_name.to_s @manifest = load_manifest @capabilities = @manifest['capabilities'] || {} end |
Instance Method Details
#check(source_dir) ⇒ Array<Hash>
Check compiled results against engine capabilities.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rosett_ai/compiler/capability_checker.rb', line 25 def check(source_dir) behaviour_dir = source_dir.join('behaviour') return [] unless behaviour_dir.exist? files = load_behaviour_files(behaviour_dir) warnings = [] warnings.concat(sensitive_warnings(files)) warnings.concat((files)) warnings end |
#check_summarized(source_dir) ⇒ Array<Hash>
Summarized check — groups warnings by feature type.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rosett_ai/compiler/capability_checker.rb', line 40 def check_summarized(source_dir) warnings = check(source_dir) warnings.group_by { |w| w[:feature] }.map do |feature, group| { feature: feature, count: group.size, message: "Engine '#{@engine_name}' does not support #{feature} — " \ "#{group.size} rule(s) compiled without it" } end end |