diff options
Diffstat (limited to '32.md')
| -rw-r--r-- | 32.md | 163 |
1 files changed, 163 insertions, 0 deletions
| @@ -0,0 +1,163 @@ | |||
| 1 | NIP-32 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Labeling | ||
| 5 | --------- | ||
| 6 | |||
| 7 | `draft` `optional` | ||
| 8 | |||
| 9 | A label is a `kind 1985` event that is used to label other entities. This supports a number of use cases, | ||
| 10 | including distributed moderation, collection management, license assignment, and content classification. | ||
| 11 | |||
| 12 | This NIP introduces two new tags: | ||
| 13 | |||
| 14 | - `L` denotes a label namespace | ||
| 15 | - `l` denotes a label | ||
| 16 | |||
| 17 | Label Namespace Tag | ||
| 18 | ---- | ||
| 19 | |||
| 20 | An `L` tag can be any string, but publishers SHOULD ensure they are unambiguous by using a well-defined namespace | ||
| 21 | (such as an ISO standard) or reverse domain name notation. | ||
| 22 | |||
| 23 | `L` tags are RECOMMENDED in order to support searching by namespace rather than by a specific tag. The special `ugc` | ||
| 24 | ("user generated content") namespace MAY be used when the label content is provided by an end user. | ||
| 25 | |||
| 26 | `L` tags starting with `#` indicate that the label target should be associated with the label's value. | ||
| 27 | This is a way of attaching standard nostr tags to events, pubkeys, relays, urls, etc. | ||
| 28 | |||
| 29 | Label Tag | ||
| 30 | ---- | ||
| 31 | |||
| 32 | An `l` tag's value can be any string. If using an `L` tag, `l` tags MUST include a mark matching an `L` | ||
| 33 | tag value in the same event. If no `L` tag is included, a mark SHOULD still be included. If none is | ||
| 34 | included, `ugc` is implied. | ||
| 35 | |||
| 36 | Label Target | ||
| 37 | ---- | ||
| 38 | |||
| 39 | The label event MUST include one or more tags representing the object or objects being | ||
| 40 | labeled: `e`, `p`, `a`, `r`, or `t` tags. This allows for labeling of events, people, relays, | ||
| 41 | or topics respectively. As with NIP-01, a relay hint SHOULD be included when using `e` and | ||
| 42 | `p` tags. | ||
| 43 | |||
| 44 | Content | ||
| 45 | ------- | ||
| 46 | |||
| 47 | Labels should be short, meaningful strings. Longer discussions, such as for an | ||
| 48 | explanation of why something was labeled the way it was, should go in the event's `content` field. | ||
| 49 | |||
| 50 | Self-Reporting | ||
| 51 | ------- | ||
| 52 | |||
| 53 | `l` and `L` tags MAY be added to other event kinds to support self-reporting. For events | ||
| 54 | with a kind other than 1985, labels refer to the event itself. | ||
| 55 | |||
| 56 | Example events | ||
| 57 | -------------- | ||
| 58 | |||
| 59 | A suggestion that multiple pubkeys be associated with the `permies` topic. | ||
| 60 | |||
| 61 | ```json | ||
| 62 | { | ||
| 63 | "kind": 1985, | ||
| 64 | "tags": [ | ||
| 65 | ["L", "#t"], | ||
| 66 | ["l", "permies", "#t"], | ||
| 67 | ["p", <pubkey1>, <relay_url>], | ||
| 68 | ["p", <pubkey2>, <relay_url>] | ||
| 69 | ], | ||
| 70 | ... | ||
| 71 | } | ||
| 72 | ``` | ||
| 73 | |||
| 74 | A report flagging violence toward a human being as defined by ontology.example.com. | ||
| 75 | |||
| 76 | ```json | ||
| 77 | { | ||
| 78 | "kind": 1985, | ||
| 79 | "tags": [ | ||
| 80 | ["L", "com.example.ontology"], | ||
| 81 | ["l", "VI-hum", "com.example.ontology"], | ||
| 82 | ["p", <pubkey1>, <relay_url>], | ||
| 83 | ["p", <pubkey2>, <relay_url>] | ||
| 84 | ], | ||
| 85 | ... | ||
| 86 | } | ||
| 87 | ``` | ||
| 88 | |||
| 89 | A moderation suggestion for a chat event. | ||
| 90 | |||
| 91 | ```json | ||
| 92 | { | ||
| 93 | "kind": 1985, | ||
| 94 | "tags": [ | ||
| 95 | ["L", "nip28.moderation"], | ||
| 96 | ["l", "approve", "nip28.moderation"], | ||
| 97 | ["e", <kind40_event_id>, <relay_url>] | ||
| 98 | ], | ||
| 99 | ... | ||
| 100 | } | ||
| 101 | ``` | ||
| 102 | |||
| 103 | Assignment of a license to an event. | ||
| 104 | |||
| 105 | ```json | ||
| 106 | { | ||
| 107 | "kind": 1985, | ||
| 108 | "tags": [ | ||
| 109 | ["L", "license"], | ||
| 110 | ["l", "MIT", "license"], | ||
| 111 | ["e", <event_id>, <relay_url>] | ||
| 112 | ], | ||
| 113 | ... | ||
| 114 | } | ||
| 115 | ``` | ||
| 116 | |||
| 117 | Publishers can self-label by adding `l` tags to their own non-1985 events. In this case, the kind 1 event's author | ||
| 118 | is labeling their note as being related to Milan, Italy using ISO 3166-2. | ||
| 119 | |||
| 120 | ```json | ||
| 121 | { | ||
| 122 | "kind": 1, | ||
| 123 | "tags": [ | ||
| 124 | ["L", "ISO-3166-2"], | ||
| 125 | ["l", "IT-MI", "ISO-3166-2"] | ||
| 126 | ], | ||
| 127 | "content": "It's beautiful here in Milan!", | ||
| 128 | ... | ||
| 129 | } | ||
| 130 | ``` | ||
| 131 | |||
| 132 | Other Notes | ||
| 133 | ----------- | ||
| 134 | |||
| 135 | When using this NIP to bulk-label many targets at once, events may be deleted and a replacement | ||
| 136 | may be published. We have opted not to use parameterizable/replaceable events for this due to the | ||
| 137 | complexity in coming up with a standard `d` tag. In order to avoid ambiguity when querying, | ||
| 138 | publishers SHOULD limit labeling events to a single namespace. | ||
| 139 | |||
| 140 | Before creating a vocabulary, explore how your use case may have already been designed and | ||
| 141 | imitate that design if possible. Reverse domain name notation is encouraged to avoid | ||
| 142 | namespace clashes, but for the sake of interoperability all namespaces should be | ||
| 143 | considered open for public use, and not proprietary. In other words, if there is a | ||
| 144 | namespace that fits your use case, use it even if it points to someone else's domain name. | ||
| 145 | |||
| 146 | Vocabularies MAY choose to fully qualify all labels within a namespace (for example, | ||
| 147 | `["l", "com.example.vocabulary:my-label"]`. This may be preferred when defining more | ||
| 148 | formal vocabularies that should not be confused with another namespace when querying | ||
| 149 | without an `L` tag. For these vocabularies, all labels SHOULD include the namespace | ||
| 150 | (rather than mixing qualified and unqualified labels). | ||
| 151 | |||
| 152 | A good heuristic for whether a use case fits this NIP is whether labels would ever be unique. | ||
| 153 | For example, many events might be labeled with a particular place, topic, or pubkey, but labels | ||
| 154 | with specific values like "John Doe" or "3.18743" are not labels, they are values, and should | ||
| 155 | be handled in some other way. | ||
| 156 | |||
| 157 | |||
| 158 | Appendix: Known Ontologies | ||
| 159 | ------------------------- | ||
| 160 | |||
| 161 | Below is a non-exhaustive list of ontologies currently in widespread use. | ||
| 162 | |||
| 163 | - [social.ontolo.categories](https://ontolo.social/) | ||