The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(kanban): a profile_routes-pinned profile without this platform's adapter delivers via the primary bot
teknium1bdd7192bcf2c
diff --git a/gateway/kanban_watchers_notifier.py b/gateway/kanban_watchers_notifier.pyindex b65d7ccbb38..3c66d90b0df 100644--- a/gateway/kanban_watchers_notifier.py+++ b/gateway/kanban_watchers_notifier.py@@ -160,16 +160,12 @@ def _adapter_for_subscription(runner: Any, platform: Any, sub: dict, owner_profiprofile = owner_profile or getattr(runner, "_kanban_notifier_profile", None)primary_profile = getattr(runner, "_primary_profile_name", None) or runner._active_profile_name()profile = profile or primary_profile- # Empty maps are startup placeholders for route-only profiles; a connected- # secondary on ANY platform establishes an independent credential boundary.- if (getattr(runner, "_profile_adapters", {}) or {}).get(profile):- _warn_unroutable_sub_once(- sub, platform,- "kanban notifier: subscription for %s on %s chat %s is pinned to profile %s, which runs "- "other-platform adapters but none for %s; it will not be delivered. Give that profile a %s "- "adapter or make it route-only, then re-subscribe with `hermes kanban notify-subscribe ... "- "--notifier-profile <a profile that holds a %s credential>`.",- profile, platform.value, platform.value, platform.value)+ # A profile holding its OWN adapter for this platform is an independent credential boundary —+ # ``_authorization_adapter`` already answered for it, so the primary never stands in. Adapters+ # on OTHER platforms do not gate this one: the primary bot is the only credential serving the+ # pinned chat, for inbound turns and for these notifications alike (#115460).+ own_adapters = (getattr(runner, "_profile_adapters", {}) or {}).get(profile) or {}+ if getattr(platform, "value", str(platform)).lower() in _platform_names(own_adapters):return Nonemetadata = sub.get("delivery_metadata") or {}guild = metadata.get("scope_id") or metadata.get("guild_id")diff --git a/tests/gateway/test_kanban_notifier_served_apiserver_wake.py b/tests/gateway/test_kanban_notifier_served_apiserver_wake.pyindex 914f5344b5b..ebd21d22019 100644--- a/tests/gateway/test_kanban_notifier_served_apiserver_wake.py+++ b/tests/gateway/test_kanban_notifier_served_apiserver_wake.py@@ -201,7 +201,11 @@ def test_served_profile_wake_runs_in_process_only_for_the_session_it_owns(servedassert resolve(_api_sub(chat_id="20260918_051500_deadbe")) is None # unknown sessionassert resolve(_api_sub(), profile="atlas") is None # not the ownerassert resolve(_api_sub(), profile="ghost") is None # unserved profile- assert resolve(_api_sub(), builder_adapters={Platform.DISCORD: object()}) is None # own boundary+ # An adapter on ANOTHER platform is not a boundary for this one (#115460); an own api_server+ # adapter is — the primary never stands in for a credential the profile holds itself.+ assert resolve(_api_sub(), builder_adapters={Platform.DISCORD: object()}) is not None+ own_api = object()+ assert resolve(_api_sub(), builder_adapters={Platform.API_SERVER: own_api}) is own_api_own_session(served.atlas, "stamped-elsewhere", "builder") # foreign storeassert resolve(_api_sub(chat_id="stamped-elsewhere")) is None# A row in the served store stamped for another profile is not ownership either.diff --git a/tests/gateway/test_kanban_routed_transport.py b/tests/gateway/test_kanban_routed_transport.pyindex 9f04a059082..ab13364b142 100644--- a/tests/gateway/test_kanban_routed_transport.py+++ b/tests/gateway/test_kanban_routed_transport.py@@ -135,9 +135,6 @@ def test_route_denials_leave_events_retryable_at_claim_and_send(tmp_path, monkeyassert all(unseen(task) for task in tasks)good = completion()- runner._profile_adapters["yuki"] = {Platform.TELEGRAM: RecordingAdapter()}- assert not collect(runner)- runner._profile_adapters["yuki"] = {}# A tombstoned (deleted) owner profile is no longer served by the multiplexer.from hermes_constants import clear_named_profile_deleted, mark_named_profile_deletedyuki_home = tmp_path / ".hermes" / "profiles" / "yuki"@@ -236,33 +233,30 @@ def test_anchorless_thread_subscription_warns_once_instead_of_silent_skip(tmp_paassert unseen(task)-def test_credential_gate_denials_warn_once_instead_of_silent_rewind(tmp_path, monkeypatch, caplog):- """A pinned profile that runs other-platform adapters but none for the subscription's- platform, and a sub stamped with a profile other than the route's, are permanent dead-ends:- the notifier rewinds the claim every tick at DEBUG only. Both skips must surface ONCE per- row at WARNING with the re-subscribe escape hatch (#115460)."""+def test_pinned_profile_without_this_platform_delivers_via_primary(tmp_path, monkeypatch, caplog):+ """A profile_routes-pinned profile that runs OTHER-platform adapters but none for the+ subscription's platform is not a dead-end: the primary bot — the only credential serving that+ chat, for inbound turns too — delivers, exactly as for a route-only profile (#115460, option 1).+ A sub stamped with a profile other than the route's still warns ONCE instead of rewinding silently."""import loggingfrom gateway import kanban_watchers_notifier as notifierrunner = setup_runner(tmp_path, monkeypatch)+ primary = runner.adapters[Platform.DISCORD]monkeypatch.setattr(notifier, "_UNROUTABLE_WARNED", set())- # The pinned profile holds a credential on another platform, so it is an independent- # credential boundary without a Discord adapter of its own.runner._profile_adapters["yuki"] = {Platform.TELEGRAM: RecordingAdapter()}task = completion()with caplog.at_level(logging.WARNING, logger=notifier.logger.name):- assert not collect(runner)- assert not collect(runner)- warnings = [r for r in caplog.records if "none for discord" in r.getMessage() and task in r.getMessage()]- assert len(warnings) == 1 and warnings[0].levelno == logging.WARNING- assert "--notifier-profile" in warnings[0].getMessage()- assert unseen(task)+ rows = collect(runner)+ assert [row["task"].id for row in rows] == [task]+ asyncio.run(deliver(runner, rows))+ assert len(primary.sent) == len(primary.handled) == 1+ assert primary.handled[0].source.profile == "yuki"+ assert not unseen(task)+ assert not [r for r in caplog.records if r.levelno >= logging.WARNING]# An owner stamped with the invoking shell's profile (#76483) instead of the route's- # is the same silent dead-end. (Fresh DB: resetting the credential boundary above- # re-enables the first sub, which is the documented workaround, and its backlog must- # not pollute this claim.)- runner._profile_adapters["yuki"] = {}+ # is a permanent dead-end and must surface once at WARNING.monkeypatch.setenv("HERMES_KANBAN_DB", str(tmp_path / "stamped-owner.db"))stamped = completion(profile="default")with caplog.at_level(logging.WARNING, logger=notifier.logger.name):diff --git a/website/docs/user-guide/features/kanban.md b/website/docs/user-guide/features/kanban.mdindex aa004045cd9..d8311c9217a 100644--- a/website/docs/user-guide/features/kanban.md+++ b/website/docs/user-guide/features/kanban.md@@ -1296,11 +1296,14 @@ dispatch and delivery have separate owners:`writer` profile's Telegram gets its `completed`/`blocked` message deliveredby the `writer` gateway, even though the `default` gateway did thedispatching.-- **Route-only multiplex profiles** can use the primary adapter when the- subscription's persisted platform, chat, thread, scope and parent-channel- anchors resolve to that exact served profile through `gateway.profile_routes`.- A connected secondary adapter remains authoritative; a partial secondary- adapter registry never falls back to the primary bot. Unmatched, reassigned,+- **Multiplex profiles pinned by `gateway.profile_routes`** can use the primary+ adapter when the subscription's persisted platform, chat, thread, scope and+ parent-channel anchors resolve to that exact served profile through+ `gateway.profile_routes` and the profile holds no adapter of its own for the+ subscription's platform. A connected secondary adapter for that platform+ remains authoritative; adapters the profile runs on *other* platforms do not+ block delivery (the shared bot is the only credential serving the pinned+ chat, for inbound turns and notifications alike). Unmatched, reassigned,disabled or ambiguous routes remain undelivered and retryable. Old rowsmissing required routing anchors are not guessed into a profile. Wake turns keepthe destination profile's runtime scope and the authorized transport.