lex-agentic-self 0.1.12 → 0.1.14
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 +15 -0
- data/README.md +27 -22
- data/lex-agentic-self.gemspec +1 -1
- data/lib/legion/extensions/agentic/self/identity/helpers/fingerprint.rb +12 -2
- data/lib/legion/extensions/agentic/self/identity/helpers/vault_secrets.rb +6 -1
- data/lib/legion/extensions/agentic/self/metacognition/helpers/self_model.rb +8 -2
- data/lib/legion/extensions/agentic/self/narrative_self/runners/narrative_self.rb +2 -2
- data/lib/legion/extensions/agentic/self/reflection/helpers/llm_enhancer.rb +2 -2
- data/lib/legion/extensions/agentic/self/reflection/runners/reflection.rb +18 -0
- data/lib/legion/extensions/agentic/self/relationship_arc/runners/relationship_arc.rb +3 -2
- data/lib/legion/extensions/agentic/self/version.rb +1 -1
- data/lib/legion/extensions/agentic/self.rb +37 -0
- data/spec/legion/extensions/agentic/self/identity/helpers/fingerprint_spec.rb +8 -0
- data/spec/legion/extensions/agentic/self/narrative_self/client_spec.rb +4 -4
- data/spec/legion/extensions/agentic/self/narrative_self/runners/narrative_self_spec.rb +11 -11
- data/spec/legion/extensions/agentic/self/reflection/helpers/llm_enhancer_spec.rb +4 -0
- data/spec/legion/extensions/agentic/self/reflection/runners/reflection_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53c28592aa4721c2cc7901452451b9836cad8d3ded37f83c2a8dc04aac3ba1f8
|
|
4
|
+
data.tar.gz: 29a423e61504f68cf11fd8c234f29b0d4ff654e33ea5651fd2d7739656cfb9ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38e5b0225a70847a4fb4a8d2f323f1bf1174004f16643deca0fca3567970f16fb5ee722e5e974051b42aff17c7dbb4ccdf7d1c403651c9d4228f3dec4433f7ca
|
|
7
|
+
data.tar.gz: 3bc0d255fb156a9ce05ac926ecd6c5ca15c57a0729c57de9b679ebb684748143e004bbb209433056b628b4de78f7fa0437393d428d810069b69cd3f0fa787ff0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.14] - 2026-05-07
|
|
4
|
+
### Fixed
|
|
5
|
+
- Identity fingerprint save now warns and returns false if local persistence disconnects after previously being available.
|
|
6
|
+
- Reflection health now updates trust drift and mode-pattern category scores from tick results.
|
|
7
|
+
- Reflection LLM enhancer rejects arbitrary extra keyword arguments instead of forwarding them.
|
|
8
|
+
|
|
9
|
+
## [0.1.13] - 2026-04-22
|
|
10
|
+
### Added
|
|
11
|
+
- Module-level snapshot methods (`personality_snapshot`, `reflection_snapshot`, `restore_personality`, `restore_reflections`) enabling memory↔self bridge for snapshot save/restore
|
|
12
|
+
- RelationshipArc documented in CLAUDE.md
|
|
13
|
+
### Fixed
|
|
14
|
+
- Faraday moved from development to runtime dependency (was causing LoadError in production)
|
|
15
|
+
- NarrativeSelf `record_episode` renamed to `record_narrative_self_episode` to resolve collision with NarrativeIdentity
|
|
16
|
+
- Silent rescue blocks in vault_secrets, self_model, relationship_arc now log errors
|
|
17
|
+
|
|
3
18
|
## [0.1.12] - 2026-04-15
|
|
4
19
|
### Changed
|
|
5
20
|
- Set `mcp_tools?`, `mcp_tools_deferred?`, and `transport_required?` to `false` — internal cognitive pipeline extension
|
data/README.md
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
# lex-agentic-self
|
|
2
2
|
|
|
3
|
-
Domain consolidation gem for self-model, identity, metacognition, and self-awareness. Bundles
|
|
3
|
+
Domain consolidation gem for self-model, identity, metacognition, and self-awareness. Bundles 17 sub-modules into one loadable unit under `Legion::Extensions::Agentic::Self`.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
**Gem**: `lex-agentic-self`
|
|
8
|
-
**Version**: 0.1.
|
|
8
|
+
**Version**: 0.1.13
|
|
9
9
|
**Namespace**: `Legion::Extensions::Agentic::Self`
|
|
10
10
|
|
|
11
11
|
## Sub-Modules
|
|
12
12
|
|
|
13
|
-
| Sub-Module |
|
|
14
|
-
|
|
15
|
-
| `Self::Identity` |
|
|
16
|
-
| `Self::Metacognition` |
|
|
17
|
-
| `Self::MetacognitiveMonitoring` |
|
|
18
|
-
| `Self::SelfModel` |
|
|
19
|
-
| `Self::SelfTalk` |
|
|
20
|
-
| `Self::Reflection` |
|
|
21
|
-
| `Self::NarrativeArc` |
|
|
22
|
-
| `Self::NarrativeIdentity` |
|
|
23
|
-
| `Self::NarrativeSelf` |
|
|
24
|
-
| `Self::Architecture` |
|
|
25
|
-
| `Self::Fingerprint` |
|
|
26
|
-
| `Self::Anchor` |
|
|
27
|
-
| `Self::Agency` |
|
|
28
|
-
| `Self::Personality` |
|
|
29
|
-
| `Self::Anosognosia` |
|
|
30
|
-
| `Self::DefaultModeNetwork` |
|
|
13
|
+
| Sub-Module | Purpose |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `Self::Identity` | Behavioral fingerprint (6 dimensions, entropy anomaly) + Entra ID binding |
|
|
16
|
+
| `Self::Metacognition` | Second-order self-model — discovers loaded extensions, maps capabilities |
|
|
17
|
+
| `Self::MetacognitiveMonitoring` | Continuous confidence calibration, feeling-of-knowing |
|
|
18
|
+
| `Self::SelfModel` | Stable beliefs about capabilities, limitations, and values |
|
|
19
|
+
| `Self::SelfTalk` | IFS-inspired inner dialogue — typed turns before action |
|
|
20
|
+
| `Self::Reflection` | Post-tick meta-cognitive analysis — seven categories, EMA health scores |
|
|
21
|
+
| `Self::NarrativeArc` | McAdams narrative arc — beats, tension, resolution |
|
|
22
|
+
| `Self::NarrativeIdentity` | McAdams narrative identity — the agent's life story |
|
|
23
|
+
| `Self::NarrativeSelf` | Minimal self vs. narrative self; autobiographical episode recording |
|
|
24
|
+
| `Self::Architecture` | Meta-layer graph of cognitive subsystems — bottleneck detection |
|
|
25
|
+
| `Self::Fingerprint` | Unique cognitive style profile |
|
|
26
|
+
| `Self::Anchor` | Stable cognitive anchor points |
|
|
27
|
+
| `Self::Agency` | Sense of agency — authorship detection |
|
|
28
|
+
| `Self::Personality` | Big Five OCEAN trait model |
|
|
29
|
+
| `Self::Anosognosia` | Unawareness of own deficits |
|
|
30
|
+
| `Self::DefaultModeNetwork` | DMN analog — active during self-referential processing |
|
|
31
|
+
| `Self::RelationshipArc` | Tracks relationship milestones and bond progression with other agents; stamps NarrativeIdentity episodes on milestone events |
|
|
31
32
|
|
|
32
33
|
## Actors
|
|
33
34
|
|
|
@@ -37,6 +38,10 @@ Domain consolidation gem for self-model, identity, metacognition, and self-aware
|
|
|
37
38
|
- `Self::NarrativeIdentity::Actors::NarrativeDecay` — interval actor, decays narrative identity strength
|
|
38
39
|
- `Self::SelfTalk::Actors::VolumeDecay` — runs every 300s, decays inner voice volumes
|
|
39
40
|
|
|
41
|
+
## Dependencies
|
|
42
|
+
|
|
43
|
+
Runtime: `legion-cache`, `legion-crypt`, `legion-data`, `legion-json`, `legion-logging`, `legion-settings`, `legion-transport`, `faraday ~> 2.0` (for Identity Microsoft Graph API calls).
|
|
44
|
+
|
|
40
45
|
## Installation
|
|
41
46
|
|
|
42
47
|
```ruby
|
|
@@ -47,8 +52,8 @@ gem 'lex-agentic-self'
|
|
|
47
52
|
|
|
48
53
|
```bash
|
|
49
54
|
bundle install
|
|
50
|
-
bundle exec rspec
|
|
51
|
-
bundle exec rubocop
|
|
55
|
+
bundle exec rspec
|
|
56
|
+
bundle exec rubocop
|
|
52
57
|
```
|
|
53
58
|
|
|
54
59
|
## License
|
data/lex-agentic-self.gemspec
CHANGED
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_dependency 'legion-settings', '>= 1.3.14'
|
|
33
33
|
spec.add_dependency 'legion-transport', '>= 1.3.9'
|
|
34
34
|
|
|
35
|
-
spec.
|
|
35
|
+
spec.add_dependency 'faraday', '~> 2.0'
|
|
36
36
|
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
37
37
|
spec.add_development_dependency 'rubocop'
|
|
38
38
|
spec.add_development_dependency 'rubocop-legion'
|
|
@@ -18,6 +18,7 @@ module Legion
|
|
|
18
18
|
@model = Dimensions.new_identity_model
|
|
19
19
|
@observation_count = 0
|
|
20
20
|
@entropy_history = []
|
|
21
|
+
@local_previously_available = false
|
|
21
22
|
load_from_local
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -87,7 +88,14 @@ module Legion
|
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
def save_to_local
|
|
90
|
-
|
|
91
|
+
unless local_available?
|
|
92
|
+
if @local_previously_available
|
|
93
|
+
Legion::Logging.warn 'lex-identity: local persistence unavailable after being available'
|
|
94
|
+
return false
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
return nil
|
|
98
|
+
end
|
|
91
99
|
|
|
92
100
|
db = local_data_connection
|
|
93
101
|
|
|
@@ -161,7 +169,9 @@ module Legion
|
|
|
161
169
|
private
|
|
162
170
|
|
|
163
171
|
def local_available?
|
|
164
|
-
defined?(Legion::Data::Local) && respond_to?(:local_data_connected?) && local_data_connected?
|
|
172
|
+
available = defined?(Legion::Data::Local) && respond_to?(:local_data_connected?) && local_data_connected?
|
|
173
|
+
@local_previously_available = true if available
|
|
174
|
+
available
|
|
165
175
|
end
|
|
166
176
|
end
|
|
167
177
|
end
|
|
@@ -16,6 +16,10 @@ module Legion
|
|
|
16
16
|
module VaultSecrets
|
|
17
17
|
VAULT_PATH_PREFIX = 'secret/data/legion/workers'
|
|
18
18
|
|
|
19
|
+
def self.log
|
|
20
|
+
Legion::Logging
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def self.secret_path(worker_id)
|
|
20
24
|
"#{VAULT_PATH_PREFIX}/#{worker_id}/entra"
|
|
21
25
|
end
|
|
@@ -68,7 +72,8 @@ module Legion
|
|
|
68
72
|
defined?(Legion::Crypt) &&
|
|
69
73
|
defined?(Legion::Settings) &&
|
|
70
74
|
Legion::Settings[:crypt][:vault][:connected] == true
|
|
71
|
-
rescue StandardError =>
|
|
75
|
+
rescue StandardError => e
|
|
76
|
+
log.error "[identity:vault] vault_available? check failed: #{e.message}"
|
|
72
77
|
false
|
|
73
78
|
end
|
|
74
79
|
end
|
|
@@ -7,6 +7,10 @@ module Legion
|
|
|
7
7
|
module Metacognition
|
|
8
8
|
module Helpers
|
|
9
9
|
module SelfModel
|
|
10
|
+
def self.log
|
|
11
|
+
Legion::Logging
|
|
12
|
+
end
|
|
13
|
+
|
|
10
14
|
module_function
|
|
11
15
|
|
|
12
16
|
def build(subsystem_states: {}, tick_results: {})
|
|
@@ -31,7 +35,8 @@ module Legion
|
|
|
31
35
|
ns = agentic.const_get(domain, false)
|
|
32
36
|
ns.is_a?(Module) && ns.const_defined?(ext_sym, false)
|
|
33
37
|
end
|
|
34
|
-
rescue StandardError =>
|
|
38
|
+
rescue StandardError => e
|
|
39
|
+
log.error "[metacognition] extension_loaded? check failed: #{e.message}"
|
|
35
40
|
false
|
|
36
41
|
end
|
|
37
42
|
|
|
@@ -39,7 +44,8 @@ module Legion
|
|
|
39
44
|
Constants::EXTENSION_CAPABILITIES.each_with_object({}) do |(ext_sym, _cat), acc|
|
|
40
45
|
acc[ext_sym] = { loaded: extension_loaded?(ext_sym) }
|
|
41
46
|
end
|
|
42
|
-
rescue StandardError =>
|
|
47
|
+
rescue StandardError => e
|
|
48
|
+
log.error "[metacognition] discover_loaded_extensions failed: #{e.message}"
|
|
43
49
|
{}
|
|
44
50
|
end
|
|
45
51
|
|
|
@@ -10,8 +10,8 @@ module Legion
|
|
|
10
10
|
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
11
11
|
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
12
12
|
|
|
13
|
-
def
|
|
14
|
-
|
|
13
|
+
def record_narrative_self_episode(description:, episode_type: :insight, domain: :general,
|
|
14
|
+
significance: nil, emotional_valence: 0.0, tags: [], **)
|
|
15
15
|
episode = autobiography.record_episode(
|
|
16
16
|
description: description,
|
|
17
17
|
episode_type: episode_type,
|
|
@@ -42,12 +42,12 @@ module Legion
|
|
|
42
42
|
false
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def enhance(prompt, phase: 'reflection'
|
|
45
|
+
def enhance(prompt, phase: 'reflection')
|
|
46
46
|
return nil unless available?
|
|
47
47
|
|
|
48
48
|
if pipeline_available?
|
|
49
49
|
response = Legion::LLM::Pipeline::GaiaCaller.chat(
|
|
50
|
-
message: prompt, phase: phase
|
|
50
|
+
message: prompt, phase: phase
|
|
51
51
|
)
|
|
52
52
|
response&.message&.dig(:content)
|
|
53
53
|
else
|
|
@@ -149,6 +149,8 @@ module Legion
|
|
|
149
149
|
update_emotion_score(tick_results)
|
|
150
150
|
update_memory_score(tick_results)
|
|
151
151
|
update_load_score(tick_results)
|
|
152
|
+
update_trust_score(tick_results)
|
|
153
|
+
update_mode_score(tick_results)
|
|
152
154
|
end
|
|
153
155
|
|
|
154
156
|
def update_prediction_score(tick_results)
|
|
@@ -190,6 +192,22 @@ module Legion
|
|
|
190
192
|
utilization = elapsed / budget
|
|
191
193
|
reflection_store.update_category_score(:cognitive_load, [1.0 - utilization, 0.0].max)
|
|
192
194
|
end
|
|
195
|
+
|
|
196
|
+
def update_trust_score(tick_results)
|
|
197
|
+
social = tick_results[:social_cognition]
|
|
198
|
+
return unless social.is_a?(Hash) && social[:trust_drift].is_a?(Numeric)
|
|
199
|
+
|
|
200
|
+
reflection_store.update_category_score(:trust_drift, 1.0 - social[:trust_drift].abs)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def update_mode_score(tick_results)
|
|
204
|
+
state = tick_results[:tick_state]
|
|
205
|
+
return unless state.is_a?(Hash) && state[:mode_transitions].is_a?(Numeric)
|
|
206
|
+
|
|
207
|
+
transitions = state[:mode_transitions].to_f
|
|
208
|
+
threshold = Helpers::Constants::MODE_OSCILLATION_THRESHOLD.to_f
|
|
209
|
+
reflection_store.update_category_score(:mode_patterns, [1.0 - (transitions / threshold), 0.0].max)
|
|
210
|
+
end
|
|
193
211
|
end
|
|
194
212
|
end
|
|
195
213
|
end
|
|
@@ -61,14 +61,15 @@ module Legion
|
|
|
61
61
|
tags: ['partner', 'milestone', milestone.type.to_s]
|
|
62
62
|
)
|
|
63
63
|
rescue StandardError => e
|
|
64
|
-
|
|
64
|
+
log.error "[relationship_arc] narrative stamp failed: #{e.message}"
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def resolve_narrative_identity
|
|
68
68
|
return nil unless defined?(Legion::Extensions::Agentic::Self::NarrativeIdentity::Client)
|
|
69
69
|
|
|
70
70
|
@narrative_client ||= Legion::Extensions::Agentic::Self::NarrativeIdentity::Client.new
|
|
71
|
-
rescue StandardError =>
|
|
71
|
+
rescue StandardError => e
|
|
72
|
+
log.error "[relationship_arc] resolve_narrative_identity failed: #{e.message}"
|
|
72
73
|
nil
|
|
73
74
|
end
|
|
74
75
|
end
|
|
@@ -40,6 +40,43 @@ module Legion
|
|
|
40
40
|
def self.transport_required?
|
|
41
41
|
false
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
def self.log
|
|
45
|
+
Legion::Logging
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.personality_snapshot
|
|
49
|
+
client = Personality::Client.new
|
|
50
|
+
client.personality_profile
|
|
51
|
+
rescue StandardError => e
|
|
52
|
+
log.warn "[self] personality_snapshot failed: #{e.message}"
|
|
53
|
+
{}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.reflection_snapshot
|
|
57
|
+
client = Reflection::Client.new
|
|
58
|
+
result = client.recent_reflections(limit: 100)
|
|
59
|
+
result.is_a?(Hash) ? (result[:reflections] || []) : []
|
|
60
|
+
rescue StandardError => e
|
|
61
|
+
log.warn "[self] reflection_snapshot failed: #{e.message}"
|
|
62
|
+
[]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.restore_personality(data)
|
|
66
|
+
return unless data.is_a?(Hash) && !data.empty?
|
|
67
|
+
|
|
68
|
+
log.info "[self] restore_personality: #{data.keys.join(', ')}"
|
|
69
|
+
rescue StandardError => e
|
|
70
|
+
log.error "[self] restore_personality failed: #{e.message}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.restore_reflections(data)
|
|
74
|
+
return unless data.is_a?(Array) && !data.empty?
|
|
75
|
+
|
|
76
|
+
log.info "[self] restore_reflections: #{data.size} entries"
|
|
77
|
+
rescue StandardError => e
|
|
78
|
+
log.error "[self] restore_reflections failed: #{e.message}"
|
|
79
|
+
end
|
|
43
80
|
end
|
|
44
81
|
end
|
|
45
82
|
end
|
|
@@ -91,5 +91,13 @@ RSpec.describe Legion::Extensions::Agentic::Self::Identity::Helpers::Fingerprint
|
|
|
91
91
|
expect(fp.save_to_local).to be_nil
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
+
|
|
95
|
+
it 'warns when local persistence was previously available but is no longer connected' do
|
|
96
|
+
fp.instance_variable_set(:@local_previously_available, true)
|
|
97
|
+
allow(fp).to receive(:local_data_connected?).and_return(false)
|
|
98
|
+
|
|
99
|
+
expect(Legion::Logging).to receive(:warn).with(/local persistence unavailable/)
|
|
100
|
+
expect(fp.save_to_local).to be false
|
|
101
|
+
end
|
|
94
102
|
end
|
|
95
103
|
end
|
|
@@ -8,7 +8,7 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Client do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it 'includes all runner methods' do
|
|
11
|
-
expect(client).to respond_to(:
|
|
11
|
+
expect(client).to respond_to(:record_narrative_self_episode)
|
|
12
12
|
expect(client).to respond_to(:recent_episodes)
|
|
13
13
|
expect(client).to respond_to(:significant_episodes)
|
|
14
14
|
expect(client).to respond_to(:create_thread)
|
|
@@ -28,20 +28,20 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Client do
|
|
|
28
28
|
client.create_thread(theme: :mastery, domain: :technical)
|
|
29
29
|
|
|
30
30
|
# Record experiences
|
|
31
|
-
client.
|
|
31
|
+
client.record_narrative_self_episode(
|
|
32
32
|
description: 'built first extension',
|
|
33
33
|
episode_type: :achievement,
|
|
34
34
|
domain: :technical,
|
|
35
35
|
emotional_valence: 0.7,
|
|
36
36
|
tags: %i[building mastery]
|
|
37
37
|
)
|
|
38
|
-
client.
|
|
38
|
+
client.record_narrative_self_episode(
|
|
39
39
|
description: 'learned about EMA',
|
|
40
40
|
episode_type: :insight,
|
|
41
41
|
domain: :cognition,
|
|
42
42
|
tags: %i[learning math]
|
|
43
43
|
)
|
|
44
|
-
client.
|
|
44
|
+
client.record_narrative_self_episode(
|
|
45
45
|
description: 'test failure taught me about edge cases',
|
|
46
46
|
episode_type: :discovery,
|
|
47
47
|
domain: :technical,
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::NarrativeSelf do
|
|
4
4
|
let(:client) { Legion::Extensions::Agentic::Self::NarrativeSelf::Client.new }
|
|
5
5
|
|
|
6
|
-
describe '#
|
|
6
|
+
describe '#record_narrative_self_episode' do
|
|
7
7
|
it 'returns success with episode data' do
|
|
8
|
-
result = client.
|
|
8
|
+
result = client.record_narrative_self_episode(description: 'completed first build', episode_type: :achievement)
|
|
9
9
|
expect(result[:success]).to be true
|
|
10
10
|
expect(result[:episode][:description]).to eq('completed first build')
|
|
11
11
|
expect(result[:episode][:episode_type]).to eq(:achievement)
|
|
@@ -14,7 +14,7 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
14
14
|
|
|
15
15
|
describe '#recent_episodes' do
|
|
16
16
|
before do
|
|
17
|
-
3.times { |i| client.
|
|
17
|
+
3.times { |i| client.record_narrative_self_episode(description: "event #{i}") }
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'returns recent episodes' do
|
|
@@ -26,8 +26,8 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
26
26
|
|
|
27
27
|
describe '#significant_episodes' do
|
|
28
28
|
before do
|
|
29
|
-
client.
|
|
30
|
-
client.
|
|
29
|
+
client.record_narrative_self_episode(description: 'major', significance: 0.9)
|
|
30
|
+
client.record_narrative_self_episode(description: 'minor', significance: 0.1)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it 'filters by significance' do
|
|
@@ -39,8 +39,8 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
39
39
|
|
|
40
40
|
describe '#episodes_by_type' do
|
|
41
41
|
before do
|
|
42
|
-
client.
|
|
43
|
-
client.
|
|
42
|
+
client.record_narrative_self_episode(description: 'win', episode_type: :achievement)
|
|
43
|
+
client.record_narrative_self_episode(description: 'learn', episode_type: :insight)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it 'filters by type' do
|
|
@@ -72,7 +72,7 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
72
72
|
|
|
73
73
|
describe '#timeline' do
|
|
74
74
|
before do
|
|
75
|
-
3.times { |i| client.
|
|
75
|
+
3.times { |i| client.record_narrative_self_episode(description: "event #{i}") }
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it 'returns timeline entries' do
|
|
@@ -85,8 +85,8 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
85
85
|
|
|
86
86
|
describe '#self_summary' do
|
|
87
87
|
before do
|
|
88
|
-
client.
|
|
89
|
-
client.
|
|
88
|
+
client.record_narrative_self_episode(description: 'a', episode_type: :achievement, domain: :tech)
|
|
89
|
+
client.record_narrative_self_episode(description: 'b', episode_type: :insight, domain: :personal)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it 'returns comprehensive summary' do
|
|
@@ -100,7 +100,7 @@ RSpec.describe Legion::Extensions::Agentic::Self::NarrativeSelf::Runners::Narrat
|
|
|
100
100
|
|
|
101
101
|
describe '#update_narrative_self' do
|
|
102
102
|
it 'decays and reports counts' do
|
|
103
|
-
client.
|
|
103
|
+
client.record_narrative_self_episode(description: 'test')
|
|
104
104
|
result = client.update_narrative_self
|
|
105
105
|
expect(result[:success]).to be true
|
|
106
106
|
expect(result[:episode_count]).to eq(1)
|
|
@@ -75,6 +75,10 @@ RSpec.describe Legion::Extensions::Agentic::Self::Reflection::Helpers::LlmEnhanc
|
|
|
75
75
|
allow(enhancer_mod).to receive(:available?).and_return(false)
|
|
76
76
|
expect(enhancer_mod.enhance('hello')).to be_nil
|
|
77
77
|
end
|
|
78
|
+
|
|
79
|
+
it 'rejects arbitrary extra kwargs instead of forwarding them to LLM' do
|
|
80
|
+
expect { enhancer_mod.enhance('hello', unexpected: true) }.to raise_error(ArgumentError)
|
|
81
|
+
end
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
describe '.available?' do
|
|
@@ -46,6 +46,23 @@ RSpec.describe Legion::Extensions::Agentic::Self::Reflection::Runners::Reflectio
|
|
|
46
46
|
expect(result[:health]).to be < 1.0
|
|
47
47
|
expect(result[:category_scores][:prediction_calibration]).to eq(0.2)
|
|
48
48
|
end
|
|
49
|
+
|
|
50
|
+
it 'updates trust_drift from social cognition results' do
|
|
51
|
+
client.reflect(tick_results: { social_cognition: { trust_drift: 0.4 } })
|
|
52
|
+
|
|
53
|
+
result = client.cognitive_health
|
|
54
|
+
|
|
55
|
+
expect(result[:category_scores][:trust_drift]).to eq(0.6)
|
|
56
|
+
expect(result[:health]).to be < 1.0
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'updates mode_patterns from tick mode transition counts' do
|
|
60
|
+
client.reflect(tick_results: { tick_state: { mode_transitions: 5 } })
|
|
61
|
+
|
|
62
|
+
result = client.cognitive_health
|
|
63
|
+
|
|
64
|
+
expect(result[:category_scores][:mode_patterns]).to eq(0.0)
|
|
65
|
+
end
|
|
49
66
|
end
|
|
50
67
|
|
|
51
68
|
describe '#recent_reflections' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-agentic-self
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -114,7 +114,7 @@ dependencies:
|
|
|
114
114
|
- - "~>"
|
|
115
115
|
- !ruby/object:Gem::Version
|
|
116
116
|
version: '2.0'
|
|
117
|
-
type: :
|
|
117
|
+
type: :runtime
|
|
118
118
|
prerelease: false
|
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
120
120
|
requirements:
|