lex-agentic-memory 0.1.11 → 0.1.13

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: 44a4999991835bdd28a7189717f6a53f38928644a86c7f653517331687659901
4
- data.tar.gz: b3aeb50fddc4b82580430829ec924549690b8dd6171be74ff9213db40b135888
3
+ metadata.gz: '0814efaa2ca66f0121dd6d783ec6383b09542f126628695cf2c375c056b5c2b1'
4
+ data.tar.gz: d6df0516525b8ff2883f9f4074eb488ac6df00c74ee24994ab7c629a9a449a0e
5
5
  SHA512:
6
- metadata.gz: 32930b8b8092925f0793eef8ae8b1a6764d50cbc9692bb2952c46fb969137b41609eed96ecb455fdc7d0518373ebd912075eff8ac47c4deb8e97e1fc9176962b
7
- data.tar.gz: a142cbf70545c4f80717ddda3d81abab26a1cc2cf5d8e40584625a416629d1551991d716fc6a9592fff194b523b0ebed2963be24fa414039cf11bdb3c934e60a
6
+ metadata.gz: ad170b27af1c27a90430d7ce82d89554b5a4cd5709504535d84bfc3ae52046495a790acf29cc9665739c2486cc736c36cbd118cf588f4f9418d3e90f307182e3
7
+ data.tar.gz: 8ee023a4360585eca2bd215dfc8601e4c9d2d96935a985c1bc8b0200e7953dbcd2f49d26032c35d23f8b5af69fa097a0d2c9c189291faa189e5892e22785405c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.13] - 2026-03-26
4
+
5
+ ### Fixed
6
+ - `PostgresStore#serialize_trace` omitted `agent_id` column, causing `PG::NotNullViolation` on every insert against PostgreSQL (migration 022 declares `agent_id null: false`). Constructor now accepts `agent_id:` with fallback to `Legion::Settings.dig(:agent, :id)` or `'default'`
7
+ - `Trace.create_store` factory now resolves and passes `agent_id` to PostgresStore
8
+ - Spec schema for PostgresStore now includes `agent_id` column matching production migration
9
+
10
+ ## [0.1.12] - 2026-03-26
11
+
12
+ ### Fixed
13
+ - `PostgresStore#store` used SQLite-specific `insert_conflict(:replace)` which fails on PostgreSQL with `TypeError: no implicit conversion of Symbol into Integer`. Replaced with proper `insert_conflict(target: :trace_id, update: ...)` syntax that generates correct `ON CONFLICT` SQL
14
+
3
15
  ## [0.1.11] - 2026-03-25
4
16
 
5
17
  ### Added
@@ -15,8 +15,9 @@ module Legion
15
15
  TRACES_TABLE = :memory_traces
16
16
  ASSOCIATIONS_TABLE = :memory_associations
17
17
 
18
- def initialize(tenant_id: nil)
18
+ def initialize(tenant_id: nil, agent_id: nil)
19
19
  @tenant_id = tenant_id
20
+ @agent_id = agent_id || resolve_agent_id
20
21
  end
21
22
 
22
23
  # Store (upsert) a trace by trace_id.
@@ -25,10 +26,11 @@ module Legion
25
26
  return nil unless db_ready?
26
27
 
27
28
  row = serialize_trace(trace)
28
- begin
29
- db[TRACES_TABLE].insert_conflict(:replace).insert(row)
30
- rescue Sequel::UniqueConstraintViolation
31
- db[TRACES_TABLE].where(trace_id: trace[:trace_id]).update(row.except(:trace_id))
29
+ ds = db[TRACES_TABLE]
30
+ if db.adapter_scheme == :mysql2
31
+ ds.insert_conflict(update: row.except(:trace_id)).insert(row)
32
+ else
33
+ ds.insert_conflict(target: :trace_id, update: row.except(:trace_id)).insert(row)
32
34
  end
33
35
  HotTier.cache_trace(trace, tenant_id: @tenant_id) if HotTier.available?
34
36
  trace[:trace_id]
@@ -261,6 +263,12 @@ module Legion
261
263
  Legion::Data.connection
262
264
  end
263
265
 
266
+ def resolve_agent_id
267
+ Legion::Settings.dig(:agent, :id) || 'default'
268
+ rescue StandardError
269
+ 'default'
270
+ end
271
+
264
272
  # Dataset for memory_traces scoped by tenant_id (if set).
265
273
  def traces_ds
266
274
  ds = db[TRACES_TABLE]
@@ -276,6 +284,7 @@ module Legion
276
284
 
