Class: Legion::Extensions::Agentic::Integration::GlobalWorkspace::Helpers::Broadcast
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::GlobalWorkspace::Helpers::Broadcast
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb
Constant Summary
Constants included from Constants
Constants::BROADCAST_TTL, Constants::COMPETITION_THRESHOLD, Constants::DOMINANCE_MARGIN, Constants::MAX_BROADCAST_HISTORY, Constants::MAX_COALITION_SIZE, Constants::MAX_COMPETITORS, Constants::MAX_SUBSCRIBERS, Constants::MAX_URGENCY, Constants::SALIENCE_DECAY, Constants::SALIENCE_LABELS, Constants::URGENCY_BOOST, Constants::UTILIZATION_ALPHA, Constants::WORKSPACE_STATE_LABELS
Instance Attribute Summary collapse
-
#broadcast_at ⇒ Object
readonly
Returns the value of attribute broadcast_at.
-
#coalition ⇒ Object
readonly
Returns the value of attribute coalition.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#received_by ⇒ Object
readonly
Returns the value of attribute received_by.
-
#salience ⇒ Object
readonly
Returns the value of attribute salience.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #acknowledge(subscriber_id) ⇒ Object
- #age ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(content:, source:, domain:, salience:, coalition: []) ⇒ Broadcast
constructor
A new instance of Broadcast.
- #label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(content:, source:, domain:, salience:, coalition: []) ⇒ Broadcast
Returns a new instance of Broadcast.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 15 def initialize(content:, source:, domain:, salience:, coalition: []) @content = content @source = source @domain = domain @salience = salience.to_f.clamp(0.0, 1.0) @coalition = Array(coalition).first(MAX_COALITION_SIZE) @broadcast_at = Time.now.utc @received_by = [] end |
Instance Attribute Details
#broadcast_at ⇒ Object (readonly)
Returns the value of attribute broadcast_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def broadcast_at @broadcast_at end |
#coalition ⇒ Object (readonly)
Returns the value of attribute coalition.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def coalition @coalition end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def content @content end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def domain @domain end |
#received_by ⇒ Object (readonly)
Returns the value of attribute received_by.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def received_by @received_by end |
#salience ⇒ Object (readonly)
Returns the value of attribute salience.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def salience @salience end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 12 def source @source end |
Instance Method Details
#acknowledge(subscriber_id) ⇒ Object
25 26 27 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 25 def acknowledge(subscriber_id) @received_by << subscriber_id unless @received_by.include?(subscriber_id) end |
#age ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 33 def age Time.now.utc - @broadcast_at end |
#expired? ⇒ Boolean
29 30 31 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 29 def expired? (Time.now.utc - @broadcast_at) > BROADCAST_TTL end |
#label ⇒ Object
37 38 39 40 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 37 def label SALIENCE_LABELS.each { |range, lbl| return lbl if range.cover?(@salience) } :subliminal end |
#to_h ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb', line 42 def to_h { content: @content, source: @source, domain: @domain, salience: @salience.round(4), label: label, coalition: @coalition, broadcast_at: @broadcast_at, age: age.round(2), received_by: @received_by.dup, expired: expired? } end |