Class: Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Catalyst
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Catalyst
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb
Constant Summary
Constants included from Constants
Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::ACTIVATION_ENERGY, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::CATALYST_REDUCTION, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::CATALYST_TYPES, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::MAX_CATALYSTS, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::MAX_REACTIONS, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::POTENCY_DECAY, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::POTENCY_LABELS, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::REACTION_TYPES, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::SPECIFICITY_BONUS, Legion::Extensions::Agentic::Learning::Catalyst::Helpers::Constants::YIELD_LABELS
Instance Attribute Summary collapse
-
#catalyst_type ⇒ Object
readonly
Returns the value of attribute catalyst_type.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#potency ⇒ Object
readonly
Returns the value of attribute potency.
-
#specificity ⇒ Object
readonly
Returns the value of attribute specificity.
-
#uses_count ⇒ Object
readonly
Returns the value of attribute uses_count.
Instance Method Summary collapse
- #broad? ⇒ Boolean
-
#catalyze!(_reaction_type) ⇒ Object
Apply this catalyst to a reaction — increments uses_count but does NOT reduce potency Catalysts are not consumed by use; they are reusable accelerators Returns activation_reduction = potency * specificity.
-
#degrade! ⇒ Object
Degrade from environmental wear (not from use).
- #inert? ⇒ Boolean
-
#initialize(catalyst_type:, domain:, potency: 0.5, specificity: 0.5) ⇒ Catalyst
constructor
A new instance of Catalyst.
- #potency_label ⇒ Object
- #powerful? ⇒ Boolean
-
#recharge!(amount) ⇒ Object
Recharge by increasing potency.
- #specific? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(catalyst_type:, domain:, potency: 0.5, specificity: 0.5) ⇒ Catalyst
Returns a new instance of Catalyst.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 17 def initialize(catalyst_type:, domain:, potency: 0.5, specificity: 0.5) @id = SecureRandom.uuid @catalyst_type = catalyst_type @domain = domain @potency = potency.clamp(0.0, 1.0) @specificity = specificity.clamp(0.0, 1.0) @uses_count = 0 @created_at = Time.now.utc end |
Instance Attribute Details
#catalyst_type ⇒ Object (readonly)
Returns the value of attribute catalyst_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def catalyst_type @catalyst_type end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def id @id end |
#potency ⇒ Object (readonly)
Returns the value of attribute potency.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def potency @potency end |
#specificity ⇒ Object (readonly)
Returns the value of attribute specificity.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def specificity @specificity end |
#uses_count ⇒ Object (readonly)
Returns the value of attribute uses_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 14 def uses_count @uses_count end |
Instance Method Details
#broad? ⇒ Boolean
57 58 59 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 57 def broad? @specificity < 0.3 end |
#catalyze!(_reaction_type) ⇒ Object
Apply this catalyst to a reaction — increments uses_count but does NOT reduce potency Catalysts are not consumed by use; they are reusable accelerators Returns activation_reduction = potency * specificity
30 31 32 33 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 30 def catalyze!(_reaction_type) @uses_count += 1 (@potency * @specificity).round(10) end |
#degrade! ⇒ Object
Degrade from environmental wear (not from use)
36 37 38 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 36 def degrade! @potency = (@potency - POTENCY_DECAY).clamp(0.0, 1.0).round(10) end |
#inert? ⇒ Boolean
49 50 51 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 49 def inert? @potency < 0.2 end |
#potency_label ⇒ Object
61 62 63 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 61 def potency_label POTENCY_LABELS.find { |range, _| range.cover?(@potency) }&.last || :inert end |
#powerful? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 45 def powerful? @potency >= 0.8 end |
#recharge!(amount) ⇒ Object
Recharge by increasing potency
41 42 43 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 41 def recharge!(amount) @potency = (@potency + amount).clamp(0.0, 1.0).round(10) end |
#specific? ⇒ Boolean
53 54 55 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 53 def specific? @specificity >= 0.7 end |
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/legion/extensions/agentic/learning/catalyst/helpers/catalyst.rb', line 65 def to_h { id: @id, catalyst_type: @catalyst_type, domain: @domain, potency: @potency, specificity: @specificity, uses_count: @uses_count, potency_label: potency_label, powerful: powerful?, inert: inert?, specific: specific?, broad: broad?, created_at: @created_at } end |