Module: Legion::Extensions::Agentic::Memory::Reserve::Runners::CognitiveReserve
- Includes:
- Helpers::Constants, Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb
Constant Summary
Helpers::Constants::CAPACITY_CEILING, Helpers::Constants::CAPACITY_FLOOR, Helpers::Constants::COMPENSATION_DECAY, Helpers::Constants::COMPENSATION_EFFICIENCY, Helpers::Constants::DEFAULT_CAPACITY, Helpers::Constants::DEGRADED_THRESHOLD, Helpers::Constants::FAILED_THRESHOLD, Helpers::Constants::MAX_COMPENSATIONS, Helpers::Constants::MAX_HISTORY, Helpers::Constants::MAX_PATHWAYS, Helpers::Constants::PATHWAY_STATES, Helpers::Constants::RECOVERY_RATE, Helpers::Constants::RESERVE_LABELS
Instance Method Summary
collapse
Instance Method Details
#add_cognitive_pathway(function:, domain: :general, capacity: DEFAULT_CAPACITY) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 13
def add_cognitive_pathway(function:, domain: :general, capacity: DEFAULT_CAPACITY, **)
pathway = engine.add_pathway(function: function, domain: domain, capacity: capacity)
return { success: false, reason: :limit_reached } unless pathway
{ success: true, pathway_id: pathway.id, capacity: pathway.capacity }
end
|
#cognitive_reserve_assessment ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 47
def cognitive_reserve_assessment(**)
{
success: true,
overall_reserve: engine.overall_reserve.round(4),
reserve_label: engine.reserve_label,
most_vulnerable: engine.most_vulnerable,
degraded: engine.degraded_pathways,
failed: engine.failed_pathways
}
end
|
#cognitive_reserve_stats ⇒ Object
77
78
79
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 77
def cognitive_reserve_stats(**)
{ success: true }.merge(engine.to_h)
end
|
#damage_cognitive_pathway(pathway_id:, amount:) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 27
def damage_cognitive_pathway(pathway_id:, amount:, **)
pathway = engine.damage_pathway(pathway_id: pathway_id, amount: amount)
return { success: false, reason: :not_found } unless pathway
{
success: true,
pathway_id: pathway_id,
capacity: pathway.capacity.round(4),
state: pathway.state,
effective_capacity: engine.effective_capacity(pathway_id: pathway_id)&.round(4)
}
end
|
#domain_cognitive_reserve(domain:) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 58
def domain_cognitive_reserve(domain:, **)
{
success: true,
domain: domain,
reserve: engine.domain_reserve(domain: domain).round(4),
pathway_count: engine.pathways.values.count { |p| p.domain == domain }
}
end
|
#link_backup_pathway(primary_id:, backup_id:) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 20
def link_backup_pathway(primary_id:, backup_id:, **)
result = engine.link_backup(primary_id: primary_id, backup_id: backup_id)
return { success: false, reason: :not_found } unless result
{ success: true, primary_id: primary_id, backup_id: backup_id, backup_count: result.backup_ids.size }
end
|
#most_redundant_pathways ⇒ Object
67
68
69
70
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 67
def most_redundant_pathways(**)
pathways = engine.most_redundant
{ success: true, pathways: pathways, count: pathways.size }
end
|
#recover_cognitive_pathway(pathway_id:, amount: RECOVERY_RATE) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 40
def recover_cognitive_pathway(pathway_id:, amount: RECOVERY_RATE, **)
pathway = engine.recover_pathway(pathway_id: pathway_id, amount: amount)
return { success: false, reason: :not_found } unless pathway
{ success: true, pathway_id: pathway_id, capacity: pathway.capacity.round(4), state: pathway.state }
end
|
#update_cognitive_reserve ⇒ Object
72
73
74
75
|
# File 'lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb', line 72
def update_cognitive_reserve(**)
engine.recover_all
{ success: true }.merge(engine.to_h)
end
|