The box VM holds the cache's store in a `cache` account, set up by `services.slop-broker-cache`, and the demo's broker pushes to it, so `slop build` can be tried by hand. The broker's key is only known at boot, so the module exposes its forced command for keys it can't list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9.6 KiB
Demo
A setup for trying the broker by hand, laid out like a real deployment: the broker runs on the host,
the agents are in a VM that reaches it only over vsock, its SSH targets are another VM, and the
agent works in a clone of a Git repository whose main branch it can't push to. Paseo and real
coding agents are out of scope: you type the agent's slop commands yourself.
It needs the devenv shell (direnv with .envrc, which provides devenv) and
KVM, with /dev/vhost-vsock usable by your user. In one terminal:
devenv up # the host side; `devenv up -d` runs it in the background
and in another, in the devenv shell:
demo # the agents' VM, on this terminal
What's in it
flowchart TB
subgraph agentvm["Agents' VM (demo)"]
slop["slop, as agent"]
clone["~/repo"]
end
browser["Browser"]
shell["devenv shell:<br>slop-approve, demo-merge"]
subgraph host["Host (devenv up)"]
pocket["Pocket ID<br>localhost:1411"]
broker["Broker, with the web app<br>localhost:8095"]
daemon["git daemon"]
builder["Builder"]
repo[("repo.git")]
end
subgraph boxvm["Box VM"]
sshd["sshd, as box<br>(nodes web, router, vault, box)"]
cache["sshd, as cache<br>(the binary cache's store)"]
end
slop -- "vsock" --> broker
clone -- "git://, through guestfwd" --> daemon --> repo
browser -- "sign in" --> pocket
browser --> broker
shell -- "approve.sock" --> broker
shell -- "moves master" --> repo
broker -- "SSH, through a wrapper" --> builder -- "fetches" --> repo
broker -- "SSH, localhost:2222" --> sshd
broker -- "SSH, localhost:2222" --> cache
| Part | Where | Runs |
|---|---|---|
Broker, from this checkout (cargo run) |
Host | devenv up (process slop-broker) |
| Web app | http://localhost:8095 | Part of the broker |
| Pocket ID, for approvers to sign in | http://localhost:1411 | devenv up (process pocket-id) |
Box VM (box.nix): sshd for the targets, the deploy target and the binary cache |
localhost:2222, as box, and as cache for the cache |
devenv up (process box) |
Agents' VM (agent.nix), signed in as agent |
Your terminal | demo |
The repository, seeded from repo/ |
.devenv/state/slop-demo/git/repo.git |
git daemon, one per connection from the agents' VM |
The builder (slop-broker builder, from this checkout) |
Host | The broker, through its ssh |
The ports are on the host's loopback, so they must be free there; they and the agents' VM's vsock
CID are in settings.nix. The broker's configuration is in
host.nix, the devenv module with the demo's host side:
- Requester:
agent, the agents' VM's vsock CID. The VMs have no network beyond their forwarded ports, and only vsock and Git link the agents' VM to the host (see the repository). - Approvers: members of your primary group, through
slop-approvein the devenv shell, and the Pocket ID userdemo(in the groupslop-approvers) through the web app. - Targets: the repository's deploy-rs nodes on
master,box,web,routerandvault, which all reach the box VM. Onlyboxhas a profile to deploy. - Policy:
- The box queries (
slop status,slop logs,slop failed) run without asking. slop ssh webasks, and offers leases of 5 minutes or an hour.slop ssh routerasks and needs a passkey (confirm = "passkey"), so only the web app can approve it.slop ssh vaultis denied.slop secret keysruns without asking; the other secret requests ask, with a 5-minute lease, except reading, which asks every time.- Using the builder asks, with leases, except for commits already on
master; deploys and builds into the binary cache ask, with a 5-minute lease.
- The box queries (
Approving
- Terminal:
slop-approvein the devenv shell lists pending requests; answer one withslop-approve <id> once|<lease>|deny. - Web app:
demo-sign-inprints a one-time link that signs in to Pocket ID asdemo. Add a passkey when Pocket ID asks, then sign in to http://localhost:8095; the passkey also approvesrouterrequests. Web Push works when the broker can reach the browser's push service.
A request blocks until it's answered, and slop ssh reads stdin to its end before asking. To keep
the agent's shell, run requests in the background with stdin closed:
slop ssh web -- uptime </dev/null &
The repository
devenv up seeds a bare repository once, committed to master as Dev.
- From
nix/demo/repo:flake.nix, with the deploy-rs nodes and thedemoprofile (see Deploys). - Generated: age keys for the demo person and the broker (
dev-age.keyandbroker-age.keyin the state directory; the broker's approvals call the firstdev), and secrets encrypted to both:secrets.nix, the agenix rules;secrets/app.env.age, withDB_USERandDB_PASSWORD;secrets/wg.key.age, a WireGuard key, as a whole file.
- Protected
master: apre-receivehook refuses pushes to it, standing in for branch protection.demo-merge <branch>in the devenv shell fast-forwards it to a branch, as a person merging after review. - The agents' VM clones it to
~/repoat login, overgit://.- The
demoscript forwards10.0.2.100:9418, an address only the VM sees, to agit daemonon the host for each connection (QEMU'sguestfwd). - So the VM can fetch and push, and reach nothing else.
- The
- The builder is reached over SSH, as in a real deployment.
- The broker's
sshis a wrapper that runsslop-broker builderfrom this checkout's build when the host isbuilder, and the realsshotherwise. - It's named
ssh, so the broker'snix copyandnix path-infouse it too when they read built paths from the builder's store (ssh-ng://builder@builder), which the builder serves asnix-daemon --stdio. - The builder fetches from the repository's path and evaluates with the host's Nix.
- The broker's
Secrets
In ~/repo on the agents' VM:
slop secret keys secrets/app.env.age # runs without asking
echo hunter2 | slop secret set secrets/app.env.age DB_PASSWORD
slop secret generate secrets/wg.key.age --kind wireguard # prints the public key
cp secrets/app.env.age secrets/notes.age
slop secret read secrets/notes.age </dev/null & # flagged: it's secrets/app.env.age
git switch -c secrets && git commit -am "Rotate secrets" && git push origin secrets
git push origin master is refused. On the host, demo-merge secrets moves master, after which
approvals show the new files as on master. To check a value as the demo person:
rage -d -i .devenv/state/slop-demo/dev-age.key <(git -C .devenv/state/slop-demo/git/repo.git show master:secrets/app.env.age)
Deploys
The repository's flake.nix has a deploy-rs node, box, with one profile, demo, deployed as
root: a small app whose activation writes its version to /run/demo/version. Its nixpkgs is
locked to this repository's, so the builder has it already, and it uses nixpkgs' build of
deploy-rs, so a build takes moments. In ~/repo on the agents' VM:
sed -i 's/version = "1.0"/version = "1.1"/' flake.nix
git switch -c bump && git commit -am "Bump the app" && git push origin bump
slop deploy box </dev/null &
The first request is to use the builder, showing the commits and the diff since master. Once
it's approved, the builder builds the profile, the broker copies it to the box VM and compares it
with what's there, and the deploy request shows the package changes (the first deploy shows a new
profile). demo-box cat /run/demo/version on the host shows what's active.
The box VM lets box use sudo without a password and copy unsigned paths into its store, which
lives in memory, like everything else in the VMs.
The binary cache
The box VM holds the binary cache's store, at /var/lib/slop-cache, owned by its cache
account, as services.slop-broker-cache sets it up: the
broker's key may only run nix-daemon --stdio on that store and add GC roots. Nothing serves it
to other boxes; it's for seeing what slop build pushes. In ~/repo on the agents' VM:
slop build packages.x86_64-linux.default </dev/null &
As with a deploy, the builder's use is approved first (or covered by a lease), then the build request shows the outputs and their closure sizes, and once approved the broker pushes them and prints their paths. To see them on the host:
demo-box ls /var/lib/slop-cache/nix/var/nix/gcroots/slop-broker
The box VM
demo-box in the devenv shell logs in to the box VM as box, with the broker's key, to see what
approved commands did; demo-box <command> runs one command there. Its console output is in
devenv processes logs box.
State
The VMs keep nothing: poweroff (or Ctrl-A X) stops the agents' VM, and each boot starts from
scratch. The host side keeps its state in .devenv/state/slop-demo between runs: Pocket ID's
database (so passkeys survive), the keys, the repository and the builder's mirror, the audit log
and the web app's sessions. demo-reset
deletes it while devenv up isn't running; the next devenv up sets Pocket ID up again and seeds
a new repository. The repository is seeded only once, so after changing
nix/demo/repo, reset (or delete git, builder and the *-age.* keys in the
state directory) to use the new version.
If the broker doesn't start, read devenv processes logs slop-broker, and the setup's output in
devenv up.