The guardian and its channel
One long-lived process per account, with two duties and no others: it brings the declared instances to their desired state and keeps them there, and it makes an instance that loses its Core lose everything that belonged to it.
- It is not a second supervisor. Restarting a unit is the Core's; the guardian's subject is the Core.
- It belongs to the application form. The service form's one deployment is the init system's.
How it comes to be running
| Started by | When |
|---|---|
| an init unit | when the host comes up — one unit, which reads the records, makes autostart work |
| the manager | on demand, where a verb needs one and nothing answers |
- Either way it is the same process reading the same records.
- It takes a claim,
$XDG_RUNTIME_DIR/yoke/guardian.lock, which the kernel releases when it dies. Two managers racing start one guardian. - It exits when it has nothing left to watch. An instance whose desired state is
runningstill counts while it is failing to start; one the gate refused does not.
What it reads
| It reads | For |
|---|---|
| the instance records | what is declared, what each is pinned to, what should be true now |
manager.conf | every value: the install root, the Core binary, the engine's address and the retention ceiling, the last two handed to the Core it executes |
| the description, through the gate | the deployment's own figures, the restart figures among them |
What it never acquires
The guardian is kept far less likely to wedge than a Core, by rule.
| It does not | Because |
|---|---|
| open an instance's stores | they are the Core's |
| speak an administrative surface | its channel carries nothing about the inside of an instance |
| address the container engine | confinement is a control group's — except in the declared fallback |
| hold anything that can block on a peer | the last supervisor in the chain must be the least likely to need one |
The init system watches the guardian. Where a host is not set up for that, a wedged guardian is not recovered.
Where its own account goes
To its standard error: under an init unit, the host's journal; started by the manager, appended to
$XDG_STATE_HOME/yoke/guardian.log. The file is what a person reads about a night nobody watched; the
channel is how a manager learns why.
The channel
$XDG_RUNTIME_DIR/yoke/guardian.sock, one per account, created by the guardian and reachable by
that account alone. Presence is not availability: a manager connects, and starts a guardian where
nothing answers.
| Message | Direction | Means |
|---|---|---|
| reconcile this record | manager → guardian | look at this one again. It names a record and carries nothing else |
| reconcile everything | manager → guardian | the same, over the set |
| report the set | manager → guardian, answered | what the guardian derived about each instance, and why one is not running |
| subscribe to changes | manager → guardian, a stream | the same, as it changes |
- The authority is in the record, never in the message. There is no start this.
- A message that never arrives costs latency, never correctness: the guardian reconciles every record when it starts.
- It carries nothing about the inside of an instance, and nothing reading needs: which instances exist is a directory listing, and whether one is alive is its claim.
- A message naming a record that does not exist is refused.
- It is not a published surface: one client, in the same account, on a local socket.
The why
| It says | Which the filesystem cannot |
|---|---|
| refused, with the gate's findings | a refusal is not retried and leaves the desired state alone |
| waiting, with the attempt and the wait | the growing wait |
| failing repeatedly | the attempt count, and when it was last reset |
| stopping, or brought back | an expected silence, distinct from a fault |