Files
docs-next/docs/contributing/structure.md
T

33 KiB

The structure test and owners

The structure test

internal/structure parses every Go file in the repo, tests and every platform's included, generated files left out, and checks what linters don't. mise run test runs it. Each failure starts with its rule and the file and line:

Rule Checks
max-methods no type has more than 24 methods, value and pointer receivers together, and no interface declares more than 24, not counting the interfaces it embeds; a larger one splits by what its methods do
no-init no func init()
package-vars a package-level var is a blank interface check, an Err*/err* sentinel from errors.New or fmt.Errorf, a regexp.MustCompile, template.Must or sync.Once* result, a //go:embed file, or listed in allowedVars; anything else becomes a field, a const or a local
layers which packages import which, in non-test files (tests may wire packages together)
owners in non-test files, only its owner runs a host command that commands lists, only the files execSites lists make a host command, only guardOwner asserts a backend package's type, only envOwner reads a DEVVM_ variable, but the settings envSettings lists, only its file in envOwners reads HOME, only its owner's string literals hold a text that literals lists, only its owner's string literals are, whole, a name that names lists, only its owner's calls to package strings split or join on a separator that separators lists, only pathsOwner builds a path in devvm's data or config folder, and only its file in callers calls a function that callers lists (details)

The layers:

  • Only cmd/devvm and internal/cli import internal/ui; only internal/cli imports internal/vm; only cmd/devvm imports internal/cli.
  • internal/backend/... imports none of internal/vm, build, tools, netpolicy, secrets, project, gitprotect, sshconfig, sshagent, trust or vmssh, so the port forwarder and the link sessions stay devvm's on every backend.
  • Only internal/backend/registry and internal/cli import a backend (lima); only tests import backendtest and internal/stubtest and the packages below it, which import only internal/msg and each other. The stubs' binary, internal/stubtest/stub, and its state, internal/stubtest/stubstate, import nothing else of devvm's, because the binary stands in for the tools devvm runs and is built apart from it.
  • internal/proxy imports no other devvm package but internal/daemon and internal/safefile.
  • assets, locales, internal/platform, internal/msg/gen, internal/testbuild, internal/hostgit, internal/shell, internal/vmname, internal/daemon, internal/fetch, internal/jsonc, internal/redact, internal/agents and internal/safefile import no devvm package; internal/agentlogin only internal/agents, internal/fetch, internal/jsonc, internal/proxy, internal/safefile and internal/state, because it holds agents' logins; internal/msg only locales; internal/paths only internal/msg; internal/state only internal/msg, internal/paths, internal/platform and internal/vmname; internal/image only assets, internal/agents, internal/msg and internal/paths; internal/devcontainer only internal/image, internal/jsonc, internal/msg and internal/shell.

Everything it holds the code to is in devvm() in internal/structure/structure_test.go:

  • largeTypes lists the types allowed more methods, which are paths.Dirs and ui.UI, each with its count as its maximum and why. A backend isn't one of them, because its methods are split by backend.Backend's roles (how a backend plugs in). One that grows fails; one that shrinks fails until its maximum is lowered.
  • allowedVars lists the other package-level vars, by package folder and name, each with why: values set by -ldflags, fixed tables, test fixtures. An entry whose var is gone fails.
  • layers is the layering table: a layer's packages (from, but not exceptFrom) import none of to (but exceptTo); x/... is x and the packages below it.
  • commands maps a host command to the one package that runs it. execSites lists the files that make a host command with exec.Command or exec.CommandContext, each with why, and a listed file that no longer makes one fails. guardOwner names internal/backend/guard.go, the one file that asserts a backend's type. envOwner names the one file that reads devvm's DEVVM_ variables. envSettings lists the variables read elsewhere, each with the files that read it and why. A listed file that no longer reads its variable fails. envOwners maps another variable to the one file that reads it, which for HOME is internal/paths/dirs.go.
  • literals maps a text that only one package's string literals may hold to that package and what the others use instead. names maps a name that only one package's string literals may be, whole, to that package and what the others use, and namesFree lists the folders whose literals may be one anyway: internal/stubtest, whose stubs are named after the commands they stand in for.
  • callers maps a function to the one file outside its package that calls it, and a listed file that no longer calls it fails. A method is listed as pkg.Type.Name, such as internal/paths.Dirs.AgentSettings, and any call of a method by that name outside its package counts, because the check reads no types, so a listed method's name is its type's alone.

