Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
ADR 0292: SSH bootstrap for remote hosts
- Status: Accepted for implementation
- Date: 2026-09-19
- Decision: D453
- Related: ADR 0205 (D373 / D374 / D375), ADR 0285 (D448), ADR 0286 (D449),
02-architecture/05-remote-agent-control.md§5.2,05-security/02-remote-control-security.md§3.4,06-delivery/07-remote-control-rollout.md§2 R2b - Amendments: ADR 0293 permits secure SSH password handling; ADR 0326 supersedes the executable-upload prohibition, remote-only download prerequisite and daily bootstrap lifecycle below.
This record describes the original bootstrap decision, not the current candidate
installation contract. ADR 0326 permits a verified release upload only after
download-failed, bundles matching Node, and separates daily startup from pairing;
the constraints below remain context for that amendment.
Context
ADR 0286 left bootstrap out of scope: every paired host assumed the loopback URL
already existed, so reaching another machine meant installing pi-host by hand,
opening ssh -L, and pasting the URL and pairing token into Settings. R2's exit
criteria do not accept that (rollout §2 R2b, security §3.4). The desktop must
install and pair a host on a machine the user already reaches over SSH while never
uploading executable bytes and never holding an SSH secret. Three properties shaped
the design: the release publishes pi-host-<version>-<platform>-<arch>.tar.gz with
a .sha256 for Linux targets only; a bootstrapped host has no stable URL because the
forward's local port is chosen per launch; and bootstrap/remote-hosts.ts already
owns every host's lifecycle.
Decision
- The system
sshclient is the transport. It keeps~/.ssh/config, the agent, jump hosts, andknown_hostsin force and leaves the app holding no secret.BatchMode=yesfails an interactive-password host immediately with a typed error instead of hanging a hidden prompt, andStrictHostKeyChecking=accept-new,ConnectTimeout=15, andExitOnForwardFailure=yesare always set. - Pure release coordinates (
pi-host-release.ts). The artifact resolves for the remote platform at the desktop's version, and the published SHA-256 is the trust anchor.PUBLISHED_TARGETS(linux-x64,linux-arm64) refuses other targets withHOST_BOOTSTRAP_FAILEDbefore a download. URL derivation,unameparsing, checksum parsing, digest comparison, and version parity are pure. - One script runs remotely (
pi-host-bootstrap-script.ts). It downloads the pinned URL, verifies the digest, installs under$HOME/.pi-desktop/pi-host, (re)starts the host on loopback with--pair, and echoesPI_HOST_READY/PI_HOST_PAIRING_TOKENunderumask 077, so the single-use token exists only in a work file and on stdout. Failures exit non-zero afterPI_HOST_BOOTSTRAP_FAILED <step>, and every input is quoted byshellQuote. ssh-transport.tsis a port, not a dependency.exec/execWithInput/forward/disposeallow tests against a fake, withcreateSystemSshTransportthe only spawning implementation.execWithInputpipes the script intosh -s, andassertSshArgumentrefuses empty values or those starting with-.- Forwards are durable and owned (
ssh-tunnel.ts). The record stores the SSH descriptor, not a URL; the manager reserves a loopback port, runsssh -N -L 127.0.0.1:<local>:127.0.0.1:<remotePort>, and derivesws://127.0.0.1:<port>/v1/racp/wsper launch. The bootstrap's own forward is adopted rather than reopened, and a forward counts as ready only once its local port accepts a connection. - Version parity is checked before a forward exists. A
PI_HOST_READY.versionmismatch raisesHOST_VERSION_MISMATCH(D375) and the desktop tears down the SSH processes it spawned. - The registry keeps a descriptor:
metadata.transport = "ssh"plusmetadata.ssh(host, optional port / user / identity file,remotePort,version). Becauseremote-hosts.jsonis user-editable it is re-validated on every read, degrading to "not an SSH host" rather than spawningsshwith garbage, and records withouttransportread asdirect. - One IPC channel and one pairing exchange.
pi-desktop/remoteHost/bootstrapjoinslist/pair/removeand carries a host, never a credential.connection/pairwas factored intoexchangePairingToken, shared with the pasted-URL path and closing its throwaway connection on every path;bootstrapHostadopts the forward before persisting the record.
Consequences
- No SSH secret is stored, prompted for, or transmitted, and no executable bytes
travel over the channel: the remote script downloads the bundle and the desktop
sends only script text on stdin.
pi-hostkeeps binding loopback only, and the renderer stays transport-agnostic withRemoteHostSummary.transportas a label. remote-hosts.jsongains a second record shape and stays backward compatible. The desktop now spawnssshprocesses, visible to endpoint-security tooling, and the newsettings.remoteHostsi18n keys must be translated in every shipped locale. No SSH library, HTTP client, or archive tool entersapps/desktop.- A failed bootstrap leaves nothing running, an empty registry is a no-op, and a machine without outbound GitHub access still cannot be bootstrapped (D375).
Out of scope
- Terminal work-panel client (Stage 5) and reverse tool relay (Stage 6)
remain unbuilt, and
resync.requiredevents are still dropped. - Provider configuration over SSH needs host-side schema work, so a freshly
bootstrapped host still fails
turn/startclosed withMODEL_NOT_CONFIGURED. - Non-Linux remote targets are refused before a download starts, since only
linux-x64andlinux-arm64are published (D638 / ADR 0318).
Alternatives
- An
ssh2-style library: re-implements config, agent, and jump-host semantics and asks users to re-enter credentials the app should never hold. - Download on the desktop and upload: rejected by security §3.4.
- Let the script read the published
.sha256: the desktop holds the trust anchor. - Store the forwarded URL: the local port is not stable across launches.
- Install into a user-level service manager:
$HOMEplus a pidfile stays privilege-free.