lex-agentic-memory 0.1.24 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c02b5c5fc14dfba427fc4a6c321eab9abc4aa12218671c132f747da6af2de92
4
- data.tar.gz: 1e7b698497e270656372bb2f47eb4dc3b93d16e64faf9d4d95ea466bcf6071c7
3
+ metadata.gz: 2c09e54494e00502435e318cabbdfda9c2f8bf8579a174caf9197d254ae05b3d
4
+ data.tar.gz: 113d1291eaade383a408a053b22bf0c872341e43b177cc2811b36b67029fde5e
5
5
  SHA512:
6
- metadata.gz: b02c36cc24ffb379cc41988398b8d69588ee5bddddd008bdc4eaedfdd062d44d3fe4fc8e5981b58e2d1d7b014863aa24a49e55a490ada138727e3f9ac9132e6d
7
- data.tar.gz: 0dc565499fac89a69ddf26b3a83465e699205ad32a9a5b10deb83ed5818ef9c9babd2d421a8fdf78f7b90ff1dc19e06fecd94cde8b3a01652082b40f85e72c1a
6
+ metadata.gz: ba8dd2da72d04f871bfe0bf403563226a29b2f920bbeee6423b1ef49da4b1db18f7283e579f57bbbe0846c08130a9981bd110eae202f2c67433b234ebed5788f
7
+ data.tar.gz: 7923d43a3447710da47c43f82a2d660b94138d43b0074299d438e7a9ebbc39c5f4b23bab1dc219c923a64519dbb37f8581d083105a1b9a6ddc7970db14089fad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## [0.1.24] - 2026-04-03
4
11
 
5
12
  ### 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 || @default_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 || @default_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 || @default_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 || @default_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 || @default_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 || @default_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 || @default_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 || @default_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 || @default_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
@@ -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 then store.delete_least_recently_used(count: count)
43
- when :lowest_confidence then store.delete_lowest_confidence(count: count)
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
 
@@ -63,7 +63,7 @@ module Legion
63
63
 
64
64
  result = scored.sort_by { |s| -s[:score] }
65
65
  log.debug("[memory] retrieve_ranked ids=#{trace_ids.size} scored=#{result.size}")
66
- result
66
+ { success: true, traces: result }
67
67
  end
68
68
 
69
69
  def delete_trace(trace_id:, store: nil, **)
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Memory
7
- VERSION = '0.1.24'
7
+ VERSION = '0.1.25'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-memory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity