Skip to content
pi-c Artifact [97b50d2f08]
Login

Artifact [97b50d2f08]

Artifact 97b50d2f084f4e98a957d4bf6631988825202002ae9e5d3434d4727529586e7b:


# Remote control: the relay side

The wire contract is [the remote protocol](../design/remote-protocol.md), with its Amendments. This
page is the invariants in `src/remote.c`. The user's view is
[remote control](../manual/remote-control.md); the inbox it writes to is [the inbox](inbox.md).

## State

Two tables in `~/.pic/pic.sqlite`, both sealed with the credential store's key:

| Table | Holds | Sealing AAD |
|---|---|---|
| `picu_remote_key` | pic's static key, the mailbox id and owner token, by `name` | `remote-key:NAME` |
| `picu_remote_device` | one paired phone: `id`, sealed JSON, `paired_ms`, `seen_ms` | `remote-device:HEX` |

The device JSON is `{"name","static","channel","push"}`; `push` is `null` or
`{"endpoint","p256dh","auth","notify"}`, rewritten in place (the row's `sealed` alone) when the
phone sends `push` or the push service ends the subscription. The VAPID key is the `vapid` row of
`picu_remote_key`, made with the others at the first pairing.

Unpair deletes a device row and needs no key. Reset deletes both tables' rows in one transaction,
then the mailbox at the relay (best effort; the relay drops an unused mailbox after 90 days).

## The passphrase rule

`pic remote` unlocks the store from its own source at every start (`rmt_unlock_fresh`): it locks
first and never takes a key from a parent. A key in the Keychain or the key file opens it with no
prompt, so launchd can start it; a passphrase store asks on the terminal, and with no terminal it
exits. When the store has no key yet it refuses and tells the user to pair first.

## Process model

One loop, one stream thread, `RMT_WORKERS` (4) workers and `RMT_POSTERS` (2) posters. The stream
thread reads the relay's up stream and writes whole records to a pipe; it never touches SQLite. The
loop owns the sessions,
the devices, the lanes and the posts, and it never calls SQLite on a journal, nor on the user
database but for one setting a phone's pairing offer reads (`remote.phonePairing`; a read WAL does
not block): it does the stream pipe, Noise, the lanes, timers, presence, pings, pairing, the live file, the status
file, forking a prompt's or a compaction's child, and the watchdog. It makes no call to the relay
but pairing's and unpairing's few (a channel made or deleted, a last word to a phone). A session is confirmed by the
first message that verifies. Nothing is persisted but rows: no cursor, no session. A restart
reconnects and each phone resyncs from its own cursor.

## Posting

Records are sealed on the loop, in the order its messages go, onto the device's lane; the posters
send them (`rmt_lane_post`, `rmt_poster`). A lane has at most one post with them at a time
(`inflight`), its first 32 records or 256 KiB, kept at the front of the queue until the answer
comes back on the loop (`rmt_posts_apply`): a 2xx takes them off, a 404 or 401 drops the lane, any
other answer or none tries again a second later. So one phone's records reach the relay in order,
and records the loop added meanwhile go in the next post. Each poster has its own connection; the
first takes the oldest post, the second only posts of 16 KiB or less (`RMT_POST_SMALL`), so a pong
or an answer to one phone never waits behind another phone's large page. A lane whose front is
taken another way (a post made on the loop, an unpair) raises its `epoch`, and an older answer is
not applied; a record that goes twice is a replay the phone drops. The stream's acknowledgement on
its own (`GET /v1/m/M/c`) is a poster's post too, one at a time; each post carries `Pic-Ack`, and
`acked` is the highest id the relay took. A follow's next page waits until less than a post's
worth waits on its lane, so a long history does not pile up past the 30 s a record may wait.

