omp packages

@srobroek/pi-remote-workers1.0.2

Runs leaf agents on Herdr saved machines: machine choice, provisioning, a doctor that compares and updates the machine, and safe worktree cleanup.

GitHub Actions Published 1 day ago Apache-2.0 ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

remote-workers

The pi package @srobroek/pi-remote-workers runs leaf agents on other machines that Herdr has saved, with the machine: placement of pi-subagents. The lead, every orchestrator, landing and the beads ledger stay on the home machine, the one the session runs on. The other machines clone, build, test and push.

Install

pi install npm:@srobroek/pi-remote-workers

The home machine needs herdr, ssh and sh. Each saved machine needs git, pi and pi-subagents at the same versions as home, plus the tools its repositories set up with (mise, uv, pnpm, bun, bd).

The package has no settings of its own and writes none. Machines come from herdr machine list. The repository root on each machine is pi-subagents' own subagents.machines.<label>.cwd. You add that entry yourself; remote_workers_provision returns it as JSON. remote-workers never writes settings.json, so it cannot race pi's own writes. Limits are built-in defaults that only tool arguments change.

What it ships

  • The remote-workers skill: leaves-only placement, choosing machines, one lane per epic per host, provisioning, the doctor before every batch, brokered delegation, the leaf's own worktree, test and push on the machine, landing at home, cleanup, the briefs rule and the beads rules across hosts. Its references/remote-leaf-preamble.md is the text an orchestrator puts at the top of every remote leaf's task.
  • remote_workers_pick: probes the saved machines and picks the one with the most spare CPU.
  • remote_workers_provision: clones or updates a repository on a machine, runs its setup, bootstraps its beads ledger, creates the worktree root, brings the machine's pi gates up to date and returns the subagents.machines entry to add when it is missing.
  • remote_workers_doctor: compares a machine with home and prints JSON, with pass, fail, warn or skip per check. With fix, it updates the machine first.
  • remote_workers_cleanup: removes a landed lane's linked worktree on a machine.

All tools are idempotent and return JSON. A failure names the failing step, for example clone.origin or worktree.dirty, and carries the last lines of the tool output.

How a machine is reached

  • The machine is a profile id or label from herdr machine list --json, selected as pi-subagents and Herdr select it: id first, then a unique label; an ambiguous label is refused. That catalog is the allowlist: a name that is not saved there, a disabled machine and local are refused. No raw ssh target is accepted.
  • The tools run POSIX sh scripts there over ssh with the saved target. They use the same hardening pi-subagents uses for its probes: BatchMode, no password prompts, strict host keys, no agent forwarding and no environment sent. Connect once by hand (ssh <target>) to accept a host key.
  • The scripts run with a fixed PATH: ~/.local/bin, the mise shims, /opt/homebrew/bin, /usr/local/bin and the system directories. Login profiles are not read.
  • Git runs only the https, ssh and file transports (GIT_ALLOW_PROTOCOL), whatever a URL or a url.*.insteadOf rewrite selects. repoUrl must be https://, ssh://, user@host:path, file:// or an absolute path.
  • A probe counts only when it exits 0 and prints its completion marker. A timeout, an ssh failure or cut-off output makes the machine unavailable.

remote_workers_pick

Parameters, all optional: machines (labels; default every enabled saved machine), lanes (lanes already placed, by label), minFreeGiB (default 5), maxLoadPerCpu (default 0.8) and cpusPerLane (default 2). Lane counts are non-negative integers and the limits finite numbers; an invalid value rejects every machine. For each machine it adds the 1-minute load and cpusPerLane for each placed lane plus the new one, divides by the CPU count, and rejects the machine above maxLoadPerCpu or below minFreeGiB. The rest are ranked by spare CPU.

remote_workers_provision

Parameters: machine, repoUrl and optional path (default ~/remote-workers/<repo>). Paths are absolute or start with ~/. The worktree root is always <path>.worktrees.

  1. With no clone at path, it clones repoUrl. With a clone of the same origin, it fetches and fast-forwards the default branch when that is checked out and clean, and otherwise leaves the checkout as it is with a warning. Any other content at path is refused.
  2. It runs the repository's setup: mise trust --yes . and mise install for a mise config, then uv sync, pnpm install --frozen-lockfile and bun install --frozen-lockfile for the lockfiles present (through mise exec when mise ran). When none applies, it runs the executable .remote-workers/setup hook from the clone root, if there is one. Setup runs repository code, so provision only trusted repositories.
  3. With a .beads directory, it runs bd bootstrap --yes and fails when the Dolt remote uses ssh. The beads-setup skill of the beads plugin rewrites it to https.
  4. It creates the worktree root.
  5. It runs the gate step of remote_workers_doctor fix and reports it under gates. ok is false when the gates still differ.
  6. It reads subagents.machines the way pi-subagents' placement does and reports settings. configured means the entry already names the clone. missing or different comes with suggestion, the exact JSON entry to add to pi's user settings or the project's .pi/settings.json. It never writes the file.

