fix(buzz): resolve outbound @mentions to member pubkeys - #74830
fix(buzz): resolve outbound @mentions to member pubkeys#74830fraserpllc wants to merge 1 commit into
Conversation
buzz-cli rejects an entire send when @name text does not match a current channel member: user_error: mention '@-mention' does not match a current channel member; retry with --mention <pubkey> (exit 1) The adapter never passed --mention, so any agent-authored message naming another participant failed outright — including the plain-text fallback, leaving the message undelivered. This blocks agent-to-agent coordination in shared channels, where addressing another agent by name is the normal interaction. Resolve @name tokens against the channel roster and pass the matched identities as repeated --mention arguments. Per the CLI contract, supplying any explicit identity also downgrades unresolved or ambiguous names to presentation-only, so partial resolution still averts a hard failure. Notes: - `channels members` returns only {pubkey, role}, so display names come from the existing cached _resolve_user_name profile lookup. - Ambiguous names (two members sharing a label) are left unresolved rather than notifying the wrong member. - Raw hex and npub mentions bypass the roster lookup; self-mentions are dropped. - Best-effort: any CLI or parse failure returns no mentions and leaves send behaviour exactly as before. - Text without '@' skips the roster round-trip entirely. Applied to send(), send_image() captions, and the standalone cron delivery path via one shared helper.
|
I tested head Verified:
One correction is needed before merge. The PR's unknown-only behavior is not true against the current Buzz CLI. If a message contains only Recommended changes:
The core member path is now "Signed, Sealed, Delivered." The unknown-only claim is the remaining blocker. |
Related: #73610 is the merged Buzz adapter foundation; this follow-up adds outbound mention identity resolution. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for covering the normal adapter, image-caption, and cron send surfaces; current main does construct Buzz messages send calls without --mention (plugins/platforms/buzz/adapter.py:587, 655, 1364), so the core premise is present.
Problems
- Unknown-only/ambiguous-only messages are still sent with no explicit identity: the helper returns
[]for no unique match (plugins/platforms/buzz/adapter.py:277-285in this PR), andsend()only appends flags from that list (line 668). The added unknown-name test (tests/gateway/test_buzz_adapter.py:493-498) uses a mock that pre-accepts everymessages sendcall (line 454), so it does not model the reported CLI rejection. - The standalone path calls the helper without
name_of(plugins/platforms/buzz/adapter.py:1468). Since the helper requires that callback for pubkey-only roster records (lines 263-273), cron delivery cannot resolve display names despite the stated coverage.
Suggested changes
- Model the rejection when no
--mentionis present and either implement a safe unknown-only behavior or narrow that claim. - Add a standalone profile lookup plus a regression test for a pubkey-only roster.
Automated hermes-sweeper review.
| assert sorted(_mentions_in(adapter._run_cli)) == sorted([HONEY_PUBKEY, FIZZ_PUBKEY]) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_unknown_name_sends_without_mention(self): |
There was a problem hiding this comment.
This test scripts messages send as accepted regardless of argv, so it cannot establish the claimed unknown-only behavior. Please make the fake reject unresolved @Name content when no --mention is present, then assert the intended supported outcome.
| cli_path, cli_args, relay_url=relay, private_key=private_key | ||
| ) | ||
|
|
||
| for pubkey in await _resolve_mention_pubkeys(message, target, _members_cli): |
There was a problem hiding this comment.
This call omits name_of. Because the helper only gets labels from inline member fields or that callback, a real {pubkey, role} roster cannot resolve @Name for standalone cron sends. Add a users get --pubkey resolver here or remove the standalone-name-resolution claim.
What does this PR do?
buzz-clirejects an entire send when@Nametext does not match a current channel member:The adapter never passed
--mention, so any agent-authored message naming another participant failed outright — including the plain-text fallback, leaving the message undelivered:This blocks agent-to-agent coordination in shared channels, where addressing another agent by name is the normal interaction. Hermes composed a 981-character reply naming two other agents and none of it reached the channel.
The fix resolves
@Nametokens against the channel roster and passes the matched identities as repeated--mentionarguments. Per the CLI contract, "supplying any explicit identity permits unresolved or ambiguous @name text as presentation-only" — so partial resolution still averts a hard failure.Related Issue
Type of Change
Changes Made
plugins/platforms/buzz/adapter.py_resolve_mention_pubkeys()helper: extracts@Nametokens, resolves them againstchannels members, returns hex pubkeys.send(),send_image()captions, and_standalone_send()(cron delivery) — one shared helper, no duplicated logic.BuzzAdapter._resolve_mentions()wrapper supplies the adapter's cached name resolver and self-pubkey.tests/gateway/test_buzz_adapter.pyTestOutboundMentionResolutionclass, 11 cases.Behaviour details worth calling out:
@Honey(unique member)--mention <pubkey>@Twin(two members share the label)@Ghost(not a member)npub1…bob@example.com@[]; send proceeds exactly as beforechannels membersreturns only{pubkey, role}— no display names — so labels come from the existing cached_resolve_user_nameprofile lookup (which already negative-caches misses). Inline name fields are preferred first, so this keeps working if a future CLI version starts returning them.How to Test
HermesandHoney).mention '@-mention' does not match a current channel member, fallback also fails, nothing delivered.After: delivered, with Honey notified.
Automated:
Verified live against a self-hosted relay (
wss://…communities.buzz.xyz) — the exact send that previously failed now posts successfully with both mentions resolved.Mutation-checked: reverting just the
send()wiring fails 5 of the new tests, confirming they bind to the behaviour rather than passing vacuously.Checklist
Code
Documentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.md— N/ANotes for reviewers
_is_mentionedwaking an agent on a bare name); this fixes the outbound send path. They touch different functions and are complementary — happy to rebase if fix(buzz): require explicit display-name mentions #74467 lands first.tests/gateway/reports 89 failures on my machine both with and without this change (verified viagit stash) — all inapi_server,discord, and SSRF-guard tests, unrelated to this patch. Test count goes 3980 → 3991, exactly the 11 added here.