lex-agentic-memory 0.1.12 → 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: 6f9d21093f342adfd656a2775f74aa1e53a397c16c484b4826bfa076d06799d7
4
- data.tar.gz: 917b0430e8fe409bbe1e857d9e3989fe722405fc7a0c746de463663552aea51c
3
+ metadata.gz: '0814efaa2ca66f0121dd6d783ec6383b09542f126628695cf2c375c056b5c2b1'
4
+ data.tar.gz: d6df0516525b8ff2883f9f4074eb488ac6df00c74ee24994ab7c629a9a449a0e
5
5
  SHA512:
6
- metadata.gz: baa0bf1ac1b2e8b49af95680e021643df0c85fd1e9eed423fc41327d7aae4e52c93b951eed9662754469e9d2ed3df63be17d22793b91d7678e2cbf61a69aa841
7
- data.tar.gz: 6463bbc07b183c771179ce3447b0846fb5b6b48065c16931c439ef5124e2e81091e13079a5c50ab6189acf5646c7fba010ae869949ef053de3612485aa21ec4c
6
+ metadata.gz: ad170b27af1c27a90430d7ce82d89554b5a4cd5709504535d84bfc3ae52046495a790acf29cc9665739c2486cc736c36cbd118cf588f4f9418d3e90f307182e3
7
+ data.tar.gz: 8ee023a4360585eca2bd215dfc8601e4c9d2d96935a985c1bc8b0200e7953dbcd2f49d26032c35d23f8b5af69fa097a0d2c9c189291faa189e5892e22785405c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## [0.1.12] - 2026-03-26
4
11
 
5
12
  ### Fixed
@@ -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.
@@ -262,6 +263,12 @@ module Legion
262
263
  Legion::Data.connection
263
264
  end
264
265
 
266
+ def resolve_agent_id
267
+ Legion::Settings.dig(:agent, :id) || 'default'
268
+ rescue StandardError
269
+ 'default'
270
+ end
271
+
265
272
  # Dataset for memory_traces scoped by tenant_id (if set).
266
273
  def traces_ds
267
274
  ds = db[TRACES_TABLE]
@@ -277,6 +284,7 @@ module Legion
277
284
 
278
285
  {
279
286
  trace_id: trace[:trace_id],
287
+ agent_id: @agent_id,
280
288
  tenant_id: @tenant_id,
281
289
  trace_type: trace[:trace_type].to_s,
282
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.12'
7
+ VERSION = '0.1.13'
8
8
  end
9
9
  end
10
10
  end
@@ -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
@@ -127,6 +128,23 @@ RSpec.describe Legion::Extensions::Agentic::Memory::Trace::Helpers::PostgresStor
127
128
  end
128
129
  end
129
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
+
130
148
  # --- store + retrieve ---
131
149
 
132
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.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity