lex-agentic-executive 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/legion/extensions/agentic/executive/prospective_memory/runners/prospective_memory.rb +20 -20
- data/lib/legion/extensions/agentic/executive/version.rb +1 -1
- data/lib/legion/extensions/agentic/executive/volition/helpers/drive_synthesizer.rb +3 -2
- data/spec/legion/extensions/agentic/executive/volition/helpers/drive_synthesizer_spec.rb +14 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60248390bb61f50186d12e7924274bf70795420a5a76142362dd8fcc127b34e6
|
|
4
|
+
data.tar.gz: bf02ad4761edd9eb3abf744a57c4c8beeb5a7068be38298b765c40844730d80d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 143d738ad28317564cbc6d0ced1ee32c1d6d511fb5d5923c76ac4c16aa5649201b8388c7144e249de44cdced648e47072d40a239ffdb124b779af695667f4123
|
|
7
|
+
data.tar.gz: 7c8c2a4223505aedb5b4f5a5e470b31ca0567660531201aa61e487f209e5345a8e9f16ed222c72d1ce5307d069622ae400064e56bde78898f57fd819c1afaed7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- add success: true/false to all ProspectiveMemory runner methods to match LEX convention
|
|
7
|
+
- fix dominant_drive to use weighted scoring instead of raw strengths
|
|
8
|
+
- fix compute_urgency_drive to read arousal from gut_instinct first
|
|
9
|
+
|
|
3
10
|
## [0.1.9] - 2026-04-03
|
|
4
11
|
|
|
5
12
|
### Fixed
|
data/lib/legion/extensions/agentic/executive/prospective_memory/runners/prospective_memory.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Legion
|
|
|
14
14
|
urgency: Helpers::Constants::DEFAULT_URGENCY,
|
|
15
15
|
domain: nil, expires_at: nil, **)
|
|
16
16
|
unless Helpers::Constants::TRIGGER_TYPES.include?(trigger_type)
|
|
17
|
-
return { error: :invalid_trigger_type, valid_types: Helpers::Constants::TRIGGER_TYPES }
|
|
17
|
+
return { success: false, error: :invalid_trigger_type, valid_types: Helpers::Constants::TRIGGER_TYPES }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
intention = prospective_engine.create_intention(
|
|
@@ -29,16 +29,16 @@ module Legion
|
|
|
29
29
|
Legion::Logging.debug "[prospective_memory] created intention id=#{intention.id[0..7]} " \
|
|
30
30
|
"type=#{trigger_type} urgency=#{intention.urgency.round(2)}"
|
|
31
31
|
|
|
32
|
-
{ created: true, intention: intention.to_h }
|
|
32
|
+
{ success: true, created: true, intention: intention.to_h }
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def monitor_intention(intention_id:, **)
|
|
36
36
|
intention = prospective_engine.monitor_intention(intention_id: intention_id)
|
|
37
37
|
if intention
|
|
38
38
|
Legion::Logging.debug "[prospective_memory] monitoring intention id=#{intention_id[0..7]}"
|
|
39
|
-
{ updated: true, intention: intention.to_h }
|
|
39
|
+
{ success: true, updated: true, intention: intention.to_h }
|
|
40
40
|
else
|
|
41
|
-
{ updated: false, reason: :not_found }
|
|
41
|
+
{ success: false, updated: false, reason: :not_found }
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -46,9 +46,9 @@ module Legion
|
|
|
46
46
|
intention = prospective_engine.trigger_intention(intention_id: intention_id)
|
|
47
47
|
if intention
|
|
48
48
|
Legion::Logging.info "[prospective_memory] triggered intention id=#{intention_id[0..7]}"
|
|
49
|
-
{ updated: true, intention: intention.to_h }
|
|
49
|
+
{ success: true, updated: true, intention: intention.to_h }
|
|
50
50
|
else
|
|
51
|
-
{ updated: false, reason: :not_found }
|
|
51
|
+
{ success: false, updated: false, reason: :not_found }
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -56,9 +56,9 @@ module Legion
|
|
|
56
56
|
intention = prospective_engine.execute_intention(intention_id: intention_id)
|
|
57
57
|
if intention
|
|
58
58
|
Legion::Logging.info "[prospective_memory] executed intention id=#{intention_id[0..7]}"
|
|
59
|
-
{ updated: true, intention: intention.to_h }
|
|
59
|
+
{ success: true, updated: true, intention: intention.to_h }
|
|
60
60
|
else
|
|
61
|
-
{ updated: false, reason: :not_found }
|
|
61
|
+
{ success: false, updated: false, reason: :not_found }
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -66,70 +66,70 @@ module Legion
|
|
|
66
66
|
intention = prospective_engine.cancel_intention(intention_id: intention_id)
|
|
67
67
|
if intention
|
|
68
68
|
Legion::Logging.debug "[prospective_memory] cancelled intention id=#{intention_id[0..7]}"
|
|
69
|
-
{ updated: true, intention: intention.to_h }
|
|
69
|
+
{ success: true, updated: true, intention: intention.to_h }
|
|
70
70
|
else
|
|
71
|
-
{ updated: false, reason: :not_found }
|
|
71
|
+
{ success: false, updated: false, reason: :not_found }
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def check_expirations(**)
|
|
76
76
|
expired_count = prospective_engine.check_expirations
|
|
77
77
|
Legion::Logging.debug "[prospective_memory] expiration check expired=#{expired_count}"
|
|
78
|
-
{ expired_count: expired_count }
|
|
78
|
+
{ success: true, expired_count: expired_count }
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def pending_intentions(**)
|
|
82
82
|
intentions = prospective_engine.pending_intentions
|
|
83
83
|
Legion::Logging.debug "[prospective_memory] pending count=#{intentions.size}"
|
|
84
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size }
|
|
84
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size }
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
def monitoring_intentions(**)
|
|
88
88
|
intentions = prospective_engine.monitoring_intentions
|
|
89
89
|
Legion::Logging.debug "[prospective_memory] monitoring count=#{intentions.size}"
|
|
90
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size }
|
|
90
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size }
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def triggered_intentions(**)
|
|
94
94
|
intentions = prospective_engine.triggered_intentions
|
|
95
95
|
Legion::Logging.debug "[prospective_memory] triggered count=#{intentions.size}"
|
|
96
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size }
|
|
96
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size }
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def intentions_by_domain(domain:, **)
|
|
100
100
|
intentions = prospective_engine.by_domain(domain: domain)
|
|
101
101
|
Legion::Logging.debug "[prospective_memory] by_domain domain=#{domain} count=#{intentions.size}"
|
|
102
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size, domain: domain }
|
|
102
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size, domain: domain }
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def intentions_by_urgency(min_urgency: 0.5, **)
|
|
106
106
|
intentions = prospective_engine.by_urgency(min_urgency: min_urgency)
|
|
107
107
|
Legion::Logging.debug "[prospective_memory] by_urgency min=#{min_urgency} count=#{intentions.size}"
|
|
108
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size }
|
|
108
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size }
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def most_urgent_intentions(limit: 5, **)
|
|
112
112
|
intentions = prospective_engine.most_urgent(limit: limit)
|
|
113
113
|
Legion::Logging.debug "[prospective_memory] most_urgent limit=#{limit} found=#{intentions.size}"
|
|
114
|
-
{ intentions: intentions.map(&:to_h), count: intentions.size }
|
|
114
|
+
{ success: true, intentions: intentions.map(&:to_h), count: intentions.size }
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def decay_urgency(**)
|
|
118
118
|
prospective_engine.decay_all_urgency
|
|
119
119
|
Legion::Logging.debug '[prospective_memory] urgency decay cycle complete'
|
|
120
|
-
{ decayed: true }
|
|
120
|
+
{ success: true, decayed: true }
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
def execution_rate(**)
|
|
124
124
|
rate = prospective_engine.execution_rate
|
|
125
125
|
Legion::Logging.debug "[prospective_memory] execution_rate=#{rate.round(4)}"
|
|
126
|
-
{ execution_rate: rate }
|
|
126
|
+
{ success: true, execution_rate: rate }
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
def intention_report(**)
|
|
130
130
|
report = prospective_engine.intention_report
|
|
131
131
|
Legion::Logging.debug "[prospective_memory] report total=#{report[:total]}"
|
|
132
|
-
report
|
|
132
|
+
{ success: true }.merge(report)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
private
|
|
@@ -33,7 +33,8 @@ module Legion
|
|
|
33
33
|
def dominant_drive(drives)
|
|
34
34
|
return nil if drives.empty?
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
weighted = weighted_drives(drives)
|
|
37
|
+
weighted.max_by { |_, data| data[:weighted] }&.first
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def generate_intentions(drives, cognitive_state: {})
|
|
@@ -74,7 +75,7 @@ module Legion
|
|
|
74
75
|
gut = tick_results[:gut_instinct] || cognitive_state[:gut] || {}
|
|
75
76
|
emotion = tick_results[:emotional_evaluation] || {}
|
|
76
77
|
|
|
77
|
-
arousal = emotion[:arousal] || cognitive_state.dig(:emotion, :arousal) || 0.0
|
|
78
|
+
arousal = gut[:arousal] || emotion[:arousal] || cognitive_state.dig(:emotion, :arousal) || 0.0
|
|
78
79
|
gut_signal = extract_gut_strength(gut)
|
|
79
80
|
|
|
80
81
|
((arousal * 0.5) + (gut_signal * 0.5)).clamp(0.0, 1.0)
|
|
@@ -71,11 +71,24 @@ RSpec.describe Legion::Extensions::Agentic::Executive::Volition::Helpers::DriveS
|
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
describe '.dominant_drive' do
|
|
74
|
-
it 'returns the
|
|
74
|
+
it 'returns the drive with highest weighted score' do
|
|
75
|
+
# curiosity: 0.8 * 0.25 = 0.20, urgency: 0.5 * 0.20 = 0.10
|
|
75
76
|
drives = { curiosity: 0.8, corrective: 0.3, urgency: 0.5, epistemic: 0.2, social: 0.1 }
|
|
76
77
|
expect(synth.dominant_drive(drives)).to eq(:curiosity)
|
|
77
78
|
end
|
|
78
79
|
|
|
80
|
+
it 'accounts for weights when raw scores are close' do
|
|
81
|
+
# curiosity: 0.5 * 0.25 = 0.125, urgency: 0.6 * 0.20 = 0.12
|
|
82
|
+
drives = { curiosity: 0.5, corrective: 0.0, urgency: 0.6, epistemic: 0.0, social: 0.0 }
|
|
83
|
+
expect(synth.dominant_drive(drives)).to eq(:curiosity)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'allows urgency to win when raw strength is much higher' do
|
|
87
|
+
# curiosity: 0.3 * 0.25 = 0.075, urgency: 0.9 * 0.20 = 0.18
|
|
88
|
+
drives = { curiosity: 0.3, corrective: 0.0, urgency: 0.9, epistemic: 0.0, social: 0.0 }
|
|
89
|
+
expect(synth.dominant_drive(drives)).to eq(:urgency)
|
|
90
|
+
end
|
|
91
|
+
|
|
79
92
|
it 'returns nil for empty drives' do
|
|
80
93
|
expect(synth.dominant_drive({})).to be_nil
|
|
81
94
|
end
|