# 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](https://devenv.sh)) and KVM, with `/dev/vhost-vsock` usable by your user. In one terminal: ```sh devenv up # the host side; `devenv up -d` runs it in the background ``` and in another, in the devenv shell: ```sh demo # the agents' VM, on this terminal ``` ## What's in it ```mermaid flowchart TB subgraph agentvm["Agents' VM (demo)"] slop["slop, as agent"] clone["~/repo"] end browser["Browser"] shell["devenv shell:
slop-approve, demo-merge"] subgraph host["Host (devenv up)"] pocket["Pocket ID
localhost:1411"] broker["Broker, with the web app
localhost:8095"] daemon["git daemon"] builder["Builder"] repo[("repo.git")] end subgraph boxvm["Box VM"] sshd["sshd, as box
(nodes web, router, vault, box)"] cache["sshd, as cache
(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 | | Part of the broker | | [Pocket ID](https://pocket-id.org), for approvers to sign in | | `devenv up` (process `pocket-id`) | | Box VM ([`box.nix`](../nix/demo/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`](../nix/demo/agent.nix)), signed in as `agent` | Your terminal | `demo` | | The repository, seeded from [`repo/`](../nix/demo/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`](../nix/demo/settings.nix). The broker's configuration is in [`host.nix`](../nix/demo/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](#the-repository)). - **Approvers:** members of your primary group, through `slop-approve` in the devenv shell, and the Pocket ID user `demo` (in the group `slop-approvers`) through the web app. - **Targets:** the repository's deploy-rs nodes on `master`, `box`, `web`, `router` and `vault`, which all reach the box VM. Only `box` has a profile to deploy. - **Policy:** - The box queries (`slop status`, `slop logs`, `slop failed`) run without asking. - `slop ssh web` asks, and offers leases of 5 minutes or an hour. - `slop ssh router` asks and needs a passkey (`confirm = "passkey"`), so only the web app can approve it. - `slop ssh vault` is denied. - `slop secret keys` runs 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. ## Approving - **Terminal:** `slop-approve` in the devenv shell lists pending requests; answer one with `slop-approve once||deny`. - **Web app:** `demo-sign-in` prints a one-time link that signs in to Pocket ID as `demo`. Add a passkey when Pocket ID asks, then sign in to ; the passkey also approves `router` requests. 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: ```sh slop ssh web -- uptime ` in the devenv shell fast-forwards it to a branch, as a person merging after review. - **The agents' VM** clones it to `~/repo` at login, over `git://`. - The `demo` script forwards `10.0.2.100:9418`, an address only the VM sees, to a `git daemon` on the host for each connection (QEMU's `guestfwd`). - So the VM can fetch and push, and reach nothing else. - **The builder** is reached over SSH, as in a real deployment. - The broker's `ssh` is a wrapper that runs `slop-broker builder` from this checkout's build when the host is `builder`, and the real `ssh` otherwise. - It's named `ssh`, so the broker's `nix copy` and `nix path-info` use it too when they read built paths from the builder's store (`ssh-ng://builder@builder`), which the builder serves as `nix-daemon --stdio`. - The builder fetches from the repository's path and evaluates with the host's Nix. ### Secrets In `~/repo` on the agents' VM: ```sh 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 ` 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`](../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`.