test(honcho): cover bot:<connection>/<profile> authors end to end

Two senders named coder on different connections get different peers and different a2a sessions, and a userPeerAliases entry keyed by the full connection-qualified id wins.
This commit is contained in:
Erosika
2026-09-08 16:29:23 -04:00
committed by Teknium
parent d96a6d9ab9
commit a2c65ace0a
2 changed files with 20 additions and 0 deletions
+11
View File
@@ -13,6 +13,7 @@ from unittest.mock import MagicMock
from plugins.memory.honcho import HonchoMemoryProvider
from plugins.memory.honcho.client import HonchoClientConfig
from plugins.memory.honcho.session import HonchoSessionManager
from tools.bot_relay import delivery_turn_author
BOT_AUTHOR = {"id": "bot:coder", "name": "coder", "is_bot": True}
HUMAN_AUTHOR = {"id": "111222", "name": "Alice", "is_bot": False}
@@ -129,6 +130,16 @@ class TestA2aRouting:
assert ivy._a2a_session_key(BOT_AUTHOR) != holly._a2a_session_key(BOT_AUTHOR)
assert ivy._a2a_session_key(BOT_AUTHOR).startswith("Bot-Chat:a2a:ivy:bot-coder-")
def test_same_named_senders_on_two_connections_get_two_sessions(self):
"""A relayed envelope's author carries the sender's connection, and the a2a key keeps it."""
provider = _provider()
east = delivery_turn_author("coder", "coder", "east")
west = delivery_turn_author("coder", "coder", "west")
assert east["id"] == "bot:east/coder"
assert provider._a2a_session_key(east) != provider._a2a_session_key(west)
assert provider._a2a_session_key(east).startswith("Bot-Chat:a2a:hermes-assistant:bot-east-coder-")
def test_long_session_key_stays_within_the_honcho_limit(self):
provider = _provider()
provider._session_key = "x" * 95
@@ -117,6 +117,15 @@ class TestResolveAuthorPeerId:
peer = mgr.resolve_author_peer_id("telegram:dm1", "bot:coder")
assert peer != "coder" and peer.startswith("coder-")
def test_connection_qualified_bot_author_keeps_its_connection(self):
"""The Desktop relays ``bot:<connection>/<profile>``; two connections' ``coder`` are two agents."""
mgr = _manager(_config(user_peer_aliases={"bot:local/coder": "coder-here"}), runtime_id="7654321")
east = mgr.resolve_author_peer_id("Bot-Chat", "bot:east/coder", is_bot=True)
west = mgr.resolve_author_peer_id("Bot-Chat", "bot:west/coder", is_bot=True)
assert east != west
assert east.startswith("east-coder-") and west.startswith("west-coder-")
assert mgr.resolve_author_peer_id("Bot-Chat", "bot:local/coder", is_bot=True) == "coder-here"
def test_bot_author_without_a_profile_keeps_the_raw_id(self):
mgr = _manager(_config(), runtime_id="7654321")
peer = mgr.resolve_author_peer_id("telegram:dm1", "bot:")