Class: Legion::Extensions::Agentic::Executive::Inhibition::Helpers::InhibitionStore

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInhibitionStore

Returns a new instance of InhibitionStore.



12
13
14
15
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 12

def initialize
  @model = InhibitionModel.new
  @impulses = []
end

Instance Attribute Details

#impulsesObject (readonly)

Returns the value of attribute impulses.



10
11
12
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 10

def impulses
  @impulses
end

#modelObject (readonly)

Returns the value of attribute model.



10
11
12
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 10

def model
  @model
end

Instance Method Details

#create_impulse(type:, action:, strength:, source: nil, context: {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 17

def create_impulse(type:, action:, strength:, source: nil, context: {})
  return nil unless Constants::IMPULSE_TYPES.include?(type.to_sym)

  resolved_strength = resolve_strength(strength)

  impulse = Impulse.new(
    type:     type,
    action:   action,
    strength: resolved_strength,
    source:   source,
    context:  context
  )

  @impulses << impulse
  impulse
end

#evaluate_and_apply(impulse) ⇒ Object



34
35
36
37
38
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 34

def evaluate_and_apply(impulse)
  strategy = @model.evaluate_impulse(impulse)
  entry    = @model.apply_strategy(impulse, strategy)
  { strategy: strategy, log_entry: entry }
end

#recent_log(limit = 20) ⇒ Object



57
58
59
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 57

def recent_log(limit = 20)
  @model.inhibition_log.last(limit)
end

#recoverObject



40
41
42
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 40

def recover
  @model.recover_willpower
end

#statsObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/legion/extensions/agentic/executive/inhibition/helpers/inhibition_store.rb', line 44

def stats
  {
    willpower:        @model.willpower.round(4),
    willpower_status: @model.willpower_status,
    suppressed:       @model.suppressed_count,
    failed:           @model.failed_count,
    redirected:       @model.redirected_count,
    success_rate:     @model.success_rate.round(4),
    log_size:         @model.inhibition_log.size,
    total_impulses:   @impulses.size
  }
end