71f3516df2
Iterating a honcho SyncPage walks every following page, so _api_workspace_peers pulled the whole workspace on its first call, never hit the `< 50` break, re-walked pages 2..N and returned duplicates; the 200-peer cap that exists so a public bot's workspace cannot stall the CLI was defeated and the `p<N>` picks pointed at the wrong peers. It now reads `.items` per page and stops at the cap; `_api_workspaces` reads `.items` too. The wizard's `new_host` probe looked only at the host block, so an install that keeps peerName/enabled/workspace at the root with no hosts.hermes block read as fresh and Enter defaulted to pinning every account onto one peer. The probe includes the root. `_seen_gateway_accounts` dropped rows whose origin said `is_bot`, but SessionSource.to_dict never serializes that field, so the filter was dead; removed with its test row. `_sanitize_peer_id` was a copy of session_peers.sanitize_peer_id. A confirmed workspace repoint is persisted, so the exit line no longer says "Nothing changed" after one.
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
"""``HonchoMemoryProvider.identity_signature()``: the identity-mapping values the gateway folds
|
|
into its agent-cache key, read from honcho.json without touching the network."""
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from plugins.memory.honcho import HonchoMemoryProvider
|
|
|
|
|
|
@pytest.fixture
|
|
def honcho_json(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
|
path = tmp_path / "honcho.json"
|
|
|
|
def _write(**values):
|
|
path.write_text(json.dumps({"apiKey": "k", **values}))
|
|
return path
|
|
|
|
return _write
|
|
|
|
|
|
def test_signature_uses_neutral_keys(honcho_json):
|
|
honcho_json(workspace="team", peerName="eri", aiPeer="hermes", pinUserPeer=True, runtimePeerPrefix="tg_",
|
|
userPeerAliases={"222": "bob", "111": "alice"}, sessionPeerPrefix=True, a2aSessions=False)
|
|
|
|
sig = HonchoMemoryProvider().identity_signature()
|
|
|
|
assert sig == {
|
|
"workspace": "team",
|
|
"user_identity": "eri",
|
|
"agent_identity": "hermes",
|
|
"pin_user_identity": True,
|
|
"runtime_identity_prefix": "tg_",
|
|
"user_identity_aliases": [("111", "alice"), ("222", "bob")],
|
|
"session_prefixing": [True, False],
|
|
"a2a_sessions": False,
|
|
}
|
|
assert not any(k.startswith("honcho") for k in sig)
|
|
|
|
|
|
def test_signature_tracks_edits_to_the_file(honcho_json):
|
|
provider = HonchoMemoryProvider()
|
|
honcho_json(peerName="eri", pinUserPeer=True)
|
|
assert provider.identity_signature()["pin_user_identity"] is True
|
|
|
|
honcho_json(peerName="eri", pinUserPeer=False)
|
|
assert provider.identity_signature()["pin_user_identity"] is False
|
|
|
|
|
|
def test_signature_never_touches_the_network(honcho_json, network_attempts):
|
|
honcho_json(peerName="eri")
|
|
HonchoMemoryProvider().identity_signature()
|
|
assert network_attempts == []
|