lex-agentic-memory 0.1.23 → 0.1.25
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 +13 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/runners/cognitive_immune_memory.rb +15 -9
- data/lib/legion/extensions/agentic/memory/trace/helpers/store.rb +9 -10
- data/lib/legion/extensions/agentic/memory/trace/quota.rb +12 -2
- data/lib/legion/extensions/agentic/memory/trace/runners/traces.rb +1 -1
- data/lib/legion/extensions/agentic/memory/version.rb +1 -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: 2c09e54494e00502435e318cabbdfda9c2f8bf8579a174caf9197d254ae05b3d
|
|
4
|
+
data.tar.gz: 113d1291eaade383a408a053b22bf0c872341e43b177cc2811b36b67029fde5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba8dd2da72d04f871bfe0bf403563226a29b2f920bbeee6423b1ef49da4b1db18f7283e579f57bbbe0846c08130a9981bd110eae202f2c67433b234ebed5788f
|
|
7
|
+
data.tar.gz: 7923d43a3447710da47c43f82a2d660b94138d43b0074299d438e7a9ebbc39c5f4b23bab1dc219c923a64519dbb37f8581d083105a1b9a6ddc7970db14089fad
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- fix retrieve_ranked to return Hash with traces key instead of bare Array for GAIA phase wiring
|
|
7
|
+
- add respond_to? guards in Quota#enforce! for store methods not present on all backends
|
|
8
|
+
- add lazy default_engine initialization in CognitiveImmuneMemory runner
|
|
9
|
+
|
|
10
|
+
## [0.1.24] - 2026-04-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Wrap `save_to_local` persist in a single SQLite transaction — 32K individual lock acquisitions become 1
|
|
14
|
+
- Use `insert_conflict(:replace)` instead of SELECT-then-INSERT/UPDATE per trace
|
|
15
|
+
|
|
3
16
|
## [0.1.23] - 2026-04-03
|
|
4
17
|
|
|
5
18
|
### Fixed
|
|
@@ -10,7 +10,7 @@ module Legion
|
|
|
10
10
|
include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
|
|
11
11
|
|
|
12
12
|
def create_memory_cell(threat_type:, signature:, cell_type: :b_memory, strength: nil, engine: nil, **)
|
|
13
|
-
eng = engine ||
|
|
13
|
+
eng = engine || default_engine
|
|
14
14
|
cell = eng.create_memory_cell(threat_type: threat_type, signature: signature,
|
|
15
15
|
cell_type: cell_type,
|
|
16
16
|
strength: strength || Helpers::Constants::VACCINATION_STRENGTH)
|
|
@@ -18,55 +18,61 @@ module Legion
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def vaccinate(threat_type:, signature:, strength: nil, engine: nil, **)
|
|
21
|
-
eng = engine ||
|
|
21
|
+
eng = engine || default_engine
|
|
22
22
|
cell = eng.vaccinate(threat_type: threat_type, signature: signature,
|
|
23
23
|
strength: strength || Helpers::Constants::VACCINATION_STRENGTH)
|
|
24
24
|
{ success: true, cell: cell.to_h }
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def encounter_threat(threat_type:, threat_signature:, severity: 0.5, engine: nil, **)
|
|
28
|
-
eng = engine ||
|
|
28
|
+
eng = engine || default_engine
|
|
29
29
|
record = eng.encounter_threat(threat_type: threat_type, threat_signature: threat_signature,
|
|
30
30
|
severity: severity)
|
|
31
31
|
{ success: true, encounter: record.to_h }
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def decay_all(engine: nil, **)
|
|
35
|
-
eng = engine ||
|
|
35
|
+
eng = engine || default_engine
|
|
36
36
|
result = eng.decay_all!
|
|
37
37
|
{ success: true, **result }
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def immunity_for(threat_type:, engine: nil, **)
|
|
41
|
-
eng = engine ||
|
|
41
|
+
eng = engine || default_engine
|
|
42
42
|
immunity = eng.immunity_for(threat_type: threat_type)
|
|
43
43
|
label = Helpers::Constants.label_for(Helpers::Constants::IMMUNITY_LABELS, immunity)
|
|
44
44
|
{ success: true, threat_type: threat_type, immunity: immunity, label: label }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def active_cells(engine: nil, **)
|
|
48
|
-
eng = engine ||
|
|
48
|
+
eng = engine || default_engine
|
|
49
49
|
cells = eng.active_cells
|
|
50
50
|
{ success: true, count: cells.size, cells: cells.map(&:to_h) }
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def veteran_cells(engine: nil, **)
|
|
54
|
-
eng = engine ||
|
|
54
|
+
eng = engine || default_engine
|
|
55
55
|
cells = eng.veteran_cells
|
|
56
56
|
{ success: true, count: cells.size, cells: cells.map(&:to_h) }
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def threat_coverage(engine: nil, **)
|
|
60
|
-
eng = engine ||
|
|
60
|
+
eng = engine || default_engine
|
|
61
61
|
coverage = eng.threat_coverage
|
|
62
62
|
{ success: true, coverage: coverage }
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def immune_status(engine: nil, **)
|
|
66
|
-
eng = engine ||
|
|
66
|
+
eng = engine || default_engine
|
|
67
67
|
report = eng.immune_report
|
|
68
68
|
{ success: true, **report }
|
|
69
69
|
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def default_engine
|
|
74
|
+
@default_engine ||= Helpers::ImmuneMemoryEngine.new
|
|
75
|
+
end
|
|
70
76
|
end
|
|
71
77
|
end
|
|
72
78
|
end
|
|
@@ -165,10 +165,12 @@ module Legion
|
|
|
165
165
|
return unless snapshots
|
|
166
166
|
|
|
167
167
|
traces_snapshot, associations_snapshot, trace_rows_snapshot, traces_dirty, associations_dirty = snapshots
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
db.transaction do
|
|
169
|
+
scoped_trace_ids = db[:memory_traces].where(partition_id: @partition_id).select_map(:trace_id)
|
|
170
|
+
memory_trace_ids = traces_snapshot.keys
|
|
171
|
+
stale_ids = persist_dirty_traces(db, trace_rows_snapshot, scoped_trace_ids, memory_trace_ids, traces_dirty)
|
|
172
|
+
persist_dirty_associations(db, associations_snapshot, scoped_trace_ids, memory_trace_ids, stale_ids, associations_dirty)
|
|
173
|
+
end
|
|
172
174
|
clear_dirty_flags(trace_rows_snapshot)
|
|
173
175
|
end
|
|
174
176
|
|
|
@@ -187,12 +189,9 @@ module Legion
|
|
|
187
189
|
def persist_dirty_traces(db, trace_rows_snapshot, scoped_trace_ids, memory_trace_ids, traces_dirty)
|
|
188
190
|
return [] unless traces_dirty
|
|
189
191
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else
|
|
194
|
-
db[:memory_traces].insert(row)
|
|
195
|
-
end
|
|
192
|
+
ds = db[:memory_traces]
|
|
193
|
+
trace_rows_snapshot.each_value do |row|
|
|
194
|
+
ds.insert_conflict(:replace).insert(row)
|
|
196
195
|
end
|
|
197
196
|
stale_ids = scoped_trace_ids - memory_trace_ids
|
|
198
197
|
db[:memory_traces].where(trace_id: stale_ids).delete unless stale_ids.empty?
|
|
@@ -25,11 +25,15 @@ module Legion
|
|
|
25
25
|
evict_count = store.count - max_traces
|
|
26
26
|
evict!(store, evict_count) if evict_count.positive?
|
|
27
27
|
|
|
28
|
+
return unless store.respond_to?(:total_bytes)
|
|
29
|
+
|
|
28
30
|
overage = store.total_bytes - max_bytes
|
|
29
31
|
evict!(store, estimate_eviction_count(overage)) if overage.positive?
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
def within_limits?(store)
|
|
35
|
+
return store.count <= max_traces unless store.respond_to?(:total_bytes)
|
|
36
|
+
|
|
33
37
|
store.count <= max_traces && store.total_bytes <= max_bytes
|
|
34
38
|
end
|
|
35
39
|
|
|
@@ -39,8 +43,14 @@ module Legion
|
|
|
39
43
|
return if count <= 0
|
|
40
44
|
|
|
41
45
|
case eviction
|
|
42
|
-
when :lru
|
|
43
|
-
|
|
46
|
+
when :lru
|
|
47
|
+
return unless store.respond_to?(:delete_least_recently_used)
|
|
48
|
+
|
|
49
|
+
store.delete_least_recently_used(count: count)
|
|
50
|
+
when :lowest_confidence
|
|
51
|
+
return unless store.respond_to?(:delete_lowest_confidence)
|
|
52
|
+
|
|
53
|
+
store.delete_lowest_confidence(count: count)
|
|
44
54
|
end
|
|
45
55
|
end
|
|
46
56
|
|