History waits unsealed (`rmt_send_bulk`, the device's `bulk`): a follow's events and marks, a
`sync`'s, a `fetch` page, `get_messages` and an image go into the lane, in order, only while it
holds less than a post (`rmt_bulk_drain`, before each post), while everything else is sealed at
once. So a pong or an answer to the phone that is reading a 2 MiB page waits behind one post of it,
not the whole page; records are sealed in the order they go, so the counter rule holds. Each waits
with the time it was queued, and one 30 s old is dropped unsent as the lane drops one; past 64 MiB
(`RMT_BULK_CAP`) it is sealed at once, and a new session or an unpair drops what waits. When
no poster thread will start, `pic remote` says so once and posts on the loop, as before
(`PIC_TEST_RC_NO_POSTER` forces that in dev builds).

## Jobs

Every read or write of a journal or the user database is a job (`rmt_job`): its `run` on a
worker, then its `done` back on the loop, which applies what it found and posts its lines. Jobs
get copies of what they read from the loop (the conversation's model choice, the devices' names,
the follow's key) and never touch the loop's state; results come back on a finished list and a
byte on a pipe in the loop's `select`.

- **Lanes.** A journal is a lane: one job of it at a time, in the order queued. Its connection
  (and every follow open on it) belongs to the lane, used by whichever worker holds it. The user
  database is one more lane; each thread has its own connection to it (`pic_userdb`). A lane is
  let go only once the loop has applied its job, so one journal's answers go out in the order the
  phone sent them. Jobs that call into pic's own state (models, keys, settings) also hold
  `rmt_user_mu`, as one thread always did.
- **Deadlines.** A command's statements stop after `RMT_MESSAGE_MS` (2 s) or 50 million steps
  (a progress handler); the phone is told `busy` and nothing the job found is applied. The loop
  answers `busy` itself for a command that runs `RMT_JOB_GRACE_MS` (1 s) past that (stuck outside
  SQLite, say on a slow disk) or waits `RMT_JOB_WAIT_MS` (10 s) in its lane's queue (then it never
  runs). A repeat of a key whose job is in hand joins it.
- **Busy is never a lie.** A command's first commit and the loop's `busy` exclude each other
  (`rmt_job.fate`, claimed by a commit hook on the journal's connection, or by the loop): a job that
  committed before the loop gave up on it sends its own answer however late, and once the loop has
  answered `busy` the job's commits roll back. A phone told `busy` was told the truth: nothing
  changed, and sending it again may succeed.
- **Order of work.** Of the jobs whose lane is free, a phone's command goes first, from the device
  after the one served last, each device's in the order it sent them: one phone's burst waits its
  turn behind every other phone's commands. Background jobs (ticks, keeping, looks, last-seen
  writes) go after the commands, or first once one has waited `RMT_BACKGROUND_MS` (500 ms), so
  neither starves the other.
- **Bursts.** A `get_state`, `get_messages` or `get_session_stats` for a conversation that the same
  device asks again while the first is still queued is dropped, and its key gets the newer job's
  answer. A `sync` replaces a queued `sync` of the same device unread. A device follows one
  conversation at a time: a new `sync` closes the follow before it.
- **Children.** A child forked while workers run may find the allocator's or SQLite's locks held,
  so it calls only async-signal-safe functions before `exec` (`sigaction`, `setsid`, `dup2`,
  `close`, `fork`, `waitpid`, `execve`); everything it needs is made before the fork. SQLite is
  built `SQLITE_THREADSAFE=1`, and no connection is used by two threads at once. Every child is
  waited for: a prompt's runs the submit, then forks `pic run` and exits, so the request is a
  grandchild that init reaps; a compaction's is waited for by its command. A child whose command
  is dropped first (a prompt's once its request is admitted, any of an unpaired phone) goes on a
  list each tick waits for (`rmt_reap`), and a restart waits until that list is empty. It waits
  for its own children by pid, never for any child (`waitpid(-1)`), which would take a status
  that code on a worker waits for.
- **Ticks.** Each open journal gets a tick job at most every `RMT_TICK_JOB_MS` (100 ms): the
  follow passes of the phones following it, its part of the list while a phone wants the list, the
  inbox rows and admissions its commands wait on, ended requests, loops and questions to notify.
  Each second a keeping job lets a journal go for a newer pic (once no command, half message or
  owed answer is in hand, `rmt_journals_quiet`; records on their way to the relay do not hold it),
  opens it again or updates an older pic's, and a user job reads the devices and the workspace registry when the
  database changed. A record on a channel no device has is kept until that read (a phone paired a
  moment ago).
- **Follows.** The loop holds a device's follow only as a handle; it gives one it lets go of back
  to its lane (`dead`), freed by the lane's next job, and raises the device's `fgen` so a job's
  result for an older follow is dropped.
- **Restart.** A newer pic waits for no job in hand, and no new tick, keeping or user job starts
  meanwhile.

`pic remote` takes no lease and writes no journal rows except inbox rows, keyed admissions, a
conversation's name (`set_session_name`) and the commands' own rows in the table above. One per
user: `~/.pic/remote.lock`. It writes `~/.pic/remote.status` (JSON: pid, state, relay, devices,
attempts, the next try, the last error, `exe`, `exeStamp`, `startedMs`, `streamOpenedAt` (UTC, null
while not connected), `recycles`, `heardMs` (wall ms of the relay's last byte on the stream, a
comment included), and `phones`, each phone in a session now with the `W/C` it
follows or null and whether its page is showing; replaced by a rename) when the stream's state or
the phones change and every 5 s; the interface's footer reads `phones` through
`pic remote status --json`; `pic remote status` trusts it only while the lock is held, and
`pic remote stop` sends SIGTERM to its pid.

## A newer pic installed

At start it records its program's path (`pic_platform.self_path`) and that file's stamp
(`file_stamp`: device, inode, size, mtime). Twice a second the loop stamps the path again; a new
stamp that has held for 2 s (`PIC_TEST_RC_SETTLE_MS` in dev builds), or SIGUSR1 from `pic remote
restart`, restarts it at the first quiet tick (`rmt_quiet`: no command, no queued record, no half
message, no offer, no push queued or in flight). It sends `bye` `restart` to each session, writes
`restarting`, and `exec`s the path as `remote --detached`, the key handed on through `PIC_KEY_FD`
(`--login` for the login agent's, which opens the store itself). The pid is kept, so `/rc`'s reaper
and the login agent see one process; the lock goes with the closed descriptor. A failed exec goes
on as it was and does not try that file again. `pic remote status` calls it stale when the file at
`exe` no longer has `exeStamp`, or when the status has no `exeStamp` at all (a pic from before
this). `restart` refuses one without `startedMs`, which would die of SIGUSR1.

## Started by /rc

The interface forks `pic remote --detached` in a session of its own, stdin `/dev/null`, output
appended to `~/.pic/remote.log`, the master key on a pipe it inherits (`PIC_KEY_FD`,
`pic_cred_handoff`). `--detached` takes that key instead of asking; without it the passphrase rule
above holds. The interface reaps it; one that died of a signal (not TERM, INT or HUP) is started
again after 1 s, doubling to 30, the count reset after a minute's run. It is not stopped when the
interface exits.

## The connection

| Constant | Value | Why |
|---|---|---|
| `RMT_IDLE_S` | 45 | no byte for this long: the stream is dead (the relay comments every 15 s) |
| `RMT_QUIET_MS` | 120000 | no record for this long: reconnect, logged while a phone is on screen (it pings each minute), else a quiet probe |
| `RMT_LOST_MS` | 30000 | a post with no answer at all reopens the stream at once, at most this often |
| `RMT_OPEN_FAILS` | 3 | records in a row that do not open on a confirmed session: it is reset |
| `RMT_BACKOFF_MAX_MS` | 60000 | the reconnect wait doubles from 1 s to this, a fifth either way |
| `RMT_RECYCLE_MS` | 30000 | a stream that lasted this long and the relay ended cleanly is a recycle: reopened at once, the wait reset, no line, no attempt counted, `recycles` raised (`PIC_TEST_RC_RECYCLE_MS` in dev builds) |
| `RMT_SLOW_REOPEN_MS` | 10000 | a stream back longer than this after the last one ended is logged, with how long it took |
| `RMT_JUMP_MS` | 10000 | a tick this late, or the wall clock this far ahead of the monotonic one: a sleep or a stop |
| `RMT_ACK_BYTES`, `RMT_ACK_RECORDS`, `RMT_ACK_MS` | 256 KiB, 128, 5000 | read and not yet acknowledged: past any, a list request carries `Pic-Ack` on its own |

On a jump the loop sets the stream's `kick` (the thread drops the connection at its next byte, or
cuts its wait short) and restamps every lane's queue, so what waited is posted rather than dropped
as 30 s stale. A relay that does not answer at the start is waited for on the same schedule; a
refusal (an HTTP status) ends `pic remote`.

Comments keep the stream within `RMT_IDLE_S` but say only that the connection is open: a relay
can keep commenting on a reader it no longer writes records to (a Worker deploy can leave the old
stream open). So the loop also drops the stream when it has brought no record for `RMT_QUIET_MS`.
While a device with a confirmed session says it is visible (`presence`) that is news, since the
phone pings each minute: it kicks the stream, with a line. Otherwise it sets the stream's `probe`:
the thread drops the connection at its next byte and opens a new one at once, counted as a recycle
and not logged, so a phone that opens after a deploy is heard within `RMT_QUIET_MS` rather than at
the 15-minute reopen. The relay holds what was posted meanwhile, and the new stream resumes from
`Last-Event-ID`. A post that gets no answer at all (not an HTTP status) kicks the stream too, at
most once every `RMT_LOST_MS`. `pic remote status` reports `heardMs`, the last byte from the relay,
rather than the thread's state alone: past `RMT_IDLE_S` and 10 s more it says `silent`. A record that does not open is dropped;
one whose counter was used already (a replay or a duplicate) says nothing against its session, but
`RMT_OPEN_FAILS` others in a row on a confirmed session drop the session and answer a reset, as for
a session pic does not have, so the phone makes a new one.

A job never waits long: each journal it opens gets a busy wait of `RMT_BUSY_MS` (250 ms) instead
of the store's 30 s, so a write another pic holds (a loop round, a running request) fails fast; a
command that needed it is answered `busy` and a follow pass is tried again next tick. A follow pass
reads at most `RMT_PAGE` (200) entries (`pic_follow_pass`'s `max`) and sends a mark after each
page, the rest on the following ticks. A watchdog thread logs a tick that has not ended after
`RMT_STALL_MS` (10 s) with the loop's last phase and how long ago it began (`rmt_doing` names each
step of the loop); the loop logs a job that has run that long as `slow:` with what it is (`answering
NAME's command TYPE`, `following and watching JOURNAL`), and once more when it ends. `pic remote
status` says stalled when the status file, written at least every 5 s while connected, is 5 s
older than that.

Every line `pic remote` writes starts with the UTC time (`rmt_log`). The stream thread logs each
reconnect with its reason (`why`); drops and resets are logged with a count, a kind at most once
every 10 s (`rmt_tally`).

The stream thread counts what it reads (atomics in `rmt_stream`); each tick the loop puts the last
id in `Pic-Ack` on every call it makes, and when none carried it and too much waits, makes one
(`GET /v1/m/M/c`), at most once a second. The relay holds a lane's records until they are
acknowledged, 1 MiB at most, so a phone's image over that would otherwise stall for a minute.

## The reply as it streams

The pic that runs a request publishes each reply's text in
`<journal>.pic-leases/ID.live` (`pic_live_begin`, `pic_live_text`, `pic_live_end` in
`src/store.c`, called around `provider->reply` in `src/loop.c` and from `pic_ev_delta`): the file
is made at the first text with the line `pic-live 1 SEQ` (the journal's last entry when the reply
began), the text is appended as it arrives (thinking is not), and the file is removed when the
reply ends, before it is committed. A new reply is a new file (a new inode); one a dead process
left is removed by the next reply's begin. It is not durable and nothing recovers it.

`pic remote` reads it for each phone whose follow's last mark said a request runs, each tick, at
most every 250 ms, and only when nothing waits on that phone's lane, so a value never queues behind
another. It reads what grew, keeps the last 8 KiB on a character boundary (a character cut off at
the end waits), counts the characters it dropped for `offset`, and sends `live` with the head's
`seq` when the text grew and that `seq` is not behind an event the follow sent. `rev` is one
counter for the process. Because the file goes before the commit and a tick runs the follow pass
before the live read, no value follows the committed reply.

## Notifications

A request is announced when it ends while `pic remote` watches its journal: one admitted when the
journal was first read, or one above the highest id then (`push_cut`), each once (`push_told`).
The check runs when the journal's `data_version` changes, in one read transaction with the move of
`push_cut` to just below the oldest request still admitted. A request that asked no model (no
`pic_generation` row: a command the user ran) or was imported (`import-` key) is not announced.
"Phone-caused" is a request key `rc:...` or an inbox row from `remote:...` delivered into it.

Each device with a subscription gets one push unless its notify or `remote.notify` (read by the
job that finds the request ended, so a change applies to the next one at once) excludes the
request, its confirmed session's last `presence` was visible, a 429 asked it to wait, or its
conversation had one in the last 30 s (per device). The plaintext is built in the loop; a pusher
thread, started at the first push, sends it with `pic_webpush_send` on its own connection and hands
the outcome back, so a slow push service holds up nothing: no transaction, no lane, no request. The
loop applies outcomes: 404 or 410 ends the subscription, as do three 400s or 403s in a row; 429
holds the device for its `Retry-After` (60 s without one, a day at most); 413 sends once more with
the line cut to 40 characters. Nothing else is sent again. At most 32 wait; more are dropped.

## The interface follows its conversation

While none of its own requests runs, the interface keeps `pic attach --from end --format json` on
its conversation and feeds its events to the same handler as its own child's, so a request from
the phone shows. It is killed (SIGKILL: it only reads) before a request starts there, and started
again after from the end, so nothing shows twice. While such a request runs, a line typed goes to it
with `pic send steer` and Esc on an empty editor with `pic send abort`. User message events carry
`origin` (the inbox row's sender, or `remote:DEVICE` for a phone's admitted prompt), which the
interface shows as `from NAME:` using `pic remote devices --json`.

## Every command commits before it answers

| Command | Commit |
|---|---|
| `steer`, `follow_up`, `abort` | an inbox row, key `rc:DEVICE:KEY`, sender `remote:DEVICE` |
| `prompt`, conversation idle | keyed admission (`pic submit KEY`), then `pic run` in a `setsid` child holding the handed-down key (`PIC_KEY_FD`), so the request outlives `pic remote`; images reach the submit as `--images -` on stdin, a temporary file unlinked before the fork |
| `prompt` to `+W` or `+F` with a choice | `provider`/`modelId`, `thinkingLevel` and `credential` checked first (`rmt_fresh_choice`: the models a component lists, the model's levels, `pic_cred_has`), before a folder's journal is made; then the admission above with `--model`, `--thinking` and the run's `--key` |
| any `prompt` that starts a request | the level clamped to the model (`pic_model_thinking_clamp`); with no key or model held, the run's `--key` is the conversation's own (`pic_session_choice`, as `resume_choice` gives `pic ask` its key), refused when that key is gone |
| `get_available_models` and the other journal-free questions to `+W` or `+F` | answered for the model a new conversation there starts on (`rmt_fresh_model`: the workspace's last request's, else the root's `initial_model`); nothing is made |
| `prompt`, request running | the inbox, as a steer would |
| `get_state`, `get_messages`, `get_session_stats`, `get_available_thinking_levels` | answered from the journal (the stats' context estimate by the policy the root hands over; their message counts over the newest 300 entries, their tokens and cost over the whole path from `pic_path_usage`); no row |
| `get_available_models`, `get_commands` | the root's registry through `pic_remote_options.ask`, journal-free (`get_commands` for the conversation's workspace); no row |
| `set_model`, `set_thinking_level` | no row: a choice per conversation in memory (`rmt_choice`, 32 at most), passed as `--model` and `--thinking` to the next `pic submit` and `pic run` there and dropped when that starts; `pic submit` with `--model` records both on the submission, as ask does |
| `set_session_name` | `pic_session_name`, as RPC mode |
| `fork_session` | `pic_fork_point` and `pic_fork` (the source's permission mode copied), the new conversation's origin `phone` and a `pic_fork_key` row (`rc:DEVICE:KEY`, the source, the `at` asked, the fork and its `at`), in one transaction on the job's connection; a resend reads the row |
| `compact` | `pic compact --now ID` in a `setsid` child holding the key, refused while a request runs; its answer is kept with the key (`CMD_DONE`) so a retry gets it again |

Images are checked in `pic remote` first (`pic_image_prepare`), so a bad one is `bad_command`
before anything is spawned. Events carry a person's images as references (`rmt_image_refs`; attach
puts image K at content position K + 1) and `image` answers from `pic_attachment`.

Retrying a key returns the first answer. A kill before the commit means the phone retries; a kill
after it means the retry is recognised: delivered once either way.

## Scrolling back

A `fetch` is one job on the conversation's lane (`rmt_fetchjob`): the seq before the last `limit`
(at most `RMT_PAGE`) entries before `before`, fewer when their bodies (a person's twice, each at
most the 256 KiB an event is elided at) pass `RMT_FETCH_BYTES` (2 MiB), one at least, so one page
never floods its lane; then one pass from there that stops before `before`
(`pic_follow_page`, a follow's pass with an upper bound, kept by no one), its events under the
fetch's key, then the end with the first entry sent and whether any is older. A request that goes
on at `before` is left open, as a capped pass leaves it. The work is the page, whatever the
conversation's length.

Every mark of a follow still carries `earlier`: computed once at the `sync` (`rmt_earlier`), the
seq before the first entry of the oldest of the `RMT_EARLIER` (5) requests that have an entry at or
before where the follow starts. A sync from it shows them and everything after again, for pages
from before `fetch`; the page keeps showing its old entries until that sync's first mark
(`Replica.rewind`).

## The pairing channel

pic deletes the pairing channel P only after the relay says the phone is reading it: `Pic-Peer: 1`
on the post of `paired`, or a peer event that it came back, at most 30 s after posting. When the
relay sends no `Pic-Peer`, 2 s. Deleting sooner loses `paired` for a phone that was reconnecting.

## Pairing from a paired phone

`/rc`'s offer and a phone's share one module (`rmt_offer_*`): the secret, the pairing channel, the
one handshake an offer admits, and the order of the device row, its channel and `paired`. `pic
remote pair` asks the terminal; `pic remote` asks the phone that sent `pair_offer`, and holds at
most one offer (`st->offer`), owned by that device's index. Its pairing channel's stream is a second
stream thread writing to the loop's own pipe; every event is written whole under `rmt_pipe_mu`, and
the loop tells the two streams apart by channel (the mailbox stream's is all zeros). An ended
offer's thread is told to quit and lets go of its heap stream itself (`refs`); its late events name
a channel the loop no longer knows and are dropped. The last word is waited for without blocking the
loop, as above, in `rmt_offer_tick`.

The approval is checked in the loop, never in the thread: from the asking device's confirmed
session, once the new device has sent `pair_ready`, and with its six digits, compared in constant
time. Anything else is `no_offer`, or, for wrong digits, the end of the offer. A device row added
by `pic remote` itself does not change its own `data_version`, so it reads the table again at once.
`unpair_device` and `unpair_all` go through `rmt_unpair_device`, as the terminal's unpair does.

## Tests

- `test/pic/fake_relay.c` is a loopback relay implementing protocol section 6 without limits;
  `test/pic/fake_phone.c` plays the phone with the dev build's initiator. `test/pic/remote.sh` runs
  `pic remote` against them, including kill-and-restart crash cases.
- `test/pic/remote-interop.sh` runs the real Worker from `~/pic-relay` under `wrangler dev` with the
  page's protocol module driven from Node, which also holds a push subscription at a loopback push
  service, watches a slow reply's live text grow and clear when the reply is committed, and gets one
  push that opens with the reply's first line. It is skipped when node, wrangler or the checkout is
  absent.
- `test/pic/remote-soak.sh` kills and restarts the test relay (its mailboxes kept in a state file,
  event ids from the clock, as the Worker's) and `pic remote`, drops the network, silences every
  stream and stops `pic remote` past its idle timeout, under a run of prompts from the phone; then
  each prompt is one request and the phone's copy equals a fresh sync. The replies stream slowly:
  the phone's live values are each the committed reply's text at their offset, rev rises within one
  `pic remote` process and none follows its reply; and the phone's push subscription gets a sealed
  push naming the conversation for all but two of the requests (those ending while `pic remote` is
  killed or stopped may be missed), none announced twice. `remote-interop.sh` ends with
  the same check across a restart of the real Worker.
- `PIC_TEST_PAIR_TTL` (seconds) shortens a pairing offer, and `PIC_TEST_RC_IDLE` (seconds) the dead
  stream's timeout, for tests only. `PIC_TEST_RC_PUSH_HTTP` lets a subscription name the test push
  service on loopback (`test/pic/fake_server.c`), and `PIC_TEST_RC_PUSH_GAP_MS` shortens the 30 s
  between notifications; `fake_phone pushkeys` subscribes and `fake_phone pushread` decrypts a push
  as the browser would.
- The test relay's `/_test/slow?BPS` takes and answers each post to a down lane as over a link of
  BPS bytes a second. `remote.sh` pages back a 5,000-entry conversation through it, a replay from
  `earlier` and five fetches, while a second phone pings every quarter second, each answered within
  a second; checks each page holds exactly the entries before its `before`, a limit over 200 is
  held to 200, entries of 200 KB go about ten a page, a fetch without a key is refused, the first
  page says there is no more, and with no poster thread the loop posts; and, after phone-started requests, that
  `pic remote` has no defunct child.
- `PIC_TEST_RC_JOB_MS="TEXT:MS"` sleeps MS in every job whose name has TEXT (a slow disk),
  `PIC_TEST_RC_JOB_AFTER_MS` the same after the job's work (a worker held up after its commit), and
  `PIC_TEST_RC_SLOW_PHASE` sleeps once in a job as in a loop phase. `remote.sh` queues 200
  commands behind slow jobs and checks that pings are answered within a second, each command once
  and in order, and that a command whose job overruns is answered busy; and has one phone ask
  `get_state` of 20 conversations at once while a second phone's ping and `get_state` are each answered within a
  second (`fake_phone`'s `timed`).