phronomy 0.5.2 → 0.5.3

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: f2129e4cbe20c3831530f0a8ef810abe272174195cbce5198207fec6bf255eff
4
- data.tar.gz: f9a0152759518cb2d85126ee5fb7a57b96e00a0ed7b8acffd54c57de91ed0c18
3
+ metadata.gz: 49b20f3defaed56477f9f1ee375a450d26a770d004c052754cc5c045746587cc
4
+ data.tar.gz: 1d2fe811e467c7d04208b82cc9d9ca5fca9b17d0bf6061aa952a2fb862c23a53
5
5
  SHA512:
6
- metadata.gz: 0af940bc5279c64221d000e4c545c5e2696f2f14c405326785786b94cf9afc567619e94e79aefbfc68b0656d761ebe88b7604d1cbacf75e82ae3aca6d39b9e3f
7
- data.tar.gz: 71d4ef2f73a4e914d4dd85fffef0643a1725857dc6bf51dce5c39e78f34a0bfdc69d2de59be574396175f3a2ea5841e502bde75d082ddb30f15ee30a1a598037
6
+ metadata.gz: 763cf25297e0c8799ad76bcd362ecb5f1899a9ccd0d90791e119d2d0946c59f7c076f7a00d92e01e64735e90b45d7e1aa5462e41efceee9147daf45ac214551f
7
+ data.tar.gz: 3a30e9198008dd9e4e512c374324b4c1cfda40c2a41762ff160f90ffa8ac98c0669f700d810e899fa661bd68af3a14db0145a00afc4d0e97d560d7de27989db0
data/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.5.3] - 2026-05-20
11
+
12
+ ### Bug Fixes
13
+
14
+ - **Ensure `from_server` closes transport on error** (#95): The short-lived
15
+ transport created inside `McpTool.from_server` is now wrapped in
16
+ `begin/ensure`, so the underlying child process (stdio) is always
17
+ terminated even when `fetch_tool` raises.
18
+ - **Correct `McpTool#close` documentation** (#94): The comment previously
19
+ stated that calling `execute` after `close` raises an error; in practice
20
+ the transport reopens automatically. The comment now reflects actual
21
+ behaviour.
22
+
23
+ ### Documentation
24
+
25
+ - **Fix CHANGELOG date for v0.5.1** (#96): The v0.5.1 entry had an
26
+ incorrect date of 2026-05-21; corrected to 2026-05-20.
27
+
28
+ ---
29
+
10
30
  ## [0.5.2] - 2026-05-20
11
31
 
12
32
  ### Bug Fixes
@@ -41,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
41
61
 
42
62
  ---
43
63
 
44
- ## [0.5.1] - 2026-05-21
64
+ ## [0.5.1] - 2026-05-20
45
65
 
46
66
  ### Bug Fixes
47
67
 
@@ -41,8 +41,11 @@ module Phronomy
41
41
  # then close it. Each McpTool instance creates its own transport
42
42
  # so that concurrent callers never share IO streams.
43
43
  transport = build_transport(server_uri)
44
- tool_def = transport.fetch_tool(tool_name)
45
- transport.close
44
+ begin
45
+ tool_def = transport.fetch_tool(tool_name)
46
+ ensure
47
+ transport.close
48
+ end
46
49
  build_tool_class(tool_name, server_uri, tool_def).new
47
50
  end
48
51
 
@@ -84,7 +87,9 @@ module Phronomy
84
87
 
85
88
  # Allow callers to deterministically shut down the underlying child
86
89
  # process (stdio) or release the HTTP connection. For HttpTransport
87
- # this is a no-op. Calling execute after close raises an error.
90
+ # this is a no-op. After close, calling execute will reopen the
91
+ # transport automatically (stdio restarts the child process; HTTP
92
+ # opens a fresh connection per call).
88
93
  klass.define_method(:close) do
89
94
  @mcp_transport.close
90
95
  end
@@ -28,7 +28,13 @@ module Phronomy
28
28
  # @param k [Integer]
29
29
  # @return [Array<Hash>] sorted by descending score
30
30
  def search(query_embedding:, k: 5)
31
- results = @documents.map do |id, doc|
31
+ # Take an atomic snapshot before iterating. Hash#dup is a C-level
32
+ # call that completes without releasing the GVL, so it is atomic with
33
+ # respect to any other Ruby thread. Iterating the copy instead of
34
+ # @documents directly prevents "can't add a new key into hash during
35
+ # iteration" when a concurrent thread calls #add.
36
+ snapshot = @documents.dup
37
+ results = snapshot.map do |id, doc|
32
38
  score = cosine_similarity(query_embedding, doc[:embedding])
33
39
  {id: id, score: score, metadata: doc[:metadata]}
34
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phronomy
4
- VERSION = "0.5.2"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phronomy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raizo T.C.S