feat(pi-bots): the pi-bots command on Pi Durable's agents' PATH (#9) #18

Manually merged
bryan merged 3 commits from n9-2-pi-bots-command into main 2026-11-10 22:36:52 +00:00
Owner

Piece N9.2 of #9: Pi Durable's services find the bot service's command.

What

  • services.pi-bots installs a pi-bots command in the system profile (services.pi-bots.package, read-only). /run/current-system/sw/bin is already on the PATH of Pi Durable's agents (agentEnvironment in pi-durable.nix), so the SGG service and the sampler find it. Under launchd, notify.pi_bots.cli can name /run/current-system/sw/bin/pi-bots as an absolute path.
  • The wrapper runs the checkout's src/cli.ts on Homebrew's node, as the service's own agent does. It sets PI_BOTS_HOMESERVER and PI_BOTS_STATE_DIR to the service's values unless the caller has set them (an empty value counts as unset). Pi Durable's notifier passes only PATH, HOME and PI_BOTS_*, so it reaches the running service's socket and needs no --homeserver.
  • Documentation: modules/services/AGENTS.md (the pi-bots row), README and a comment in pi-durable.nix.

Not here: switching sgg.json and sampler.json to pi_bots, which is durable-pi-workspace's job.

Tests

python3 scripts/test_pi_bots_service.py (28, 5 of them new, in Command):

  • the package is installed, and the built system profile links bin/pi-bots;
  • the PATH of both Pi Durable agents contains /run/current-system/sw/bin;
  • the built wrapper runs against a stand-in command line, with only PATH and HOME:
    • it gets the service's defaults;
    • the caller's own PI_BOTS_* settings win;
    • empty values fall back to the defaults;
    • arguments pass through unchanged;
    • exit 3 reaches the caller;
  • with the service disabled, nothing is installed.

Each guard was mutated: defaults dropped, export dropped, :- → +x, package not installed, arguments altered, stdin cut off (</dev/null), and exec dropped. Every mutation fails a test. The stand-in echoes its stdin and pid, so the test checks that a Markdown body sent with --file - arrives verbatim and that the command line is the caller's own child (the notifier's SIGKILL on a timeout reaches it).

darwin-rebuild build --flake .#studio builds. With only PATH and HOME set, the built result/sw/bin/pi-bots service status answered from the running service.

scripts/test_pi_durable_module.py has 5 failures. The same 5 fail on main: a Dashy statusName assertion in sampler-off and commissioning-off cases. They are unrelated to this change.

Review

A visible Pi reviewer (Opus 5.5, medium) checked the change against the consumer, notify.ts. It found one should-fix: the tests did not guard stdin passthrough or exec. It also raised two nits: the wording said "every agent's PATH", and the docs did not say the command exists only while services.pi-bots is enabled. All three are fixed. Correction 1 was approved, and the line-wrap nit it raised is fixed too.

Piece N9.2 of #9: Pi Durable's services find the bot service's command. ## What - `services.pi-bots` installs a `pi-bots` command in the system profile (`services.pi-bots.package`, read-only). `/run/current-system/sw/bin` is already on the `PATH` of Pi Durable's agents (`agentEnvironment` in `pi-durable.nix`), so the SGG service and the sampler find it. Under launchd, `notify.pi_bots.cli` can name `/run/current-system/sw/bin/pi-bots` as an absolute path. - The wrapper runs the checkout's `src/cli.ts` on Homebrew's node, as the service's own agent does. It sets `PI_BOTS_HOMESERVER` and `PI_BOTS_STATE_DIR` to the service's values unless the caller has set them (an empty value counts as unset). Pi Durable's notifier passes only `PATH`, `HOME` and `PI_BOTS_*`, so it reaches the running service's socket and needs no `--homeserver`. - Documentation: `modules/services/AGENTS.md` (the pi-bots row), README and a comment in `pi-durable.nix`. Not here: switching `sgg.json` and `sampler.json` to `pi_bots`, which is durable-pi-workspace's job. ## Tests `python3 scripts/test_pi_bots_service.py` (28, 5 of them new, in `Command`): - the package is installed, and the built system profile links `bin/pi-bots`; - the PATH of both Pi Durable agents contains `/run/current-system/sw/bin`; - the built wrapper runs against a stand-in command line, with only `PATH` and `HOME`: - it gets the service's defaults; - the caller's own `PI_BOTS_*` settings win; - empty values fall back to the defaults; - arguments pass through unchanged; - exit 3 reaches the caller; - with the service disabled, nothing is installed. Each guard was mutated: defaults dropped, export dropped, `:-` → `+x`, package not installed, arguments altered, stdin cut off (`</dev/null`), and `exec` dropped. Every mutation fails a test. The stand-in echoes its stdin and pid, so the test checks that a Markdown body sent with `--file -` arrives verbatim and that the command line is the caller's own child (the notifier's SIGKILL on a timeout reaches it). `darwin-rebuild build --flake .#studio` builds. With only `PATH` and `HOME` set, the built `result/sw/bin/pi-bots service status` answered from the running service. `scripts/test_pi_durable_module.py` has 5 failures. The same 5 fail on `main`: a Dashy `statusName` assertion in sampler-off and commissioning-off cases. They are unrelated to this change. ## Review A visible Pi reviewer (Opus 5.5, medium) checked the change against the consumer, `notify.ts`. It found one should-fix: the tests did not guard stdin passthrough or `exec`. It also raised two nits: the wording said "every agent's PATH", and the docs did not say the command exists only while `services.pi-bots` is enabled. All three are fixed. Correction 1 was approved, and the line-wrap nit it raised is fixed too.
services.pi-bots installs a pi-bots wrapper in the system profile
(/run/current-system/sw/bin/pi-bots, already on Pi Durable's agents'
PATH). It runs the checkout's src/cli.ts on Homebrew's node and defaults
PI_BOTS_HOMESERVER and PI_BOTS_STATE_DIR to the service's, so Pi
Durable's notifier, which passes only PATH, HOME and PI_BOTS_*, reaches
the running service and needs no --homeserver.
bryan changed title from feat(pi-bots): the pi-bots command on every agent's PATH for Pi Durable (#9) to feat(pi-bots): the pi-bots command on Pi Durable's agents' PATH (#9) 2026-11-10 22:35:18 +00:00
bryan manually merged commit 4cf9454d39 into main 2026-11-10 22:36:52 +00:00
Sign in to join this conversation.
No reviewers
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bryan/nix-configs!18
No description provided.