Files
devvm/testdata/script/fixture_v010_strict.txtar
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
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]>
2026-11-15 19:36:28 -07:00

42 lines
1.5 KiB
Plaintext

# devvm 0.1.0's app VM (testdata/v0.1.0/darwin: see fixture_v010.txtar)
# as 0.1.0's devvm git-protect strict would have left it on macOS, the
# one host where 0.1.0 locked .git: its mode strict, and
# diff.ignoreSubmodules = all in .git/config. It reads as on, its next
# launch takes strict's all out, .git/config unlocked for the edit and
# locked again before the VM starts, and says so once.
[!darwin] skip '0.1.0 locked .git on macOS only'
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
mkdir $HOME/src/db $HOME/src/app $HOME/src/web $HOME/src/scratch
cd $HOME/src/app
exec git init -q -b main
exec git commit -q --allow-empty -m one
fixture v0.1.0
vm_name APP app
# Strict, as 0.1.0 recorded and set it.
json_set $APP_dir/vm.json git.mode=strict
exec git config --file .git/config diff.ignoreSubmodules all
exec devvm ls
stdout '^devvm-app-[0-9a-f]{14} +Stopped +base +node,claude,codex +on +allowlist '
exec devvm git-protect --json
stdout '\A{\n "version": 1,\n "mode": "on"\n}\n\z'
stub_reset
exec devvm
stdout '^==> starting what=devvm-app-[0-9a-f]{14}$'
stderr '^devvm: git_strict_converted vm=devvm-app-[0-9a-f]{14}$'
! stderr 'replaced|refused|failed|git_strict_left'
! exec git config --file .git/config diff.ignoreSubmodules
stub_calls
stdout '^chflags -R -P nouchg \S*/home/src/app/\.git/config\n(.*\n)*chflags -R -P uchg \S*/home/src/app/\.git/config\n(.*\n)*limactl start '
vm_state $APP_dir/vm.json
stdout '^git\.mode=on$'
# Once only.
exec devvm stop
! stderr git_strict
exec devvm
! stderr git_strict
exec devvm stop