feat(relay): emit NOTICE when mentioned pubkey has no active connection (#1743)#1862
feat(relay): emit NOTICE when mentioned pubkey has no active connection (#1743)#1862cameronhotchkies wants to merge 1 commit into
Conversation
…on (block#1743) When a kind:9 channel message with p-tags is ingested, the relay now checks whether each mentioned pubkey has an active WebSocket connection in the community. If not, a NOTICE is sent back to the sender indicating the target appears offline. This is pod-local only (no Redis round-trip) — a mentioned user connected to a different pod will still trigger the notice. Acceptable for v1; a future enhancement can consult Redis presence. Implementation: - Extract p-tag pubkeys before ingest (deduped, sender excluded) - After successful ingest, check conn_manager for each pubkey - Send NIP-01 NOTICE for each offline mention - Metric: buzz_mention_offline_notices_total Co-authored-by: Cameron Hotchkies <chotchkies@block.xyz> Signed-off-by: Cameron Hotchkies <chotchkies@block.xyz> Co-authored-by: Goose <opensource@block.xyz> Ai-assisted: true
There was a problem hiding this comment.
From my agent...
The underlying silent-stall problem is real, but this implementation does not yet provide a reliable sender warning.
Blocking issues:
-
Every
ptag is treated as an explicit mention. Buzz replies structurally include the replied-to author'sptag (desktop/src/features/messages/lib/threading.ts), so an ordinary reply to an offline author will produce a misleading “mentioned user” notice even when the message did not mention them. The wire format needs to distinguish explicit mentions from reply routing metadata (or this check needs to consume existing explicit-mention metadata). -
The desktop sender drops
NOTICEframes.RelayClientSession.handleWsMessagehandles onlyAUTH,EVENT,OK, andEOSE; ACP only writesNOTICEto its warning log. Thus normal desktop users get no visible feedback, and sending agents do not receive a machine-actionable failure signal. Please wire the result into the sender UX/agent send path so this actually fixes #1743. -
Presence is only pod-local and checks any authenticated connection, not a matching subscription/delivery. In a multi-pod deployment it can report an online recipient as offline; conversely, an unrelated authenticated socket can suppress the warning even when no harness subscription received the message. Please use authoritative cross-pod presence with semantics tied to the intended recipient/delivery guarantee, or explicitly narrow and prove the behavior.
Please also add focused relay/client tests covering accepted-only behavior, kind restriction, dedupe/self-exclusion, explicit mention vs reply-author p tags, online/offline cases, and visible handling of the notice. The current change adds no tests for this critical path.
Summary
When a kind:9 channel message with
ptags is successfully ingested, the relay now checks whether each mentioned pubkey has an active WebSocket connection in the community. If not, a NIP-01 NOTICE is sent back to the sender indicating the target appears offline.This is Fix #1 from the #1743 scoping — giving senders immediate feedback that their mention may not be delivered in real-time.
How it works
p-tag pubkeys (deduped, sender excluded)conn_manager.connection_ids_for_pubkey_in_community()for each pubkeyConstraints & trade-offs
buzz_mention_offline_notices_totalcounter for observability.Testing
cargo check -p buzz-relay✅cargo clippy -p buzz-relay -- -D warnings✅ (zero warnings)Related