- state: test builds and tests check the state locks' order (state.held, CheckLockOrder): a second VM's lock, a VM's lock under the claims lock, or a lock taken again panics before waiting.
- platform: PinBeneath opens the path again when a rename takes the file away before move_mount (ENOENT), so the keeper no longer reports a false lost pin (TestPinsInNamespace's 'f lost / f pinned-again'); TestPinWhileRenamed.
- daemon: Proc.Stop signals the process group (SignalGroup), so forwarders' and link sessions' ssh masters and relays end with them; ui.UI.StopsItsOwn makes _ports and _links wait for their ssh on an outside SIGTERM.
- vm: gc --orphans and devvm space count forwarders' leftover control sockets (vmssh.ControlGlob).
- CLI tests: each sandbox claims a block of ports below devvm's range and the ephemeral range (claimPortBlock, /tmp/devvm-test-ports); free_port, the fixtures' ports and DEVVM_SSH_PORTS come from it, and the sandbox's devvm chooses from its own range (DEVVM_PORT_RANGE override). Fixtures' forwarded ports and settings ports are rewritten too (FIXTURE_PORT_<port>).
- netpolicy and vm tests: the fake proxy's stop waits for its reap, and fake daemons run until the test ends, not 30 s.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.
Boundary parsers, the only places a string becomes a VM:
- vmname.Parse: a project VM's name (state's vm.json name, export file
names, devvm _links's argument, the forwarder's -vm, project.Nth)
- vmname.ParseListed: one path element, for what a backend lists
- VM.UnmarshalText: JSON (Lima's list, proxy config and events, links'
targets in state, link lists); empty stays no VM
- vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs
- msg.M.VM: the VM a message's function took, read back
vmname's functions on names became methods (Hash, Slug, Short, Aside,
AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname;
vmname.Join joins VM lists. Messages' vm and vm_name fields are typed
by the generator. Seven messages whose field took something else became
what= (backend_lacks, backend_unreviewed, backend_unreviewed_used,
starting, deleting, configuring, running_script) and rm_vm_failed's
name=: the text is unchanged, the names-mode scripts follow.
Review.RequireFor names an image or the tools being built.
Typed sites per package (added lines with vmname.VM, non-test): msg 347
(generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22,
backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8,
ports 6, paths 3, sshagent 2, sshconfig 2, tools 2.
The structure test's owners rule now fails on a field, parameter or
result named for a VM (vm, vms, otherVM, vmName) typed string, []string
or map[string]…, and on converting anything but a literal to vmname.VM
outside the files it lists; internal/stubtest is free. depguard holds
internal/vmname to the standard library, and the proxy may import it.
ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Commands fail by returning: RunE returns the error, as failed(err, what)
when it may not be a message (replacing fail and the direct Die calls in
cli), and a.env returns its failure. checkLayout returns its error from the
root's PersistentPreRunE. execute alone prints a failure (showFailure): a
backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces
DieLogged), a message as it is, else what failed or output_failed, with a
corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130.
Die is now the UI's own die, for where no command can return: a question
without an answer, a run log that can't be opened. Error prints nothing once
the run is interrupted.
After INT, TERM or HUP, Main waited only for the logged command and then ran
the cleanups while the command's own code still ran. It now also waits for
the command to return, up to returnGrace (2 s), when there are cleanups to
run; a run without cleanups ends at once, so the proxy and the other
background processes still stop as soon as they are told to. A start's
undoStart stays registered once interrupted (interruptCleanup), as the
cleanups now run after the start returned.
Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old
ordering), TestSignalsWaitForAStuckCommandAWhile,
TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure;
DieLogged's tests are ErrorLogged's.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
NewRoot makes one app for the run's UI and hands it to every command.
The app makes each service the first time a command asks for it and
keeps it, or its error, for the rest of the run: devvm's folders
(dirs), a test build's overrides, the secrets store, the backends'
registry, the shared tools, the VM environment (vmEnv) and the image
builder of the backend new VMs get (builder). The retention that runs
before a command and the command itself share them.
- paths.FromEnv: 23 of 24 calls go through a.dirs; partNames, which the
parser's flag and word checks call before any command, keeps its own.
- The registry is made once (8 newRegistry calls and newEnv's).
- builder(u) (6 calls) and cli's newBuilder are gone: a.builder and the
per-backend builders in images, space and gc are vm.Env.Builder,
exported, the only builder. setup's feature choice takes a build.Env
of its folders and prompts alone.
- The shared tools are made once (newTools and vm.NewEnv's), and the
secrets store once (companyProxy's, newTools', vm.NewEnv's and
_proxy's): vm.NewEnv takes the run's tools and store.
- withEnv (46 calls) is a.env; autoRetain, retainOrphans and gc
--orphans use the run's VM environment.
- thisHost and readOverrides' other callers read the overrides once
(a.host); space and gc --caches time out on the registry's host.
TestAppMakesEachServiceOnce checks that one run makes each service once
and that the VM environment and builder share the run's registry and
tools; TestAppKeepsAFailure that a failure is kept.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
vmssh.Links runs a running client VM's link session: one ssh master of
its own to the client (never the forwarder's), started with
ClearAllForwardings=yes and -N, to which each link is added with
-O forward -R 127.77.x.y:PORT:<socket> and from which it's removed with
-O cancel, read again every second (Want). Each forward is its own, so
one the client refuses fails that link alone (Failed, which warns with
link_port_taken through Link.PortTaken). Each link's end on the host is
a unix socket, mode 600, in the run folder (made 700), named
link-<hash of client, address, port>.sock; masters' control sockets are
link-<hash>.ctl (the session's; a target's by target and start). A
stale socket is replaced, anything else refused, and sockets go with
their link or the session.
Each connection is checked again (Check), then carried by
ssh -S <target master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT
through a master kept per target and start: a channel goes through the
master or nowhere. At most 256 at once, then refused (link_limit).
Events (link, link_refused, link_target_stopped, link_limit) go to the
client's event log. The session ends once the client no longer runs its
start, or has no links.
vm.Links.Session builds it from the state and the backends: the
client's and targets' ssh from Backend.SSH, the key its first
IdentityFile, host keys devvm's pinned known_hosts (HostKeyAlias), only
on a host loopback port or through the backend's ProxyCommand, FeatureSSH
allowed. linkConn re-reads the states per connection: the link still in
the client's state (removed), CheckLink (gone, replaced, unpublished,
policy), the link features on the target's backend, the target running
(Inspect, StartID: link_target_stopped otherwise; it never starts one),
its ssh (ssh). devvm _links VM (hidden, one argument) runs it, failing
with link_session_failed or vm_not_running.
The port forwarder never forwards a listener in 127.77.0.0/16 (dialAddr,
vmssh.IsLinkAddr), on any VM; a test keeps vmssh.IsLinkAddr equal to
vm.IsLinkAddr on every link address and around them.
netpolicy.AppendEvent writes devvm _links's events beside the proxy's,
mode 600, rotating past 10 MiB; events carry target, which FormatEvent
and devvm network log --json show.
Tests: TestLinkArgs, TestLinkFiles, TestListenSocket, TestLinks,
TestLinksSessionLost, TestLinksCap, TestIsLinkAddr, TestListeners
(range exclusion) in vmssh; TestLinkAddrsAgree, TestLinkConn,
TestSessionLinks, TestLinkEvents in vm; TestAppendEvent and link cases
in TestFormatEvent; link_session.txtar for _links's argument and
refusals; e2e's project section checks a server on 127.77.0.1 isn't
forwarded while the VM's own on 127.0.0.1 with its port is.
Co-Authored-By: Claude Opus 5.5 <[email protected]>