Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIP-19: add nreq #882

Closed
wants to merge 2 commits into from
Closed

NIP-19: add nreq #882

wants to merge 2 commits into from

Conversation

fiatjaf
Copy link
Member

@fiatjaf fiatjaf commented Nov 16, 2023

@staab
Copy link
Member

staab commented Nov 16, 2023

seems like a good idea to me

@Semisol

@staab
Copy link
Member

staab commented Nov 16, 2023

Ok, so one thing @Semisol pointed out is that you can't reference a list of authors (i.e. follow list or whatever) in this. In coracle I have a DynamicList type where authors can be an array of pubkeys, or follows | network, and then I compile that based on whatever the user's current network looks like. So it makes custom feeds static, which seems highly limiting.

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

So you want unix pipes?

@staab
Copy link
Member

staab commented Nov 16, 2023

yes

@staab
Copy link
Member

staab commented Nov 16, 2023

Can we make an entity that's turing complete?

@staab
Copy link
Member

staab commented Nov 16, 2023

nlua

Edit: sorry, I'll stop spamming everyone now

@fabianfabian
Copy link

I like the idea of nreq, but this one seems a bit limited? It could be powerful if it is just any filter+relays+title so you could share almost any kind of feed.

@v0l
Copy link
Member

v0l commented Nov 16, 2023

As you know this isnt how i implemented it, i feel like putting TLV entries for search/limit/until into NIP-19 just doesn't make any sense because they dont apply to the other prefixes.

I simply put the JSON req filter array into type 0, then i just pass this value directly to query system, its very simple and flexible.

Here is the example: https://main.snort-social.pages.dev/nreq1qp54k7ezdd5kuernyga9kv2a9s3xc6tdd96zyw33xqkzyct4w35x7unnyga9kg3nvfnrqcekxdnxxc3exv6rvve5xqmkze3exasn2ef4v4jnvdrxvyursvmyxycrwetx89jn2dfcxsmnyce5v43rjctpv9jkvcf5x5ukggja04wsz9rhwden5te0wfjkccte9ejxzmt4wvhxjmc09xpux

A link to fiatjafs 10 latest posts: [{"kinds":[1],"limit":10,"authors":["3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"]}]

@fabianfabian
Copy link

As you know this isnt how i implemented it, i feel like putting TLV entries for search/limit/until into NIP-19 just doesn't make any sense because they dont apply to the other prefixes.

I simply put the JSON req filter array into type 0, then i just pass this value directly to query system, its very simple and flexible.

Here is the example: https://main.snort-social.pages.dev/nreq1qp54k7ezdd5kuernyga9kv2a9s3xc6tdd96zyw33xqkzyct4w35x7unnyga9kg3nvfnrqcekxdnxxc3exv6rvve5xqmkze3exasn2ef4v4jnvdrxvyursvmyxycrwetx89jn2dfcxsmnyce5v43rjctpv9jkvcf5x5ukggja04wsz9rhwden5te0wfjkccte9ejxzmt4wvhxjmc09xpux

A link to fiatjafs 10 latest posts: [{"kinds":[1],"limit":10,"authors":["3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"]}]

This looks good, I think the addition of a title or description field would improve it because the request can be anything. Right now you said "A link to fiatjafs 10 latest posts" but it could have been just part of the nreq and a client would just render a link titled "fiatjafs 10 latest posts" and after clicking it it would open the feed.

@staab
Copy link
Member

staab commented Nov 16, 2023

I like title and filters as the keys. It should definitely support multiple filters.

@gzuuus
Copy link
Contributor

gzuuus commented Nov 16, 2023

This looks good, I think the addition of a title or description field would improve it because the request can be anything. Right now you said "A link to fiatjafs 10 latest posts" but it could have been just part of the nreq and a client would just render a link titled "fiatjafs 10 latest posts" and after clicking it it would open the feed.

I think that description within the entity may be superfluous since the filter is self-explanatory, if you want a description it could be formed by parsing the filter and verbosing.

@vitorpamplona
Copy link
Collaborator

