docs: Add the design, architecture and agent rules
The design and architecture docs come from nixfiles' `docs/slop-broker.md` and its working notes, rewritten to describe the broker rather than one deployment: roles such as the agents' VM and the broker's box replace box names, and the rollout plan and deployment's agent setup stay in nixfiles. `AGENTS.md` carries over the general rules from nixfiles plus this repository's commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
313c028ad9
commit
1f834df326
5 files changed
+797
No files matched your search
+443
@@ -0,0 +1,443 @@
|
||||
# slop-broker design
|
||||
|
||||
`slop-broker` lets coding agents use credentials they must never hold: deploy and SSH keys, the
|
||||
age identity for secrets, a binary cache and DNS API tokens. Agents send it requests through the
|
||||
`slop` CLI, and it carries out each one under a policy, usually after a human approves it from a
|
||||
terminal, the web app or the phone.
|
||||
|
||||
The usual setup runs agents in a VM (the **agents' VM**) and the broker on the box that hosts it
|
||||
(the **broker's box**), outside the agents' reach. Agents on other boxes can use it too (see
|
||||
[Other requesters and approvers](#other-requesters-and-approvers)). The reference deployment is
|
||||
[nixfiles](https://git.nul.ie/dev/nixfiles), whose `docs/slop-broker.md` describes how its boxes use
|
||||
the broker.
|
||||
|
||||
**Status:** the core, the box queries, `slop ssh`, the SSH transport, deploys, builds, Home
|
||||
Assistant notifications and the approvals web app are implemented. The other operations here are
|
||||
designed but not built yet (see [Planned operations](#planned-operations)). How the code is put
|
||||
together is in [`architecture.md`](architecture.md); the NixOS and home-manager modules are in
|
||||
[`nix/modules`](../nix/modules).
|
||||
|
||||
## Trust model
|
||||
|
||||
- Everything inside the agents' VM is agent-controlled, including root, and so is any other
|
||||
requester. Anything a requester sends is untrusted: commands, file contents, commit IDs,
|
||||
labels and its own descriptions of requests.
|
||||
- The broker holds the credentials and runs every privileged step itself. A credential never
|
||||
reaches a requester. The only exception is an explicit `slop secret read`.
|
||||
- Each requester names a policy, and several requesters can share one. Leases and request
|
||||
limits are still counted per requester.
|
||||
- Each request has a **scope**, which is what an approval covers (for example: deploy `web` at
|
||||
commit X). The broker builds both the scope and the text shown to the approver from validated
|
||||
fields, never from text the agent wrote.
|
||||
- Anything returned to a requester should be treated as published. It ends up in the agent's
|
||||
context, so in the model provider's transcript and in the agent's session logs.
|
||||
- The broker never evaluates agent-written Nix itself. A builder does, as a separate user that only
|
||||
holds a read-only Git key. The broker's privileged half only copies, signs, encrypts or
|
||||
activates the results.
|
||||
- The broker's box should already be trusted with what the broker holds. With deploys, the deploy
|
||||
key is root on every box it reaches, so also giving the broker access to secrets adds little.
|
||||
|
||||
## Transport
|
||||
|
||||
- The agents' VM gets a `vhost-vsock` device with a fixed CID. The broker listens on `AF_VSOCK` on
|
||||
its box, and the kernel-reported peer CID identifies the requester. Nothing the guest sends can
|
||||
change its CID.
|
||||
- Messages are typed Rust enums shared by `slop` and the broker, encoded as CBOR and framed with
|
||||
a length prefix (`tokio-util`'s `LengthDelimitedCodec`). Decoding validates every value (node and
|
||||
unit names, ports and so on) and rejects unknown fields. The request carries a protocol version,
|
||||
so a mismatched `slop` gets a clear error.
|
||||
- One connection carries the request, then the operation's stdin (only after approval, and only
|
||||
for operations that read it), its stdout and stderr, and a final message with the exit status
|
||||
and any structured result. If the connection closes, the broker cancels the request or kills the
|
||||
process it started.
|
||||
- The VM never connects to the broker over the network, so the VM's network can stay isolated
|
||||
from the broker's box.
|
||||
- Local users on the broker's box can be requesters too, identified by UID on a Unix socket.
|
||||
|
||||
### Other requesters and approvers
|
||||
|
||||
Requesters and approvers on other boxes connect with SSH instead of vsock. That reuses `sshd` for
|
||||
authentication and stream handling.
|
||||
|
||||
- They log in as `slop` on the broker's box. Each key has a forced command,
|
||||
`slop-broker remote <requester|approver> <name>`, set from
|
||||
`services.slop-broker.requesters.<name>.sshKeys` or `services.slop-broker.sshApprovers.<name>`.
|
||||
It connects to the broker's remote socket, which only `slop` can use, and tells the broker whose
|
||||
key it is. The broker trusts that the same way it trusts a CID.
|
||||
- A key does one job. The module refuses the same key as both requester and approver, and the
|
||||
client says which job it wants (`ssh … request` or `ssh … approve`), so a key used with the
|
||||
wrong client fails with a clear error.
|
||||
- A requester key only allows making requests, so it's fine for the agents on that box to be able
|
||||
to read it. An approver key must be out of their reach.
|
||||
- Each requester names a policy. The agents' VM is identified by its CID, the others by their
|
||||
key. For example, workstations might share a policy that only allows `dns`, the box queries
|
||||
and `requests`.
|
||||
- `slop` connects to `$SLOP_BROKER`, else `broker` in `~/.config/slop/config.toml`, else vsock;
|
||||
`slop-approve` likewise uses `$SLOP_APPROVE`, else `approve`, else `approve.sock` on the box.
|
||||
An `ssh:<destination>` address goes to `ssh` as is, so a `Host` entry with `IdentitiesOnly` can
|
||||
pick the right key when a box has both kinds. `SLOP_SSH` replaces the `ssh` command, like
|
||||
`GIT_SSH_COMMAND`.
|
||||
- The `programs.slop` home-manager module sets this up: `programs.slop.request` and
|
||||
`programs.slop.approve` each take a key file, and get the `slop-request` and `slop-approve`
|
||||
`Host` entries and the config file pointing at them. A config file rather than session
|
||||
variables, because shells started before a switch don't see new variables.
|
||||
|
||||
## The `slop` CLI
|
||||
|
||||
There is one client command. Every subcommand blocks until the request is answered,
|
||||
then streams the output.
|
||||
|
||||
| Command | Purpose | Suggested policy |
|
||||
|---|---|---|
|
||||
| `slop status <node> [unit]`, `slop logs <node> <unit>`, `slop failed <node>` | Fixed read-only queries on boxes | auto |
|
||||
| `slop ssh <node> -- <cmd>`, `slop ssh --host user@host[:port] -- <cmd>` | Any command over SSH | ask |
|
||||
| `slop deploy <node[.profile]>… [--commit <rev>] [--boot]` | Build a pushed commit and deploy it, to all targets at once | ask |
|
||||
| `slop build <attr>… [--commit <rev>]` | Build flake attributes of a pushed commit and push them to a binary cache | ask |
|
||||
| `slop secret keys\|set\|generate\|rekey\|read …` (planned) | Work with age secrets | `keys` auto, `read` always ask, others ask |
|
||||
| `slop dns list\|set\|delete …` (planned) | Change records in public DNS zones | `list` auto, others ask |
|
||||
| `slop preview <port> [--name n] [--public] [--auth basic\|sso] [--ttl 4h]` (planned) | Publish a dev server | ask |
|
||||
| `slop requests` | Show this requester's pending requests and active leases | always allowed |
|
||||
|
||||
Every request can carry `--label` (agent, repo and a one-line reason). The CLI fills it in
|
||||
automatically where it can. Approvals show it marked as agent-supplied.
|
||||
|
||||
## Approvals and policy
|
||||
|
||||
- Each operation has a policy, configured in Nix: `auto`, `ask` or `deny`, plus the lease lengths
|
||||
it allows (`"5m"`, `"1h"`). The module writes the broker's configuration as TOML. Narrower rules
|
||||
override wider ones, for example per node, per DNS name or per secret path.
|
||||
- Policies are named in `services.slop-broker.policies`, and each requester picks one with
|
||||
`policy`, so several requesters, for example agents on different boxes, can share the same rules.
|
||||
- An `ask` request waits for an answer (`services.slop-broker.timeout`) from the
|
||||
[approvals web app](#approvals-web-app), `slop-approve` (on the broker's box, or over SSH from
|
||||
another box) or a Home Assistant Companion notification. The answers are **once**, a **lease**
|
||||
(the same scope is approved for a while, and only lengths the policy allows are offered) or
|
||||
**deny**.
|
||||
- An operation or rule can also set `confirm = "passkey"`: approving such a request needs a fresh
|
||||
passkey in the web app, so `slop-approve` and Home Assistant can only deny it. Deploys to routers
|
||||
are a typical use.
|
||||
- `auto` operations are rate-limited per requester, so a looping agent can't hammer boxes or APIs.
|
||||
- Pending requests are capped per requester and overall to limit notification spam. If the broker
|
||||
restarts, pending requests and leases are dropped.
|
||||
|
||||
### Home Assistant notifications
|
||||
|
||||
The broker keeps an outbound connection to Home Assistant's
|
||||
[WebSocket API](https://developers.home-assistant.io/docs/api/websocket/) and sends a
|
||||
[Companion actionable notification](https://companion.home-assistant.io/docs/notifications/actionable-notifications/)
|
||||
for each `ask` request.
|
||||
|
||||
- The notification text is built from the scope, followed by the agent's label. Requests that
|
||||
reveal a secret or change recipients are marked.
|
||||
- Notifications are sticky and persistent: tapping one doesn't remove it, and before Android 14 it
|
||||
can't be swiped away either. The broker clears each one once its request is answered, expires or
|
||||
is cancelled. Since Android 14, users can dismiss even persistent notifications, and apps can't
|
||||
prevent it. A dismissed request stays pending until it's answered elsewhere or expires.
|
||||
- A possible fix: the Companion app fires `mobile_app_notification_cleared` when a notification is
|
||||
dismissed. The broker could watch for it and re-post the notification while its request is still
|
||||
pending, on a quiet notification channel so it doesn't alert again. Check first that the event
|
||||
carries the notification's `tag`. The approvals web app (below) makes this matter less.
|
||||
- Action IDs are random and never shown to the VM. A reply must match a live action and the
|
||||
configured `device_id`: the Companion app's own ID, which differs from the device registry's.
|
||||
The broker logs the ID of any answer it ignores, which is how to find it. Home Assistant, and
|
||||
anyone who can fire events on it, is trusted to approve.
|
||||
- If the connection fails, requests stay pending; a failure never approves anything. When the
|
||||
broker reconnects, it reissues pending notifications with new action IDs.
|
||||
|
||||
### Approvals web app
|
||||
|
||||
Phone notifications are easy to lose, and a terminal isn't always at hand. The broker serves a web
|
||||
app (`services.slop-broker.web`, code in [`src/web`](../src/web)) that makes approving reliable, and
|
||||
on a desktop shows what `slop-approve` can only print.
|
||||
|
||||
- **The page is the source of truth.** It lists what's pending with full detail and the active
|
||||
leases, and updates itself, so a dismissed or missed notification costs nothing; a notification
|
||||
only points at its request. Requests that need a passkey are marked, with a padlock on their
|
||||
approve buttons.
|
||||
- **Audit log.** The log page groups the audit file by request: who asked, what, the outcome and
|
||||
who approved it, with filters by requester, operation and outcome and a search. Each request's
|
||||
page shows its full timeline, including the detail approvers saw, so a notification for a
|
||||
request that's since been answered still leads somewhere useful.
|
||||
- **Front end.** Server-rendered HTML that works without JavaScript; a small script refreshes the
|
||||
list and manages notifications, and a service worker shows them. Everything shown passes through
|
||||
the same filter as `slop-approve` for control and bidirectional characters, and a strict content
|
||||
security policy allows only the app's own scripts.
|
||||
|
||||
#### Sign-in
|
||||
|
||||
The web app listens on the broker's box (loopback by default, `web.address`) behind a reverse
|
||||
proxy that terminates TLS; only the proxy should reach it. Approvers sign in through an OpenID
|
||||
Connect provider. [Pocket ID](https://pocket-id.org), which only uses passkeys, is the one it's
|
||||
tested with, and the [demo](demo.md) runs it.
|
||||
|
||||
- **Signing in.** The broker is an OIDC client (`web.clientId`, the `openidconnect` crate, with
|
||||
PKCE), checking the ID token itself rather than trusting a header from the proxy. Only members of
|
||||
`web.group` may sign in: the provider should restrict the client to that group, and the broker
|
||||
checks the token's `groups` claim too.
|
||||
- **Sessions.** A sign-in gives a session cookie (`tower-sessions`) that lasts seven days without
|
||||
use. Sessions are kept in an SQLite database in the broker's state directory, so a restart
|
||||
doesn't sign phones out.
|
||||
Answers are POSTs that need the browser's `Origin` to be the app and the session's token. The
|
||||
audit log names web approvers like `alice (web)`.
|
||||
- **Per-request passkeys, optional.** Approving a request whose policy says
|
||||
`confirm = "passkey"` sends the approver back to the provider with `max_age=0`, which makes it ask
|
||||
for the passkey again. The sign-in remembers the request, the answer and a hash of what was
|
||||
shown; the broker accepts it only if the ID token is the same account's and its `auth_time` is no
|
||||
older than the challenge, and the request hasn't changed. Pocket ID was tested to prompt and
|
||||
return a fresh `auth_time` for both `max_age=0` and `prompt=login`; a provider that doesn't
|
||||
can't confirm these requests. The audit log names these approvers like `alice (web, passkey)`.
|
||||
- **What a session trusts.** Anything that can use the approver's session can answer requests that
|
||||
don't need a fresh passkey, including agents running as that user on a workstation. That's
|
||||
accepted when agents mostly run in the agents' VM; per-request passkeys cover operations where it
|
||||
matters.
|
||||
|
||||
#### Notifications
|
||||
|
||||
The web app sends [Web Push](https://web.dev/articles/push-notifications-overview) notifications to
|
||||
every device an approver turns them on for. Each links to its request; on desktop browsers and
|
||||
Android it also has **Once** and **Deny** buttons (Android shows at most two), which the service
|
||||
worker answers with the session like the page does. Requests that need a passkey only offer
|
||||
**Deny**. The broker clears a notification once its request is answered or expires.
|
||||
|
||||
- **Privacy.** Payloads are encrypted to the browser, so the push service (Google, Mozilla, Apple)
|
||||
sees only timing and size. The broker signs pushes with a VAPID key it creates in its state
|
||||
directory.
|
||||
- **Where it works.** Desktop browsers deliver pushes while the browser is running, with or without
|
||||
the tab. Android delivers them with everything closed. iOS (16.4 and later) only does once the
|
||||
app is added to the Home Screen, and shows no buttons.
|
||||
- **Endpoints.** The broker only accepts subscriptions at the major push services (Google's
|
||||
`fcm.googleapis.com` and `jmt<N>.google.com`, Mozilla, Apple, Microsoft), so a session can't make
|
||||
it send requests elsewhere.
|
||||
|
||||
| Channel | Arrives with the app closed | Action buttons | Who can read it on the way | Needs |
|
||||
|---|---|---|---|---|
|
||||
| Web Push to the web app | Android; desktop while the browser runs; iOS 16.4 and later once added to the Home Screen | Yes, except on iOS | Nobody: the payload is end-to-end encrypted to the browser | An OIDC provider and a reverse proxy |
|
||||
| [Home Assistant Companion](#home-assistant-notifications) | Yes | Yes | Google: pushes go through Firebase Cloud Messaging, encrypted only in transit, except with Local Push while the app holds its own connection to Home Assistant | Home Assistant |
|
||||
|
||||
### Audit log
|
||||
|
||||
Each request, decision, approver, lease use and result is an event with the request's ID. The
|
||||
broker writes it to the journal as a line of text and to `audit.jsonl` in its state directory as a
|
||||
line of JSON. `slop-approve log [-n 50] [--json]` shows the recent events through the approve
|
||||
socket, with each request's full detail. Secret operations will record the file and a hash of the
|
||||
ciphertext before and after, never values.
|
||||
|
||||
## Operations
|
||||
|
||||
### Box queries and SSH
|
||||
|
||||
- Targets are named in trusted config (`services.slop-broker.ssh.targets`), normally the
|
||||
deployment's deploy-rs nodes. `--host` covers boxes outside them (OpenWrt, switches) with an
|
||||
explicit `user@host` and port.
|
||||
- SSH runs with options fixed by the broker: `-F none`, the key with `IdentitiesOnly`, no agent,
|
||||
`BatchMode`, no forwarding or local commands, and the broker's own `known_hosts`.
|
||||
- `ssh` joins its arguments into a string that the remote shell runs. Because of that, a
|
||||
free-form command's text can't be judged as read-only, so `slop ssh` should always be `ask`.
|
||||
- The fixed queries (`status`, `logs`, `failed`) validate their arguments (unit names, `--since`,
|
||||
line counts), and the broker builds the quoted remote command. That makes them safe to run as
|
||||
`auto`, which covers most of what agents need SSH for without prompting.
|
||||
|
||||
### Deploys
|
||||
|
||||
`slop deploy <target>… [--commit <rev>] [--boot]` deploys a pushed commit of a
|
||||
[deploy-rs](https://github.com/serokell/deploy-rs) flake to one or more targets, each a node (all
|
||||
its profiles, like `deploy .#node`) or `node.profile` (such as `host.container-web`). The client
|
||||
resolves `--commit` (default `HEAD`) to a full ID in its checkout.
|
||||
|
||||
1. **Describe, then approve use of the builder.** The broker runs the builder over SSH. The
|
||||
builder is a user without keys, `slop-broker-build`, whose key's forced command is
|
||||
`slop-broker builder` ([`services.slop-broker-builder`](../nix/modules/nixos/builder.nix)).
|
||||
It fetches every branch from the Git server with a read-only key, so the agent never supplies
|
||||
the source, and refuses commits that aren't on a branch. This first stage runs only Git: it
|
||||
returns the commits since the main branch, their diffstat and their diff. Evaluation runs
|
||||
agent-written Nix, so it waits for a separate `builder` request to be approved, which shows
|
||||
those. Its scope is empty, so a lease lets the agent build any commit for a while; rules see
|
||||
the `commit`, `on_branch` (whether it's already on the main branch) and `for` (`deploy` or
|
||||
`build`).
|
||||
2. **Build.** The builder evaluates the targets' deploy-rs profiles and builds them with the box's
|
||||
Nix daemon. Only `git` gets the repository key, never the evaluator. Build logs stream to the
|
||||
agent. One build runs at a time.
|
||||
3. **Compare, before approval.** The broker copies the closures to each node, as deploy-rs does
|
||||
(nodes substitute what the caches have; progress streams to the agent), and runs a fixed
|
||||
read-only script on the node that compares each profile with the one installed. Nothing runs as
|
||||
root, and no agent-written code runs.
|
||||
4. **Approve.** One approval covers every target, the commit and the mode. Policy rules see one
|
||||
scope per target (`node`, `profile`, `mode`, `commit`), and the strictest answer applies, so
|
||||
for example a rule can allow routers only `boot`.
|
||||
5. **Activate, once approved.** On every node at once, the broker runs deploy-rs's `activate-rs`
|
||||
on each profile in deploy-rs's order, as root through the target's `sudo` command (`sudo -u` by
|
||||
default), inside a transient unit (`systemd-run`). The activation therefore finishes even if the
|
||||
connection drops, including when the broker deploys its own box and restarts. Output comes back
|
||||
prefixed with the node. Deploys run in parallel; an agent that needs an order sends separate
|
||||
requests.
|
||||
|
||||
There is no magic rollback, unlike deploy-rs from a workstation. `--boot` makes the new
|
||||
configuration the boot default without switching to it. Activation, including `dry-activate`, runs
|
||||
the new system's own code as root, so none of it happens before approval.
|
||||
|
||||
#### Approval contents
|
||||
|
||||
Package versions come from `nix store diff-closures`. Configuration changes come from comparing
|
||||
the two profiles' `etc` trees, whose entries are links into the store: changed, added and removed
|
||||
systemd units (drop-ins count as their unit) and `/etc` files. That approximates what activation
|
||||
will restart without running anything. A kernel or initrd change is called out because it needs a
|
||||
reboot. The commit messages and diffstat are Git's, from the commits since the main branch. The
|
||||
full view, in `slop-approve show <id>` or the web app, looks like this:
|
||||
|
||||
```text
|
||||
deploy hub (switch) at 3f9c2e1a8b0c
|
||||
Commit 3f9c2e1a8b0c4d…
|
||||
Commits:
|
||||
3f9c2e1 nixos/hub: Update Home Assistant
|
||||
8a1b7d0 nixos/hass: Add Zigbee coordinator
|
||||
nixos/boxes/hub/containers/hass.nix | 14 +++++++++-----
|
||||
1 file changed, 9 insertions(+), 5 deletions(-)
|
||||
hub.system (switch):
|
||||
packages: no version changes
|
||||
changed units: container@hass.service
|
||||
hub.container-hass (switch):
|
||||
packages:
|
||||
home-assistant: 2026.11.1 → 2026.11.2, +3.4 MiB
|
||||
python3.13-zha: 0.0.71 → 0.0.72
|
||||
changed units: home-assistant.service
|
||||
changed files: /etc/hass/configuration.yaml
|
||||
```
|
||||
|
||||
The phone notification carries only the first line and the label. It isn't the place to review a
|
||||
large deploy. For those, approve from the web app or a terminal.
|
||||
|
||||
### Binary cache
|
||||
|
||||
Anything in a cache's store is signed and trusted by every box that uses it. A path built inside
|
||||
the agents' VM proves nothing, because the agent could upload a different output under the hash of
|
||||
a real derivation. So the cache is filled only from builds done by the builder (`slop build`):
|
||||
|
||||
- `slop build <attr>… [--commit <rev>]` works like a deploy up to approval: once use of the
|
||||
builder is approved, it builds the flake attributes, and the `build` request shows the commits
|
||||
and each output with its closure size. The `builder` approval is where a person reviews the
|
||||
source; a policy can then let `build` push without asking again.
|
||||
- Once approved, the broker pushes the outputs with `nix copy --to ssh-ng://` as the store's owner
|
||||
(`services.slop-broker.cache`). That key's forced command
|
||||
([`services.slop-broker-cache`](../nix/modules/nixos/cache.nix)) allows only `nix-daemon --stdio`
|
||||
on the cache's store and `root <path>…`, which adds GC roots under `gcroots/slop-broker`.
|
||||
- The broker adds the roots before copying, so a garbage collection in that store can't take the
|
||||
paths mid-copy. A daily timer removes roots `keepDays` after their path was last pushed
|
||||
(`services.slop-broker-cache`), and the store's next collection takes the paths: agent builds are
|
||||
for sharing for a while, not for keeping.
|
||||
|
||||
## Planned operations
|
||||
|
||||
### Secrets
|
||||
|
||||
The broker gets its own age identity, added as a recipient of the secrets it may handle (next to
|
||||
the people's keys), so no person's key goes to the broker's box. Adding it to an existing
|
||||
repository needs one full rekey.
|
||||
|
||||
The agent sends the current `.age` file with each request, and the broker returns new ciphertext.
|
||||
The broker never writes to a checkout.
|
||||
|
||||
| Command | Result | Value enters VM? |
|
||||
|---|---|---|
|
||||
| `keys <file>` | Key names of an env, JSON or YAML secret | No |
|
||||
| `set <file> <key>` (value on stdin) | That field replaced, re-encrypted | Only what the agent sent |
|
||||
| `set <file> --whole` | Whole file replaced | Only what the agent sent |
|
||||
| `generate <file> <key> --type password\|hex\|base64\|wireguard\|ssh-ed25519\|age` | Value created by the broker; keypair types return the public half | No |
|
||||
| `rekey <file> -r <recipient>…` | Re-encrypted to the given recipients | No |
|
||||
| `read <file>` | Plaintext | Yes, so always `ask`, never leased |
|
||||
|
||||
- The requester lists the recipients. The broker names each one from a trusted list of known keys
|
||||
(such as host keys and people's keys on the main branch), and shows changes from the file's
|
||||
current recipients. An unknown key is flagged in the approval. This avoids evaluating
|
||||
agent-written Nix just to get a recipient list.
|
||||
- Encrypting to new recipients is done offline (`rage -r`) and needs no broker.
|
||||
- The operations work for any repository that uses age files with the broker as a recipient.
|
||||
|
||||
### DNS
|
||||
|
||||
For public zones that are edited through a provider's API rather than from Nix config. Zones that
|
||||
come from Nix config are changed with commits and deploys instead. Cloudflare is the first
|
||||
provider.
|
||||
|
||||
- `slop dns list <zone> [name]` shows the live records. `slop dns set <name> <type> <value>…
|
||||
[--ttl] [--proxied]` replaces the record set for that name and type, and `slop dns delete <name>
|
||||
<type>` removes it.
|
||||
- The approval shows the record set before and after, read live from the provider. Leases are
|
||||
scoped by name and type.
|
||||
- The broker uses its own API token, limited to DNS edits in the allowed zones and separate from
|
||||
any other automation's tokens.
|
||||
- Policy denies zone apexes, `NS`, `MX` and `_acme-challenge` names by default. Records the broker
|
||||
creates get a record comment, so the approval can say whether an agent is changing one of its own
|
||||
records or an existing one.
|
||||
|
||||
### Previews
|
||||
|
||||
`slop preview 5173 [--name foo] [--public] [--auth basic|sso] [--ttl 4h]` publishes a dev server
|
||||
in the agents' VM under a wildcard domain until its TTL expires.
|
||||
|
||||
- A reverse proxy serves the wildcard domain with a wildcard certificate and proxies to the broker.
|
||||
The broker looks up the host in its active previews and connects to the guest port over vsock.
|
||||
The VM still accepts no inbound connections.
|
||||
|
||||
#### Access
|
||||
|
||||
The hostname and the authentication are chosen separately.
|
||||
|
||||
- **Secret URL (default):** the hostname is an unguessable label, for example
|
||||
`foo-<26 base32 characters>.<domain>`, which is 128 random bits after the optional name.
|
||||
Because DNS and the certificate are wildcards, the name never appears in the zone or in
|
||||
Certificate Transparency logs. Unknown hostnames get the same 404 as expired ones. Responses
|
||||
carry `Referrer-Policy: no-referrer` and `X-Robots-Tag: noindex`.
|
||||
- **`--public`:** the hostname is just the name (`foo.<domain>`). Without `--auth` this is a fully
|
||||
public site. Public names are never leased, so each one needs its own approval.
|
||||
- **`--auth basic`:** adds basic auth with a generated password. It's shown in the approval and
|
||||
returned to the agent, which needs it to test the page and controls the content anyway.
|
||||
- **`--auth sso`:** adds the proxy's existing single sign-on.
|
||||
- The secret URL still leaks through browser history, shared links and resolver logs. Use an auth
|
||||
option for anything that matters.
|
||||
- If the preview domain is a subdomain of other services' domain, preview pages are same-site with
|
||||
them: they can set cookies on the parent domain, and browsers send `SameSite=Lax` cookies
|
||||
(including an SSO session) with their requests to those services. A separate registrable domain
|
||||
avoids this.
|
||||
|
||||
### TCP forwards and a cache for VM builds
|
||||
|
||||
- **TCP forwards:** time-limited access from the VM to one internal `host:port` (for example a
|
||||
database), approved per destination.
|
||||
- **VM-built paths:** a separate store with its own signing key, trusted only by the agents' VM and
|
||||
by boxes that opt in. Useful for sharing agent build artifacts or keeping them across VM
|
||||
rebuilds.
|
||||
|
||||
Both wait until a concrete need comes up.
|
||||
|
||||
## Agent-facing docs
|
||||
|
||||
- **Agent context:** the package ships [`slop-tools.md`](../slop-tools.md), which describes the
|
||||
`slop` CLI and how requests behave (they block while waiting for approval, so no retrying in a
|
||||
loop). `slop guide` prints it, and it's installed as `share/slop-broker/slop-tools.md` for
|
||||
deployments to add to their agents' rules. Update the guide with each new operation. It asks
|
||||
agents to suggest new operations when they would otherwise work around a missing one or keep
|
||||
asking for the same `slop ssh` approval.
|
||||
- **Agent permissions:** the broker is the gate, so an agent's own permission prompt for `slop`
|
||||
would only ask twice; allow `slop` and keep denying direct use of deploy tools and keys.
|
||||
- **Deployment docs:** deployment-specific notes (which nodes exist, their login shells, where the
|
||||
Git server is) belong in the deployment's own agent rules.
|
||||
|
||||
## Scope
|
||||
|
||||
- **Out of scope for now:** secret tools other than age (such as `sops`), and a general
|
||||
credential proxy for other APIs (forges, package registries). Agents keep using deploy keys of
|
||||
their own for pushing. If more API operations are needed later, add them one at a time like
|
||||
`dns`.
|
||||
|
||||
## Tests
|
||||
|
||||
- **Unit and integration tests** cover the protocol, policy, approvals, leases, SSH execution
|
||||
against a fake `ssh`, the builder against a local Git repository, and the web app's pieces. They
|
||||
run in the package build, or in the devenv shell with `cargo test` (`devenv test` adds clippy).
|
||||
- **VM test** ([`vm-test.nix`](../nix/vm-test.nix)): a minimal system running the broker through
|
||||
the `services.slop-broker` module, with its real service hardening, over vsock loopback, against
|
||||
a local `sshd`. Run it after changing the module, the service or the transport (it needs KVM):
|
||||
`vm-test` in the devenv shell, or `nix build -L .#checks.x86_64-linux.vm`.
|
||||
- **Demo** ([`demo.md`](demo.md)): not a test, but the quickest way to try the web app and
|
||||
passkey approvals by hand.
|
||||
- New operations add tests against fakes of what they call (deploy-rs, the DNS provider's API).
|
||||
Reference in new issue
Block a user