on master help sign in
Added Hall interface documentation.
a6381c7Fang
docs/talk/interface.mdnew file+386
@@ -0,0 +1,386 @@
1+
2+# Hall interface
3+
4+This document describes the different interfaces Hall provides and the data that is accessible and modifyable through them. Knowledge of the Urbit application model (including [new gall](gall.md)) and #[Hall's architecture](architecture.md) is assumed.
5+
6+While the structures here are given in Hoon, they match fairly closely to their JSON equivalent. Most important to note is that `$%({$x y/z})` becomes accessible as `json.x.y`.
7+
8+
9+## Table of contents
10+
11+* [Queries](#queries)
12+ * [/client](#client)
13+ * [/client prize](#client-prize)
14+ * [/client rumor](#client-rumor)
15+ * [/public](#public)
16+ * [/public prize](#public-prize)
17+ * [/public rumor](#public-rumor)
18+ * [/peers](#peers)
19+ * [/peers prize](#peers-prize)
20+ * [/peers rumor](#peers-rumor)
21+ * [/circle](#circle)
22+ * [/circle prize](#circle-prize)
23+ * [/circle rumor](#circle-rumor)
24+* [Actions][#actions]
25+ * [Circle configuration](#circle-configuration)
26+ * [Messaging](#messaging)
27+ * [Personal metadata](#personal-metadata)
28+ * [Changing shared UI](#changing-shared-ui)
29+ * [Miscellaneous changes](#miscellaneous-changes)
30+
31+
32+## Queries
33+
34+Queries are the paths you pass into `%peer` moves. Internally, they get translated to a `++query` structure for easier handling. We'll be giving examples of valid query paths alongside the structures themselves.
35+
36+### /client
37+
38+To be able to keep certain UI elements like glyphs and local nicknames consistent across different Hall clients, they can query Hall for the current UI state.
39+
40+```
41+++ query ::
42+ $% {$client $~} :< shared ui state
43+ :: .... ::
44+ == ::
45+```
46+
47+Valid paths include:
48+
49+```
50+:> all shared ui state
51+/client
52+```
53+
54+#### /client prize
55+
56+Contains a map of glyphs and the audiences they map to, as well as a map of ships and their locally set nicknames.
57+
58+```
59+++ prize :> query result
60+ $% {$client prize-client} :< /client
61+ :: ... ::
62+ == ::
63+++ prize-client :> shared ui state
64+ $: gys/(jug char audience) :< glyph bindings
65+ nis/(map ship nick) :< local nicknames
66+ == ::
67+```
68+
69+#### /client rumor
70+
71+Contains either a bound or unbound glyph and its target, or a ship with its new ncikname. A `nic`kname of `''` means the associated ship no longer has a nickname set for it.
72+
73+```
74+++ rumor :> query result change
75+ $% {$client rum/rumor-client} :< /client
76+ :: ... ::
77+ == ::
78+++ rumor-client :< changed ui state
79+ $% {$glyph diff-glyph} :< un/bound glyph
80+ {$nick diff-nick} :< changed nickname
81+ == ::
82+++ diff-glyph {bin/? gyf/char aud/audience} :< un/bound glyph
83+++ diff-nick {who/ship nic/nick} :< changed nickname
84+```
85+
86+
87+### /public
88+
89+To aid in circle discoverability, users can add circles to their "public membership" list. This can then be queried for by, for example, a profile page.
90+
91+```
92+++ query ::
93+ $% {$public $~} :< public memberships
94+ :: .... ::
95+ == ::
96+```
97+
98+Valid paths include:
99+
100+```
101+:> all public memberships
102+/public
103+```
104+
105+#### /public prize
106+
107+Contains the set of circles the user has on their public list.
108+
109+```
110+++ prize :> query result
111+ $% {$public cis/(set circle)} :< /public
112+ :: ... ::
113+ == ::
114+```
115+
116+#### /public rumor
117+
118+Contains a circle that was either added or removed from the public list.
119+
120+```
121+++ rumor :> query result change
122+ $% {$public add/? cir/circle} :< /public
123+ :: ... ::
124+ == ::
125+```
126+
127+### /peers
128+
129+To allow a circle owner to inspect who is actually currently subscribed to their stories, they can issue a query to retrieve subscription data.
130+
131+```
132+++ query ::
133+ $% {$peers nom/naem} :< readers of story
134+ :: .... ::
135+ == ::
136+```
137+
138+Query paths are structured as follows:
139+
140+```
141+/peers/[circle-name]
142+```
143+
144+Valid paths include:
145+
146+```
147+:> peers for circle %urbit-meta
148+/peers/urbit-meta
149+```
150+
151+#### /peers prize
152+
153+Contains a map of ships and the different queries they currently have active for the selected story.
154+
155+```
156+++ prize :> query result
157+ $% {$peers pes/(jar ship query)} :< /peers
158+ :: ... ::
159+ == ::
160+```
161+
162+#### /peers rumor
163+
164+Contains a ship and a query, and a flag to indicate whether that subscription has started or ended.
165+
166+```
167+++ rumor :> query result change
168+ $% {$peers add/? who/ship qer/query} :< /peers
169+ :: ... ::
170+ == ::
171+```
172+
173+### /circle
174+
175+Circle queries allow for the retrieving of data from stories. Their messages, configuration, presences, can all be accessed. Since this is a lot of data, there are lots of possibilities for filtering it built in to the query itself.
176+
177+A quick refresher on the difference between "local" and "remote" presence and configuration: "local" means it pertains to the circle itself, "remote" means it pertains to one of its configured sources. The latter is primarily useful to clients when using a circle for aggregation, like the `%inbox`.
178+
179+```
180+++ query ::
181+ $% $: $circle :> story query
182+ nom/naem :< circle name
183+ wer/(unit circle) :< from source
184+ wat/(set circle-data) :< data to get
185+ ran/range :< query duration
186+ == ::
187+ :: .... ::
188+ == ::
189+++ circle-data :> kinds of circle data
190+ $? $grams :< messages
191+ $group-l :< local presence
192+ $group-r :< remote presences
193+ $config-l :< local config
194+ $config-r :< remote configs
195+ == ::
196+++ range :> inclusive msg range
197+ %- unit :< ~ means everything
198+ $: hed/place :< start of range
199+ tal/(unit place) :< opt end of range
200+ == ::
201+++ place :> range indicators
202+ $% {$da @da} :< date
203+ {$ud @ud} :< message number
204+ == ::
205+```
206+
207+Query paths are structured as follows:
208+
209+```
210+/circle/[circle-name]/(from-circle)/[what/data]/(range-start(/range-end))
211+(from-circle) : optional message source, ~ship/circle
212+[what/data] : one or more of grams, group, group-l, group-r,
213+ : config, config-l, config-r, combined using /
214+(range) : an optional range with an optional end, its points denoted
215+ : in either message number (@ud) or date (@da)
216+```
217+
218+Valid paths include:
219+
220+```
221+:> get all messages from circle %urbit-meta
222+/circle/urbit-meta/grams
223+:> get all messages, all presences and local configs from %urbit-meta
224+/circle/urbit-meta/grams/group/config-l
225+:> get all messages %urbit-meta has heard from its source ~zod/fora
226+/circle/urbit-meta/~zod/fora/grams
227+:> get the first 100 messages from %urbit-meta
228+/circle/urbit-meta/grams/0/99
229+:> get the first 100 messages %urbit-meta has heard from its source ~zod/fora
230+/circle/urbit-meta/~zod/fora/grams/0/99
231+:> get all messages from %urbit-meta, starting now
232+/circle/urbit-meta/grams/group/(scow %da now)
233+:> get all messages from %urbit-meta, starting now, ending at the 100th message
234+/circle/urbit-meta/grams/(scow %da now)/99
235+:> get local presences from %urbit-meta for a week
236+/circle/urbit-meta/group-l/(scow %da now)/(scow %da (add now ~d7))
237+```
238+
239+#### /circle prize
240+
241+Contains (where applicable) messages in envelopes (with message numbers), local and remote configurations and presences.
242+
243+```
244+++ prize :> query result
245+ $% {$circle package} :< /circle
246+ :: ... ::
247+ == ::
248+++ package :> story state
249+ $: nes/(list envelope) :< messages
250+ cos/lobby :< loc & rem configs
251+ pes/crowd :< loc & rem presences
252+ == ::
253+```
254+
255+#### /circle rumor
256+
257+Contains a detailed change description of the data relevant to the query that changed.
258+Messages are wrapped in envelopes to include their sequence number, and note the source they were heard from.
259+Configuration and status changes specify the circle they apply to.
260+
261+```
262+++ rumor :> query result change
263+ $% {$circle rum/rumor-story} :< /circle
264+ :: ... ::
265+ == ::
266+++ rumor-story :> story rumor
267+ $% {$new cof/config} :< new story
268+ {$gram src/circle nev/envelope} :< new/changed message
269+ {$config cir/circle dif/diff-config} :< new/changed config
270+ {$status cir/circle who/ship dif/diff-status} :< new/changed status
271+ {$remove $~} :< removed story
272+ == ::
273+++ diff-config :> config change
274+ $% {$full cof/config} :< set w/o side-effects
275+ {$source add/? src/source} :< add/rem sources
276+ {$caption cap/cord} :< changed description
277+ {$filter fit/filter} :< changed filter
278+ {$secure sec/security} :< changed security
279+ {$permit add/? sis/(set ship)} :< add/rem to b/w-list
280+ {$remove $~} :< removed config
281+ == ::
282+++ diff-status :> status change
283+ $% {$full sat/status} :< fully changed status
284+ {$presence pec/presence} :< changed presence
285+ {$human dif/diff-human} :< changed name
286+ {$remove $~} :< removed status
287+ == ::
288+++ diff-human :> name change
289+ $% {$full man/human} :< fully changed name
290+ {$handle han/(unit cord)} :< changed handle
291+ {$true tru/(unit truename)} :< changed true name
292+ == ::
293+```
294+
295+
296+## Actions
297+
298+Actions can be sent by poking Hall with data marked as `%hall-action`. Actions are used for all user operations. If an error or other unexpected behavior occurs while executing an action, Hall notifies the user by sending an `%app` message to their `%inbox`.
299+
300+### Circle configuration
301+
302+Since all of these apply to a specific circle, they all specify a name `nom` of the circle to operate on.
303+
304+```
305+++ action :> user action
306+ $% {$create nom/naem des/cord sec/security} :< create circle
307+ {$delete nom/naem why/(unit cord)} :< delete + announce
308+ {$depict nom/naem des/cord} :< change description
309+ {$filter nom/naem fit/filter} :< change message rules
310+ {$permit nom/naem inv/? sis/(set ship)} :< invite/banish
311+ {$source nom/naem sub/? srs/(set source)} :< un/sub to/from src
312+ :: ... ::
313+ ==
314+```
315+
316+`%create`: Creates a circle with description `des` and security mode `sec`. If this mode is a whitelist, the user is automatically added to it.
317+
318+`%delete`: Deletes the circle. If a reason `why` is provided, posts that as the last message to the circle before deleting it.
319+
320+`%depict`: Set the description of the circle to `des`.
321+
322+`%filter`: Set the filter (message sanitation rules) for the circle to `fit`.
323+
324+`%permit`: Either invite or banish ships to/from the circle, modifying the access control list accordingly. Regardless of whether this actually makes any changes, sends an `%inv` message to the involved ships' `%inbox`es.
325+
326+`%source`: Add or remove sources to/from the circle, un/subscribing it to/from the `grams`, `group-l` and `config-l` each one.
327+
328+### Messaging
329+
330+There are two interfaces for telling hall to send a message. The first takes entire `thought`s, the second only `speech`es and the audience to send them to.
331+
332+```
333+++ action :> user action
334+ $% {$convey tos/(list thought)} :< post exact
335+ {$phrase aud/audience ses/(list speech)} :< post easy
336+ :: ...
337+ ==
338+```
339+
340+`%convey`: Sends the thoughts to their audiences.
341+
342+`%phrase`: Turns the speeches into thoughts by applying sane defaults for metadata (auto-generated `uid`, `now` for `wen`), and then sends those thoughts.
343+
344+### Personal metadata
345+
346+These concern the presence users have in circles they are participating in.
347+
348+```
349+++ action :> user action
350+ $% {$notify aud/audience pes/(unit presence)} :< our presence update
351+ {$naming aud/audience man/human} :< our name update
352+ :: ... ::
353+ ==
354+```
355+
356+`%notify`: Sets the user's presence in the audience circles to `pes`. A good client will automatically set these based on the user's activity. (`%talk` on typing, `%idle` on idle, `%gone` on sign-off.)
357+
358+`%naming`: Sets the user's name (handle and real name) for the given audience. Good clients can display these in place of ship names.
359+
360+### Changing shared UI
361+
362+When the user makes any changes to shared UI elements (elements that should persist between clients), this has to be communicated to Hall.
363+
364+```
365+++ action :> user action
366+ $% {$glyph gyf/char aud/audience bin/?} :< un/bind a glyph
367+ {$nick who/ship nic/nick} :< new identity
368+ :: ... ::
369+ ==
370+```
371+
372+
373+`%glyph`: Adds or removed a binding of a glyph to an audience.
374+
375+`%nick`: Sets a local nickname for a ship. An empty nickname `''` means the ship has no nickname.
376+
377+### Miscellaneous changes
378+
379+```
380+++ action :> user action
381+ $% {$public add/? cir/circle} :< show/hide membership
382+ :: ... ::
383+ ==
384+```
385+
386+`%public`: Adds or removes a circle to/from the user's public membership list.