Class: Legion::Extensions::Agentic::Memory::Palimpsest::Helpers::BeliefLayer
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Palimpsest::Helpers::BeliefLayer
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb
Constant Summary
Constants included from Constants
Constants::CONFIDENCE_LABELS, Constants::DEFAULT_CONFIDENCE, Constants::DRIFT_LABELS, Constants::EROSION_RATE, Constants::GHOST_DECAY, Constants::GHOST_LABELS, Constants::GHOST_THRESHOLD, Constants::LAYER_DOMAINS, Constants::MAX_LAYERS_PER_TOPIC, Constants::MAX_PALIMPSESTS
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#superseded_by ⇒ Object
readonly
Returns the value of attribute superseded_by.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #confidence_label ⇒ Object
- #dissipated? ⇒ Boolean
- #erode!(rate: EROSION_RATE) ⇒ Object
- #ghost? ⇒ Boolean
- #ghost_label ⇒ Object
-
#initialize(content:, confidence: DEFAULT_CONFIDENCE, domain: :unknown, version: 1, author: :system) ⇒ BeliefLayer
constructor
A new instance of BeliefLayer.
- #supersede!(next_layer_id) ⇒ Object
- #superseded? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(content:, confidence: DEFAULT_CONFIDENCE, domain: :unknown, version: 1, author: :system) ⇒ BeliefLayer
Returns a new instance of BeliefLayer.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 18 def initialize(content:, confidence: DEFAULT_CONFIDENCE, domain: :unknown, version: 1, author: :system) @id = ::SecureRandom.uuid @content = content @confidence = confidence.to_f.clamp(0.0, 1.0) @domain = domain @version = version @author = @timestamp = ::Time.now.utc @superseded_by = nil end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def @author end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def confidence @confidence end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def content @content end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def id @id end |
#superseded_by ⇒ Object (readonly)
Returns the value of attribute superseded_by.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def superseded_by @superseded_by end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def @timestamp end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 15 def version @version end |
Instance Method Details
#confidence_label ⇒ Object
50 51 52 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 50 def confidence_label Constants.label_for(CONFIDENCE_LABELS, @confidence) end |
#dissipated? ⇒ Boolean
42 43 44 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 42 def dissipated? superseded? && @confidence <= GHOST_THRESHOLD end |
#erode!(rate: EROSION_RATE) ⇒ Object
46 47 48 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 46 def erode!(rate: EROSION_RATE) @confidence = (@confidence - rate).clamp(0.0, 1.0).round(10) end |
#ghost? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 38 def ghost? superseded? && @confidence > GHOST_THRESHOLD end |
#ghost_label ⇒ Object
54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 54 def ghost_label return :not_ghost unless superseded? Constants.label_for(GHOST_LABELS, @confidence) end |
#supersede!(next_layer_id) ⇒ Object
30 31 32 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 30 def supersede!(next_layer_id) @superseded_by = next_layer_id end |
#superseded? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 34 def superseded? !@superseded_by.nil? end |
#to_h ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb', line 60 def to_h { id: @id, content: @content, confidence: @confidence.round(4), domain: @domain, version: @version, author: @author, timestamp: @timestamp.iso8601, superseded_by: @superseded_by, superseded: superseded?, ghost: ghost?, label: confidence_label } end |