elo-node 0.4.7__tar.gz → 0.4.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: elo-node
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: Elo — malha P2P de mensagens para agentes de IA. Zero infraestrutura.
5
5
  Author: Elo Contributors
6
6
  License: MIT
@@ -26,4 +26,4 @@ __all__ = [
26
26
  "Node", "Task", "Result", "Event", "NodeInfo", "Capabilities",
27
27
  "EphemeralIdentity", "generate_and_save_identity", "load_identity",
28
28
  ]
29
- __version__ = "0.4.7"
29
+ __version__ = "0.4.8"
@@ -78,7 +78,7 @@ class Node:
78
78
  peers: list[str] | None = None,
79
79
  tracker: str = "public",
80
80
  allowlist: list[str] | None = None,
81
- version: str = "0.4.7",
81
+ version: str = "0.4.8",
82
82
  identity: EphemeralIdentity | None = None,
83
83
  verify_peers: bool = True,
84
84
  heartbeat_interval_s: int = 30,
@@ -247,17 +247,17 @@ class Node:
247
247
  if addr.startswith(target_node[:12] + "@"):
248
248
  peer = addr
249
249
  break
250
- if not peer:
250
+ if not peer:
251
+ # Bug fix: target_node especificado mas offline —
252
+ # NÃO fazer find_peer_for(capability) que acharia o tracker.
253
+ # Vai direto pra relay-via-tracker.
254
+ return await self.send_task_via_tracker(
255
+ "", target_node, capability, payload, ttl_s=ttl_s
256
+ )
257
+ else:
251
258
  peer = self._routing.find_peer_for(capability)
252
-
253
- # Se não encontrou, faz QUERY broadcast
254
- if not peer:
255
- peer = await self._query_capability(capability, ttl=5, timeout=5)
256
- if peer:
257
- hello = hello_msg(self._node_id, self._tracker.get_public_caps(),
258
- list(self._routing.local_interests),
259
- self._tracker.visibility, self._version)
260
- peer = await self._tcp.connect_to_peer(peer, hello_payload=hello)
259
+ if not peer:
260
+ peer = await self._query_capability(capability, ttl=5, timeout=5)
261
261
 
262
262
  if peer:
263
263
  try:
@@ -266,10 +266,6 @@ class Node:
266
266
  except Exception as e:
267
267
  return Result.make_error(task_id, "SEND_ERROR", str(e))
268
268
 
269
- # Bug 2: Fallback via tracker antes de desistir
270
- if not peer:
271
- return await self.send_task_via_tracker("", target_node, capability, payload, ttl_s=ttl_s)
272
-
273
269
  return Result.make_error(task_id, "NO_PEER", f"No peer for: {capability}")
274
270
 
275
271
  async def send_task_async(self, target_node: str, capability: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: elo-node
3
- Version: 0.4.7
3
+ Version: 0.4.8
4
4
  Summary: Elo — malha P2P de mensagens para agentes de IA. Zero infraestrutura.
5
5
  Author: Elo Contributors
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "elo-node"
7
- version = "0.4.7"
7
+ version = "0.4.8"
8
8
  description = "Elo — malha P2P de mensagens para agentes de IA. Zero infraestrutura."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -136,7 +136,7 @@ class TestNodeConstruction:
136
136
  node = Node("test-node")
137
137
  assert node._name == "test-node"
138
138
  assert node._port == 7878
139
- assert node._version == "0.4.7"
139
+ assert node._version == "0.4.8"
140
140
  assert node.connected is False
141
141
  assert node.node_id is not None
142
142
  assert len(node.node_id) > 20
@@ -148,6 +148,19 @@ class TestNodeConstruction:
148
148
  assert node._port == 9000
149
149
  assert node.tracker_visibility == "private"
150
150
 
151
+ @pytest.mark.asyncio
152
+ async def test_send_task_to_offline_target_returns_error(self):
153
+ """send_task with offline target_node must return error, not route to tracker."""
154
+ node = Node("test-a", port=0)
155
+ await node.connect()
156
+ await node.register(agents=["echo"])
157
+
158
+ # Target node_id that won't match any connected peer address
159
+ result = await node.send_task("nonexistent-node-id-42", "echo", {"msg": "hello"})
160
+
161
+ assert result.status == "error"
162
+ await node.disconnect()
163
+
151
164
 
152
165
  # ── TestNodeLifecycle ──────────────────────────────────────
153
166
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes