Expand description
host add: the SSH orchestration that wires the pure pieces in
hostspec.rs/registry.rs onto a real box.
Everything here that actually talks to a host (ssh_run,
ssh_pipe_file, ssh_append_unique, host_add) is exercised end to end
by the controller against docker/test-host, not by a unit test — there
is no live host in CI. What IS unit-tested is every pure seam: parsing
user@host, building the ssh argument vector, the remote shell
commands those transport fns run, and the client-side path resolution
(keydir, registry path, ~/.ssh/config upsert).
Structs§
- Host
AddArgs - Host
Adopt Args - Inputs for
host adopt. - SshSpec
- The control-channel SSH target: the operator’s interactive key, never the
forced-command key that
host addgoes on to install.
Enums§
- Host
Status - One host’s status, as
probe_statusdiagnoses it.Reachablecarries exactly what the host’s ownselfcheckreported;Brokenis a real ssh connection that came back unhealthy (selfcheck errored);Unreachableis no connection at all — the graduated diagnosisstatusneeds to tell “the box is off” from “the box is up but git-ark is broken on it”. - KeyPlan
- What
pick_or_plan_keygendecided for the client’s control key: reuse an existing one, or generate a fresh one. Both carry the PRIVATE key path — its public half is always<path>.pub, the standard ssh-keygen naming.
Functions§
- client_
keydir - client_
ssh_ config_ path - format_
status_ row - Render one
statusrow. PURE —probe_statusdoes the SSH; this only formats what it found.mirror(from the registry entry, not carried onHostStatus) appends a★ mirrormarker. - host_
add - Probe, wire, verify, and register a host. Fails before mutating anything
on the host if the probe/capability check doesn’t pass; re-running for
the same
nameis idempotent (re-streams the binary/config, never duplicates theauthorized_keys/~/.ssh/configentries). - host_
adopt - Adopt an already-deployed host into the client registry — the recovery path
(a lost registry) and the way to bring in a host wired before the registry
existed. Reconstructs the registry entry from the host’s deployed surface
over the control channel, verifies with
selfcheck, and registers it. - host_
discover - Scan the local
/24for hosts answering onport, printing each reachableip:port— labeled(known: <name>)when the IP already appears in a registered host’sssh_target. Finding nothing is success (exit 0), not an error; a probe is a bare TCP connect, no auth, no data. - host_
list - Print the registry, one line per host as
name ssh_target triple, sorted by name.Registry::list()is in insertion order (onlysavesorts on disk), so sort a copy here — an empty/missing registry prints nothing. - host_
list_ json host list --json: the client contract for resolving a host name to its push alias and backend. Emits a flat JSON array of [HostRow].- host_
remove - Remove
namefrom the registry and drop its~/.ssh/configalias block. A name not in the registry is reported, not an error — there’s nothing to retry. - host_
setup_ key - Generate a client SSH key (if none exists) and copy it to
targetviassh-copy-id, so a box without key auth set up can get to “sshable” without leaving git-ark. This is the operator’s own CONTROL key, never the forced-command keyhost addgoes on to install —setup-keynever touches an existing key, only creates one when none exists. - mirror_
check - Preflight the GitHub token against a repo’s mirror config: read the
committed
.git-ark.ymlgithub block, check the token’s auth/scopes and its access to the target repo, and print a report — catching a token lacking org access or theworkflowscope before a real push does. - mirror_
set - Reassign the GitHub mirror to
name: load the registry, require the host exists, read the token fromGIT_ARK_GITHUB_TOKEN(never argv), and enforce the singleton viadesignate_mirror. - mirror_
show - Print the current mirror host’s name, or
none. - parse_
forced_ command_ config - Extract the
--config <path>from a git-ark forced-command line in anauthorized_keysbody. The path ends at the first quote or whitespace. - parse_
target - Split an ssh target
user@hostinto(user, host). git-ark hosts always run under a dedicated user, so a bare hostname (no@) is rejected rather than guessed at. - pick_
or_ plan_ keygen - Decide which client key
host setup-keyshould use. PURE:existingis the set of candidate basenames the caller found actually present inssh_dir— this only picks among them. Reuses the first preferred name present (ed25519 > ecdsa > rsa); plans to generateid_ed25519when none exist. Never plans to overwrite an existing key. - probe_
status - Probe
hostover the control channel: run its ownselfcheckand parse the result. Never errors — a dead or misconfigured host is aHostStatusvariant, not aResult::Err, sostatus()can report the whole fleet even when part of it is down. - registry_
path - The host registry path:
GIT_ARK_HOSTSoverrides (tests, alternate profiles); else<keydir>/hosts.toml. - remove_
ssh_ config_ block - Remove the
Host git-ark-<name>block fromexisting, if present. Every other block is preserved untouched. Used byhost removeto drop the client~/.ssh/configalias once a host leaves the registry. - route
- Fan a repo’s
git push git-arkout acrosshost_names: verify every name is registered, then (re)materialize thegit-arkremote inrepo_pathwith one push URL per host, so a singlegit push git-arkreaches all of them. Idempotent — re-running (even with a differenthost_names) removes and rebuilds the remote rather than accumulating stale push URLs alongside new ones. - ssh_
append_ unique - Append
linetoremote_fileon the host, idempotently (seeappend_unique_script). - ssh_
pipe_ file - Stream
bytestoremote_pathon the host, thenchmod mode. Used for the binary,config.toml, andsecrets.toml— the proven pattern of piping over the same control-channelsshrather than requiringscp. - ssh_run
- Run
cmdonspecover the control channel, returning stdout. Non-zero exit is an error carrying stderr. - status
- Print a fleet health/liveness/drift dashboard: one row per registered host, probed over the control channel. Never fails the process on a dead/broken host — that’s the point of the dashboard — only on a genuine local error (e.g. an unreadable registry).
- triple_
from_ uname - Map
uname -s/uname -moutput (two lines) to a git-ark release triple. - upgrade
- Push
binarytonames(or every registered host, withall) over the control channel and re-verify each withselfcheck. The binary is read once and streamed unchanged to every target. A per-host failure is printed and does not abort the rest — the fleet-wide--allcase must finish attempting every host before this returns a non-zero error, so a script driving it can detect a partial upgrade without losing the hosts that did succeed. - upsert_
ssh_ config_ block - Insert or replace the
Host git-ark-<name>block withinexisting(the current contents of~/.ssh/config), keyed by itsHostline. Every other block is preserved untouched; a prior block for this name is replaced in place (idempotent re-runs ofhost add), otherwise the new block is appended.