Module: Legion::Extensions::Agentic::Self::Reflection::Helpers::ReflectionFactory
- Defined in:
- lib/legion/extensions/agentic/self/reflection/helpers/reflection.rb
Class Method Summary collapse
- .new_reflection(category:, observation:, severity: :notable, metrics: {}, recommendation: :no_action) ⇒ Object
- .severity_for_drop(drop) ⇒ Object
- .severity_weight(severity) ⇒ Object
Class Method Details
.new_reflection(category:, observation:, severity: :notable, metrics: {}, recommendation: :no_action) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/self/reflection/helpers/reflection.rb', line 14 def new_reflection(category:, observation:, severity: :notable, metrics: {}, recommendation: :no_action) raise ArgumentError, "invalid category: #{category}" unless Constants::CATEGORIES.include?(category) raise ArgumentError, "invalid severity: #{severity}" unless Constants::SEVERITIES.include?(severity) { reflection_id: SecureRandom.uuid, category: category, observation: observation, severity: severity, metrics: metrics, recommendation: recommendation, created_at: Time.now.utc, acted_on: false } end |
.severity_for_drop(drop) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/legion/extensions/agentic/self/reflection/helpers/reflection.rb', line 41 def severity_for_drop(drop) if drop >= 0.4 then :critical elsif drop >= 0.25 then :significant elsif drop >= 0.1 then :notable else :trivial end end |
.severity_weight(severity) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/self/reflection/helpers/reflection.rb', line 31 def severity_weight(severity) case severity when :critical then 1.0 when :significant then 0.7 when :notable then 0.4 when :trivial then 0.1 else 0.0 end end |