I am not sure if this is feasible. Sure we can share filters (I like @v0l's idea of a single text field) but it's really hard for the Client to figure out how to display the results.

What if it is a filter for chat messages? You would have to somehow parse the filter, see that this is returning only chat messages, and direct the user to that View type. Obviously, most filters will return a set of different event kinds. What happens if the filter is just anything by users X, Y and Z at the same time? It's not a profile view. Reactions are mixed with DMs, which are mixed with ephemeral NWC events, etc.. What do you do when you open this in your client?

We don't have a super generic way to build a view for that.

@staab
Copy link
Member

staab commented Nov 16, 2023

We don't have a super generic way to build a view for that.

Coracle's feeds can mostly handle this (other than DMs which is a degenerate case). If a client dev doesn't want to build generic feeds, they can also open the link in a client which does support it (maybe njump could have an nreq page).

@vitorpamplona
Copy link
Collaborator

Coracle's feeds can mostly handle this (other than DMs which is a degenerate case).

Sure, feed-based clients can just dump the whole thing in front of the user without any additional context. I don't know how to display a Zap Request or an Event Deletion but if it is in the filter it should be displayed somehow.

This, of course, assumes this link is to be displayed. It could be used just to build a local storage of events.

Either way, the client parsing the request doesn't know if this is a display thing or a storage thing. Or maybe something to send to relays just to confuse their user tracking tools. I don't know... It feels too broad.

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

Is this a solution in search for a problem?

Maybe we should actually really come up with a nscript thing for querying.

@staab
Copy link
Member

staab commented Nov 16, 2023

Is this a solution in search for a problem?

Maybe

Maybe we should actually really come up with a nscript thing for querying.

lol

The use case I had imagined for this was custom feed lists, where each entry was a filter. But that could be done independent of nreq.

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

The nscript could be a WASM script like @jb55 was doing -- although I don't know how his thing works at all.

What I am thinking is that this would specify various steps in a query process and yield events in the process. Here's a stupid example that would use some constant values assumed to be defined and then perform a three step querying process to yield a custom feed of recent posts from people of whom I have bookmarked content but I don't follow.

val me;
val myOutboxRelays;
val myInboxRelays;
val myFollowList;

for tag in querySync({kinds: [10003], authors: [me]}, myOutboxRelays).tags:
  if (tag.0 == "e" or tag.0 == "a") and tag.2:
    val bookmark = querySync({ids: [tag.1]}, [tag.2])
    if bookmark.pubkey not in myFollowList:
      val events = querySync({kinds: [1], authors: [bookmark.pubkey]}, [tag.2])
      yield events

This is not a fleshed out idea in any sense, by the way, and may also be a solution in search for a problem just like nreq (in this case a much more complex solution).

Can you give a concrete example of how you would do custom feeds, @staab?

@vitorpamplona
Copy link
Collaborator

vitorpamplona commented Nov 16, 2023

Read-only query languages can be quite effective.

For instance, I have a use case for contextual Amber alerts based on Nostr data. It would be a simple new Event kind with the message and a boolean filter. The client runs the filter in the local DB and if it passes, it displays the message.

Then you could do alerts on things like:

Filter: User has pneumonia and is in New York
Message: "Today's wildfire-affected air-quality is likely to delay your recovery rate by days. Make sure to use a good air-filter and stay indoors to avoid any side effects. Click here if you have questions or need additional recommendations".

@jb55
Copy link
Contributor

jb55 commented Nov 16, 2023 via email

@staab
Copy link
Member

staab commented Nov 16, 2023

Can you give a concrete example of how you would do custom feeds, @staab?

Thinking through this more has been on my to-do list for a while. But off the top of my head, a custom feed would be an OR of multiple dynamic filters, where:

  • authors/#p is a list of pubkeys, a list id, or the keywords "follows", "network"
  • kinds is an optional list of kinds (but probably omitted and set to some reasonable default by the client)
  • relays is optional list of urls or a list id of relays that replace the client's default routing behavior
  • topics is an optional list of topics or a list id of topics
  • #l is an optional list of labels or a list id of labels. Clients should probably interpret this as the targets of the labels, not the labels themselves
  • search is an optional string
  • Zero or more dvm tags that define a job pipeline to run the filter or results through. Really, all the special logic above could probably be handled by a dvm instead of the client.

Here's what Coracle currently does:

Screenshot 2023-11-16 at 8 33 37 AM

@vitorpamplona
Copy link
Collaborator

vitorpamplona commented Nov 16, 2023

Neil has been pushing for Custom feeds as well:

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

It's looking like nreqs directly won't be as powerful as anyone really wants, and having ad-hoc special cases added on top of the nreq would break it formidably, such that the nscript approach is looking better.

In the simplest case the nscript could be just a request filter that is sent to a relay and the results are returned, so exactly like the simplest nreq case.

What is your approach for taking input into the nscript, @jb55? Can a user be prompted to select some options -- for example, a user loads a script and the script wants the user to pick from one of the users' relay sets or something like that before continuing?

@Semisol
Copy link
Collaborator

Semisol commented Nov 16, 2023

@jb55, @fiatjaf Could we have a repo or something to standardize nostrscripts and collaborate on the spec? I don't think they would fit into just one NIP.

@v0l
Copy link
Member

v0l commented Nov 16, 2023

Personally i don't have any use case for nreq (right now) and would much rather see nscript be standardized, an nscript to load a specific DVM requested algorithmic feed would be very cool

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

@Semisol I think they definitely fit in a NIP, but yes, I would like to see what @jb55 has done how we can proceed to get a working standard from there too.

@fiatjaf
Copy link
Member Author

fiatjaf commented Nov 16, 2023

I'll close this for now since we all agree nreqs are not very useful for now.

@fiatjaf fiatjaf closed this Nov 16, 2023
@AsaiToshiya
Copy link
Collaborator

I feel like nreq is optimal for dynamic references like wikilinks.
https://asaitoshiya.github.io/nostr-toybox/wiki-article/dist/#nreq1qvzxy7qqqqz3qertdaex2ctw94kxzmn8w4skwegkhym52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants