Files
jackos1998andClaude Opus 5.5 4b2c32636e
CI / Check (pull_request) Successful in 5m17s
CI / Check (push) Canceled after 0s
broker: Containers as targets
`slop status`, `logs`, `failed` and `ssh` take `node.container-<name>`,
the name `slop deploy` already takes, so agents can check a container
without asking for `slop ssh` on its host.

- The builder evaluates each node's profile names; its
  `container-<name>` profiles are the containers requests can name.
- Commands run on the node as root through its `sudo`:
  `systemctl --machine`, `journalctl --machine` and, for `ssh`,
  `systemd-run --machine --pipe --wait` with `/bin/sh -l`.
- A container's scope is its node as `target` plus `container`, so
  node rules apply to it while leases stay per target. Rules can
  match `container`.
- Remote commands are now quoted so `fish` reads them as POSIX shells
  do: it treats `\\` and `\'` as escapes inside single quotes.

`PROTOCOL_VERSION` 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 17:28:57 +00:00

111 lines
6.9 KiB
Markdown

# Privileged operations through `slop`
You don't have credentials for other boxes or services. Instead, the `slop` command asks a broker
outside this environment to carry out privileged operations for you. The broker holds the keys,
applies a policy, and asks a human to approve most requests.
## How requests behave
- A request that needs approval blocks while a human answers, for as long as the broker allows:
five minutes by default, but often much longer. `slop` prints how long when it starts waiting
(`approvers have 45m to answer`), and a deploy or build waits that long at each approval. Run
`slop` in the background, or with a tool timeout longer than that. Don't retry a request that
is waiting, denied or expired in a loop; tell the user instead.
- Exit status **125** means the broker did not run the operation: it was denied, expired, invalid
or failed. Any other status is the operation's own.
- Approvers see who sent a request and can see `--label` (or `SLOP_LABEL`). Use it to say briefly
why you need it, e.g. `--label "checking nginx after config change"`.
- Approvers may grant a lease, so repeats of the same request (same target) may run without
waiting. `slop requests` shows your pending requests and leases.
- Anything a command prints ends up in your context and transcript. Avoid printing secrets.
## Commands
| Command | What it does | Approval |
|---|---|---|
| `slop status <node> [unit]` | `systemctl status`, of one unit or the whole box | usually none |
| `slop logs <node> <unit> [-n 200] [--since 2h]` | A unit's journal; `--since` takes a duration or a date (`2026-01-31 12:00`) | usually none |
| `slop failed <node>` | Failed units | usually none |
| `slop ssh <node> -- <command>…` | Any command over SSH, as the node's configured user | asks |
| `slop deploy <node>… [--commit <rev>] [--boot]` | Build a pushed commit and deploy it to all the nodes at once | asks |
| `slop build <attr>… [--commit <rev>]` | Build flake attributes of a pushed commit and push them to the binary cache | asks |
| `slop secret keys\|set\|generate\|rekey\|read <file> …` | Work with an age secret in your checkout | `keys` usually none; others ask |
| `slop requests` | Your pending requests and active leases | none |
- Prefer `status`, `logs` and `failed` to `slop ssh` for looking at a box: they don't wait for a
human.
- Every box command (`status`, `logs`, `failed`, `ssh`) also takes a container instead of a node,
as `<node>.container-<name>` (the name `slop deploy` takes, such as `host.container-web`). It
runs in the container as root, and `slop ssh` runs the command with `/bin/sh -l`. A lease for
the node doesn't cover its containers.
- Every box command also takes `--host <user>@<host> [-p <port>]` instead of a node, for hosts
outside the deploy nodes.
- `--json` prints structured results (such as `slop requests`) as JSON.
- For `slop ssh`, the remote command is joined with spaces and run by the remote login shell, as
with `ssh`. If a box's login shell isn't POSIX (such as `fish`), pipe multi-statement scripts
through `bash`: `slop ssh <node> -- bash -s < script.sh`.
- There is no TTY. Interactive programs won't work; use non-interactive flags (`--no-pager`,
`-y`).
- `slop ssh` reads all of its stdin (unless it's a terminal) before asking, and the approver sees
it with the command. It must be text, and the command and stdin together at most 32 KiB; copy
larger or binary files another way.
### Deploying
- Push the commit first: the broker fetches it from the Git server, not from you, and only finds commits
on a branch. `--commit` defaults to `HEAD` of your checkout (with `jj`, pass the commit).
- A target is a node (all its profiles, like `deploy .#node`) or `node.profile`, such as
`host.container-web`. Several targets deploy in parallel; for an order, deploy them one
at a time.
- Before anything is built, a human approves your use of the builder after seeing your commits
and their diff; that may be covered by a lease from an earlier request. Then the build and the
copy to the nodes happen, their output streaming to you, and the deploy itself waits for
approval. Keep commits focused so the diff is quick to review.
- `--boot` makes it the boot default without switching; the box uses it after its next reboot.
- Check the result afterwards with `slop failed` and `slop status`.
### Building into the binary cache
- `slop build` builds on the broker's box from a pushed commit, like `slop deploy` (including the
approval to use the builder first), and pushes the outputs to the binary cache every box uses.
Use it when boxes or other agents should be able to substitute something instead of building
it, not just to check that something builds: for that, build locally.
- Attributes are dotted flake output paths, such as `packages.x86_64-linux.hello` or
`nixosConfigurations.host.config.system.build.toplevel`; names containing dots can't be built.
- Once pushed, it prints the output paths, one per line.
### Secrets
`slop secret` works with agenix secrets in your checkout: it sends the `.age` file to the broker,
which holds a key that can decrypt it, and writes the new file back. Commit the rewritten file
like any other change.
- `slop secret keys <file>` lists the keys of an env (`.env.age`) or JSON (`.json.age`) secret.
- `slop secret set <file> [KEY] < value` sets one key, or the whole file without `KEY`, to the value
on stdin. Pipe the value from wherever it is; don't put it on the command line.
- `slop secret generate <file> [KEY] --kind password|hex|base64|wireguard|ssh-ed25519|age` has the
broker generate the value, which never reaches you; keypair kinds print the public key.
- `slop secret rekey <file>` re-encrypts to the recipients the rules file lists now, for example
after adding a box to a secret.
- `slop secret read <file>` prints the plaintext. It always asks, so only use it when the task
needs the value itself, and don't print it anywhere else.
- Recipients come from the agenix rules file (`secrets.nix`, found above the file, or `--rules`),
evaluated in your checkout; `-r <key>` overrides them. Approvers see whether they match the
rules on the main branch, so change `secrets.nix` in the same commit as the secret and expect
an approver to look closely at differences.
- A file that doesn't exist yet is created by `set` and `generate`.
## Don't
- Don't try to find, read or copy the broker's credentials, or use deploy tools or keys directly.
They won't work from here, and trying is a policy violation.
- Don't ask for broader access than the task needs.
## Suggest new operations
`slop` grows one operation at a time. If you find yourself working around a missing operation, or
making the same `slop ssh` request (and waiting for approval) again and again for something that
could be a fixed, checkable operation, tell the user. Say what the operation would do, which
arguments it would take, and whether it could run without approval. Don't build the workaround
into a habit instead.