TRUSTed Events
TRUSTed Info, Rankings, & Assertions
nip-trusted-events
draft
kind 37571 "TRUSTed Info"
kind 37572 "TRUSTed Rankings"
kind 37573 "TRUSTed Assertions"
extends nip-trusted-filters
extends nip-trusted-filter-presets
This NIP specifies three event kinds and for generating Assertions, Rankings, and Stats from TRUSTed Filters, and a general purpose ranking plugin
- The TRUSTed Info Event (kind
37571) renders general interpreted data (not limited to asubjector apov) about the network or a set of events. Used for publishing aggregated metrics, counts, and computed values. - The TRUSTed Rankings Event (kind
37572) renders interpretedrankingvalues related to ONE or MOREsubjectsfrom ONEpovand ONEcontext. Used for publishing WoT style rankings for anytypeofsubject. - The TRUSTed Assertions Event (kind
37573) renders any set of interpreted data about a SINGLEsubjectusing any number ofassertion presets. Used for making specific claims about a single subject.
Terminology:
subject- a value (from index 1) of any standard indexable tag (single letter key) about which assertions MAY be generated. (eg: a pubkey fromptags, an event id frometags, a hashtag string fromttags)type- Any single-letter tag key used typing subject data and for matching subject tags in events (e.g.,p,e,t)ranking(orrank) - A numeric value (0-100) representing a subject's influence within a context.context- A unique (per author) string identifying aranking preset(which generates TRUSTed Rankings events) OR a reference to ANY event containingptags (a list of possibly ranked users).pov- The "point of view" pubkey from which rankings MAY be calculated (usually subscriber pubkey) within a context.assertion preset- Any preset that writes interpreted data about a subject toIO.assertions(for rendering as a tag in assertion events).
TRUSTed Info Event (kind 37571)
This is the simplest of TRUSTed events. Because interpreted data is not related to a specific subject or context, generation of these events does not require any special plugins or W inputs.
Use Cases:
- Network-wide statistics (total events, user counts, etc.)
- Aggregated metrics (sums, averages, min/max values)
- Time-based analytics (events per day, growth rates)
- Any computed values that don't relate to a specific subject
Info Event Format
{
"kind": 37571,
"pubkey": "<subscription_pubkey>",
"tags": [
// Required: replaceable event identifier
["d", "<identifier>"],
// Reference one or more data presets
["W", "<naddr_to_data_preset>"],
// (or assertion presets that DON'T require `W` inputs)
["W", "<naddr_to_assertion_preset>"],
// tags SHOULD be rendered
// from aggregated IO `w` and `#` namespaces
["w", "<key>:<value>"],
]
}Info Preset Format:
{
"kind": 37570,
// preset content is always JSON stringified (and MAY be encrypted)
"content": [
// any number of filters MAY collect events from the network
{
"plugins": [
// any number of plugins MAY interpret data from events
["<any_plugin>",
// plugins SHOULD NOT require `W` inputs
// plugins SHOULD write data to `w` or `#` namespaces in `IO`
],
// IO should NOT be published to events
]
}
]
}TRUSTed Rankings Event (kind 37572)
TRUSTed Rankings events are used to rank multiple subjects from a single point of view within a specific context. These events are rendered by ONE ranking preset, which outputs ranked subject tags to the event. Each TRUSTed Ranking Preset interprets interactions and calculates rank values for subjects.
Rankings Event Format:
{
"kind": 37572,
"pubkey": "<subscription_pubkey>",
"tags": [
// Required: replaceable event identifier
["d", "<rankings_event_id>"],
// Reference one ranking preset
["W", "<naddr_to_ranking_preset>"],
// These (lowercase) `w` output tags
// SHOULD be provided by each ranking preset
// to help identify the events generated by it
["w", "ranking:<ranking_preset_id>"],
["w", "tagletter:<tag_letter>"],
// this (uppercase) `W` tag
// reflects the `pov` pubkey used by the ranking preset
["W", "pov:<pov_pubkey>"],
// Additional (uppercase) `W` tags
// may reflect provider specific inputs to calculate ranking
["W", "<provider_param>:<param_value>"],
// ALL ranking presets SHOULD output ranked subject tags
// in the format: ["<type>", "<subject>", "<rank>"]
["<type>", "<subject_1>", "<rank>"],
["<type>", "<subject_2>", "<rank>"],
]
}Ranking Preset Format:
{
"kind": 37570,
"pubkey": "<subscription_pubkey>",
"tags": [
// Required: replaceable event identifier
["d", "<ranking_preset_id>"],
],
"content": [
{
"plugins": [
// Ranking presets SHOULD
// set "default" values in these (lowercase) `w` output plugins
// to advertise specific info about the ranking preset (in generated events)
["w",
// `tagletter` is a single letter tag key used for the output subject tags
// (set default to the tag letter used by the ranking preset)
["tagletter", "", "p"],
// `ranking` SHOULD reflect the preset's `d` tag value
// (and make it available for string replacement in the filters)
["ranking", "", "<ranking_preset_id>"],
],
// Rankings presets SHOULD
// get input from requestors using these (uppercase) `W` plugins
["W",
// `pov` is a pubkey "point of view" for the generated rankings
// (usually a subscriber or subscription pubkey)
["pov", "pubkey"],
// ranking presets MAY have additional (calculator) `W` inputs
// required or optional as determined by the service provider
["<provider_param>", "<param_type>", "", "<param_default>"]
],
]
},
// any number of filters MAY be used to collect events from the network
// for interpreting interactions and calculating ranks
{
"plugins": [
// Rankings presets SHOULD output "ranked subject" tags to `IO.#`
// (in the format of: ["<tagletter>", "<subject>", "<rank>"]).
// Rankings presets MAY use the `ranked` plugin to request this list directly
// from the service provider and to output it to `#` namespace
["ranked", ["${W.pov}", "${w.ranking}", "${w.tagletter}", "#"]]
]
}
]
}TRUSTed Assertions Event (kind 37573)
TRUSTed Assertion events are used to assert specific claims about a single subject. These events are rendered by ONE OR MORE Assertion Presets, each charged with outputting ONE or more assertion tags to IO:#. Each TRUSTed Assertion Preset MAY make use of (a list of) TRUSTed Rankings in the process of filtering events for generating assertion values.
Assertions Event Format:
{
"kind": 37573,
"pubkey": "<subscription_pubkey>",
"tags": [
// Required: replaceable event identifier
["d", "<assertion_event_id>"],
// Reference one or more assertion presets
["W", "<naddr_to_assertion_preset>"],
["W", "<naddr_to_assertion_preset>"],
// the following `W` inputs
// are passed to every assertion preset
["W", "subject:<tag_value>"],
["W", "tagletter:<tag_letter>"],
["W", "ranking:<ranking_preset_id>"],
["W", "pov:<pov_pubkey>"],
// assertion presets SHOULD output these (lowercase) `w` tags
// advertising the `d` tag value of the preset
["w", "assertion:<assertion_preset_id_1>",],
["w", "assertion:<assertion_preset_id_2>",],
// ALL assertion presets SHOULD output `assertion` tags
// keyed by the `d` tag value of the assertion preset
["<assertion_preset_id_1>", "<value>"],
["<assertion_preset_id_2>", "<value>"],
]
}Assertions Preset Format:
{
"kind": 37570,
"pubkey": "<subscription_pubkey>",
"tags": [
// Required: replaceable event identifier
["d", "<assertion_preset_id>"],
],
"content": [
// Assertions presets SHOULD have the following
// (uppercase) `W` plugin inputs
{
"plugins": [
["W",
// `W.tagletter` is the expected tag letter
// (type) for subject (MAY default to `p`)
["tagletter", "tagletter", "", "p"],
// `W.subject` is a unique identifier for a subject (of `tagletter`)
// upon which assertions are made (like a pubkey or an event id)
["subject", "string"],
// `W.pov` is a pubkey "point of view" for the generated assertions
// (usually a subscriber or subscription pubkey)
["pov", "p", "", "<subscriber_pubkey>"],
// `W.ranking` SHOULD reference a known filter or preset
// from which a service can provide rankings (on any subject type)
// which MAY be used by assertions to limit the set of candidate events
["ranking", "identifier", "", ""]
],
// Assertion presets SHOULD use these (lowercase) `w` plugins
// `w.assertion` advertizes the preset's `d` tag value in generated events
// AND makes it available for string replacement in the presets filters
["w", "assertion", "", "<assertion_preset_id>"],
]
},
{
// any number of additional filters MAY collect events from the network
// and transform these into `IO` data for assertions output
"plugins": [
// Assertions presets MAY call `ranked` plugin
// to have user rankings available for assertion calculations
["ranked", ["${W.pov}", "${W.ranking}"]]
]
},
{
"plugins": [
// Assertions presets SHOULD render assertions ONLY to the `IO:#` namespace
// Keyed by the preset's `d` tag value in this format:
// `["<assertion_preset_id>", "<value>"]`
["#",
// This will render a basic assertions tag
// using the preset's `d` tag value from `IO:w.assertion`
["${w.assertion}", "<value>", "#"],
],
// Any (conventional) transformation plugins can also be used
// to output assertions directly to `IO:#` namespace
// (by using "#" for the `namespace` param)
["<any_transformation_plugin>",
["${w.assertion}", "<any_param>", ..., "#"],
],
// The above format (outputting ONLY to `IO:#` namespace)
// will result in assertions tags rendering properly
// when assertion event presets are executed 'indirectly'
// (by requesting the event kind and W tags in a TRUST message)
]
}
]
}ranked Plugin
ranked is a Transformation plugin. It requests ranked subjects from the service provider and stores them in IO at ranked (or any writable namespace). This MAY be used within any filter to request subject rankings directly from the provider based on a specific point of view and context.
Functions:
{
"plugins": [
["ranked", ["<pov>", "<ranking>", "<tagletter?>", "<namespace?>"]]
]
}Arguments:
<pov>:pubkey: (required) : Point of view pubkey from which rankings are calculated<ranking>:string: (required) : An identifier for the algorithm (presetdtag value) to use for ranking<tagletter>:tagletter: (optional) : Tag letter for subject type (defaults top)<namespace>:string: (optional) : Namespace inIOto store the ranked subject tags (defaults toranked)
IO:
- Outputs: an array of ranked subject tags in format
["<subject_type>", "<subject>", "<rank>"] - Writes to:
IOatranked, or any writable namespace as specified in the namespace argument. - Write Access: Any plugin may append ranked subjects tags to the
ranked:<plugin>namespace.
Behavior:
- Requests ranked subjects from service provider using
<pov>and<ranking>. - Stores ranked subjects in
IO, atrankedas an array of tag arrays. - Each ranked subject is stored as
["<tagletter>", "<subject>", "<rank>"]. - If
<tagletter>is omitted, the ranking preset should determine the tag letter to use. - Allows other plugins to append their own ranked subjects to
ranked:<plugin>namespace.