277
285
  {
278
286
  trace_id: trace[:trace_id],
287
+ agent_id: @agent_id,
279
288
  tenant_id: @tenant_id,
280
289
  trace_type: trace[:trace_type].to_s,
281
290
  content: payload.is_a?(Hash) ? Legion::JSON.dump(payload) : payload.to_s,
@@ -34,7 +34,7 @@ module Legion
34
34
  def create_store
35
35
  if postgres_available?
36
36
  Legion::Logging.debug '[memory] Using shared PostgresStore (write-through)'
37
- Helpers::PostgresStore.new(tenant_id: resolve_tenant_id)
37
+ Helpers::PostgresStore.new(tenant_id: resolve_tenant_id, agent_id: resolve_agent_id)
38
38
  elsif defined?(Legion::Cache) && Legion::Cache.respond_to?(:connected?) && Legion::Cache.connected?
39
39
  Legion::Logging.debug '[memory] Using shared CacheStore (memcached)'
40
40
  Helpers::CacheStore.new
@@ -60,6 +60,12 @@ module Legion
60
60
  rescue StandardError
61
61
  nil
62
62
  end
63
+
64
+ def resolve_agent_id
65
+ Legion::Settings.dig(:agent, :id) || 'default'
66
+ rescue StandardError
67
+ 'default'
68
+ end
63
69
  end
64
70
  end
65
71
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Memory
7
- VERSION = '0.1.11'
7
+ VERSION = '0.1.13'
8
8
  end
9
9
  end
10
10
  end
@@ -99,7 +99,9 @@ RSpec.describe Legion::Extensions::Agentic::Memory::Hologram::Helpers::Hologram
99
99
 
100
100
  describe '#reconstruct' do
101
101
  context 'with sufficient fragments' do
102
- let(:fragments) { hologram.fragment!(4) }
102
+ # Force completeness above RECONSTRUCTION_THRESHOLD (0.3) so the context
103
+ # is deterministic — fragment!(4) uses rand and can produce all-insufficient sets.
104
+ let(:fragments) { hologram.fragment!(4).each { |f| f.completeness = 1.0 } }
103
105
 
104
106
  it 'returns success: true' do
105
107
  expect(hologram.reconstruct(fragments)[:success]).to be true
@@ -12,6 +12,7 @@ RSpec.describe Legion::Extensions::Agentic::Memory::Trace::Helpers::PostgresStor
12
12
  d.create_table(:memory_traces) do
13
13
  primary_key :id
14
14
  String :trace_id, size: 36, null: false, unique: true
15
+ String :agent_id, size: 64, null: false, default: 'test-agent'
15
16
  String :tenant_id, size: 64
16
17
  String :trace_type, null: false
17
18
  String :content, text: true, null: false
@@ -110,6 +111,40 @@ RSpec.describe Legion::Extensions::Agentic::Memory::Trace::Helpers::PostgresStor
110
111
  end
111
112
  end
112
113
 
114
+ # --- store insert_conflict syntax ---
115
+
116
+ describe '#store insert_conflict syntax' do
117
+ it 'calls insert_conflict with target: :trace_id (not :replace symbol)' do
118
+ ds = double('dataset')
119
+ allow(db).to receive(:[]).with(:memory_traces).and_return(ds)
120
+ allow(ds).to receive(:where).and_return(ds)
121
+ allow(ds).to receive(:insert_conflict).and_return(ds)
122
+ allow(ds).to receive(:insert)
123
+
124
+ store.store(semantic_trace)
125
+
126
+ expect(ds).to have_received(:insert_conflict)
127
+ .with(hash_including(target: :trace_id))
128
+ end
129
+ end
130
+
131
+ # --- store agent_id population ---
132
+
133
+ describe '#store agent_id population' do
134
+ it 'writes agent_id to the database row' do
135
+ store.store(semantic_trace)
136
+ row = db[:memory_traces].where(trace_id: semantic_trace[:trace_id]).first
137
+ expect(row[:agent_id]).not_to be_nil
138
+ end
139
+
140
+ it 'uses the resolved agent_id from settings' do
141
+ custom_store = described_class.new(tenant_id: tenant_id, agent_id: 'my-agent')
142
+ custom_store.store(semantic_trace)
143
+ row = db[:memory_traces].where(trace_id: semantic_trace[:trace_id]).first
144
+ expect(row[:agent_id]).to eq('my-agent')
145
+ end
146
+ end
147
+
113
148
  # --- store + retrieve ---
114
149
 
115
150
  describe '#store and #retrieve' do
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.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity