feat(relay): accept NIP-32 labels (kind:1985) - #5127
Open
magks wants to merge 1 commit into
Open
Conversation
`required_scope_for_kind` returns Err for unknown kinds and the relay rejects
them, so kind:1985 is refused at ingest today. This adds it as an ordinary
member write and advertises NIP-32.
A label is deliberately NOT routed like kind:1984. A report is a private signal
to moderators and is suppressed from fanout; a label is a public claim, so it
takes the normal store-and-fanout path and the same membership gate as any
other message write.
Registered in ALL_KINDS, which is what makes `no_duplicate_kind_values` cover
1985 — without it a future kind could silently reuse the number.
Tests:
- kind.rs collision guard now covers 1985 (verified by adding a duplicate:
"duplicate kind value: 1985").
- required_scope_for_kind returns MessagesWrite for KIND_LABEL.
- kind:1985 collides with no existing special-routing branch.
- NIP-11 advertises 32.
- e2e (buzz-test-client): a label is accepted, then read back through the
same generic POST /query surface a third-party client uses, with its L/l
pair intact. Acceptance alone would also be satisfied by a relay that ACKs
and discards, so the read-back is the half that matters.
The e2e test was checked against stock buzz as a control: it fails there with
"restricted: unknown event kind", so it discriminates rather than passing
vacuously.
Docs: NOSTR.md "What Works" gains a kind:1985 row, including the `#h` scoping
note — a label published without one is accepted but never matches a
channel-scoped subscription, which presents as the relay silently dropping it.
Signed-off-by: magks <magks@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Registers kind:1985 (NIP-32 labels) as an ordinary member write, so Buzz accepts
labels and advertises
32in its NIP-11 document.required_scope_for_kindreturnsErrfor unregistered kinds and the relayrejects them, so a kind:1985 event is refused at ingest today.
A label is deliberately not routed the way kind:1984 is. A report is a private
signal to moderators and is suppressed from fanout; a label is a public claim, so
it takes the normal store-and-fanout path and the same membership gate as any
other message write.
#hscopes it to a channel, per the existing convention.The reason to want this in Buzz specifically: a relay may label a pubkey with its
own key, and paired with the NIP-11
selfidentity Buzz already publishes, thatmakes the label attributable to the relay that issued it rather than merely to
some keypair. A reader cannot establish that any other way.
No migration, no new HTTP surface, no side-effect handler.
Related issue
Discussion in #5126 — opened first, per CONTRIBUTING, since this adds a new
event kind. That issue carries the motivation; this PR is the implementation so the
proposal is reviewable rather than abstract. Happy to close this if the direction
isn't wanted — the issue is the part worth your time.
Searched open issues and PRs for NIP-32 / 1985 / labeling — none found.
Testing
just checkandjust test-unitpass. Unit coverage:no_duplicate_kind_valuesnow covers 1985 —KIND_LABELis registered inALL_KINDS. Verified the guard is real by adding a duplicate entry:duplicate kind value: 1985.required_scope_for_kind(KIND_LABEL)→Scope::MessagesWrite.handle_event(reports, gift wraps, etc.), so a label cannot be silently diverted off the
ordinary path.
32.End-to-end (
crates/buzz-test-client/tests/e2e_nostr_interop.rs):test_nip32_label_is_accepted_and_readablepublishes a label over theWebSocket, then reads it back through the same generic
POST /querysurface athird-party client would use, asserting the
L/l/ptags survive.Acceptance alone would also be satisfied by a relay that ACKs and discards, so
the read-back is the half that matters.
The e2e test was checked against stock Buzz as a control — it fails there with
restricted: unknown event kind. It discriminates rather than passing vacuously.Run it with:
Docs
NOSTR.md "What Works" gains a kind:1985 row, including the
#hscoping note — alabel published without one is accepted but never matches a channel-scoped
subscription, which presents as the relay silently dropping it.
Not in this PR
the relay half only.
ordinary filters, deliberately.