lex-llm 0.6.13 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0307598766a4f750febc8f0e72b2ebfa344291eb7feb3f134b2f7f1fffcb7620'
4
- data.tar.gz: 713d7789cc022b01300ab4cc75811c43ea297ec817bb2780ce046426328155e9
3
+ metadata.gz: b28d2162e2284642dcbb0e39384957962b8b609aa982c2dc1c085f84f560243f
4
+ data.tar.gz: a68c5e7d429b6ba04c2f431a4140d44c93542993430fe5b36e921347b1d9a728
5
5
  SHA512:
6
- metadata.gz: ef02b0c8ac4f2850a2823982d564ea6ca0a9f6e9c5fb23180231080ff2291f22b242848ad700b889fe7a721d555c2a8d10f55b9f057e11ea0f4c67f3348df6a4
7
- data.tar.gz: cb4a22c7c6c8e4f151f09c7cb4f6b6b445a8faa085936344c747d7a90b648620f79673435731f9fe3f311e95b804e16c2af439b577aaa180ad2ae1d20b052721
6
+ metadata.gz: 4a76155cd1c0b1ac8952647afff1ed38728bdb130a241ec4b416b752fd19c07074db18cf787c9dca6f2e4ffe1afe3be144800093837add92311e68a63219593b
7
+ data.tar.gz: 9eeadc0a087bb111ccaaea7feffc55aae57b44a0f60f331b3f7e0b7a43ed75737b70338319b6d1b8aa62de668a41b04b605444a9989e7776b2d315debd59ca38
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.14 - 2026-07-31
4
+
5
+ ### Added
6
+ - **Connection#close tears down the underlying Faraday connection.** Previously `Connection` had no lifecycle method — persistent HTTP connections were never explicitly closed, causing CLOSE_WAIT socket accumulation when provider peers sent FIN (e.g. during daemon shutdown or provider restarts)
7
+ - **Provider#disconnect closes the connection and clears the reference.** Callers (legion-llm registry shutdown) can now explicitly tear down provider connections during graceful shutdown
8
+
3
9
  ## 0.6.13 - 2026-07-24
4
10
 
5
11
  ### Fixed
@@ -65,6 +65,13 @@ module Legion
65
65
  end
66
66
  end
67
67
 
68
+ def close
69
+ return unless @connection
70
+
71
+ @connection.close if @connection.respond_to?(:close)
72
+ @connection = nil
73
+ end
74
+
68
75
  def instance_variables
69
76
  super - %i[@config @connection]
70
77
  end
@@ -84,6 +84,11 @@ module Legion
84
84
  @connection = Connection.new(self, @config)
85
85
  end
86
86
 
87
+ def disconnect
88
+ @connection&.close
89
+ @connection = nil
90
+ end
91
+
87
92
  def api_base
88
93
  raise NotImplementedError
89
94
  end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Llm
6
- VERSION = '0.6.13'
6
+ VERSION = '0.6.14'
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Legion::Extensions::Llm::Connection do
6
+ describe '#close' do
7
+ let(:provider) do
8
+ instance_double(
9
+ Legion::Extensions::Llm::Provider,
10
+ api_base: 'https://example.com',
11
+ configured?: true,
12
+ headers: {}
13
+ )
14
+ end
15
+
16
+ let(:config) do
17
+ instance_double(
18
+ Legion::Extensions::Llm::Configuration,
19
+ request_timeout: 300,
20
+ max_retries: 3,
21
+ retry_interval: 0.1,
22
+ retry_interval_randomness: 0.5,
23
+ retry_backoff_factor: 2,
24
+ http_proxy: nil,
25
+ log_regexp_timeout: nil
26
+ )
27
+ end
28
+
29
+ it 'nils out the underlying Faraday connection' do
30
+ conn = described_class.new(provider, config)
31
+ expect(conn.connection).not_to be_nil
32
+ conn.close
33
+ expect(conn.connection).to be_nil
34
+ end
35
+
36
+ it 'is safe to call multiple times' do
37
+ conn = described_class.new(provider, config)
38
+ conn.close
39
+ expect { conn.close }.not_to raise_error
40
+ end
41
+
42
+ it 'calls close on the Faraday connection when supported' do
43
+ conn = described_class.new(provider, config)
44
+ faraday = conn.connection
45
+ allow(faraday).to receive(:close)
46
+ conn.close
47
+ expect(faraday).to have_received(:close)
48
+ end
49
+ end
50
+ end
@@ -717,4 +717,29 @@ RSpec.describe Legion::Extensions::Llm::Provider do
717
717
  expect(key_v3).to include('schema3')
718
718
  end
719
719
  end
720
+
721
+ describe '#disconnect' do
722
+ let(:provider_class) do
723
+ Class.new(described_class) do
724
+ def api_base = 'https://test.invalid'
725
+ end
726
+ end
727
+
728
+ let(:provider) do
729
+ provider_class.new({ request_timeout: 60, max_retries: 0,
730
+ retry_interval: 0, retry_backoff_factor: 0,
731
+ retry_interval_randomness: 0 })
732
+ end
733
+
734
+ it 'closes the connection and nils the reference' do
735
+ expect(provider.connection).not_to be_nil
736
+ provider.disconnect
737
+ expect(provider.connection).to be_nil
738
+ end
739
+
740
+ it 'is safe to call multiple times' do
741
+ provider.disconnect
742
+ expect { provider.disconnect }.not_to raise_error
743
+ end
744
+ end
720
745
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13
4
+ version: 0.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO
@@ -395,6 +395,7 @@ files:
395
395
  - spec/legion/extensions/llm/conformance/fixtures/canonical_tools_request.json
396
396
  - spec/legion/extensions/llm/conformance/provider_tool_rendering_examples.rb
397
397
  - spec/legion/extensions/llm/conformance/provider_translator_examples.rb
398
+ - spec/legion/extensions/llm/connection_close_spec.rb
398
399
  - spec/legion/extensions/llm/connection_logging_spec.rb
399
400
  - spec/legion/extensions/llm/connection_retry_spec.rb
400
401
  - spec/legion/extensions/llm/context_spec.rb