Profiles, names and search

Feeds have no names but their keys. A feed declares a display name in its profile, people give feeds nicknames of their own, and relays answer searches by name and title and lookups of programs by name. This article is part of the network's description; NETWORK.md 4.6 to 4.8 are exact.

Profiles, display names and nicknames

A profile is a kind 2 entry. Its title is the feed's display name; its blob is the profile document. The profile in force is the feed's valid profile entry with the highest seq.

A display name is 1 to 48 bytes of UTF-8 with no control characters (U+0000 to U+001F, U+007F to U+009F) and no character of the Unicode White_Space property (U+0020, U+00A0, U+3000 and others) first or last.

The profile document is UTF-8 text of at most 4,096 bytes, lines ending with 0Ah: header lines field: value, then optionally an empty line and a free-text description to the end. A header line without : makes the document invalid. Unknown fields are ignored.

FieldValue
listedyes: search may find the name; anything else, or no line, means not listed
relaya wss:// URL of a relay where the author publishes; 0 to 4 lines; readers take the first four that are URLs; a plain ws:// line is invalid and skipped

A client writing its user's profile adds a relay line for each of its encrypted, non-loopback relays; a plain relay is never listed. Names are self-declared and not unique, so a feed's name is always shown with its key or a short form of it (first and last six hex digits). A nickname is a name the user gives a feed (same rules), kept in the client's configuration, never sent anywhere, and shown in preference to the declared name.

A find's scope is 1 (feeds by display name), 2 (article and document titles) or 3 (program names); the query is 1 to 48 bytes of UTF-8. Another scope or a bad query is refused (status 3, count 0). The query matches if it occurs as a contiguous run of bytes in the name or title after A to Z are changed to a to z on both sides; nothing else is folded.

ScopeRelay returnsOrder
1the profile in force of each feed whose document says listed: yes and whose name matchesnames starting with the query first, then the rest; each group by increasing feed key
2article and document entries of feeds with a listed profile in forcenewest first by the order the relay stored them
3program entries, current versions only, of feeds with a listed profilenewest first by store order

A relay returns at most 16 results a page from what it holds (a profile document it lacks or cannot parse counts as not listed), and may refuse a connection that searches too often.

A find ends with c and a cursor; c 0 asks for the first page. A reply whose results do not end the list carries a cursor (1 to 64 bytes, the relay's own), else c 0. The next page is the same find with that cursor, sent back unchanged to the relay that gave it: the results after the last one of the page before, in the same order; what the relay stored since the first page is not in it. A cursor the relay cannot continue from is refused (3), and the client starts again from the first page. Each page counts as a find. A find that ends at its query (before paging) is a first page, answered without a cursor.

Clients ask all their relays and merge: they drop invalid entries, ones of the wrong kind and ones that do not match, and keep one per feed and seq. Scope 1 keeps the highest seq of each feed, ordered as above; scopes 2 and 3 go by rank (each relay's first result, then each one's second, and so on), and scope 3 drops a program another result has a higher seq of. The first 16 are kept. For more, a client sends the next find to each relay that gave a cursor, merges those pages the same way, drops the results it has shown (same feed and seq; scope 1, same feed) and shows up to 16 more. NETWORK.md 4.7 has the rest.

Lookup

A lookup's kind must be 3 (program) and the name a valid display name, else it is refused (3). The relay answers with the current version it holds of that feed's program (1), or 2 if none, listed or not; it may refuse a client that asks too often. A client asks all connected relays, keeps the valid matching entry with the highest seq (stored, not subscribed), then gets the image (a machine host, when a shell starts a program it holds no entry for).