@@ -4,49 +4,18 @@ weight = 6
44template = "doc.html"
55+++
66
7−# Contents
8−
9−- [Introduction](#introduction)
10−- [%warp](#warp) - Read and Subscribe.
11− - [%sing](#sing) - Read a file or directory.
12− - [%next](#next) - Subscribe for the next change to a file or directory.
13− - [%mult](#mult) - Subscribe for the next change to a set of files and/or directories.
14− - [%many](#many) - Track changes to a `desk` for the specified range of revisions.
15− - [Cancel Subscription](#cancel-subscription)
16−- [Write and Modify](#write-and-modify)
17− - [%info](#info)
18−- [Manage Mounts](#manage-mounts)
19− - [%boat](#boat) - List mounts.
20− - [%mont](#mont) - Mount something.
21− - [%ogre](#ogre) - Unmount something.
22− - [%dirk](#dirk) - Commit changes.
23−- [Merge Desks](#merge-desks)
24− - [%merg](#merg)
25−- [Permissions](#permissions)
26− - [%perm](#perm) - Set file permissions.
27− - [%cred](#cred) - Add permission group.
28− - [%crew](#crew) - Get permission groups.
29− - [%crow](#crow) - Get group usage.
30−- [Foreign Ships](#foreign-ships)
31− - [%warp](#warp-remote) - Read a file on a foreign ship.
32− - [%merg](#merg-remote) - Merge from a foreign `desk`.
33−
34−# Introduction
35−
36−This document details all the `task`s you're likely to use to interact with Clay, as well as the `gift`s you'll receive in response. Each section has a corresponding practical example in the [Examples](/docs/arvo/clay/examples) document. Many of the types referenced are detailed in the [Data Types](/docs/arvo/clay/data-types) document. It may also be useful to look at the `++ clay` section of `/sys/lull.hoon` in Arvo where these `task`s, `gift`s and data structures are defined.
7+This document details all the `task`s you're likely to use to interact with Clay, as well as the `gift`s you'll receive in response. Each section has a corresponding practical example in the [Examples](/docs/arvo/clay/examples) document. Many of the types referenced are detailed in the [Data Types](/docs/arvo/clay/data-types) document. It may also be useful to look at the `++ clay` section of `/sys/lull.hoon` in Arvo where these `task`s, `gift`s and data structures are defined.
378
389The focus of this document is on interacting with Clay from userspace applications and threads, so it doesn't delve into the internal mechanics of Clay from a kernel development perspective.
3910
40−# `%warp`
41−
42−A `%warp` `task` is for reading a subscribing to files and directories.
43−
44−### Accepts
11+## `%warp` - Read and track
4512
4613```hoon
47−[wer=ship rif=riff]
14+[%warp wer=ship rif=riff]
4815```
4916
17+A `%warp` `task` is for reading and subscribing to files and directories.
18+
5019The `wer` field is the target ship. The `(unit rave)` of the [riff](/docs/arvo/clay/data-types#riff-clay-request-desist) is null to cancel an existing subscription, otherwise the [rave](/docs/arvo/clay/data-types#rave-clay-general-subscription-request) is tagged with one of:
5120
5221- `%sing` - Read a single file or directory.
@@ -56,7 +25,7 @@ The `wer` field is the target ship. The `(unit rave)` of the [riff](/docs/arvo/c
5625
5726We'll look at each of these in more detail below.
5827
59−### Returns
28+#### Returns
6029
6130Clay responds to a `%mult` request with a `%wris` `gift`, and the rest with a `%writ` `gift`.
6231
@@ -76,7 +45,7 @@ The `unit` of the [riot](/docs/arvo/clay/data-types#riot-clay-response) will be
7645
7746Now we'll look at each of the `rave` request types in turn.
7847
79−## `%sing`
48+### `%sing` - Read
8049
8150```hoon
8251[%sing =mood]
@@ -88,11 +57,11 @@ The `care` of the [mood](/docs/arvo/clay/data-types#mood-clay-single-subscriptio
8857
8958The [case](/docs/arvo/clay/data-types#case-specifying-a-commit) specifies the `desk` revision and you can use whichever kind you prefer. The `path` will usually be a path to a file or directory like `/gen/hood/hi/hoon` but may be something else depending on the `care`.
9059
91−### Example
60+#### Example
9261
9362[See here for an example of using %sing.](/docs/arvo/clay/examples#sing)
9463
95−## `%next`
64+### `%next` - Await next
9665
9766```hoon
9867[%next =mood] :: await next version
@@ -102,19 +71,19 @@ This subscribes to the next version of the specified file. See [here](/docs/arvo
10271
10372If you subscribe to the current `case` of the `desk`, Clay will not respond until the file changes. If you subscribe to a previous `case` of the `desk` and the file has changed in between then and now, it will immediately return the first change it comes across in that range. For example, if you're currently at `case` `100`, subscribe to case `50` and the file in question has been modified at both `60` and `80`, clay will immediately return the version of the file at `case` `60`.
10473
105−### Example
74+#### Example
10675
10776[See here for an example of using %next.](/docs/arvo/clay/examples#next)
10877
109−## `%mult`
78+### `%mult` - Next of any
11079
11180```hoon
112−[%mult =mool] :: next version of any
81+[%mult =mool]
11382```
11483
115−This subscribes to the next version of a `set` of files or directories. Clay will only send a single response, and it will send it when *any* of the specified files change. For example, if you subscribe to both `/foo/txt` and `/bar/txt`, and only `/foo/txt` changes, Clay will send a response indicating a change to `/foo/txt`. If `/bar/txt` changes subsequently, it will not tell you. If more than one file changes at once, it will tell you about each of the changes in the one response.
84+This subscribes to the next version of a `set` of files or directories. Clay will only send a single response, and it will send it when _any_ of the specified files change. For example, if you subscribe to both `/foo/txt` and `/bar/txt`, and only `/foo/txt` changes, Clay will send a response indicating a change to `/foo/txt`. If `/bar/txt` changes subsequently, it will not tell you. If more than one file changes at once, it will tell you about each of the changes in the one response.
11685
117−The behaviour with respect to requesting old `case`s is the same as explained in the [`%next`](#next) section above.
86+The behaviour with respect to requesting old `case`s is the same as explained in the [`%next`](#next---await-next) section above.
11887
11988The `mool` specified in the request is this structure:
12089
@@ -122,16 +91,16 @@ The `mool` specified in the request is this structure:
12291+$ mool [=case paths=(set (pair care path))] :: requests in desk
12392```
12493
125−You can use a different `care` for each of the files specified by the `path` if you like. Significantly, the `care` will determine whether Clay sends a response for a given change. For example, if you subscribe to an existing `/foo/txt` with a `%u` `care` and `/foo/txt` is modified but isn't deleted, Clay will *not* tell you. However, if you subscribe with an `%x` `care`, it *will* tell you.
94+You can use a different `care` for each of the files specified by the `path` if you like. Significantly, the `care` will determine whether Clay sends a response for a given change. For example, if you subscribe to an existing `/foo/txt` with a `%u` `care` and `/foo/txt` is modified but isn't deleted, Clay will _not_ tell you. However, if you subscribe with an `%x` `care`, it _will_ tell you.
12695
127−### Example
96+#### Example
12897
12998[See here for an example of using %mult.](/docs/arvo/clay/examples#mult)
13099
131−## `%many`
100+### `%many` - Track range
132101
133102```hoon
134−[%many track=? =moat] :: track range
103+[%many track=? =moat]
135104```
136105
137106This subscribes to all changes to a `desk` for the specified range of `case`s. Note that you're unlikely to use this directly, it's mostly used implicitly if you make a `%sing` or `%next` request with a `%v` `care` to a foreign `desk`. Regardless, we'll have a look at it for completeness.
@@ -146,7 +115,7 @@ If the `track` is `%.y` it will just return a `%writ` like:
146115
147116If the `track` is `%.n`, the `cage` of the `%writ` will contain a [nako](/docs/arvo/clay/data-types#nako-subscription-response-data) with the relevant data for all changes to a desk between what you have and the `case` requested. It is very large and fairly complicated. The `nako` structure is defined in the `clay.hoon` source file itself rather than in `lull.hoon` or elsewhere since you're unlikely to work with it yourself.
148117
149−The `from` and `to` fields of the [moat](/docs/arvo/clay/data-types#moat-clay-range-subscription-request) specify the range of `case`s for which to subscribe. The range is *inclusive*. It can be specified by date or by revision number, whichever you prefer.
118+The `from` and `to` fields of the [moat](/docs/arvo/clay/data-types#moat-clay-range-subscription-request) specify the range of `case`s for which to subscribe. The range is _inclusive_. It can be specified by date or by revision number, whichever you prefer.
150119
151120The `path` in the `moat` is a path to a file or directory. If it's `~` it refers to the root of the `desk` in question. This lets you say "only inform me of changes to the `desk` if the specified file or directory exists". If it doesn't exist, Clay will not send you anything.
152121
@@ -156,30 +125,28 @@ When you reach the end of the subscribed range of `case`s, Clay will send you a
156125[%writ p=~]
157126```
158127
159−### Example
128+#### Example
160129
161130[See here for an example of using %many.](/docs/arvo/clay/examples#many)
162131
163−## Cancel Subscription
132+### Cancel Subscription
164133
165134To cancel a subscription, you just send a `%warp` with a null `(unit rave)` in the `riff`. Clay will cancel the subscription based on the `wire`. The request is exactly the same regardless of which type of `rave` you subscribed with originally.
166135
167−### Example
136+#### Example
168137
169138[See here for an example of cancelling a subscription.](/docs/arvo/clay/examples#cancel-subscription)
170139
171−# Write and Modify
140+## Write and Modify
172141
173−## `%info`
174−
175−To write or modify a file, we send Clay a `%info` `task`.
176−
177−### Accepts
142+### `%info` - Write
178143
179144```hoon
180−[des=desk dit=nori]
145+[%info des=desk dit=nori]
181146```
182147
148+To write or modify a file, we send Clay a `%info` `task`.
149+
183150The `%|` tag in the [nori](/docs/arvo/clay/data-types#nori-clay-repository-action) is not currently supported and will crash with a `%labelling-not-implemented` if used, so you can focus on the `%&` part. The [soba](/docs/arvo/clay/data-types#soba-clay-delta) in the `nori` is just a list of changes so you can make more than one change in one request. Its `path` is just the path to a file like `/gen/hood/hi/hoon` and the [miso](/docs/arvo/clay/data-types#miso-clay-ankh-delta) is one of these types of requests:
184151
185152- `%del` - Delete a file.
@@ -187,11 +154,11 @@ The `%|` tag in the [nori](/docs/arvo/clay/data-types#nori-clay-repository-actio
187154- `%dif` - This has not yet been implemented so will crash with a `%dif-not-implemented` error.
188155- `%mut` - Change a file. At the time of writing this behaves identically to `%ins` so its use merely informs the reader.
189156
190−### Returns
157+#### Returns
191158
192159Clay does not give any response to an `%info` `task` so don't expect a `sign` back.
193160
194−### Example
161+#### Example
195162
196163Here are examples of using each of these as well as making multiple changes in one request:
197164
@@ -200,31 +167,26 @@ Here are examples of using each of these as well as making multiple changes in o
200167- [%mut](/docs/arvo/clay/examples#mut)
201168- [Multiple Changes](/docs/arvo/clay/examples#multiple-changes)
202169
203−
204−# Manage Mounts
170+## Manage Mounts
205171
206172Here we'll look at managing Clay unix mounts programmatically.
207173
208174There are four Clay `task`s relevant to mounts:
209175
210−- [%boat](#boat) - List mounts.
211−- [%mont](#mont) - Mount something.
212−- [%ogre](#ogre) - Unmount something.
213−- [%dirk](#dirk) - Commit changes.
214−
215−## `%boat`
216−
217−A `%boat` `task` requests the list of existing mounts.
176+- [%boat](#boat---list-mounts) - List mounts.
177+- [%mont](#mont---mount) - Mount something.
178+- [%ogre](#ogre---unmount) - Unmount something.
179+- [%dirk](#dirk---commit) - Commit changes.
218180
219−### Accepts
181+### `%boat` - List mounts
220182
221183```hoon
222−~
184+[%boat ~]
223185```
224186
225−A `%boat` `task` does not take any arguments.
187+A `%boat` `task` requests the list of existing mounts and does not take any arguments.
226188
227−### Returns
189+#### Returns
228190
229191The type it returns is a `%hill` `gift`, which looks like:
230192
@@ -234,21 +196,18 @@ The type it returns is a `%hill` `gift`, which looks like:
234196
235197...where the `@tas` is the name of the mount point.
236198
237−### Example
199+#### Example
238200
239201[See here for an example of using %boat.](/docs/arvo/clay/examples#boat)
240202
241−## `%mont`
242−
243−
244−A `%mont` `task` mounts the specified `beam` to the specified `term` mount point.
245−
246−### Accepts
203+### `%mont` - Mount
247204
248205```hoon
249−[pot=term bem=beam]
206+[%mont pot=term bem=beam]
250207```
251208
209+A `%mont` `task` mounts the specified `beam` to the specified `term` mount point.
210+
252211A `beam:clay` is the following structure:
253212
254213```hoon
@@ -257,73 +216,69 @@ A `beam:clay` is the following structure:
257216
258217You can mount the whole desk with a `path` of `/`, and you can also mount subdirectories or even individual files. If you want to mount an individual file, you must exclude its `mark` from the path. For example, if you want to mount `/gen/hood/hi/hoon`, you'd specify `/gen/hood/hi`. It will automatically be given the correct file extension when mounted. If you include the `hoon` mark it will crash (and currently crash your ship).
259218
260−### Returns
219+#### Returns
261220
262221Clay does not return a `gift` in response to a `%mont` `%task`.
263222
264−### Example
223+#### Example
265224
266225[See here for an example of using %mont.](/docs/arvo/clay/examples#mont)
267226
268−## `%ogre`
269−
270−A `%ogre` `task` unmounts the specified mount.
271−
272−### Accepts
227+### `%ogre` - Unmount
273228
274229```hoon
275−[pot=$@(desk beam)]
230+[%ogre pot=$@(desk beam)]
276231```
277232
233+A `%ogre` `task` unmounts the specified mount.
234+
278235It's defined in `lull.hoon` as taking `$@(desk beam)` but in fact it will only unmount the target when specified as a `term` mount name. Passing it a `desk` will incidentally work if the mount is named the same as the `desk` but otherwise it won't work. Passing it a `beam:clay` will simply not work.
279236
280−### Returns
237+#### Returns
281238
282239Clay does not return a `gift` in response to a `%ogre` `task`.
283240
284−### Example
241+#### Example
285242
286243[See here for an example of using %ogre.](/docs/arvo/clay/examples#ogre)
287244
288−## `%dirk`
289−
290−A `%dirk` `task` commits changes in the target mount.
291−
292−### Accepts
245+### `%dirk` - Commit
293246
294247```hoon
295−des=desk
248+[%dirk des=desk]
296249```
297250
298−It's defined in `lull.hoon` as taking a `desk` but like [%ogre](#ogre), it actually takes the name of a mount point rather than a `desk` as is specified.
251+A `%dirk` `task` commits changes in the target mount.
252+
253+It's defined in `lull.hoon` as taking a `desk` but like [%ogre](#ogre---unmount), it actually takes the name of a mount point rather than a `desk` as is specified.
299254
300−### Returns
255+#### Returns
301256
302257Clay does not return a `gift` in response to a `%dirk` `task`.
303258
304−### Example
259+#### Example
305260
306261[See here for an example of using %dirk.](/docs/arvo/clay/examples#dirk)
307262
308−# Merge Desks
263+## Merge Desks
309264
310−## `%merg`
311−
312−A `%merg` `task` will merge the specified source `desk` into the target local `desk`.
313−
314−### Accepts
265+### `%merg` - Merge
315266
316267```hoon
317−$: des=desk :: target
268+$: %merg
269+ des=desk :: target
318270 her=@p dem=desk cas=case :: source
319271 how=germ :: method
320272==
321273```
274+
275+A `%merg` `task` will merge the specified source `desk` into the target local `desk`.
276+
322277The `germ` specifies the merge strategy. You can refer to the [Strategies](/docs/arvo/clay/using#strategies) section of the [Using Clay](/docs/arvo/clay/using) document for details of each `germ`.
323278
324279If you're merging into a new `desk` you must use `%init`, all other strategies will fail. If the desk already exists, you cannot use `%init`. Otherwise, you're free to use whichever you'd like.
325280
326−### Returns
281+#### Returns
327282
328283Clay will respond to the request with a `%mere` `gift` which looks like:
329284
@@ -344,15 +299,15 @@ If the merge failed, `p` will have a head of `%.n` and then a `[term tang]` wher
344299]
345300```
346301
347−### Example
302+#### Example
348303
349304[See here for an example of using %merg.](/docs/arvo/clay/examples#merg)
350305
351−# Permissions
306+## Permissions
352307
353308For each file or directory, there is both a read permission and a write permission. Each may be set separately and is either a whitelist or a blacklist (but not both). The whitelist/blacklist contains a `set` of ships and/or groups which are allowed or banned respectively. If it's an empty whitelist it means all foreign ships are denied. If it's an empty blacklist it means all foreign ships are allowed.
354309
355−If permissions are not set for a particular file, they will be inherited from the directory in which it resides. If *that* directory has no permissions set, they will be inherited from another level up, and so on to the `desk`'s root directory. If the root directory has no permissions set, it will have the default permissions of an empty whitelist, meaning "deny all".
310+If permissions are not set for a particular file, they will be inherited from the directory in which it resides. If _that_ directory has no permissions set, they will be inherited from another level up, and so on to the `desk`'s root directory. If the root directory has no permissions set, it will have the default permissions of an empty whitelist, meaning "deny all".
356311
357312A group is called a `crew` and is just a `set` of ships with a `@ta` name.
358313
@@ -390,18 +345,16 @@ A `%perm` `task` is for setting permissions, and the other three are for managin
390345
391346We'll look at each of these in turn.
392347
393−## `%perm`
348+### `%perm` - Set perms
349+
350+```hoon
351+[%perm des=desk pax=path rit=rite]
352+```
394353
395354A `%perm` `task` sets permissions for the target file or directory.
396355
397356Note this will replace existing permissions rather than add to them, so if you want to add a ship to an existing whitelist or whatever you'll have to first read the existing permissions, add the ship, then send the whole lot back.
398357
399−### Accepts
400−
401−```hoon
402−[des=desk pax=path rit=rite]
403−```
404−
405358The `pax` path is the file or directory whose permissions you want to change, and the `rite` is this structure:
406359
407360```hoon
@@ -409,6 +362,7 @@ The `pax` path is the file or directory whose permissions you want to change, an
409362 $% [%r red=(unit rule)] :: for read
410363 [%w wit=(unit rule)] :: for write
411364 [%rw red=(unit rule) wit=(unit rule)] :: for read and write
365+ ==
412366```
413367
414368Where a `rule` is this structure:
@@ -425,51 +379,47 @@ Where a `rule` is this structure:
425379
426380As the comment suggests, the `@ta` is the name of a `crew` (group).
427381
428−### Returns
382+#### Returns
429383
430384Clay does not return a `gift` in response to a `%perm` `task`.
431385
432−### Example
386+#### Example
433387
434388[See here for an example of using %perm.](/docs/arvo/clay/examples#perm)
435389
436−## `%cred`
437−
438−This simply creates a permission group.
439−
440−### Accepts
390+### `%cred` - Add group
441391
442392```hoon
443−[nom=@ta cew=crew]
393+[%cred nom=@ta cew=crew]
444394```
445395
396+This simply creates a permission group.
397+
446398The `nom` is a name for the group and the `crew` is just a `(set ship)`:
447399
448400```hoon
449401+$ crew (set ship) :: permissions group
450402```
451403
452−### Returns
404+#### Returns
453405
454406Clay does not return a `gift` in response to a `%cred` `task`.
455407
456−### Example
408+#### Example
457409
458410[See here for an example of using %cred.](/docs/arvo/clay/examples#cred)
459411
460−## `%crew`
461−
462−This retrieves all permission groups.
463−
464−### Accepts
412+### `%crew` - Get groups
465413
466414```hoon
467−~
415+[%crew ~]
468416```
469417
418+This retrieves all permission groups.
419+
470420A `%crew` `task` takes no arguments.
471421
472−### Returns
422+#### Returns
473423
474424Clay wil return a `%cruz` `gift`. It looks like:
475425
@@ -479,23 +429,21 @@ Clay wil return a `%cruz` `gift`. It looks like:
479429
480430The `cez` is just a map from group name to `crew` which is just a `(set ship)`.
481431
482−### Example
432+#### Example
483433
484434[See here for an example of using %crew.](/docs/arvo/clay/examples#crew)
485435
486−## `%crow`
487−
488−A `%crow` `task` retrieves all files and directories in all `desk`s which have permissions set for the group in question. It will not return inherited permissions, only those explicitly set.
489−
490−### Accepts
436+### `%crow` - Group files
491437
492438```hoon
493−nom=@ta
439+[%crow nom=@ta]
494440```
495441
442+A `%crow` `task` retrieves all files and directories in all `desk`s which have permissions set for the group in question. It will not return inherited permissions, only those explicitly set.
443+
496444The `nom` is the name of a `crew`.
497445
498−### Returns
446+#### Returns
499447
500448The `gift` you get back is a `%croz` which looks like:
501449
@@ -509,19 +457,19 @@ The `gift` you get back is a `%croz` which looks like:
509457+$ regs (map path rule) :: rules for paths
510458```
511459
512−### Example
460+#### Example
513461
514462[See here for an example of using %crow.](/docs/arvo/clay/examples#crow)
515463
516−# Foreign Ships
464+## Foreign Ships
517465
518466Here we'll looking at making Clay requests to a foreign ship.
519467
520468As it currently stands, it's not possible to write to a foreign `desk`. Additionally, remote scries are not implemented. That leaves requests to read files (`%warp`) and merge desks (`%merg`), which we'll look at next.
521469
522−## `%warp` - Remote
470+### `%warp` - Remote
523471
524−To read files on a foreign `desk`, you just send Clay a `%warp` `task` (as you would for a local read) and specify the target ship in the `wer` field. For details on making such requests, see the [Read and Subscribe](#warp) section.
472+To read files on a foreign `desk`, you just send Clay a `%warp` `task` (as you would for a local read) and specify the target ship in the `wer` field. For details on making such requests, see the [Read and Subscribe](#warp---read-and-track) section.
525473
526474Clay only allows a subset of `care`s to be used remotely. They are:
527475
@@ -538,11 +486,11 @@ The foreign ship will respond only if correct permissions have been set. See the
538486
539487Note that if you're reading a whole `desk` or directory, all subfolders and files must also permit reading. If even a single file does not permit you reading it, the foreign ship will not respond to the request.
540488
541−### Example
489+#### Example
542490
543491[See here for examples of requests to foreign ships.](/docs/arvo/clay/examples#foreign-ships)
544492
545−## `%merg` - Remote
493+### `%merg` - Remote
546494
547495To merge a foreign `desk` into a local one, you just send Clay a `%merg` `task` (as you would for a local merge) and specify the foreign ship in the `her` field. For details on making such requests, see the [Merge Desks](#merge-desks) section.
548496
@@ -550,6 +498,6 @@ The foreign ship will respond only if correct permissions have been set. See the
550498
551499Note that all subfolders and individual files within the `desk` must permit your reading in order for the merge to succeed. If even one file does not permit you reading it, the remote ship will not respond to the request at all.
552500
553−### Example
501+#### Example
554502
555503[See here for examples of requests to foreign ships.](/docs/arvo/clay/examples#foreign-ships)