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>
6.6 KiB
AGENTS.md
This file provides guidance to coding agents working in this repository. CLAUDE.md is a symlink to
it — edit AGENTS.md, not the symlink.
Prefer this file over agent memory. When you learn something durable about this repo — a
convention, a workflow gotcha, a design rationale — record it here or in the doc under docs/ that
owns the topic, not in agent memory. This file is versioned and shared; memory is not.
Keep this file lean: rules, workflows, safety constraints and sharp gotchas an agent needs before
starting work. Design and rationale belong in docs/design.md, and how the code is
put together in docs/architecture.md; link to them instead of repeating
them.
Overview
slop-broker runs privileged operations (SSH commands, deploys, builds, and later secrets, DNS and
previews) for coding agents, under a policy and usually after a human approves each one. Agents use
the slop CLI; approvers use slop-approve, Home Assistant notifications or the web app. It's a
Rust crate (one library, the slop-broker and slop binaries) plus NixOS and home-manager modules,
all in this flake.
Its reference deployment is nixfiles, which consumes this flake as an input; box-specific configuration (which box runs the broker, its policies, firewall, secrets and persistence) lives there, not here.
Commands
The development environment is devenv (devenv.nix): direnv with .envrc,
which takes the devenv CLI from the flake's nixpkgs, or devenv shell (without direnv,
nix shell --inputs-from . nixpkgs#devenv provides it). It has the Rust toolchain, the build's
native inputs and git, and lists its scripts on entry. The flake doesn't need devenv: it has the
package, modules, the demo's VMs and the checks. nix develop is a plainer alternative
(devShells.default): the same toolchain, with the native inputs taken from the package, but none
of devenv's scripts, devenv test or the demo's host side.
cargo build,cargo test— the unit and integration tests (tests/).tests/builder.rsneedsgit, which the devenv shell provides.cargo clippy --all-targets— keep it free of warnings.devenv testruns clippy (warnings as errors) and the tests.cargo fmt— the crate is formatted withrustfmt(rustfmt.toml); run it on code you change.nix build— the package, which also runs the tests.vm-test(ornix build -L .#checks.x86_64-linux.vm) — the NixOS VM test of the broker module (needs KVM).- The demo:
devenv up -dstarts the host side (the broker from this checkout, its web app, Pocket ID and the box VM);devenv processes logs <name>shows a process's output anddevenv processes downstops them.demoboots the agents' VM on the terminal and holds it untilpoweroff, so an agent should run it in the background with stdin from a pipe it controls.slop-approvein the devenv shell answers requests, anddemo-boxSSHes into the box VM. Stop the agents' VM withpoweroffon its console or by stopping that background task, not withpkill -f, whose pattern also matches the shell running it. nix fmt— formats Nix withnixpkgs-fmt. Ask before running it on a file you didn't write: some files aren't canonically formatted, and a whole-file reindent buries a logical change.
Nix only sees files Git tracks, so a new file must be added (jj does this when it snapshots;
otherwise git add -N) before nix build can use it.
Conventions
- Prefer
jjfor status, diffs, history, commits, rebases and remote operations; the repository is colocated, so Git tooling works too. Inspectjj status,jj diffandjj logbefore editing, preserve existing changes, and use explicit revisions when rewriting history. - Separate logical steps in code with blank lines, in every language and inside function bodies: a function that gathers its inputs, checks them, acts and reports should read as short paragraphs, not one block. Keep closely related statements together, and leave a blank line before a comment that introduces the next step.
- Comment where it genuinely aids understanding, not for trivial code; match the existing, fairly sparse comment density. When adding something general, comment its general purpose, not the specific change or one-off reason it was introduced for.
- Everything an approver sees comes from agents and must be treated as hostile: pass it through
ops::printable(the web app's templates do both that and HTML escaping; never mark a value|safe). Never let request contents decide what runs beyond what the operation's typed fields allow. - Nix modules use plain
lib.mkOption, options underservices.*(NixOS) andprograms.*(home-manager), and never reference a particular deployment. Runtime secrets are paths outside the Nix store, loaded withLoadCredential. - Commit subjects follow
area: Capitalized summary(e.g.web: Show leases,nix: Add a cache option); aim for 50 characters and do not exceed 72. Hard-wrap commit bodies at 72 characters;-mpreserves unwrapped text, so include literal line breaks or use a file. Checkjj log --no-graph -r <revision> -T descriptionand fix any line over 72 characters before reporting a commit. A short body with the rationale is welcome when the subject isn't enough.Co-Authored-Byis the only trailer used here; don't add session or tooling trailers. - Keep logically distinct (unrelated) changes in separate commits, but one piece of work stays in one commit even when it touches code, modules and docs; split only when a reader would ask why two things arrived together.
Writing
- In prose and commit messages, quote code-like identifiers (commands, options, paths, crate and attribute names) in backticks.
- Keep docs plain — avoid vague filler. Use "layout"/"structure" rather than "shape", and name things directly instead of reaching for umbrella words.
- Use tables for lists of structured items, with the item's name as the link. Break up long prose:
a bullet running past about four lines over several distinct facts becomes a
###subheading with a lead sentence and nested bullets. - Prefer durable concepts and named configuration identifiers over exact numbers that are tunable and likely to drift; describe those by purpose and point at their source.
- Each fact has one home. Update the doc that owns a topic when the code changes it: the design and
its rationale in
docs/design.md, the code's structure indocs/architecture.md, the agents' guide inslop-tools.md(update it with each new operation).