TestRulesFail breaks each rule, and each layer, on small sources and checks the failure names it.

One owner for each concern

Each concern in devvm has one owner, the package or function that does it, such as internal/hostgit for every git command devvm runs on the host, internal/paths for every folder and file devvm uses, internal/settings for every default (settings.Read and settings.Save, over config.toml and settings.json, with each value's parser), and locales/en.toml for every message. Before you add a helper, a parser, a path, a file reader, a message or a table, find its owner and extend it. A second copy drifts from the first, and then one of them is wrong. AGENTS.md's layout table names the owners, and so do the failures of the checks below.

The checks on owners

An owner gets a check only when a second copy would be a bug or a security hole, and only when the check is exact, so that it never fails on code that's right. Each check's failure names the owner. The table is written from ownerDocs in internal/structure/owners_doc_test.go, which TestOwnersDoc checks it against and TestOwnersAgree checks against the structure test's own tables, so a change to a check changes its row there, and go test ./internal/structure -run TestOwnersDoc -update writes the table again:

Check Owner Allowed elsewhere
forbidigo, testbuild.On internal/cli, whose readOverrides is the only code that asks whether this is a test build nowhere: other packages take the overrides as fields
forbidigo, os.FindProcess, syscall.Kill, unix.Kill and os.Process's Kill and Signal internal/daemon, which signals a background process only while its pid file and its arguments say it's still that process (Proc), or through the process it started (Handle) internal/platform; tests, which signal the children they started; and a child that hasn't been waited for yet, whose pid is still its own, with a nolint saying so
forbidigo, unicode.IsGraphic, IsPrint, IsControl and Bidi_Control msg.Safe in internal/msg/safe.go, the one rule for which characters reach the terminal, which msg.Printable, msg.OneLine, the UI's renderers and devvm agent save's diff follow, so a second rule can't let through what this one refuses (Colors says what it refuses) a check that isn't about the terminal, such as a path one line long, with a //nolint:forbidigo saying so
forbidigo, HTTP clients internal/fetch, whose NewClient sets each client's timeout and redirect policy (HTTPSOnly or SameScheme), and whose Retry, Transient, ReadCapped, Get, Resolve and Download try again after the failures that may pass, cap what a body or a download may hold, follow a HEAD's redirects to where they end and check a download's SHA-256 before anything uses it. fetch.Client is its own type, so a client that NewClient didn't make, such as &fetch.Client{}, fails every request, and a caller changes a client's transport through its Transport method internal/proxy, which is the standard library only, and tests, which make their own servers' clients
forbidigo, os.WriteFile, os.Create and os.O_TRUNC internal/state, whose WriteFile and WriteFileMode write a file whole through a temporary file in its folder, renamed over it, so a reader never sees half of it internal/proxy, which imports only the standard library and has its own writer, writeAtomic; internal/msg/gen, which imports no devvm package; internal/stubtest; tests; and, with a nolint saying why, a file written another way: a log that a process writes as it runs, a download that streams into its file, and internal/daemon's pid and status files, each written in one write that a reader takes as missing until its line ends
forbidigo, os.Open, os.OpenFile, os.ReadFile, os.OpenRoot, os.OpenInRoot, os.DirFS and os.Root's Open, OpenFile, ReadFile and FS, in the code that reads files a VM can write or swap: internal/gitprotect, internal/agentlogin, internal/vm's devcontainer.go, detect.go and agentsave*.go, internal/netpolicy/rules.go, and internal/proxy's config.go and policy.go internal/safefile, which imports only the standard library, so the proxy reads with it too. Its Read and Open open a file without blocking and, unless the caller passes Follow, without following a symbolic link at the path's end. They then check the file they opened, not its name, so a FIFO, a device or a folder is refused with ErrNotRegular, a file past its cap with ErrTooLong, and, with OneLink, a file with another hard link with ErrLinked. A FIFO that the VM swaps in after a check can't hold devvm, and a link to /dev/zero can't flood it. OpenRoot opens beneath a folder through os.Root, never through a link out of it, and its FS lists and stats what's there but opens only regular files every other file, which is devvm's own or the user's; tests, which make their own fixtures; and, with a nolint saying why, what opens a file to write it or a folder to lock it
forbidigo, os.Setenv, os.Unsetenv, os.Clearenv and syscall's each command's own environment, its exec.Cmd's Env, because every command and background process devvm starts inherits devvm's. A VM's SSH agent is one: the finder's target carries its socket, which goes to the backend in backend.ExecOpts.Agent, backend.ShellOpts.Agent and Confinement.AgentSocket, and Lima sets SSH_AUTH_SOCK on that VM's limactl commands alone, so a run that reaches several VMs never gives one another's daemon.Ready in internal/daemon/status.go, which takes the status file's name out of a background process's own environment, and tests, which use t.Setenv
the structure test's owners, host commands the runners: the UI's LoggedCmd, which a package takes as a field and which runs a command into the run log, a backend's Runner, and internal/hostgit. A host command that one of them doesn't run is made only in the files execSites lists: those that make the command a runner then runs, such as Lima's limactl and mise's, and those whose command can't go into the run log, because it streams for as long as a link, the port forwarder or the desktop's relay lasts, asks on the terminal, outlives the run, or carries a secret tests
the structure test's owners, a backend's other interfaces backend.As in internal/backend/guard.go, because the registry's backends are behind its guard, whose type has only backend.Backend's methods, so a type assertion to backend.Forgetter or *lima.Lima on one is always false tests
the structure test's owners, git internal/hostgit, which runs git without the repo's fsmonitor, hooks or filters, over ssh only, without the environment's GIT_* variables and prompts tests, which run git to make their repos
forbidigo, os.UserHomeDir, and the structure test's owners, HOME paths.FromEnv in internal/paths/dirs.go, which reads HOME once into paths.Dirs.Home, so a test or an e2e run that sets its own HOME moves every path devvm takes from it tests
the structure test's owners, DEVVM_ variables readOverrides in internal/cli/overrides.go, which reads a test build's stand-ins, while a release reads none the settings in envSettings, and tests
the structure test's owners, shell quoting internal/shell, whose Quote and QuoteJoin quote words for a POSIX shell, so a value never runs as a command tests
the structure test's owners, the VM-name grammar internal/vmname, whose IsVM tells a project VM's name from an image's, so gc never takes a project VM for an image tests
the structure test's owners, the coding agents internal/agents, whose Defs hold every fact devvm keeps of each agent, so no copy of an agent's list or paths goes stale when one is added. A string literal that is an agent's name or a login file's kind, whole, or that holds an agent's folder below the home folder, fails, and code of one agent's own names the agent by its constant there (adding a coding agent) internal/stubtest, whose stubs are named after the commands they stand in for, and tests
the structure test's owners, the toolchains internal/image, whose SharedTools holds every fact devvm keeps of each toolchain: its members, the files that call for it, its installer, its guest environment, its PATH folders and its version files. A string literal that is a toolchain's name or a member's, whole, fails, so code elsewhere asks the table, and a new toolchain is an entry there (adding a toolchain) internal/stubtest, and tests
the structure test's owners, image names internal/image, whose Name is an image's name and splits it into its layers (Layers, Parent, Has), whose NameOf joins layers into one, and whose ParseName reads the name the user gives, which build.Names' Parse checks against the layers there are. devvm build, devvm rebuild and devvm images rm read their names there once, and the rest of devvm passes the image.Name on tests
the structure test's owners, state.ReadHash and project.Parents the finder in internal/vm/finder.go, whose target finds the VM every command acts on: the folder's own, the nearest parent folder's under --here and --parent (resolveFolder), or one named (devvm rm VM). It finds a folder's VM by the state that records the folder (finder.state, by the path's hash first, then recorded), offers to move a VM whose folder moved there (moveHere in internal/vm/move.go, the match here.movedFrom), and names a new VM by the first of the folder's names whose VM folder is free (newName, project.Nth). Its need says what the command needs of the VM, and need.check is the one place that refuses one that isn't there, one made for an earlier folder at its path, one whose remake didn't finish and one whose creation didn't, the last with refuseUnfinished, which every start (starter.bringUp in internal/vm/start.go) makes too. It reads the folder devvm runs in only then, so the commands that act on no folder's VM run in a folder that's gone. The VM it finds is a target (internal/vm/target.go). It holds what the VM's backend told the finder, which each start and stop of the VM then updates, and it runs what a command does with that VM: exec, shell, stop, running, ownSSH and the name of its ssh config entry internal/state, and tests
the structure test's owners, state.ReadAll the inventory in internal/vm/inventory.go, which reads every VM's state (ReadStates), and with ReadInventory the backends' lists too, each within its wait, for every listing of VMs: devvm ls, devvm space, devvm images and devvm gc, the ssh config, devvm gc --orphans, the links, devvm secret's list, finding a VM by its name and the mounts that devvm's SSH agent checks a key against. Its one failure policy is that a backend that can't list fails a listing (Inventory.Err) only when some VM's state names it, and that a state that can't be read is a row of its own, which the readers leave out and ToolsInUse and Mounts fail on. state.VMNames, which fails on such a state, stays for the readers below internal/vm: netpolicy, ports and sshconfig.ChooseAlias internal/state, and tests
the structure test's owners, paths.Dirs.AgentSettings and paths.Dirs.AgentLogins devvm's agent store: agentStore in internal/vm/agents.go for the agents' settings, which the mounts, the setup's copies, a remake's home and devvm agent import take, and secrets.LoginFile in internal/secrets/secrets.go for their logins, which the setup's copies and the proxy read, so nothing reads an agent's files from the home folder but vm.AgentImport internal/paths, and tests
the structure test's owners, paths in devvm's folders internal/paths, whose Dirs and VM name every file and folder devvm keeps, so the layout, its golden listing in testdata/script/layout.txtar and a VM's teardown miss none. A filepath.Join onto a Data or Config field fails, and so does an os.MkdirTemp or os.CreateTemp there whose name is a literal; a name from paths, such as paths.ToolsBuildPrefix, passes tests

forbidigo matches only the function a call names, so the checks that look at a call's arguments are in the structure test. It finds a host command in an exec.Command or exec.CommandContext call that names it, as a literal or as a constant, whatever name the file imports os/exec under. It finds a DEVVM_ variable in a call to any function or field named Getenv or LookupEnv, in any case, so t.Getenv and a getenv parameter count as well as os.Getenv, and it finds HOME the same way. The settings envSettings lists are the ones users set, DEVVM_NO_TOOL_CHECK, DEVVM_NO_RELEASE_CHECK, DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE and DEVVM_FROM; names mode, DEVVM_MESSAGES, which any build has; and the variables devvm sets for its own processes, DEVVM_GUESTFWD for devvm _qemu and DEVVM_DAEMON_STATUS for each background process internal/daemon starts.

The structure test also finds a copy of an owner's code by its text, in literals. A string literal outside tests that holds '\'', the escaped quote a shell quoter writes, belongs in internal/shell, and one that holds [0-9a-f]{14}, the hash at the end of a project VM's name, belongs in internal/vmname. A quote written as a rune, such as '\'' in Go, isn't a string literal, so it doesn't count. One that holds a coding agent's folder below the home folder, such as .codex/ or .pi/agent, belongs in internal/agents, and so does one that is an agent's name or a login file's kind, whole, such as "opencode" (names), so code of one agent's own names it by its constant there, such as agents.Opencode, and a longer text that mentions an agent, such as a command's example, doesn't count. A literal that is a toolchain's name or one of its members', whole, such as "dotnet" or "pnpm", belongs in internal/image in the same way, so code elsewhere finds a toolchain's facts in its image.SharedTools entry. In the same way, separators finds a copy of a parser by what it splits on: a call to any function of package strings with + as an argument, as a literal or as a constant, splits or joins an image's layers, so it belongs in internal/image. A call with another argument that holds a +, such as strings.ContainsAny(arg, "+,"), doesn't count.

The shared tools have one owner too, the table image.SharedTools in internal/image/tool.go, whose agents' entries it makes from the coding agents' registry, agents.Defs (adding a coding agent). Each entry, an image.ToolDef, holds a tool's name, its kind (a toolchain or an agent), its members (the tools in the lock that its name stands for, such as pnpm and bun for node), the files in a project folder that call for it, and its installer, which is mise for every tool but rust, which rustup installs, and dotnet, which assets/shared-tools/build.sh unpacks from Microsoft's SDK archive. A toolchain's entry also holds the environment that every VM's shells get for it, such as NPM_CONFIG_PREFIX and .NET's telemetry switch (Env), the folders of the VM's home that go on every VM's PATH, where its global installs go (PathDirs), and the members whose version files mise reads in a project (VersionFiles). mise locks dotnet's version without a download, because its own installer runs Microsoft's install script, which checks nothing, so devvm adds each platform's archive and its SHA-512 from Microsoft's release metadata to the lock (withSDKDownloads in internal/tools/dotnet.go), and Share.Build passes them to build.sh (image.OwnDownload), which checks the archive with devvm-fetch. image.Toolchains, image.Agents, image.GroupTools, the files that make devvm choose a toolchain for a new VM, the lock's check for downloads (image.NoDownload) and the devcontainer.json features that devvm maps to a toolchain all come from it. So do the files that every launch's setup writes for the toolchains: /etc/devvm/toolchains.sh, with every toolchain's environment and PATH folders (image.GuestEnv and image.GuestPath), which base's /etc/profile.d/devvm-tools.sh reads in every shell, as it reads the agents' /etc/devvm/agents.sh, and the VM's mise setting that names the tools whose version files it reads (image.VersionFileTools). The image builds read none of them, so a toolchain's environment changes no image. The structure test fails on a string literal outside internal/image that is a toolchain's name or a member's, whole, so code elsewhere asks the table, through image.Def, an entry's Installer or its other fields, rather than naming a toolchain. Adding a toolchain and adding a coding agent list the files a new shared tool needs, and the agreement tests fail until the table and those files match.

The scripts that devvm's builds run with bash have one owner for the machine they run on, assets/prelude.sh, whose $devvm_arch, $devvm_libc and devvm_sha give each script its architecture, its C library and its pinned checksum for each download (the scripts' prelude). A script reads them rather than run uname -m or look for apk itself, and checks that the prelude came first with : "${devvm_arch:?}" for each variable it reads, which also tells shellcheck that the variable is set. Go reads each of those scripts through image.OwnScript, which puts the prelude before it, so a recipe, a tool image's key and the conversion's copy of oci/build.sh all hold the two together. TestPreludeUsers in internal/image fails when a script that doesn't get the prelude, such as assets/oci/bootify.sh or assets/guest/'s, uses it, or when a script reads a variable without that check. testdata/script/prelude.txtar checks which pin devvm_sha picks from each script's pins on arm64 and amd64, with glibc and with musl. A CLI test or a Go test that sources one of these scripts sources assets/prelude.sh first.

internal/paths also owns how a path on the host is resolved and compared with a folder, in resolve.go, whose comment says which resolver each question takes. paths.Physical resolves every symlink as far as the path exists, for where a folder or file really is, such as a project folder against devvm's own folders or an SSH key against the folders VMs mount. paths.PhysicalParent resolves only the folder's symlinks and keeps the last element as named, for a path that may itself be a symlink devvm mustn't follow, such as a key's recorded path or a Seatbelt rule. filepath.EvalSymlinks itself, which fails when the path doesn't exist, is for a path that must exist, such as the folder devvm runs in. Then paths.Within tells whether a path is a folder or inside it, and paths.Below whether it's inside it only. Both compare names, so both paths are resolved the same way first.

A VM's state, vm.json, has one owner too, internal/state, which reads and writes the whole file and knows only its core fields. Every other package that keeps something of a VM's owns one section of it, with its own type, its name (Section), and an Of that reads it through state.Section: internal/netpolicy owns net, internal/gitprotect git, internal/ports ports, internal/sshagent agent, internal/tools tools, internal/secrets secrets, and internal/vm size, clone, devcontainer, desktop and links (internal/vm/state.go). A section's type keeps what the user asked for at its top level and what devvm made under made. A change goes through state.VM.Update, which takes the VM's lock, reads the file again, runs the change and writes the file once: the change sets its section with state.SetSection and works out a list's new value from the file as it is then, never from what the command read earlier, so a change another devvm made meanwhile is kept. A change that fails writes nothing. Update holds one VM's lock, so a change takes no other lock inside it, and a change to several VMs updates each in turn. state.VM.Claim is Update that also holds the claims lock, for what no two VMs may have (ports.Allocator chooses every VM's host port through it), and state.VM.Create writes a new VM's whole state once, its ssh alias chosen under the claims lock. A build VM has no state, so ports.Allocator.Build chooses its ssh port through state.Claims, which holds the claims lock alone. A VM's alias is one vmname.IsAlias accepts, or devvm doesn't use it. internal/vm's checkState reads every section of the folder's VM's state as the VM is found, so a section that can't be read stops the command instead of reading as empty. A new section adds its check there.

Agreement tests

When two places must agree but can't be one, a test checks that they agree. TestEveryPartHasAPolicy checks that every image part has its policy, TestSharedToolsPolicies that the policies in assets/shared-tools/ are one for each shared tool in image.SharedTools, TestConfigTools that assets/shared-tools/mise.toml lists each shared tool's members and nothing else, TestBuiltinPolicies that every policy devvm ships parses, TestEveryMessageIsUsed that every message has a caller, TestDocLinks that every doc link is a message and a heading, TestPreludeUsers that only the scripts that get the prelude use it, TestDefsComplete that every coding agent has its [tool_alias] line and its row in the docs' Supported agents table, TestProvidersComplete that every provider in agents.Providers has its row in the docs' table of the API keys the proxy puts in, TestToolchainsComplete that every toolchain has files that call for it and its row and section on the toolchains page, which names those files and its PATH folders, TestFormatsCoverLogins that every agent's login file has its format in internal/agentlogin, and TestReferenceIsCurrent that the CLI reference matches the commands. A new pair of places that must agree gets such a test.

The consolidation pass

A review of a body of work, and the review before a release, look across the code for copies:

  • two parsers of one format
  • a path built outside internal/paths
  • a list of files kept beside the folder that holds them
  • a value encoded in a string
  • two messages that say one thing
  • a comment that says to keep two places in sync
  • a test that copies a constant

Each copy gets one of three outcomes: extend the owner, make one owner, or leave it. Leave it when the only shared helper would be the wrong one, because a copy costs less than the wrong helper, and wait for a third copy before making one. The pass is part of those reviews, not a step every change runs.

Changing the state layout

State files describes the layout, and the design note says why it's built that way. Every path in it comes from internal/paths. paths.Dirs names the shared folders and files, and Dirs.VM(name) gives a VM's paths.VM, whose methods name each file in the VM's folder: Dirs.VMDir(hash), vms/<hash>/, for a project VM, and run/builds/<name>/ for a build VM. A new file of a VM's gets a method on paths.VM, so it lands in the VM's folder, and vmFolders.teardown in internal/vm/teardown.go deletes it with the folder, with no list of files to update. A new socket goes in Dirs.Run(), named by a hash, and TestSocketsFit checks the longest path against paths.SocketMax. A new record that only devvm writes is JSON, read with encoding/json, which ignores fields it doesn't know, and written whole with state.WriteFile. A new default goes in internal/settings, which reads config.toml strictly and saves settings.json, and a new lock is an OS file lock (platform.LockFile and its kin) on a file that paths names.

The data folder and the config folder each hold a version file with their layout version, state.Layout in internal/state/layout.go. Before each command that reads them, state.CheckLayout takes version.lock in the data folder and compares both files with state.Layout. A folder without the file gets this devvm's version, the same version goes on, and a newer one stops the command with layout_newer, because a newer devvm changed the folders. An older one runs the migrations from that version to this one, in order, and then writes state.Layout into both files. skipsLayout in internal/cli/root.go lists the commands that skip the check: help, completion, the version and devvm's own hidden commands.

testdata/script/layout.txtar makes two VMs on the allowlist tier, a forwarded port, a link and a secret, lists every file and folder under the data and config folders, and compares the lists with the ones at the end of the script, one for macOS and one for Linux. A change to the layout, such as a new file, a renamed folder or a file that moves, changes a listing, so the test fails until you update it. When it does, decide whether the change needs a new layout version:

  1. A change that an older devvm would read wrongly, or a file that moves, raises state.Layout by one.
  2. It adds a state.Migration at the end of migrations(), which changes the folders from the version before to the new one. A migration takes paths.Dirs, and a run that it fails stops before the versions change, so the next run tries it again. TestMigrations checks that there's one migration for each version before this one, and TestCheckLayout runs fake ones.
  3. It updates the listings in layout.txtar.

A new file that an older devvm doesn't need to know about, or a field added to a JSON file, which an older devvm ignores, keeps the version and changes only the listings.

Released state

testdata/v0.1.0/darwin/ holds the state that devvm 0.1.0 left on a Mac, and testdata/v0.1.0/linux/ the state it left on Linux: four VMs' states, its defaults, its agent store and logins, the stubs' record of the VMs, and what its --json printed for them. Version 0.1.0 made these files itself. testdata/v0.1.0/generate.sh checks out the v0.1.0 tag in a temporary folder and runs generate.txtar with that version's own CLI test harness, then copies what the run left, with each file's mode in modes, because git doesn't keep modes. TestV010VMStates and the other TestV010 tests in internal/vm read every file with today's readers and check that each field 0.1.0 wrote reads and writes back unchanged. testdata/script/fixture_v010.txtar puts the state into a sandbox with fixture v0.1.0, which moves it to the sandbox's folder: the folder's path, each VM's name hash, its folder's and .git's identities and its backend's place become what they are there, and nothing else changes. The script then runs today's devvm on it. Each --json must have everything 0.1.0's had (json_superset), the read-only commands must change no file, and a launch must start each VM as it is, without a Lima edit.

When one of these fails, today's devvm breaks the state that 0.1.0's users have. Fix devvm, or add a migration, but never change the fixture. The fixture is frozen: never run generate.sh from a newer devvm, and never edit its files. A new release whose state differs gets its own folder, such as testdata/v0.2.0/, with its own generate.sh, and the older folders stay as they are.