feat(relay): deliver pubkey mentions to relay companions - #7718
jsibbison-square wants to merge 3 commits into
Conversation
Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com> test(relay): cover operator listener API authorization Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com> test(relay): cover operator listener API persistence Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com> style(relay): place operator listener tests after implementation Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com>
🔐 Codex Security Review
|
Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com>
Signed-off-by: Jarrod Sibbison <jsibbison@squareup.com>
baxen
left a comment
There was a problem hiding this comment.
Approving the overall approach, but please address these three points before merging:
-
Add replay protection to the listener registration/removal API.
authorize_operator_listener_requestverifies the NIP-98 signature and request binding but dropsevent_id_bytesand never calls the replay guard, unlike the adjacentauthorize_operator_request. A previously signed POST replayed after a DELETE can restore a registration while the auth timestamp is still accepted (the verifier allows ±60 seconds); an old DELETE can likewise undo a new registration. Please use the shared operator replay guard and add a register → remove → replay regression test, including cross-worker coverage. -
Index the match queue's
claim_idlookup.match_claimed_jobsselects/deletes byclaim_id, andretry_match_jobsupdates by it, but the migration has no index supporting a selective claim-token lookup. Please add an appropriate index and check the plans against a substantial backlog withEXPLAIN (ANALYZE, BUFFERS). The missing index is visible in the code; the performance impact has not been benchmarked in this review. -
Make unregister behavior explicit and prevent unwanted queued deliveries.
remove_pubkeysdeletes only the registration; existing outbox entries remain eligible for delivery/retry because neither claiming nor sending rechecks the registration. This permits notifications after a successful unregister even when no HTTP request was in flight. Please suppress pending/retrying deliveries after removal and cover the matcher/removal race, or explicitly agree and document a drain-existing-deliveries contract before merging.
@Tornquist could you review the use of the database trigger on event_mentions, particularly its write-path overhead and the choice to enqueue all supported mention-bearing events once any listener registration exists?
Review scope: static code review at e8b6fde9ba000f392a325a707588aea9e2cde1ea; no tests or load benchmarks run as part of this review.
Summary
Enable a relay companion service to receive pubkey mention notifications regardless of communities. Enabling them to be notified so that they can do agent-specific authenticated work after. The notifications do not include event content (only id, kind, pubkey, community), the event must be looked up/or websocket started in order to retrieve the event and work with it.
BUZZ_OPERATOR_LISTENERSenv config, a semicolon-separated list ofpubkey:delivery_urlpairs for one or more operator listeners. Each listener is a Nostr identity owned by the companion service and needs its full keypair for NIP-98 authentication.operator_listener_pubkeys,operator_listener_match_queue, andoperator_listener_outboxtables.Related issue
N/A. No duplicate open issue or PR found.
Testing
cargo fmt --all -- --check