Class: Legion::Extensions::Agentic::Learning::Fermentation::Helpers::Substrate
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Learning::Fermentation::Helpers::Substrate
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb
Constant Summary collapse
- STAGE_THRESHOLDS =
{ (0.0...0.1) => :inoculation, (0.1...0.25) => :primary_fermentation, (0.25...0.4) => :secondary_fermentation, (0.4...0.55) => :conditioning, (0.55...0.7) => :maturation, (0.7...0.85) => :aging, (0.85...0.95) => :peak, (0.95..) => :over_fermented }.freeze
Constants included from Constants
Constants::CATALYSIS_BOOST, Constants::CATALYST_TYPES, Constants::DEFAULT_POTENCY, Constants::DOMAINS, Constants::FERMENTATION_STAGES, Constants::MATURATION_RATE, Constants::MATURITY_LABELS, Constants::MAX_BATCHES, Constants::MAX_SUBSTRATES, Constants::OVER_FERMENTED_DECAY, Constants::PEAK_THRESHOLD, Constants::POTENCY_LABELS, Constants::RIPE_THRESHOLD, Constants::SPOILAGE_THRESHOLD, Constants::SUBSTRATE_TYPES, Constants::VOLATILITY_DECAY, Constants::VOLATILITY_LABELS
Instance Attribute Summary collapse
-
#catalysts_applied ⇒ Object
readonly
Returns the value of attribute catalysts_applied.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#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.
-
#maturity ⇒ Object
readonly
Returns the value of attribute maturity.
-
#potency ⇒ Object
readonly
Returns the value of attribute potency.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#substrate_type ⇒ Object
readonly
Returns the value of attribute substrate_type.
-
#volatility ⇒ Object
readonly
Returns the value of attribute volatility.
Instance Method Summary collapse
- #age ⇒ Object
- #aging? ⇒ Boolean
- #catalyze!(catalyst_type) ⇒ Object
- #ferment!(rate = MATURATION_RATE) ⇒ Object
-
#initialize(substrate_type:, domain:, content: '', potency: nil, volatility: nil) ⇒ Substrate
constructor
A new instance of Substrate.
- #multi_catalyzed? ⇒ Boolean
- #over_fermented? ⇒ Boolean
- #peak? ⇒ Boolean
- #raw? ⇒ Boolean
- #ripe? ⇒ Boolean
- #spoil! ⇒ Object
- #spoiled? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(substrate_type:, domain:, content: '', potency: nil, volatility: nil) ⇒ Substrate
Returns a new instance of Substrate.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 15 def initialize(substrate_type:, domain:, content: '', potency: nil, volatility: nil) @id = SecureRandom.uuid @substrate_type = substrate_type.to_sym @domain = domain.to_sym @content = content @potency = (potency || DEFAULT_POTENCY).to_f.clamp(0.0, 1.0) @maturity = 0.0 @volatility = (volatility || 0.5).to_f.clamp(0.0, 1.0) @stage = :inoculation @catalysts_applied = [] @created_at = Time.now.utc end |
Instance Attribute Details
#catalysts_applied ⇒ Object (readonly)
Returns the value of attribute catalysts_applied.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def catalysts_applied @catalysts_applied end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def id @id end |
#maturity ⇒ Object (readonly)
Returns the value of attribute maturity.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def maturity @maturity end |
#potency ⇒ Object (readonly)
Returns the value of attribute potency.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def potency @potency end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def stage @stage end |
#substrate_type ⇒ Object (readonly)
Returns the value of attribute substrate_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def substrate_type @substrate_type end |
#volatility ⇒ Object (readonly)
Returns the value of attribute volatility.
12 13 14 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 12 def volatility @volatility end |
Instance Method Details
#age ⇒ Object
65 66 67 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 65 def age ((Time.now.utc - @created_at) / 60.0).round(2) end |
#aging? ⇒ Boolean
50 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 50 def aging? = @stage == :aging |
#catalyze!(catalyst_type) ⇒ Object
35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 35 def catalyze!(catalyst_type) @catalysts_applied << catalyst_type.to_sym @potency = (@potency + CATALYSIS_BOOST).clamp(0.0, 1.0).round(10) @volatility = (@volatility + 0.05).clamp(0.0, 1.0).round(10) end |
#ferment!(rate = MATURATION_RATE) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 28 def ferment!(rate = MATURATION_RATE) @maturity = (@maturity + rate).clamp(0.0, 1.0).round(10) @volatility = (@volatility - VOLATILITY_DECAY).clamp(0.0, 1.0).round(10) advance_stage! @potency = compute_potency end |
#multi_catalyzed? ⇒ Boolean
52 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 52 def multi_catalyzed? = @catalysts_applied.uniq.size >= 3 |
#over_fermented? ⇒ Boolean
51 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 51 def over_fermented? = @stage == :over_fermented |
#peak? ⇒ Boolean
47 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 47 def peak? = @potency >= PEAK_THRESHOLD && @stage == :peak |
#raw? ⇒ Boolean
49 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 49 def raw? = @stage == :inoculation |
#ripe? ⇒ Boolean
46 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 46 def ripe? = @potency >= RIPE_THRESHOLD && @maturity >= 0.5 |
#spoil! ⇒ Object
41 42 43 44 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 41 def spoil! @potency = (@potency * 0.5).round(10) @stage = :over_fermented end |
#spoiled? ⇒ Boolean
48 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 48 def spoiled? = @potency < SPOILAGE_THRESHOLD |
#to_h ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/legion/extensions/agentic/learning/fermentation/helpers/substrate.rb', line 69 def to_h { id: @id, substrate_type: @substrate_type, domain: @domain, content: @content, potency: @potency.round(10), maturity: @maturity.round(10), volatility: @volatility.round(10), stage: @stage, ripe: ripe?, peak: peak?, spoiled: spoiled?, catalysts_applied: @catalysts_applied.uniq, age_minutes: age, created_at: @created_at.iso8601 } end |