--- name: jazzhands description: | Use when heavy, parallel or long-running work would load this machine: a slow test suite, a build or eval loop run many times, a benchmark that needs a clean box, or a job that needs another OS (Linux or macOS) — "my laptop is too slow", "run it somewhere with more cores", "on a clean Linux box". Borrows a disposable guest from a Jazzhands lease controller over ssh (`ssh lease@ pools`), runs the work there, copies results back and releases it. Linux leases first, Macs second. --- # jazzhands Jazzhands hands out short leases on disposable VMs ("guests") on spare build machines. A lease is a fresh guest you reach over ssh, keep for minutes to hours, and throw away. The hands usually sit idle while workstations choke: when a job is heavy, borrow one instead of piling it onto the machine you're on. Nobody has to ask you to. ## When to borrow, and when not Borrow when the job is: - **heavy or parallel**: a test suite, build or loop that would saturate local cores for more than a few minutes; - **long**: runs that outlast your patience or your laptop's battery; - **clean-room**: "on a fresh box", a benchmark that local load would skew, an install script to prove from zero; - **another OS**: Linux from a Mac, or macOS from Linux (Mac pools are smaller: try Linux first unless the job needs macOS). Stay local when: - the job takes under a couple of minutes here (lease and sync overhead is about half a minute, more with toolchain setup); - it needs secrets, credentials or customer data: **nothing secret goes into a guest.** No `ssh -A`, no tokens, no `.env`, no private-registry credentials. If the build needs private dependencies, vendor or fetch them locally and sync the result, or stay local; - it needs this machine's hardware, display or local services; - it's bound by something more cores don't speed up: an API's latency or rate limit, a remote service, the network. When only part of a job needs a secret (a few tests that hit a payment sandbox), split it: run the rest in the guest, exclude that part there, and run it locally after. ## Find the controller Use `$JAZZHANDS_CONTROLLER` if set. Otherwise ask the user for the controller's host name; don't guess. Below, `` is that name. If `lease-run` is on `PATH`, prefer it: it automates this loop. Everything below works without it. ```sh C=${JAZZHANDS_CONTROLLER:?ask the user which Jazzhands controller to use} ssh lease@$C pools # human-readable: every pool, its limits, free slots now ssh lease@$C pools --json # one JSON object per line, one line per pool ssh lease@$C help # the verbs (exits 64, as usage does) ``` `pools` shows each pool's guest OS, vCPUs and memory, the longest lease and renewal, the snapshot policy and **how many slots are free now**. Sizes, limits and pools change; read them each time, never hard-code them. In `--json`: `.pool`, `.guests[].os`, `.guests[].cpu`, `.guests[].memoryMiB`, `.maxMinutes`, `.renewMinutes`, `.snapshots` (null when none), `.now.free`. Pick a pool by guest OS first, then by free slots; among equals, leave the pool with the longest leases for jobs that need them. Different pools can share the same machines, so one pool's lease can take another's free slot. ## The loop **Release on every path**, failure included. Run it as one script with a `trap`, or step by step. Step by step, mind that an agent's shell usually doesn't survive between tool calls: keep the state in files (`$W/env` below), source it at each step, and never set a `trap ... EXIT` there, or the lease is released when that one call's shell exits. ### 1. A key for this task alone ```sh C=${JAZZHANDS_CONTROLLER:?or the controller the user named} W=$(mktemp -d); echo "$W" # task dir: key, ssh config, state ssh-keygen -q -t ed25519 -N '' -C "lease-$(basename "$PWD")" -f "$W/key" printf 'C=%s\nW=%s\n' "$C" "$W" > "$W/env" # every later step starts with: . /env ``` Step by step, start each later call with `W=; . "$W/env"`. Never request with your main key (`~/.ssh/id_ed25519.pub`): a long-running tool that leases with the same key can adopt leases made with it. A key made for the task is yours alone, and is thrown away with `$W`. ### 2. Request ```sh . "$W/env" ssh lease@$C request --pool --minutes 60 --wait 5m < "$W/key.pub" > "$W/lease" echo "exit $?"; cat "$W/lease" ``` It prints ` on until