Class: Legion::Extensions::Agentic::Integration::DistributedCognition::Helpers::Participant
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Integration::DistributedCognition::Helpers::Participant
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb
Constant Summary
Constants included from Constants
Constants::CONTRIBUTION_TYPES, Constants::DECAY_RATE, Constants::DEFAULT_RELIABILITY, Constants::DISTRIBUTION_LABELS, Constants::MAX_ARTIFACTS, Constants::MAX_CONTRIBUTIONS, Constants::MAX_HISTORY, Constants::MAX_PARTICIPANTS, Constants::PARTICIPANT_TYPES, Constants::PENALTY_RATE, Constants::REINFORCEMENT_RATE, Constants::RELIABILITY_CEILING, Constants::RELIABILITY_FLOOR, Constants::RELIABILITY_LABELS, Constants::STALE_THRESHOLD
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#contribution_count ⇒ Object
readonly
Returns the value of attribute contribution_count.
-
#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.
-
#last_active_at ⇒ Object
readonly
Returns the value of attribute last_active_at.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#participant_type ⇒ Object
readonly
Returns the value of attribute participant_type.
-
#reliability ⇒ Object
readonly
Returns the value of attribute reliability.
-
#success_count ⇒ Object
readonly
Returns the value of attribute success_count.
Instance Method Summary collapse
- #add_capability(capability) ⇒ Object
- #agent? ⇒ Boolean
- #artifact? ⇒ Boolean
- #capable_of?(capability) ⇒ Boolean
- #contribute!(success:) ⇒ Object
- #decay! ⇒ Object
-
#initialize(name:, participant_type:, domain:, capabilities: []) ⇒ Participant
constructor
A new instance of Participant.
- #reliability_label ⇒ Object
- #stale? ⇒ Boolean
- #success_rate ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, participant_type:, domain:, capabilities: []) ⇒ Participant
Returns a new instance of Participant.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 18 def initialize(name:, participant_type:, domain:, capabilities: []) @id = SecureRandom.uuid @name = name @participant_type = participant_type @domain = domain @capabilities = capabilities @reliability = DEFAULT_RELIABILITY @contribution_count = 0 @success_count = 0 @created_at = Time.now.utc @last_active_at = @created_at end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def capabilities @capabilities end |
#contribution_count ⇒ Object (readonly)
Returns the value of attribute contribution_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def contribution_count @contribution_count end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def id @id end |
#last_active_at ⇒ Object (readonly)
Returns the value of attribute last_active_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def last_active_at @last_active_at end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def name @name end |
#participant_type ⇒ Object (readonly)
Returns the value of attribute participant_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def participant_type @participant_type end |
#reliability ⇒ Object (readonly)
Returns the value of attribute reliability.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def reliability @reliability end |
#success_count ⇒ Object (readonly)
Returns the value of attribute success_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 14 def success_count @success_count end |
Instance Method Details
#add_capability(capability) ⇒ Object
38 39 40 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 38 def add_capability(capability) @capabilities << capability unless @capabilities.include?(capability) end |
#agent? ⇒ Boolean
56 57 58 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 56 def agent? @participant_type == :agent end |
#artifact? ⇒ Boolean
60 61 62 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 60 def artifact? @participant_type == :artifact end |
#capable_of?(capability) ⇒ Boolean
42 43 44 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 42 def capable_of?(capability) @capabilities.include?(capability) end |
#contribute!(success:) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 31 def contribute!(success:) @contribution_count += 1 @success_count += 1 if success @last_active_at = Time.now.utc adjust_reliability(success) end |
#decay! ⇒ Object
64 65 66 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 64 def decay! @reliability = (@reliability - DECAY_RATE).clamp(RELIABILITY_FLOOR, RELIABILITY_CEILING) end |
#reliability_label ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 52 def reliability_label RELIABILITY_LABELS.find { |range, _| range.cover?(@reliability) }&.last || :unknown end |
#stale? ⇒ Boolean
68 69 70 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 68 def stale? (Time.now.utc - @last_active_at) > STALE_THRESHOLD end |
#success_rate ⇒ Object
46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 46 def success_rate return 0.0 if @contribution_count.zero? @success_count.to_f / @contribution_count end |
#to_h ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb', line 72 def to_h { id: @id, name: @name, participant_type: @participant_type, domain: @domain, capabilities: @capabilities, reliability: @reliability, reliability_label: reliability_label, contribution_count: @contribution_count, success_rate: success_rate, created_at: @created_at, last_active_at: @last_active_at } end |