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]>
Leftovers.Forget takes the folder's creation lock (holdCreate) for its
re-check and teardown, so a VM a devvm is making again, its state written
before its backend has it, is refused (create_running) however old its
state; gc --orphans and retention's orphans.age both go through it.
TestForgetHoldsCreateLock failed first. TestMoveUnsafe covers a move's
refusal of an unsafe folder, which no test did (fails without
checkUnsafe in finder.move).
Docs: the creation lock in internals/overview.md and space.md's
leftovers; commands.md's moved folder says the agents' sessions keyed by
the folder's path stay under the old one (claude --continue/--resume,
codex resume --all).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The finder returns a target (target.go): the VM's folder, state, backend
and the instance its backend gave the finder, which each start
(starter.start, target.started, backend.Apply) and stop (target.stop)
then sets as the backend has it, without asking again. It runs what a
command does with that VM: exec, shell, shellDir, running, stop,
ensureRunning, ownSSH, sshHost and widen. Stop, network, ports, size and
ssh-agent read the finder's instance instead of asking again; git-protect
reads it again after its question (refresh), as before.
Env's parts are made once over it (wire, from NewEnv): the finder,
starter, linkRuns, syncer, remaking, clones, vmFolders, devcontainers,
creation, and the command types one reaches from another (launcher,
lifecycle, vmTools, groups, links, leftovers). The 110 conversions
between the package's struct{ *Env } types (finder(e), Launch(e),
starter{e}, creation{Launch(e)}...) are gone: none is left outside wire.
setUp and Groups.warnUnenforced went, their callers using setUpVM with
the target and Links.warnUnenforced; seedClone, gitSSH, fetchUnfetched
and setUpVM take the target. The fake backend applies a Want with
backend.Apply too.
TestTargetAfterStartAndStop: a target's instance after a start and a
stop is the backend's, a start reading it once and a stop not at all.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing held a lock from finding that a folder has no VM until Create,
and a second creation's clear deleted the vms/<hash>/ folder of the VM
the first had just made; the remake's lock lives inside that folder, so
it couldn't help.
- paths.Dirs.CreateLock(hash): run/create-<hash>.lock, outside the VM's
folder.
- Launch.makeHeld: when up finds no VM, or the folder's own unfinished
one, it TryLocks the folder's creation lock before the plan's
questions, finds the VM again under it (finder.again, sameCreation)
and opens one another devvm made meanwhile; create lets go of the lock
once created records Created, before the first start. After an
interrupt the lock is let go of by a cleanup that runs after
undoCreate's.
- A second devvm refuses at once (create_running), never waiting on the
first one's questions; so does up's remakeUnfinished question.
- devvm rm (Rm and rmGone) takes the lock too (holdForRm) and refuses
while it's held, or when the VM's state changed once it has it.
- The holder deletes the lock file as it lets go, so no file named by
the VM stays outside its folder; teardown deletes one a killed devvm
left (dropCreateLock).
- Tests: TestUpCreateLock (two creations at once: one VM, one state;
failed before the fix with two CreateVMs), TestUpMadeMeanwhile,
TestUpInterruptedHoldsCreateLock, TestCreateLockRefuses (up's
remake-unfinished question and rm by folder and by name refused),
TestRmChangedMeanwhile, TestTeardownDropsCreateLock.
- Docs: internals overview (a new VM's step 1, run/, the locks section
and table), troubleshooting.
Co-Authored-By: Claude Opus 5.5 <[email protected]>