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]>
A command's metadata moves from hand-kept tables into the command itself:
an about (docs page, help group, why no --json) set as its Cobra
Annotations. msg.commandDocs, commandGroups and withoutJSON are gone;
TestDocLinks reads the links from the generated CLI reference, and help
output and the reference are byte-identical. AGENTS.md's cli and vm rows
point at new doc.go package comments.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Messages that said the same thing for different settings are one message
each, given what differs:
- new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command)
replace from_ignored, net_flag_ignored, git_protect_flag_ignored,
size_flags_ignored, ports_flag_ignored, parts_flags_ignored,
ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning
for each command that changes the same on the VM, naming only the
flags given (ignoredFlags).
- setting_already (command, vm) replaces net_already, agent_already,
clone_on_already and clone_off_already.
- setting_set (vm), for a stopped VM, replaces net_set_stopped,
agent_set_stopped and links_next_start.
- next_start (count, vm), for a running VM, replaces net_set_running,
agent_set_running, size_next_start, agent_next_start,
mounts_next_start, folder_next_start and net_off_next_start; a launch
warns of each change with its next_start_* line, then next_start once.
- program_missing, program_broken and program_old (+ _fix) replace
lima_missing, lima_broken, lima_old, qemu_missing, macos_old and
their _fix messages; the minimum versions are minLima and minMacOS in
the lima backend, passed into program_old.
- ports_list_needed replaces link_ports_invalid: devvm link publish and
unpublish check their ports with ParsePortList, as devvm ports add
does, and ParsePublish is gone.
- no_vm replaces no_vm_link.
- vm_unfinished says nothing of the user's is in the VM, as
remake_unfinished does.
Kept apart: git_protect_next_stop (it applies at the next stop, and
devvm stop applies it), already_stopped and ports_all_already (not
settings), group_already (joining again syncs the group's links),
has_tools and has_layers (they name which of those given were there),
docker_missing (Docker is optional, so it never says to install it).
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]>
The VM a folder uses is decided once, by vm's resolveFolder, from the
folder's own VM, the nearest parent folder's (with any repo of its own
in between) and the command's rule (vm.Env.Folder): by default the
folder's own, else the parent's unless a nested repo is in between,
else none (devvm makes the folder's own, other commands say no_vm).
--here takes only the folder's own; --parent takes the parent's across
a nested repo and past the folder's own, and refuses a folder inside
none with a VM (no_parent_vm). devvm asks nothing now, in a terminal
or not: use_parent_vm and use_parent_vm_repo are gone. The questions
before deleting, remaking or widening a parent's VM stay.
find resolves through it; own is the folder's own VM (adopt, --clone);
lookup and useParent are gone; Options.Here is the rule's.
cli: addFolderFlags (flags.go) adds --here and --parent into the run's
app, which vmEnv sets as the rule; the two are exclusive, and with -g
where a command has it; --clone and --parent are exclusive; devvm rm VM
takes neither (rm_vm_folder_flag). Commands: devvm, restart, stop,
update, rm, code, desktop, host, history export, tools (add, rm,
update), size, ports (add, rm), network (allow, deny, rm, log),
ssh-agent, git-protect, clone, secret use, secret unuse, layer add,
layer rm, group (join, leave), link (add, rm, publish, unpublish).
Tests: TestResolveFolder (own, parent, none, nested repo, --here,
--parent), TestFolderFlags (every folder command takes both, and no
other; refusals before anything runs; the rule each sets), the parent
tests and subfolder.txtar's cases updated for no questions and --parent.
Docs: the Commands page's subfolder section, first VM, --clone's
subfolders, the overview's subfolder VM; the CLI reference regenerated.
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]>
A group's links are links in each member's state, marked as the group's
(a sixth field, ,group), so the link session, the proxy's list and every
connection check treat them as any link. Membership is each member's own
state (group, group_as), so a VM made again is in none.
- internal/vm/groups.go: Groups (Show, Join, Leave), groupLinks (pure:
the user's links kept and taking precedence, a link per published port
of each other member, one address per member kept across changes),
sync/syncVM/change (records, names what each member gains and loses,
applies to running members), clashes warned.
- All or none: join refused by network policy (group_policy_on/off);
devvm network on/off refused for a member (group_policy_mixed).
- One group at a time (group_other); names unique in a group
(group_name_taken, group_name_host); a member whose hostname is
another's name gets no links to it (group_link_name_host).
- CheckLink refuses a group's link once the two aren't in one group
(ungrouped); leave removes the leaver's own group links first; join
again works every member's links out again; link rm refuses a group's
link that still applies (link_from_group).
- Publish/unpublish, link add/rm and devvm rm reach the group's links.
- Docs: using/links.md Groups, the Commands page, safety/network.md,
internals/ports.md, the design note's Groups section and threat check;
the CLI reference.
- Tests: groups_test.go, testdata/script/group.txtar, JSON shape; e2e:
three VMs in a group and the all-or-none refusals in the link section
on every backend.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Links between VMs' commands and state, without anything carrying a
connection yet.
- state: every VM gets a random ID (KeyID, "id") when CreateVM makes it.
- vm: Links (links.go) lists, adds and removes the folder's VM's links
(KeyLinks, "links": NAME,PORT,TARGET,TARGET_ID,ADDR entries) and
publishes and withdraws its ports (KeyPublish, "publish"). Each target
gets one address in 127.77.0.0/16 per client, the lowest free. CheckLink
says why a link doesn't apply (gone, replaced, unpublished, policy).
- project: Matching (which sshconfig.Alias now uses), IsPath, ForDir and
Targets resolve a link's TARGET: a path, a VM's name or a folder name.
- cli: link.go, in the Links between VMs group; --json on devvm link and
devvm link publish; --as checked with the other flag values.
- Messages: no_vm_link, link_failed, link_port_invalid, link_ports_invalid,
link_unknown_target, link_ambiguous_target, link_self,
link_not_published, link_policy_mismatch, link_name_invalid,
link_name_host, link_name_taken, link_target_named, link_exists,
link_added, link_trust, link_removed, link_not_found, link_port_taken,
published, unpublished, port_not_published.
- Docs: the Links between VMs table on the Commands page, the CLI
reference, AGENTS.md and the cli skill's tree.
Co-Authored-By: Claude Opus 5.5 <[email protected]>