Class: Legion::Extensions::Agentic::Inference::Affordance::Helpers::AffordanceItem
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::Affordance::Helpers::AffordanceItem
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb
Constant Summary
Constants included from Constants
Constants::ACTIONABLE_THRESHOLD, Constants::AFFORDANCE_TYPES, Constants::CAPABILITY_MATCH_THRESHOLD, Constants::DEFAULT_RELEVANCE, Constants::MAX_AFFORDANCES, Constants::MAX_CAPABILITIES, Constants::MAX_ENVIRONMENT_PROPS, Constants::MAX_HISTORY, Constants::RELEVANCE_DECAY, Constants::RELEVANCE_FLOOR, Constants::RELEVANCE_LABELS, Constants::URGENCY_BOOST
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#affordance_type ⇒ Object
readonly
Returns the value of attribute affordance_type.
-
#detected_at ⇒ Object
readonly
Returns the value of attribute detected_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#relevance ⇒ Object
Returns the value of attribute relevance.
-
#requires ⇒ Object
readonly
Returns the value of attribute requires.
Instance Method Summary collapse
- #actionable? ⇒ Boolean
- #blocked? ⇒ Boolean
- #decay ⇒ Object
- #faded? ⇒ Boolean
-
#initialize(id:, action:, domain:, affordance_type:, requires: [], relevance: DEFAULT_RELEVANCE) ⇒ AffordanceItem
constructor
A new instance of AffordanceItem.
- #relevance_label ⇒ Object
- #risky? ⇒ Boolean
- #threatening? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(id:, action:, domain:, affordance_type:, requires: [], relevance: DEFAULT_RELEVANCE) ⇒ AffordanceItem
Returns a new instance of AffordanceItem.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 15 def initialize(id:, action:, domain:, affordance_type:, requires: [], relevance: DEFAULT_RELEVANCE) @id = id @action = action @domain = domain @affordance_type = affordance_type @requires = Array(requires) @relevance = relevance.to_f.clamp(0.0, 1.0) @detected_at = Time.now.utc end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def action @action end |
#affordance_type ⇒ Object (readonly)
Returns the value of attribute affordance_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def affordance_type @affordance_type end |
#detected_at ⇒ Object (readonly)
Returns the value of attribute detected_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def detected_at @detected_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def id @id end |
#relevance ⇒ Object
Returns the value of attribute relevance.
13 14 15 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 13 def relevance @relevance end |
#requires ⇒ Object (readonly)
Returns the value of attribute requires.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 12 def requires @requires end |
Instance Method Details
#actionable? ⇒ Boolean
25 26 27 28 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 25 def actionable? %i[action_possible resource_available opportunity].include?(@affordance_type) && @relevance >= ACTIONABLE_THRESHOLD end |
#blocked? ⇒ Boolean
30 31 32 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 30 def blocked? @affordance_type == :action_blocked end |
#decay ⇒ Object
42 43 44 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 42 def decay @relevance = [@relevance - RELEVANCE_DECAY, 0.0].max end |
#faded? ⇒ Boolean
46 47 48 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 46 def faded? @relevance <= RELEVANCE_FLOOR end |
#relevance_label ⇒ Object
50 51 52 53 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 50 def relevance_label RELEVANCE_LABELS.each { |range, lbl| return lbl if range.cover?(@relevance) } :negligible end |
#risky? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 34 def risky? @affordance_type == :action_risky end |
#threatening? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 38 def threatening? @affordance_type == :threat end |
#to_h ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb', line 55 def to_h { id: @id, action: @action, domain: @domain, affordance_type: @affordance_type, requires: @requires, relevance: @relevance.round(4), relevance_label: relevance_label, actionable: actionable?, blocked: blocked?, risky: risky? } end |