Class: Legion::Extensions::Agentic::Defense::Whirlpool::Helpers::CapturedThought
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::Whirlpool::Helpers::CapturedThought
- Defined in:
- lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb
Constant Summary collapse
- ESCAPE_DISTANCE =
1.0- CORE_DISTANCE =
0.05
Instance Attribute Summary collapse
-
#captured_at ⇒ Object
readonly
Returns the value of attribute captured_at.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#distance_from_core ⇒ Object
readonly
Returns the value of attribute distance_from_core.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#spiral_depth ⇒ Object
readonly
Returns the value of attribute spiral_depth.
-
#thought_id ⇒ Object
readonly
Returns the value of attribute thought_id.
Instance Method Summary collapse
- #at_core? ⇒ Boolean
- #depth_label ⇒ Object
- #escape! ⇒ Object
- #escaped? ⇒ Boolean
-
#initialize(content:, domain: :general, spiral_depth: 0.0, distance_from_core: 1.0) ⇒ CapturedThought
constructor
A new instance of CapturedThought.
- #spiral!(rate: Constants::SPIRAL_RATE_DEFAULT) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(content:, domain: :general, spiral_depth: 0.0, distance_from_core: 1.0) ⇒ CapturedThought
Returns a new instance of CapturedThought.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 15 def initialize(content:, domain: :general, spiral_depth: 0.0, distance_from_core: 1.0) @thought_id = SecureRandom.uuid @content = content @domain = domain @spiral_depth = spiral_depth.clamp(0.0, Constants::DEPTH_MAX) @distance_from_core = distance_from_core.clamp(0.0, Constants::CAPTURE_RADIUS_MAX) @captured_at = Time.now.utc @escaped = false end |
Instance Attribute Details
#captured_at ⇒ Object (readonly)
Returns the value of attribute captured_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def captured_at @captured_at end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def content @content end |
#distance_from_core ⇒ Object (readonly)
Returns the value of attribute distance_from_core.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def distance_from_core @distance_from_core end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def domain @domain end |
#spiral_depth ⇒ Object (readonly)
Returns the value of attribute spiral_depth.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def spiral_depth @spiral_depth end |
#thought_id ⇒ Object (readonly)
Returns the value of attribute thought_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 10 def thought_id @thought_id end |
Instance Method Details
#at_core? ⇒ Boolean
32 33 34 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 32 def at_core? @distance_from_core <= CORE_DISTANCE end |
#depth_label ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 44 def depth_label Constants::DEPTH_LABELS.find { |entry| entry[:range].cover?(@spiral_depth) }&.fetch(:label, :surface) || :surface end |
#escape! ⇒ Object
40 41 42 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 40 def escape! @escaped = true end |
#escaped? ⇒ Boolean
36 37 38 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 36 def escaped? @escaped end |
#spiral!(rate: Constants::SPIRAL_RATE_DEFAULT) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 25 def spiral!(rate: Constants::SPIRAL_RATE_DEFAULT) return if @escaped @spiral_depth = (@spiral_depth + rate).clamp(0.0, Constants::DEPTH_MAX) @distance_from_core = (@distance_from_core - rate).clamp(0.0, Constants::CAPTURE_RADIUS_MAX) end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/defense/whirlpool/helpers/captured_thought.rb', line 48 def to_h { thought_id: @thought_id, content: @content, domain: @domain, spiral_depth: @spiral_depth.round(10), distance_from_core: @distance_from_core.round(10), depth_label: depth_label, at_core: at_core?, escaped: @escaped, captured_at: @captured_at } end |