remote_workers_doctor

Parameters: machine, optional path, fix, lanes, minFreeGiB, maxLoadPerCpu and cpusPerLane. It runs the same read-only probe on home and on the machine, then compares:

Check Passes when
reach the machine ran the probe
pi pi --version is the same
packages every package of pi list at home is on the machine at the same version (npm) or commit (git)
child-gates both sides report a valid gate plan, and the machine's covers home's: each package at the same version, each extension file with the same sha256, and the child-gates settings key when home has it. An unavailable or invalid plan on either side fails
clone the clone at path is clean, on its default branch and at origin HEAD; skip without path
disk free space at path (or the login directory) is at least minFreeGiB
load the 1-minute load plus lanes placed lanes, per CPU, is at most maxLoadPerCpu
machine-settings warn when the machine has no subagents.machines cwd, with the entry to add, or an entry names a label Herdr has not saved; never fails

ok is true when no check fails.

With fix: true, when the pi, packages or child-gates checks fail, it runs pi update --extensions on the machine, with pi update --self first when the machine's pi is older than home's. Then it probes again and reports fix: updated, the checks that changed (before and after), stillBehind when the machine still differs, and error when the update failed. When only home is behind, nothing runs and fix.homeBehind says to run pi update --extensions and /reload at home. No tool updates home.

The update script checks the host's identity itself, on the same ssh connection, before either pi update. It receives the identity the probe read (host name and machine id from /etc/machine-id, the dbus id or the macOS platform UUID) and home's. It refuses with identity.home when the host is home, as for a saved alias of this host. It refuses with identity.mismatch when the host is not the one probed, and with identity.unknown when any identity cannot be read. Doctor also compares the two probes before it connects again.

The update runs from $HOME with --no-approve, so it reaches user packages only. Project packages that differ are listed in fix.projectDrift; trust the clone and run pi update --extensions in it yourself. Project-only drift runs no update.

The gate plan (stub)

The child-gates check reads the gate plan from the safety plugin's child-gates-plan --json output. That output is still being built, so its shape is an assumption, read only through one adapter (parseGatePlan in pi-src/plan.ts). The probe reports three distinct states: unavailable (no command), invalid (it exited nonzero, or its output is not a plan) and valid, which includes a valid empty plan. The output is sent as hex of its exact bytes and parsed as strict UTF-8 JSON, so nothing is stripped on the way. Only two valid plans can pass. The probe's approximation from the installed child-gates files, their packages and the settings key appears in a failing check's detail as a diagnostic, and never passes the check. Until the safety plugin ships the command, the child-gates check fails.

remote_workers_cleanup

Parameters: machine and worktree. It removes only a linked worktree of the machine's configured clone, subagents.machines.<label>.cwd, read the way pi-subagents' placement reads it: the nearest project .pi/settings.json above the session directory over the user settings, and the first of the requested name, label and id in each file.

  • The worktree root is always <physical clone>.worktrees, derived by the script. It must be a real directory: a symlinked root, or one that resolves anywhere else, is refused.
  • The worktree's physical path, with symlinks resolved, must sit under that root, and its git common directory must be the clone's.
  • The configured cwd itself and any path that resolves to the clone are refused.

It refuses when the clone is not configured or cannot be read, and when any check cannot be made. It removes the worktree with git worktree remove, never with --force. It refuses a main checkout, a path inside a worktree, a worktree with changed or untracked files, and commits that no remote ref holds. A worktree that is already gone reports state: "absent". It leaves the branch in place.

Limits

  • The gate-plan adapter follows an assumed shape until the safety plugin ships child-gates-plan. The authoritative check is child-gates' own attestation at launch.
  • The clone check reads origin HEAD with git ls-remote on the machine, so it needs that machine's credentials for the repository.
  • pi update --extensions moves the machine to the latest package versions, not to home's. A machine that ends up ahead makes home the side that is behind.
  • remote-workers writes no settings. Until you add the subagents.machines entry that provision suggests, placement has no root for the machine and cleanup refuses.
  • The tools do not launch agents. Launching, brokering and landing follow the remote-workers skill.