Class: Legion::Extensions::Agentic::Memory::Hologram::Helpers::HolographicFragment
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Hologram::Helpers::HolographicFragment
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb
Constant Summary
Constants included from Constants
Constants::FIDELITY_LABELS, Constants::FRAGMENT_LABELS, Constants::INTERFERENCE_DECAY, Constants::INTERFERENCE_LABELS, Constants::MAX_HOLOGRAMS, Constants::RECONSTRUCTION_THRESHOLD, Constants::RESOLUTION_LABELS, Constants::RESOLUTION_LEVELS
Instance Attribute Summary collapse
-
#completeness ⇒ Object
Returns the value of attribute completeness.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#fidelity ⇒ Object
Returns the value of attribute fidelity.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#parent_hologram_id ⇒ Object
readonly
Returns the value of attribute parent_hologram_id.
Instance Method Summary collapse
- #completeness_label ⇒ Object
- #degrade!(rate = Constants::INTERFERENCE_DECAY) ⇒ Object
- #enhance!(boost = 0.1) ⇒ Object
- #fidelity_label ⇒ Object
-
#initialize(content:, parent_hologram_id:, completeness: 1.0, fidelity: 1.0) ⇒ HolographicFragment
constructor
A new instance of HolographicFragment.
- #sufficient? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(content:, parent_hologram_id:, completeness: 1.0, fidelity: 1.0) ⇒ HolographicFragment
Returns a new instance of HolographicFragment.
18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 18 def initialize(content:, parent_hologram_id:, completeness: 1.0, fidelity: 1.0) @id = SecureRandom.uuid @content = content @parent_hologram_id = parent_hologram_id @completeness = completeness.clamp(0.0, 1.0) @fidelity = fidelity.clamp(0.0, 1.0) @created_at = Time.now.utc end |
Instance Attribute Details
#completeness ⇒ Object
Returns the value of attribute completeness.
16 17 18 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 16 def completeness @completeness end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 15 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 15 def created_at @created_at end |
#fidelity ⇒ Object
Returns the value of attribute fidelity.
16 17 18 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 16 def fidelity @fidelity end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 15 def id @id end |
#parent_hologram_id ⇒ Object (readonly)
Returns the value of attribute parent_hologram_id.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 15 def parent_hologram_id @parent_hologram_id end |
Instance Method Details
#completeness_label ⇒ Object
43 44 45 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 43 def completeness_label Constants.label_for(Constants::FRAGMENT_LABELS, @completeness) end |
#degrade!(rate = Constants::INTERFERENCE_DECAY) ⇒ Object
27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 27 def degrade!(rate = Constants::INTERFERENCE_DECAY) @completeness = (@completeness - rate).round(10).clamp(0.0, 1.0) @fidelity = (@fidelity - rate).round(10).clamp(0.0, 1.0) self end |
#enhance!(boost = 0.1) ⇒ Object
33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 33 def enhance!(boost = 0.1) @completeness = (@completeness + boost).round(10).clamp(0.0, 1.0) @fidelity = (@fidelity + boost).round(10).clamp(0.0, 1.0) self end |
#fidelity_label ⇒ Object
47 48 49 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 47 def fidelity_label Constants.label_for(Constants::FIDELITY_LABELS, @fidelity) end |
#sufficient? ⇒ Boolean
39 40 41 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 39 def sufficient? @completeness > Constants::RECONSTRUCTION_THRESHOLD end |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb', line 51 def to_h { id: @id, parent_hologram_id: @parent_hologram_id, content: @content, completeness: @completeness, fidelity: @fidelity, completeness_label: completeness_label, fidelity_label: fidelity_label, sufficient: sufficient?, created_at: @created_at.iso8601 } end |