Module: Legion::Extensions::Agentic::Executive::Volition::Helpers::Intention
- Defined in:
- lib/legion/extensions/agentic/executive/volition/helpers/intention.rb
Class Method Summary collapse
- .active?(intention) ⇒ Boolean
- .decay(intention) ⇒ Object
- .drive_label(drive) ⇒ Object
- .expired?(intention) ⇒ Boolean
- .new_intention(drive:, domain:, goal:, salience:, context: {}) ⇒ Object
- .reinforce(intention, amount: 0.1) ⇒ Object
Class Method Details
.active?(intention) ⇒ Boolean
43 44 45 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 43 def active?(intention) intention[:state] == :active && !expired?(intention) end |
.decay(intention) ⇒ Object
28 29 30 31 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 28 def decay(intention) new_salience = [intention[:salience] - Constants::INTENTION_DECAY, 0.0].max intention.merge(salience: new_salience, age_ticks: intention[:age_ticks] + 1) end |
.drive_label(drive) ⇒ Object
47 48 49 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 47 def drive_label(drive) Constants::DRIVE_LABELS[drive.to_sym] || drive.to_s end |
.expired?(intention) ⇒ Boolean
38 39 40 41 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 38 def expired?(intention) intention[:age_ticks] >= Constants::MAX_INTENTION_AGE || intention[:salience] < Constants::INTENTION_FLOOR end |
.new_intention(drive:, domain:, goal:, salience:, context: {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 14 def new_intention(drive:, domain:, goal:, salience:, context: {}) { intention_id: SecureRandom.hex(8), drive: drive.to_sym, domain: domain.to_sym, goal: goal, salience: salience.clamp(0.0, 1.0), state: :active, created_at: Time.now.utc, age_ticks: 0, context: context } end |
.reinforce(intention, amount: 0.1) ⇒ Object
33 34 35 36 |
# File 'lib/legion/extensions/agentic/executive/volition/helpers/intention.rb', line 33 def reinforce(intention, amount: 0.1) new_salience = [intention[:salience] + amount, 1.0].min intention.merge(salience: new_salience) end |