Reading diagrams / Topic 34 of 42

Bands: loops and detached tasks

The rule

A route that works through a list, such as fold_until over the ids a request brings, draws that work as a shaded band on its path. The band's title says what it is: one iteration · loop · at most once per item, then where the items come from, here items computed from request.ids.

Inside the band is the tree of one pass: its forks, and its rings in order, read top to bottom as on the route's own line. A ring in the band runs at most once for each item, not once per request. A ring on only some of the band's arms, such as write · outbox under the True arm of ready, is made on only those passes. And a route ending above the band, such as not signed in, never reaches the loop, so on that path no item gets anything.

A pass does not end in a cap. Its ends say what the loop does next: next item moves on to the following item, stop the loop ends the loop early, and abort the transaction gives up the whole transaction. None of them is what the request gets back. Under the band, the route's line goes on: path continues when the loop finishes, then the route's own ending.

Under each end of a pass, a grey line says what the loop carries on. In outbox the loop's value is a record, and the line names each field the pass computes anew, with ← and the program's words, then the fields it hands on unchanged: under the True arm of ready, released ← the loop's item, the loop's value, with keeps deferred at the end. A pass that hands everything on reads keeps the loop's value. ← says the field is computed again, not that its value differs. The words are a summary: a constant inside a computed value, two reads of the same table, or one choice made in the other order can read alike, so two ends that read alike may still hand on different values, and different words can compute the same value. Only keeps is exact.

A loop over values alone, with no effect inside, gets no band; what it chose shows in the value it hands on. A read that chose which values flow, without being copied into them, is named after the value as selected by and the read. In keep-skip, /home tests each post against the caller's mute and keeps it or skips it, so the feed it writes reads selected by mutes as read, posts as read. keep-skip-unfiltered keeps every post: it reads the same mute, but nothing it read selects what it writes, and its label says no selected by. Its absence proves less than its presence. A read that flows in as a source is not named again. A fork above a ring decides whether the effect runs, and its own label says what it is computed from: ready, computed from drafts as read, sits above write · outbox, so drafts decides which drafts are written. And a value Yichus does not follow to its roots, such as the loop's value, can hide a choice.

Work the route starts and does not wait for, written with background, gets the same kind of band, titled detached task · started, not waited for · a failure is only logged. In detached-task's /posts/reply, the post is written on the route's own line, and the reply count's write is in the band. Its end, step returns Unit, is the task's, and the line under the band says path continues without waiting: the request answers without the count, and a failed count write never reaches the caller. The post's write is waited for only on the paths that reach it: not signed in answers above it, with no post written.

So a band answers questions about each item, and about what the request waits for: whether every item is read, what comes first inside a pass, and whether the answer depends on a task. It does not say how many items a request brings, since a loop may run no items, or when a detached task finishes.

outbox /outbox/release: a loop over the requested ids.

Loading the outbox tree.

outbox /drafts/save: no loop.

Loading the outbox tree.

detached-task /posts/reply: the reply count is written in a task the route does not wait for.

Loading the detached-task tree.

keep-skip /home: a feed that skips muted authors.

Loading the keep-skip tree.

keep-skip-unfiltered /home: the near miss that keeps every post.

Loading the keep-skip-unfiltered tree.

Loading the worked examples and practice.