44 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 a8f0517579 feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut
in its 900 MB fails base's build, and a stall hangs it. devvm now
downloads the pinned image itself through fetch.Resumable
(ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage),
resuming across cuts, stalls and runs, and gives Lima that file. Lima
2.3 checks a local file against the digest before it copies it.

- Before downloading, it takes the image from Lima's own download cache
  when that holds it with the pin's SHA-256: copied into a new file of
  devvm's own, mode 600, hashed as it's written, capped, stopped by the
  context, and kept only once it checks out. Lima's cache is never
  changed, and a base whose dated release Ubuntu may have removed still
  builds again.
- One devvm downloads at a time (images/locks/ubuntu-image), another
  waiting under ubuntu_image_waiting and looking again under the lock
  (TestUbuntuImageAfterWait, which fails without that second look).
- The download goes through the company proxy and trusts the user's CAs
  (Lima.Roots, from trust.Pool, which internal/cli passes through the
  registry), as do the Finder's lookups (TestNewTrustsRoots, and the
  registry's TestOverrides). An untrusted certificate is
  ubuntu_untrusted, naming the CAs' folder, one from a trusted CA
  that's for another host, out of date or not valid yet
  ubuntu_bad_certificate (check the clock and what answers for the
  host), and any other that fails to verify (a SHA-1 signature, a CA's
  name constraints, a key for clients alone) ubuntu_certificate_invalid,
  naming Go's reason, for the lookups (the listing, the checksums, their
  signature: TestLookupCertificates) and the download alike
  (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410)
  ubuntu_release_gone, which names devvm rebuild base; none is retried.
  ubuntu_download_failed no longer starts with devvm.
- fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a
  CertificateInvalidError that's Expired) and fetch.Unverified (any
  failure to verify, with its reason, so every error the other two
  name), beside fetch.Gone, are the one
  place that tells a certificate's failures apart: Transient asks
  Unverified, the lookups and the download ask all three, host mise
  asks Untrusted, and a forbidigo rule keeps x509's and tls's
  verification errors in internal/fetch (TestCertificateClasses,
  TestTransient, testdata/lint, the owners doc's row).
- An https address, or a test build's file:// DEVVM_UBUNTU_URL, read
  from disk the same way; anything else is refused. The CLI tests'
  sandbox has a stand-in of this host's image in the store.
- Base's record keeps the image's address, and the key is as it was: it
  hashes the pin (release, file, digest), not the location.
- devvm gc --caches frees devvm's copies that no record names and that
  aren't pinned now, unchanged for an hour, a stopped .part and a killed
  import's .import included, and those of a kept image once its .img is
  there. A pin it can't read fails it.
- Of Lima's cache, it frees only an entry that devvm's own state shows a
  build of devvm's left: a base record names its address, devvm has its
  own copy of the image, and the installed Lima's own templates
  (share/lima/templates beside limactl, Lima.Templates) don't name it.
  An entry no record names may be the user's own Lima's, so it stays,
  and none is freed when the templates can't be read, with a line in
  the run log naming the folder and why. A test build's
  DEVVM_LIMA_TEMPLATES stands in for the templates folder.
- ubuntu.ParseImage reads a record's image as Image.String writes it,
  and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in
  place of Lima's own regex.
- devvm space shows the copies as a cloud images row, freed by gc
  --caches, kept as state, as a release Ubuntu removed can't be
  downloaded again.

0.1.0's frozen state runs the new commands (fixture_v010_cloud_image):
devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's
base record keeps and never changes the entry, base builds from devvm's
own copy, and gc --caches keeps that copy, frees Lima's entry the
record names and devvm's own stale copies, and keeps an older entry no
record names.

Docs: images.md (the download, its failures, the import, gc's rules),
space.md, backends/lima.md, settings.md (the lookups and the download
trust your CAs), troubleshooting.md, overview.md, testing.md,
tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed
lines, which later commits make highlights, What to do 5 and 6, and the
release page's Ubuntu's cloud image in devvm's folder.

New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting,
ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate,
ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted.
Lima.LocalImage is the seam, Lima.ImageClient the client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 4ccdbf8125 fix(vm): folder identity's last checks: a renumbered folder keeps its volume
From the volume UUID commit's security review. A folder at its own
recorded path on a disk numbered anew (platform.SameFolder's renumbered
case) must now also be on the volume its state records, when both are
known (platform.KeepsVolume): the finder checks it (finder.sameFolder,
Env.keepsVolume, so a launch refuses with vm_other_folder) and so does
recordFolder under the state's lock, so a copy of the disk with a volume
ID of its own mounted at the folder's path is another folder. A volume
that can't be told leaves the device's rule, as for a state that
records none. mountedBy and mountsRepo keep the check without volumes
(madeFor), which errs towards warning.

hereOf reads the folder's identity, uniqueness, owner and volume from
one open folder (platform.StatFolder, now with Owner), so the folder
checked as the user's is the one matched and recorded. StatFolder is
one function for macOS and Linux (folderstat_unix.go) over each
system's openFolder, which SameFolder's renumbered case uses too, in
place of openFolderID and darwin's copy.

devvm ls and devvm space look volumes up through the run's Env
(Env.FolderOf, Inventory.List(ctx, e)), each mount once a run, in
place of diskutil for each VM; FolderOf, parentVolume and movedAway go.
FolderDevice is unexported (folderDevice), so only platform reads a
device; OnRecordedDisk takes a record without a device as on any disk.

The folder-ids rule tracks names assigned from such names, however
many steps on, and maps keyed by an identity, indexed or in a map's
literal, without counting a struct literal's field; its loop is
sitesWhereIn, shared with sitesWhere. The hdiutil e2e check makes sure
macOS gave the disk a new number, attaching up to three images first,
and is skipped when it never does. The design notes say who can forge
a volume ID and what it gets them.

Tests: TestKeepsVolume, OnRecordedDisk without a device,
TestRenumberedOnAnotherVolume (a launch and recordFolder),
TestListLooksUpVolumesOnce, StatFolder's Owner on both systems, the
folder-ids rule's new cases, and fixture_v010_renumbered.txtar (another
volume at its own path refused with nothing recorded; ls calls the
moved folder gone by its recorded volume, where it said not_connected).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:15:53 -07:00
w3cjandClaude Opus 5.5 90a64a44d1 fix(races): lock order checked, sandboxes' own ports, pins that meet a rename, daemons' groups stopped
- 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]>
2026-11-15 22:04:31 -07:00
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
w3cjandClaude Opus 5.5 3e81767482 refactor(cli): each command carries its own docs link, group and samples
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]>
2026-11-08 10:05:13 -07:00
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 ca8a91305b fix(ui): one failure path, and an interrupt's cleanups wait for the command
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]>
2026-11-05 10:42:20 -07:00
w3cjandClaude Opus 5.5 c1ca05bd94 refactor(vm): housekeeping and exports move out of cli
vm.Housekeeping owns what devvm keeps besides its VMs, and cli only
renders what it returns: ListImages and ShareListing (the tool targets,
worked out once in ToolTargets, for devvm images, gc, space and
retention), LockGC, PlanGC (one inventory per run: the states, with
--orphans the backends' lists too), GCPlan.Apply (returns GCDone, what
it deleted in order, an image the backend refused among it) and Retain.
gc runs on the run's one registry throughout, --caches included.

vm.Exports owns an export's name (parsed without a regex), the list,
the .folder file written and read, deletion and a folder's newest
export; it replaces lifecycle.go's name, history.go's parse and
retention's handling.

One orphan definition: devvm space's leftover state is now what
devvm gc --orphans would forget (Leftovers.FindIn, on space's own
inventory), so a VM whose state changed in the last hour, one made in
another Lima home and one being made again count as state, not
leftover, and the row's retention uses the orphan's Changed time.
space.txtar pins it against gc --orphans' list.

gc's Short names old files and the Nix cache over its cap; the CLI
reference is regenerated. using/space.md says what leftover state is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 03:29:38 -07:00
w3cjandClaude Opus 5.5 e6f64dae31 refactor(vm): one VM inventory per run
vm.Inventory (internal/vm/inventory.go) holds each project VM's state,
backend and Instance, read in one place: ReadStates for the states
alone, ReadInventory (UsedBackends or AllBackends) for the backends'
lists too, each within the host's list wait (30 s), with the backend's
Check saying why a list failed. It replaces Env.mounts, recordedVMs,
vm.List and vm.ToolsInUse, linkstate's clientStates listing, the
secret list's, Leftovers.Find's (and backendVMs), cli/space.go's two
(backendRows' list, vmFolders), images' state.Backends and sshconfig's
running list: sshconfig.Write takes the inventory's Running VMs.
state.ReadAll reads each VM folder on its own (only the inventory calls
it, a structure-test callers rule); state.Backends and Registry.Used go.

One failure policy:
- a backend that can't list fails a listing (Inventory.Err) only when
  some VM's state names it: devvm ls and the ssh config fail, and the
  ssh config stays as it was rather than lose that backend's entries;
  space and gc --orphans name it and leave its VMs alone;
- an unreadable vm.json is its own row: ls lists the VM with its name
  and status alone and warns (vm_state_unreadable); links, the secret
  list, rm VM and link targets leave it out; gc --orphans never takes it
  for an orphan; ToolsInUse and Mounts (images, gc, space, the SSH
  agent's mounted-key check) fail on it, naming the file;
- FolderOf is bounded (5 s): a folder on a hung share is there.

Mounts come from the states alone, stopped VMs and agents' folders
included, so the mounted-key check asks no backend. ui.Table shows every
cell through msg.OneLine, so ls's cells can't move the cursor or break
a row.

Docs: internals/overview's listing, troubleshooting's file devvm can't
read, ssh's mounted keys, contributing's owners table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 02:30:53 -07:00
w3cjandClaude Opus 5.5 e132a29b5a refactor(cli): one per-run app holds the run's services
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]>
2026-11-05 00:53:51 -07:00
w3cjandClaude Opus 5.5 0941219a76 feat(build): base's packages recorded per key, replayed from a host cache
base's apt packages are no longer pinned by a snapshot. A key's first
build of base records them: assets/layers/apt.sh (a recipe step, as
root, before base.sh and after the last feature) points the image's
sources at an apt mirror+file: list of config.toml's ubuntu-mirror and
then Ubuntu's own archive, so apt checks everything against the archive
key whichever server answers, and keeps what it downloads. At the end it
gives back each package with apt's entry for it. devvm checks what comes
back (regular files only, each named by its own SHA-256, each entry
matching a file's size and SHA-256, nothing left over, at most 20,000
entries and 16 GiB), keeps the files in
~/.local/share/devvm/packages/<sha256>.deb and the key's set in
packages/sets/<key>.json, before the image's record. Every later build of
that key replays the set from the cache, checked on the host first, with
apt given only those files: no network for base's packages, and a key's
packages never change. A --from base keeps its image's own sources,
unpinned. base keeps no package lists, so each layer's recipe starts
with apt.sh lists, which fetches them when there are none.

- backend.ImageSpec.Packages (Send before the steps, Take after) and
  backend.PackagesDir; Lima runs both over limactl shell as root.
- Fail fast: apt.sh turns apt's retries off and exits 75 when no source
  answers, which Lima reports as build_sources_unreachable.
- packages_missing refuses a replay whose cached file is gone or changed;
  packages_refused what a build gives back that isn't packages.
- config.toml's ubuntu-mirror (settings.UbuntuMirror), checked as an
  http(s) address without a user, query or spaces (ubuntu_mirror_invalid).
- devvm gc deletes the sets of keys neither current nor built, then,
  under the cache's lock, the files no set names at that moment, and
  builds' leftover folders over a day old (gc_packages,
  deleted_packages); devvm space lists the cache.
- The snapshot is gone from base.sh, guest/sync.sh and desktop.sh, and
  scripts/bump.sh's apt step with it.
- Tests: recording then replaying, a missing or changed cached file,
  every refusal of what comes back, gc's view of the cache and its race
  with a new set, the set record, the mirror setting, Lima's exchange and
  exit 75, apt.sh's mirrored and record functions, apt.sh in the keys;
  the limactl stub keeps what's sent and gives back
  $STUB_DIR/packages-out.tar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:58:23 -07:00
w3cjandClaude Opus 5.5 1640feb608 feat(netpolicy): one CA per VM, with a successor the VM trusts ahead of time
Each VM with network policy has CAs of its own in its run folder,
vms/<hash>/run/ca/ (paths.VM.CA, paths.CA: ca.pem/ca.key, next.pem/
next.key; folder 700, keys 600, kept out of Time Machine on macOS), so a
leaked key reaches one VM and no proxy can sign for another VM. The
shared ~/.local/share/devvm/ca (Dirs.CA) is gone.

trust.InitCA(paths.CA) readies the current CA and the next one at each
launch: the current one stays while it has over a week left, then the
next one (started) takes its place, else a new one; the next one starts
a week and an hour before the current one ends and is made again when it
doesn't follow it. Each CA lasts 30 days and an hour, and its common
name holds its serial, so a VM's two CAs never share a subject.

The proxy's config gains ca_next, ca_next_key and ca_next_sha256 (part
of Sum); the proxy signs with the next CA from an hour after its start
(ca.signer), so the switch needs no launch or new proxy, and a VM not
opened again stays verifiable for at least 30 days less an hour after
its last launch. /ca.pem serves both certificates. loadCA reads the CA
files with readPrivate (no links, a key only the user may read, 64 KiB
cap) instead of tls.LoadX509KeyPair. The VM's setup sends both
certificates (devvm-proxy.crt, devvm-proxy-next.crt) and no key.

Tests: TestInitCA, TestInitCASwitch, TestInitCAReplaced (trust);
TestNextCASigns, TestLoadCA, config check rows (proxy); TestPrepare and
TestPrepareRestartsTheProxy for the VM's CA files and both sums
(netpolicy); TestVMFiles; network, sync and layout txtar; e2e network: a
second network-policy VM with different CAs, each VM trusting only its
own and holding no key, each proxy serving and presenting only its own
VM's CAs, devvm rm deleting one VM's CAs.

Docs: internals/network.md (The VM's CA), design.md (A CA per VM, its
threat check), safety/network.md, overview.md's per-VM files, space.md,
security.md, attack-vectors.md, limits.md, coding-agents.md,
contributing, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 20:54:41 -07:00
w3cjandClaude Opus 5.5 120ca70279 fix(vm): a VM whose folder is on a disk that isn't connected isn't gone
A folder with nothing at its path is now one of three folder states
(vm.FolderOf): there, gone, or not connected. With nothing at the path,
devvm compares the device of the nearest folder above it that exists
(platform.DeviceOf) with the device in the recorded folder identity
(platform.FolderDevice): the same device is gone, another is not
connected (a folder moved to another disk and then deleted counts too),
and no recorded identity or an unreadable device is gone.

devvm ls writes (not connected) and --json gives folder_state (there,
gone, not_connected) in place of folder_gone; devvm space names such
VMs (space_folder_not_connected) and lists them as
folder_not_connected. devvm rm VM refuses one without a terminal, even
with --force (rm_vm_not_connected), and in one asks
(delete_not_connected_folder_vm), which --force never answers.

Tests: TestFolderOf (a fake device: same, other, none, unreadable, and
a real deleted folder), TestDeviceOf, the JSON shapes, rm_vm.txtar's
not-connected case, ls.txtar. Docs: commands (rm, ls, a folder on a
disk that isn't connected), space, troubleshooting, overview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 20:49:36 -07:00
w3cjandClaude Opus 5.5 6128f400e4 refactor(backend): Backend is four role interfaces, and Running replaces StartID, Confined and Lifeline
backend.Backend is Name, Caps and four roles, each required:
- Host: Problems, NameMax, Location, DiskDirs, Floors
- Images: BuildImage, Images, ImageSize, DeleteImage, BuildTools,
  ToolFormat, KeyFiles
- Machines: CreateVM, Start, Running, ProxyURL, Stop, Delete, Rename,
  List, Inspect, Exec, Shell, SSH, ForwardTarget
- Housekeeping: Usage, Strays, DevvmCache, DeleteCache

The optional interfaces Lima implemented (KeyFiles, Storage, Locator,
UsageReporter, StrayFinder, CacheCleaner) are gone into the roles, and
their callers call the methods directly; Forgetter stays the one
optional role, found with backend.As. Running(ctx, vm) returns a
backend.Run (ID, Confined, Lifeline) in place of StartID, Confined and
Lifeline. Space.Check, Space.Warning and LocationOf take a Host.

lima.Lima keeps its fields, Name, Caps and its shared helpers (14
methods), and embeds host, images, machines and housekeeping, each over
the Lima it's part of (withRoles); backendtest.Fake is split the same
way. The guard has every role's methods, its own for the ones it guards.

Structure test: max-methods counts an interface's declared methods too;
Lima and the fake leave largeTypes. Tests: TestRunning, TestGuardRoles,
TestAs (Forgetter), TestFakeRunningAndNone, two TestRulesFail cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:58:19 -07:00
w3cjandClaude Opus 5.5 619570e445 refactor(backend): backend.Check, the specs' Validate and the registry's guard
backend.Check(ctx, b) returns the first of a backend's Problems, in place
of Check in the Backend interface (Lima's and the fake's go).

ImageSpec.Validate and ToolsSpec.Validate hold the build specs' checks
Lima made itself: a layer from a container image, a network that isn't a
build's, a key that isn't one, a tools format other than the backend's,
folders that aren't absolute. ToolsSpec gets Name, what it builds, for
the refusal's vm.

The registry hands out each backend behind a guard: CreateVM, Start,
BuildImage and BuildTools run the spec's Validate and the review's
refusal for spec.Features() (VMSpec's, Want's and Confinement's,
ImageSpec's, ToolsSpec's) before the backend sees them, without a second
warning for an unreviewed emulation let through. Callers' own Require
calls stay as the clear error path; the guard is the backstop.
Want.Features is new; VMSpec.Features uses it and adds agent-toggle when
the VM is made ready for it. backend.As finds a backend's other
interfaces behind the guard (KeyFiles, Storage, Locator, Forgetter,
UsageReporter, StrayFinder, CacheCleaner).

Structure test: execSites lists the 17 files whose 24 exec.Command*
calls stay, each with why (they make a command a runner runs, or one
that streams, asks on the terminal, outlives the run or carries a
secret); a host command made anywhere else fails, as does a listed file
making none. guardOwner: a type assertion or type switch to a backend
package's type outside guard.go fails (use backend.As). TestRulesFail
cases for both.

Tests: TestCheck, TestImageSpecValidate, TestToolsSpecValidate,
TestGuardRefuses, TestGuardLetsThrough, TestAs; TestFeaturesNeeded
gains Want's and agent-toggle; Lima's refuse cases for what Validate
owns move to the backend package.

Docs: internals/backends.md (the guard behind the first check);
contributing's How a backend plugs in (Check, the guard, Validate, As),
the structure test's execSites and guardOwner, and the owners table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:13:57 -07:00
w3cjandClaude Opus 5.5 8ec7547ebd feat(cli): devvm rm VM deletes a VM whose folder is gone, and ls and space mark it
A VM whose recorded project folder is gone (nothing at its path) is
marked: devvm ls writes "(gone)" after its folder and gives
"folder_gone" in --json; devvm space names it in a note and in
--json's "folder_gone". devvm rm takes an optional VM, by name or ssh
alias, from any folder: this folder's own VM goes through rm; a VM
whose folder is there, a name that isn't a VM's, and a VM its backend
lost are refused. It asks in a terminal, --force answers, and without
either it refuses. Agents' history is exported first unless
--no-export; a stopped VM that mounts its folder is refused, as
starting it would make the folder again (Lima makes a missing mount's
folder); a --clone VM needs --no-clone-check. Never deleted by gc or
retention.

vm: FolderGone, Lifecycle.RmVM/rmGone, recordedVMs (moved from
Links.projectVMs); project: Named (Targets uses it). Messages:
rm_unknown_vm, rm_vm_folder_there, rm_vm_lost, rm_gone_stopped,
rm_gone_clone, rm_vm_export_failed, rm_vm_failed,
delete_gone_folder_vm (answered by --force), space_folder_gone.
Tests: testscript rm_vm, ls; TestFolderGone, TestList, TestTargets,
TestJSONShapes. Docs: commands (rm, ls, a VM whose folder is gone),
space, troubleshooting, coding-agents, overview; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 16:19:44 -07:00
w3cjandClaude Opus 5.5 9f6f62d28a refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name,
alias, image, chain, from, dir, folder, backend, backend_at, created)
and one section per package, each a json.RawMessage its owner decodes
into its own type (state.Section, state.SetSection), what was asked for
at its top level and what devvm made under "made":
net (netpolicy), git (gitprotect), ports (the new internal/ports),
agent (sshagent), tools (tools), secrets (secrets), and size, clone,
devcontainer, desktop and links (vm, internal/vm/state.go).

- state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the
  file again, applies a change and writes it once; a failed change, or
  write, writes nothing. VM.Set and its calls are gone; read-modify-write
  of lists (links, publish, secrets, tools, size, ports) happens inside
  Update. VM.Claim also holds run/claims.lock, after the VM's own;
  VM.Create writes a new VM's whole record once, its alias chosen
  (sshconfig.ChooseAlias) under the claims lock. Reads take no lock.
- created replaces "net unset" as unfinished (VM.Finished).
- internal/ports: the ports section (forward, host.ssh/proxy/desktop),
  ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy
  and desktop ports under the claims lock (desktop allocated without
  one before; run/ports.lock and netpolicy's own ports key are gone).
- gitprotect: mode recorded before the backend makes the VM (NewMode;
  clone for --clone, which ls and git-protect share as gitprotect.Mode);
  made.git_id (platform.FolderID), one git_dirs list for modules and
  embedded git dirs, delegations, protected; Unlock takes the union of
  recorded and current git dirs.
- links' entries, git dirs, tools and devcontainer commands are JSON
  lists, not strings in values; the key=value parser is gone.
- vm.checkState reads every section of the folder's VM as it's found.
- registry.For drops its unused Dirs.
- Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate,
  TestVMUpdateTogether (two writers on one VM and on crossed VMs),
  TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether,
  TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded,
  TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's
  vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 14:47:06 -07:00
w3cjandClaude Opus 5.5 79b3ef94d4 refactor(cli): one backend: no --backend flag, no BACKEND column
devvm runs every VM on Lima, so the command line has no backend choice:

- --backend is gone from devvm, build, rebuild, images, images rm, gc,
  space, doctor and setup (addBackendFlag, addBackendFilterFlag, setup's
  own, checkFlagValue's case, its completion); a removed flag now fails
  as an unknown flag (exit 2).
- devvm setup no longer asks for or saves a default backend; config.toml
  and settings.json have no backend key (settings.KeyBackend, Values and
  Defaults' Backend, checkBackend, Value.With, Source.File, FromFlag).
- Tables lose BACKEND: ls, images (both tables), space (both tables);
  doctor's FEATURE table is FEATURE and SUPPORT for Lima. space's images
  row is freed by images rm.
- --json keeps every backend field (ls, images, tool records, space,
  doctor's backend, backend_source "built-in" and every backend's
  features).
- The registry keeps Lookup, For and Default: For(d, vm) gives a VM its
  recorded backend and a new VM NewVMs, else Default; tests set NewVMs.
  vm.Env's lookups lose the flag parameter, found.flagIgnored and
  Options.Backend.
- Messages removed: backend_unknown, backend_unknown_default,
  default_backend, backend_help, doctor_backend_from,
  backend_flag_ignored; backend_unknown_vm stays (a VM's recorded
  backend), linked to backends#a-vms-backend.
- Docs: Backends' choosing section becomes "A VM's backend"; settings,
  setup, images, gc, space, doctor, commands and install pages lose
  --backend and BACKEND; Contributing gains "How a backend plugs in".
- Tests: unit tests for For, settings, setup, doctor's table, the
  tables; CLI scripts check --backend as an unknown flag on devvm,
  build, restart, images, gc, space, doctor and setup, and a config.toml
  backend key as unknown; e2e's table checks lose the column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 12:46:28 -07:00
w3cjandClaude Opus 5.5 f4fd373439 refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend,
Caps, Features, Review/Require, the registry, backendtest.Fake), so
another backend is an addition.

State from a smolvm VM reads as an unknown backend (backend_unknown_vm,
gc_orphans_unknown); nothing migrates it. The image keys of
layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images
rebuild once.

Lima's port forwarder moves off smolvm's files first: newForwarderCmd and
forwarderMain from internal/cli/smolvmports.go to limaports.go, and
assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder
at run time, so no image key changes).

Removed:
- internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its
  registry entry, registry.Experimental and backend_experimental.
- The decider: backend.Decider/UsesDecider, Confinement.Decider and
  DeciderToken, internal/proxy/decider.go and its test, the proxy's
  -decider, -decider-to and -decider-token-file, netpolicy's
  KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in
  vm's forwarding and UsedPorts.
- backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and
  agent_unchosen_stop.
- vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped).
- paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's
  Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing
  called (a test helper now).
- ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and
  bump.sh's ubuntu_image, with its part of bump.txtar.
- assets/smolvm/ and assets/container/; the no-init-system branches of
  layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in
  features/desktop.sh and guest/ca.sh.
- Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh,
  creating_from_image, packing_image, pack_failed, backend_experimental,
  agent_unchosen_stop; descriptions naming smolvm reworded.
- Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and
  sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a
  failing or hanging Lima listing instead (the limactl stub's list-fails
  and list-hangs); the --backend smolvm examples; e2e's --backend smolvm
  and its section (about 1,130 lines), the smol_* helpers and the
  link section's backend switch.
- Coverage: internal/backend/smolvm's lines in both baselines.
- Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm
  notes (Ports on Lima now holds the forwarder's description), the
  backends table's smolvm column, every page naming smolvm, the README,
  the home page's backends art, and AGENTS.md's smolvm rows and gotchas
  (and the Docker bind-mount gotcha, which nothing refers to).

Kept: the docker layer, on Lima; --from's local Docker; --backend, the
BACKEND column and setup's backend choice, which the next commit removes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 11:34:05 -07:00
w3cjandClaude Opus 5.5 1917072228 refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the
default backend and smolvm stays experimental. The backend architecture
(Backend, Caps, Require, the registry, backendtest.Fake) stays, so
another backend is an addition.

Removed:
- internal/backend/docker, its registry entry and Names/Experimental's
  docker half; devvm _docker-connect and _docker-ports
  (internal/cli/dockerssh.go); assets/docker/unpack.sh.
- Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS,
  DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256
  ldflags vars and the CLI tests' Linux-build archive (linux_release).
- Interfaces only Docker implemented, with their callers:
  backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix),
  DiskUser (ls's and size's disk-over warning, size's disk_used and
  --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover
  (gc --orphans' volumes, networks, containers and images),
  DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and
  vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name.
- The docker layer's runtime on a backend that makes VMs for it:
  vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet
  returns a bool now), the refusals at start and devvm network on, ls's
  "(sysbox)" and --json docker_layer, size_disk_default_unused.
- The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix).
- paths.Dirs.Docker and paths.VM.Lifeline.
- assets/guest/tools.sh's linked-folder branch; services.sh's
  DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd.
- Messages: every docker_* the backend used, docker_layer_runtime,
  net_docker_layer, net_off_docker_layer, committing_image,
  pulling_image, unpacking_tools, disk_over, size_disk_default_unused,
  gc_orphan_volume/_network/_container/_image, docker_connect_failed;
  gc_orphan_elsewhere reworded.
- Tests: docker.txtar, the docker stub's engine (its --from half
  stays), the ssh stub's login-shell branch; e2e's --backend docker,
  --engine, the docker host VM and Docker Desktop runs.
- Release: one GoReleaser pass, no Linux-build pin in the macOS builds,
  no Linux devvm in the Homebrew formula's libexec. Linux builds stay.
- Docs: backends/docker.md and internals/docker.md, design.md's Docker
  notes, the Docker column of the feature table, and every page's
  mentions of the Docker backend, Docker Desktop as one, and Sysbox.

Kept: the docker layer in Lima VMs, devcontainer docker-in-docker,
--from with images only a local Docker has, Docker Hub references.

State written by a Docker VM before this reads as an unknown backend
(backend_unknown_vm).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 10:26:07 -07:00
w3cjandClaude Opus 5.5 d8a7d4de7f refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/,
where <hash> is the 14-hex hash of the project folder's path that the VM's
name ends with: its state, its own rules (policy), its backend's files
(backend/: record.json, key, known_hosts, proxy, ports and the port
forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb,
started, lifeline.pid, secrets.*, links.*) and its logs (logs/:
network.jsonl, proxy.log, links.log). Build VMs keep the same layout in
run/builds/<name>/. The top-level run/ holds only what isn't one VM's or
must be short: the hashed control sockets, links' link-<hash>.sock/.ctl,
the QEMU wrapper and the ports lock.

A folder's VM is found by its path's hash (state.ReadHash), with the name
and backend its state records, so devvm --backend docker then devvm in
the same folder opens the one VM, and a backend's name limit applies to
new VMs only. The state records the VM's name and its ssh alias, chosen
once at creation (sshconfig.ChooseAlias) and never recomputed. Links'
targets match recorded names, aliases and folders (project.Targets).

One teardown (vmFolders.teardown) replaces Lifecycle.forget,
undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's
leftoverFiles: it stops the proxy and link session, then the pieces
outside the folder (clone remote or .git locks, other VMs' links and the
group, host keys, the backend's leftovers), removes the folder, and
writes the ssh config. Each backend's Delete and Forget remove the VM's
backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier
one's folder was left clears it first. devvm space counts an orphan's
whole folder as leftover state and the other VMs' logs as network logs.

Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files
(secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog,
LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file,
vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and
lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the
user's cache folder for Lima's and smolvm's caches is Dirs.UserCache,
from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and
DockerVM go. vmname.HashOf and IsHash, project.Hash.

The proxy takes the links' sockets' folder (-link-sockets, devvm's run
folder) apart from the links' list, which is in the VM's run folder.

Tests: a VM made and removed (rm, gc --orphans) leaves nothing under
vms/, and with network policy has no file named for it outside its
folder (TestTeardownLeavesNothing); a new VM over an old folder starts
clean; lookup finds a VM made on another backend with a long folder name
and makes no second one (TestLookupOtherBackend, and in docker.txtar);
the alias stays put when a second VM shares the folder name
(TestChooseAlias, ssh.txtar); every socket fits under a 35-character
home with the longest VM name (TestSocketsFit); space counts an
orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by
hash and name; the proxy refuses a socket in the list's own folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 08:16:39 -07:00
w3cjandClaude Opus 5.5 dd3f0deb3f feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).

internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.

devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.

ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.

Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:56:29 -07:00
w3cjandClaude Opus 5.5 299ddb1476 refactor(state): image records in images/<key>/, rebuild counters per backend and --from, tool image records, cache/
- Image records are images/<key>/record.json (JSON, unknown fields
  ignored; name, chain, from, digest, libc, built). state.Images lists
  the folders; AnyImage needs a record.json; RemoveImage deletes the
  folder. Lima's cache cleaner reads records through state.Images.
- Rebuild counters are images/rebuilds.json, keyed by (backend, from as
  given, name), changed under images/locks/rebuilds. image.Inputs takes
  them through an image.Rebuilds interface. A rebuild on one backend no
  longer outdates the others' images, and two --from references that
  wrote the same counter name (node:24, node-24) stay apart.
  paths.RebuildFile, RebuildName and unsafeName are gone.
- Tool images: <file>.sha256, .target and .idle become one <file>.json
  (sha256, libc, format, backend, built, idle_since; state.ToolImage).
  BACKEND and LIBC read the record; the fallbacks (format matching,
  a VM's target, the current target) go, with toolTargets, vmToolTargets,
  formatBackend and gc's backendTools (toolsOn does it).
  Share.IdleFor owns reading idle_since.
- cache/ (Dirs.Cache) holds mise/, nix-cache/ and from-digests.json.
  With the cache gone, from.Recorded takes the newest base record's
  digest for the reference, so no key changes.
- Key check: the rebuild counter is the one input that moved and changes
  keys (deliberately: per backend and exact from). The --from digest
  moved to cache/ and stays an input, kept stable by the records'
  fallback. Records, mise and the Nix cache are outputs.
- Tests: state's image, rebuild, digest and tool record tests; image key
  cases per backend and exact from; build.TestRebuildIsPerBackend;
  from.TestRecordedWithoutTheCache; cli.TestToolsOn; rebuild.txtar
  (Docker's and smolvm's rebuilds keep Lima's and the other --from's
  bases), gc_caches.txtar and from.txtar (a missing cache/); the
  testscript command json_set; e2e reads the JSON records.
- Docs: space, images, settings (retention), internals images,
  overview, network, security, contributing (json_set).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:37:36 -07:00
w3cjandClaude Opus 5.5 a134e0d8a6 feat(cli): choose a new VM's toolchains, agents and layers in a picker or with --tools, --agents and --layers
devvm takes no IMAGE word any more than any other: in a terminal a new VM's
toolchains, coding agents and layers are checked in one picker, under three
headings, before the network-policy question; --tools, --agents and
--layers (each an exact list, or none) skip it, and a part left out takes
its default: the detected toolchains, devvm setup's agents, no layers (a
devcontainer.json's features still count). Without a terminal, or with
--no-input, the VM gets the defaults and new_vm_gets says so in one line.
devvm setup --agents (and its first-run question) chooses new VMs' agents.
devvm tools in a terminal opens the same picker for the VM, its layers
fixed, and turns the changes into tools add and rm.

An image is base and layers only: tools are the VM's tool_names state key.
build, rebuild and images rm refuse a shared tool (tool_not_layer), and
devvm build builds no tool images. devvm ls gains a TOOLS column and
--json tools. gc's --tools is --tool-images, so --tools has one meaning.

Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or
no_command_like, did-you-mean over commands, msg.Closest), the lacks path
in internal/vm/existing.go, and the messages vm_lacks_tools,
vm_lacks_layer, layer_is_command, layer_name_command, no_image_for,
no_command_or_image*, tools_not_images, tools_not_images_rm, detected,
vm_is_now (vm_tools_now), secret_with_image (secret_with_claude).
New: ui.Pick takes headed sections with fixed rows, ui.CanPick,
vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go),
state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents,
project.DetectFiles. Image keys are unchanged in form: images never held
tools; docker.sh's and nix.sh's comments changed, so those layers rebuild.

Docs: the home page's quick start steps, diagram (sandbox.svg), cards and
FAQ; README; getting started; using (images' What a new VM gets, coding
agents' Running an agent, settings' agents); internals; contributing;
the cli skill; AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 00:45:09 -07:00
w3cjandClaude Opus 5.5 f71adb5a04 refactor: devvm's own files stay in the binary
assets.FS is the only copy of devvm's own files: nothing writes them to
~/.local/share/devvm/assets/<hash> any more, so an edit on disk can't
widen running proxies' allowlists or change a --from base its key
doesn't describe.

- Proxy: -builtin-policy NAME,... names policies in IO.FS (cli's _proxy
  passes assets.FS; proxy stays stdlib-only). Built-ins are parsed once
  at start (readBuiltins), ahead of -policy's files in the union, never
  re-read; a missing one, or one with a line that isn't a rule, refuses
  to start. -policy carries only the user's files.
- netpolicy: PolicyFiles(d, assets, vm, img) becomes Policies(d, vm, img)
  (builtin, files); Proxy.PolicyFiles and AssetsInUse go. .proxy.policy
  records both lists, a line each, for the restart check. ReadRules takes
  built-ins from an fs.FS; RuleFile.Builtin.
- devvm network: built-ins labelled "# devvm: layers/base.policy";
  --json entries carry "builtin": NAME or "file": PATH ("version": 1).
- Lima: createArgs ends in "-" and create() feeds base.yaml on stdin;
  convert writes oci/ and, with company CAs, guest/ca.sh into its own
  temp folder beside vm/ (writeScripts, state.WriteFile), mounted
  read-only and deleted by the existing cleanup. Lima.assets() goes.
- Deleted: internal/state/assets.go and its test (WriteAssets,
  StaleAssets, AssetsHash), paths.Dirs.Assets, gc's stale-assets plan
  and the gc_assets/deleted_assets messages, space's devvm's files row.
- Tests: proxy built-ins (order, not re-read, missing/invalid refuse,
  Main refuses before listening), Policies, the restart check on either
  list, ReadRules/WriteRules labels, JSON shape, createArgs and create's
  stdin, writeScripts' files and modes; CLI scripts check
  $XDG_DATA_HOME/devvm/assets never appears after up, build and --from,
  base.yaml on create's input (the limactl stub keeps it), the
  conversion's mounts and script paths in its temp folder.
- Docs: design (One binary), install, overview, space, images (gc),
  internals network, images and lima, safety/network, proxy README,
  the network command's Long and its CLI page; AGENTS.md rule.
- Coverage baselines (darwin) raised: cli 88.2, netpolicy 87.2,
  proxy 88.2, state 91.8. Dirs' method cap lowered to 41.

Image keys are unchanged: they already hash the embedded files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -07:00
w3cjandClaude Opus 5.5 94c126275c fix(secrets): VM and proxy files written through unique temporary files
The secret store's files, a VM's secret bindings and secret-hosts policy,
and the files a VM's proxy starts with (its password, the decider token,
the company proxy's settings and its run records) were written through a
fixed path.tmp: two devvm runs writing one file at once could rename each
other's half-written file or fail, and a failed write left the temporary
file behind. They go through state.WriteFile now, which writes a temporary
file of its own (owner-only), syncs it and renames it, removing it on any
failure. The two private writeFile copies are gone. A temporary file that
a killed run leaves (.<file>.tmp-*) goes with what it was for: devvm
secret rm deletes a file-saved secret's, and a VM's run files' go with
Proxy.Forget and gc's leftovers (leftoverFiles).

Tests: TestSaveAtOnce and TestWriteFilesFailing (secrets),
TestWriteUpstreamAtOnce and TestPrepareWriteFails (netpolicy); TestForget
and TestLeftoverFiles cover the temporary files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 17:58:56 -07:00
w3cjandClaude Opus 5.5 bdd26779b4 fix(cli): only a test build reads the test overrides
DEVVM_HOST_MISE (which replaced the pinned, checksummed mise), DEVVM_KVM
and DEVVM_UBUNTU_URL were read in every build, a release's included. One
ldflag in a leaf package, internal/testbuild (testBuild=yes, set by
tests/e2e.sh and the CLI tests), now marks a test build, and cli's
readOverrides is the one place devvm reads every test override, into
Overrides (registry.Overrides, with platform.Overrides for the host's
size, and HostMise): empty unless testbuild.On(). registry.New takes
them; lima.New takes Ubuntu's URL; ubuntu.New takes a URL, not getenv;
Lima's and smolvm's KVM default to /dev/kvm; tools.Env has Mise in place
of reading DEVVM_HOST_MISE; platform.NewHost takes Overrides. Gone:
registry.unreviewed, registry.Host, newFor, hostFor, ubuntu.URLEnv. The
documented settings (DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE,
DEVVM_NO_TOOL_CHECK, DEVVM_FROM) stay as they are.

Tests: TestReleaseReadsNoOverrides (cli: a release reads none, its mise,
KVM, unreviewed and host its own), TestOverrides (registry: every override
reaches its backend, none leaves the defaults), TestHostOverrides and
TestListTimeout (platform) and ubuntu's TestNew moved to the new shapes.

Docs: contributing/testing.md's Test builds, contributing's sandbox table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:13:23 -07:00
w3cjandClaude Opus 5.5 9b7652d347 feat(link): links in VMs' lifecycle, and the link backend feature
backend.FeatureLink ("link"), native on Lima, smolvm and Docker, with its
row on internals/backends.md; linkFeatures() returns it, so link add, each
launch, the session and each connection check it with Require.

- Env.Links is guestLinks: an address and a name per target, by address,
  none for a target whose policy rule no longer holds.
- Launch (setUpVM, after the ssh config pins host keys): linkRuns.atLaunch
  starts devvm _links detached (pid in run/<vm>.links.pid, its log in
  logs/<vm>.links.log), warns once per stopped target (link_target_stopped)
  and per target whose policy rule broke (link_policy_mismatch) or whose
  backend lacks links (link_target_unusable), never starting one, and
  reads the new session's log for refused forwards (link_port_taken).
- link add and link rm on a running client send the setup again and make
  sure _links runs (linkRuns.apply), reporting a new link the VM refused;
  on a stopped one, links_next_start.
- Stopping: Lifecycle.Stop and every Env.start stop the session; a session
  killed has its sockets removed; its masters' control sockets go with
  their ssh.
- devvm rm (Lifecycle.forget, so gc --orphans and retention too) stops the
  session and removes every link to the VM from other clients
  (links_target_gone), giving running clients their links at once.
- devvm network off on a target linked by clients with policy
  (network_off_linked) and on for a client linked to a target without
  (network_on_linked) are refused.
- link unpublish names the clients that link to the withdrawn ports
  (unpublished_linked).
- devvm ls has a LINKS column and "links" in --json; devvm doctor lists
  link; gc --orphans removes links to VMs without state and link sockets
  nothing listens on, which devvm space counts as leftover state.
- net_off_log says devvm logs only a VM's links' connections without
  network policy.
- Lima: Start already compares the guest environment, so it edits only
  when the links' names change (TestStartSetsLinkNames); lima.md and the
  design note say the edit's new host keys are pinned again at the start.

Fixes to the earlier link code: vmssh's masters left their control
sockets when killed; the session's log names a forward the VM refused on
a line of its own (ReadLinksLog).

Tests: vm TestGuestLinks, TestPolicyLinked, TestUnlinkTarget,
TestLinkLeftovers, TestLinkRuns, TestLinksAtLaunch; vmssh TestReadLinksLog;
lima TestStartSetsLinkNames; link.txtar updated, link_life.txtar new, the
stub ssh carries link masters; e2e's project section has a link smoke check
on Lima.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:38:24 -08:00
w3cjandClaude Opus 5.5 608d287d00 test(cli): devvm space's backend timeout is a test-build setting, so the space script doesn't depend on load
A test build's Host reads DEVVM_TEST_LIST_TIMEOUT (platform.TestListWait):
comma-separated durations, each for every backend ("10m") or one
("smolvm:1s"), one backend's winning. spaceTimeout(backend) reads it
through registry.Host(), so a release always waits 30 s. devvm space's
listings and strays and gc --caches' cache listing use it.

The CLI tests' fakeHost sets 10m for every script. space.txtar adds a
case where smolvm's listing hangs (the stub's smolvm-ls-hangs) past a
1 s smolvm timeout: smolvm is named (space_backend_unknown) and its VM's
state isn't a leftover. TestListTimeout covers the parsing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:13:27 -08:00
w3cjandClaude Opus 5.5 0b03f334fb feat(cli): help in groups, with short texts, examples and each command's docs page
devvm --help lists the commands in groups: Your VM, Change your VM,
Images, Disk space and This machine, with help under Cobra's Additional
Commands. A group whose commands don't exist yet, such as Links between
VMs, stays out of the help.

Each command's Long is one to three sentences, and the rules it held are
on the command's docs page. Every visible command has an Example, with
the most common invocations first, each with a comment. Flag
descriptions are shorter. Each help ends with the address of the
command's docs page, and the root's also ends with the issue tracker.

- internal/cli/help.go: commandGroups, addGroups, addDocs (Cobra's usage
  template with Docs and Issues sections), examples
- internal/msg/docs.go: commandDocs, CommandDoc, CommandDocURL,
  IssuesURL; TestDocLinks checks commandDocs (user pages only)
- docgen: each reference page has a Docs section before See also
- docs: commands.md in the help's groups, with new sections on
  restarting and stopping and on deleting a VM; install.md has doctor's
  engine, feature values, Docker and CA notes; Contributing describes a
  command's help
- tests: TestExamples, TestHelpGroupsAndDocs, TestAddGroups,
  TestWithDocs, TestCheckCommandDocs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 04:39:39 -08:00
w3cjandClaude Opus 5.5 e782de9ae8 feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory,
--disk, --ports, --network-policy, --no-network-policy) are the root's
own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown
flags. build, rebuild and images rm take --backend and --from;
images, gc and space take --backend as a filter of their own (images
and space now filter: only that backend's rows); doctor takes
--backend; restart and tools take none. ports -g is local on ports,
ports add and ports rm. No command has a persistent flag.

One name, one meaning: network log --follow loses -f (-f is --force's,
and gc --force gains it); the hidden secret get's --force becomes
--to-terminal. Flag defaults name the setting command (devvm size -g,
devvm ports -g, devvm setup --backend); descriptions lose then/also
openings.

Special values are words: an empty flag value (flag_blank) or an empty
argument (arg_blank) is refused everywhere, replacing features_empty.
Durations: state.ParseDuration (a whole number and m, h, d or w) for gc
--older-than, retention's ages and ssh-agent add --lifetime (which also
takes forever, via sshagent.CheckLifetime), with one message,
bad_duration, replacing gc_bad_age and agent_lifetime_invalid.
Blanks are checked with the other usage errors (checkCommand, before
checkFlags), and an unknown --backend NAME is a usage error checked
first too (checkFlagValue, against registry.Names, which a test keeps
equal to the registry's own).

Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning,
TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root,
setup, images, space, gc_history, retention, ssh_agent and network_log
scripts. Docs: commands.md (Flags and values), from.md, install.md,
images.md, space.md, settings.md, ssh.md, network pages; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:14:23 -08:00
w3cjandClaude Opus 5.5 cd6fc60576 feat(cli): --json on every command that shows or lists
ls, images, tools, size, ports, network (and -g), network log (and
--blocked), ssh-agent, git-protect, secret, history, space, retention and
doctor take --json: one JSON object on stdout with "version": 1 first,
messages on stderr (ui.DataOnly), lists [] when empty. Settings commands
only show with --json and refuse a value (json_shows_only). doctor --json
replaces --fixes: problems with key, fix (null without one) and message,
warnings, docker and every backend's features; it prints nothing else and
succeeds whatever is missing, and install.sh reads its problems with awk.
TestJSONShapes holds each command's field names and types. Each shape is
documented on its command's page, with the contract under Everyday
commands' Output for scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:06:56 -08:00
w3cjandClaude Opus 5.5 f9e14e9b37 feat(cli): usage errors as devvm messages, checked before anything runs, exit code 2
Every argument and flag error is a devvm message naming what the command
expected, followed by usage_help naming that command's own --help, and
exits with 2. Arguments and flag values are checked in Args, before the
root's PersistentPreRun and any VM lookup.

- internal/cli/args.go: noArgs, exactArgs, maxArgs, minArgs (argsN, with
  ValidArgs), argsOf (the arguments in Use), checkCommands (wraps every
  command's Args with checkFlags and marks RunE's errors as ranError),
  checkFlagValue (--cpus, --memory, --disk, --ports, --lifetime,
  --older-than), exclusive (flag groups checked first, then Cobra's own
  required flags and groups), flagError (SetFlagErrorFunc: pflag's
  NotExist, ValueRequired, InvalidValue, InvalidSyntax errors).
- Execute: 0, 1 for a failure (RunE's error: a message, or
  output_failed), 2 for a usage error; usage_error is only the fallback.
- Checked early: ports LIST and add/rm LIST (vm.ParsePortList), network
  allow/deny RULEs, network on/off(/ask with -g), layer new NAME
  (build.CheckLayerName), retention KEY=VALUE (state.CheckRetention),
  setup --features '', secret NAME, completion SHELL, git-protect and
  ssh-agent values.
- ui.UI.Error prints an error without ending the run (UI's method limit
  44).
- Messages: usage_help, arg_missing, args_too_many, args_none,
  arg_not_choice, no_subcommand, flag_unknown, flag_needs_value,
  flag_bad_value, flag_bad_switch, flags_exclusive, output_failed;
  usage_error reworded; doc links to troubleshooting.
- Tests: TestUsageErrorsEveryCommand, TestRanErrorIsAFailure, TestArgsOf,
  TestFlagErrors; txtars check message names; e2e checks a bad port list
  exits 2.
- Docs: troubleshooting (a command refused before it runs, exit codes),
  contributing (command arguments), AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 07ca65c098 feat(cli): devvm host, the tools noun and devvm history
devvm ssh is devvm host. devvm tools shows this folder's VM's shared
tools (TOOL VERSION NEWER BUILT, from the lock as it is, never online);
devvm tools add/rm TOOL... add and take out shared tools, each a word of
its own (joined with + refused: tools_joined; add takes only shared
tools: unknown_tool), and devvm tools update moves the VM to the newest.
devvm IMAGE on a VM that exists adds nothing and asks nothing: it fails
with vm_lacks_tools, naming the devvm tools add command, or
vm_lacks_layer, as only a new VM gets a layer. devvm export is devvm
history export [FILE]; devvm history lists the exports in the exports
folder (FILE VM FOLDER DATE SIZE), the folder from a <export>.folder
file written beside devvm's own exports and deleted with them. gc
--exports is gc --history, retention's exports.age/count are
history.age/count, and devvm space's row is history.

The in-place layer machinery goes: Launch.addLayers and runLayers,
dockerLayers' inPlace/set/unset, backend.DockerLayerVM.SetDockerLayer
and the Docker backend's SetDockerLayer, with the add_in_place,
restart_for_mounts, no_terminal_confirm, keeping, adding and
add_layer_failed messages. vm.Tools (tools.go) holds Add, Remove,
Update and List; tools.VMs.Show lists a VM's tools; tools.Remove takes
names as a list; VMs.Update compares a VM's files as a set.

New messages: vm_lacks_tools, vm_lacks_layer, has_tools, tools_joined,
history_failed, tools_failed; renamed: unknown_tool, gc_history,
gc_history_export, deleted_history, gc_older_than_needs_history.
Command files: host.go, tools.go, history.go, refreshtools.go
(_refresh-tools); ssh.go, remove.go, update.go, export.go and
gc_exports.go gone. Tests: TestImageLacks, TestToolsAdd, TestShow,
TestCompleteToolNames; history.txtar, gc_history.txtar, host_code.txtar
and the e2e tools, docker layer and host checks updated. Docs, the CLI
reference, AGENTS.md and the e2e header follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:27:24 -08:00
w3cjandClaude Opus 5.5 18eefddc16 feat(cli): devvm retention, bare secret and ssh-agent, ssh-agent rm, and setup's network question
- devvm retention [KEY=VALUE...] shows every retention setting (off when
  unset) and changes them; KEY=off turns one off, KEY= is refused and
  nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
  Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
  agent's keys once one is added (it starts no agent without one).
  devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
  its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
  key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
  refused). In a terminal it also asks for new VMs' network policy (ask,
  on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
  VMs read unless --network-policy or --no-network-policy is given.

Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:38:54 -07:00
w3cjandClaude Opus 5.5 6f680a6f8b feat(proxy): a shared, read-only Nix cache that only the host fills
VMs with network policy and the nix layer share their downloads from
cache.nixos.org: the proxy answers http://devvm.proxy/nix/ itself (a
reserved endpoint, never forwarded), and the guest setup puts it before
https://cache.nixos.org in Nix's substituters, trusted-public-keys left
as Nix's own (cache.nixos.org-1). Each VM keeps its own store and daemon;
only downloads are shared, and no VM can change what another gets.

The proxy (internal/proxy/nixcache.go, -nix-cache DIR and
-nix-cache-max BYTES):
- takes only GET and HEAD, no query, nothing escaped, of
  nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no
  suffix or .xz, .zst or .bz2 (nixPath, FuzzNixPath); 400 otherwise;
- makes up nix-cache-info (priority 30, before cache.nixos.org's 40);
- fetches from https://cache.nixos.org alone, when the VM's policy
  allows cache.nixos.org:443, through the floor or the company proxy,
  with the system's roots and the user's CAs, following no redirect,
  sending nothing of the VM's request;
- keeps a narinfo when its StorePath is the path asked for, its URL is
  of the pattern and named by its own NarHash or FileHash, and a Sig by
  the pinned cache.nixos.org-1 Ed25519 key verifies over
  1;StorePath;NarHash;NarSize;References (parseNarinfo, against a real
  narinfo and NAR of cache.nixos.org's in testdata/nix/);
- fetches a NAR only after a narinfo it checked names it, never for a
  HEAD, once however many ask and at most four at once (fetchOnce), and
  keeps it when its SHA-256 and size are the narinfo's FileHash and
  FileSize; a cached copy of another size is dropped;
- answers 404 to anything that fails, keeping nothing, so Nix goes to
  cache.nixos.org itself; logs each request as a nix-cache event
  (hit, fetched, or why not), which devvm log shows as cache;
- writes files whole and renames them in, 600 in folders of 700.

The cap: the nix-cache.size retention setting, 10 GiB when off
(state.NixCacheDefault, proxy.NixCacheDefault), with state.ParseSize
(500M, 20G, 1T). Under a flock on .lock every proxy takes a file's room
before writing it (reserve, in whole blocks), deleting the least
recently used files (by mtime, which a hit sets) down to nine tenths of
the cap; a NAR being fetched is made its full size at once and counts,
so a fetch the in-flight files leave no room for is refused. devvm gc
trims to the cap, devvm gc --nix-cache empties it, and the daily
retention run trims it (proxy.TrimNixCache, NixCacheUsage). devvm space
has a Nix cache row (GC: what's over the cap, FREED BY gc --nix-cache,
RETAIN nix-cache.size), devvm images says what it takes of its cap.

netpolicy passes -nix-cache and -nix-cache-max only for images with the
nix layer (nixCacheArgs; a retention file it can't read warns and uses
the default). The guest setup writes /etc/nix/devvm-cache.conf through
!include in nix.conf only with the nix layer and policy on, removes it
otherwise, and restarts nix-daemon when it changes. VMs without network
policy get no shared cache: they fetch from cache.nixos.org directly,
and nothing new runs or listens on the host for them.

Review (security-audit skill, on nixcache.go, its callers and the
setup): a NAR could be kept under another NAR's name, as the URL isn't
signed (fixed: the URL must be named by the narinfo's own hashes, and a
hit of another size is dropped); files being fetched didn't count
against the cap and blocks weren't counted, so one VM's parallel
requests could pass it (fixed: reserve, full-size temp files, block
counts, fetchOnce); a HEAD downloaded a NAR (fixed). Ruled out: stored
VM input, paths out of the folder, another upstream, parser
differences, cross-VM visibility beyond timing, a VM's own nix.conf.
Open, documented: timing tells a VM whether some VM fetched a public
path, and a VM can fill the cache to its cap.

Messages: gc_nix_cache_over, gc_nix_cache, deleted_nix_cache,
images_nix_cache; retention_deleted gains nix_files. Paths:
Dirs.NixCache (structure limit for Dirs to 40). Flags: devvm gc
--nix-cache; the CLI reference regenerated.

Tests: TestNixPath, TestNix32, TestParseNarinfo, TestNixCacheServes,
TestNixCacheRefuses, TestNixCachePolicy, TestNixCacheFetches,
TestTrimNixCache, TestNixCacheCap, FuzzNixPath, TestParseSize,
TestRetention, TestNixCacheArgs, TestFormatEvent; nix_cache.txtar (the
proxy's endpoint and refusals, space, images, gc, gc --nix-cache,
retention); e2e nix: the VM's substituters and keys, hello through the
cache, fetched by the host (600/700), a VM's writes and other requests
refused and nothing kept, a second VM's hits fetching nothing, no cache
after devvm network off.

Docs: the design note (internals/design.md), internals/network.md's The
shared Nix cache, the VM's setup, logs and flags, internals/security.md,
internals/images.md, safety/network.md's Nix and Logs,
using/toolchains.md's Nix projects, using/images.md, using/space.md,
using/settings.md's Retention, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:56:53 -07:00
w3cjandClaude Opus 5.5 bb48f435cc feat(ui): color devvm's tables when stdout is a terminal
devvm ls, devvm images, devvm space and devvm doctor's feature table
are colored with the messages' rule for stdout (NO_COLOR or names mode
off, FORCE_COLOR or CLICOLOR_FORCE on, TERM=dumb off, else only when
stdout is a terminal). Pipes, scripts, --json, doctor --fixes, the run
log, DEVVM_MESSAGES=names and tests stay byte-identical.

Header rows and totals bold; names, paths, sizes and counts in the
default color; base 16 colors only. The roles, by table:

- images: current green (32); stale, unfinished, unused, not built
  yellow (33); DIGEST and KEY dim (2)
- ls: Running green, Stopped yellow, any other status (Broken) red
  (31); GIT on, strict and clone green; NET on green, unenforced red
- space: KEPT only copy and leftover yellow; the total row bold
- doctor: native green, emulated yellow, unreviewed and none red

internal/ui: Table (Header, Row, Total, Break, Flush), Cell and Role
(Plain, Good, Attention, Bad, Secondary), from u.Table(), on stdout and
colored as it is; cli never reads the environment. Table pads each
cell on its plain text before painting it, as text/tabwriter counts
the codes' bytes; a plain table is byte for byte tabwriter's with
padding 2. New's UIs color only when FORCE_COLOR or CLICOLOR_FORCE says
so, which is how cli's tests get a colored one. ui.UI's method max
goes to 43 for Table.

internal/cli: writeImages, writeList, writeSpace and writeFeatures
take a *ui.Table; cell, dim, cellAs and the role functions imageStates,
toolStates, vmStatuses, gitModes, netModes, keptRoles, supportCell.

Tests: TestTableLikeTabwriter (plain and colored, against tabwriter),
TestTableBreak, TestUITable; cli's tables helper renders each table
plain and colored and checks they match without the codes, in
TestWriteListColored, TestWriteImagesColored, TestWriteImagesTools,
TestWriteSpace and TestWriteFeatures, with the expected codes.

Docs: using/settings (Colors: tables); contributing (Messages: Colors:
tables and roles).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 15:57:03 -07:00
w3cjandClaude Opus 5.5 7cd15a0862 feat(retention): retention settings for what devvm keeps, all off by default
~/.config/devvm/retention holds key=value lines, written by devvm space
set KEY=VALUE... (KEY= turns one off; a bad key or value is refused
before the file is written; all off removes the file). Every setting
is off unless set:

- logs.runs: run logs kept (20 when off; ui.KeepRunLogs).
- exports.age, exports.count: exports that old deleted, then all but
  the newest count.
- tools.unused-age: current shared tool images no VM's state lists,
  counted from when retention first found them so (an <image>.idle
  record in the share, dropped when a VM lists it again).
- orphans.age: what devvm keeps for VMs their backend no longer has
  (vm.Leftovers, as gc --orphans), once their state hasn't changed for
  that long.

Ages as state.ParseAge (30d, 2w, 12h). Not the backends' caches (gc
--caches only), and never a VM, an image, or a tool any VM's state
lists. devvm's commands apply the settings at their start at most once
a day (data/retention.run; again at once after a clock that went
back), under a lock so two devvms never apply them at once (a dead
one's lock is taken over after 10 minutes), skipping the tools while a
build holds the share's lock; it says what it deleted in one line on
stderr (retention_deleted). orphans.age needs the backends asked, so
only devvm gc --retention applies it; gc --retention applies all of
them at once. space, gc, completion and devvm's internal commands
don't apply them on their own. A bad line names the file and the line,
and then none applies (retention_unreadable). devvm space shows each
setting beside its row (RETAIN), with what it would free now.

Not done here: logs.network.size and logs.network.files, which
override the proxy's log rotation defaults: rotation is another task's
(the proxy rotates its logs), not on this branch; space set refuses
them until it is.

Messages: retention_deleted, retention_off, retention_busy,
retention_unreadable, retention_failed, retention_bad,
retention_saved. Docs: using/settings.md (the file, each setting, all
off), the What devvm keeps page (what each setting does, RETAIN),
using/images.md's Cleaning up, the CLI reference.

Review (deletes only what it's told to): no file or an empty one
deletes nothing (txtar, unit); a VM, an image and a tool any VM's state
lists are never retention's (Idle builds on NoVM: a stopped VM's and a
leftover state's tools stay until orphans.age deletes that state); two
runs at once (lockRetention); a clock that jumps (retainDue, Idle and
the age checks skip a negative age); the one-line report on every
deletion. Tests: TestRetention (parser, set, off, bad lines),
TestIdle, TestExportsToRetire, TestRetainDueAndLock; retention.txtar
(refusals, space set and RETAIN, the automatic run once a day and
again after a day, gc --retention with tools, a VM's tool kept).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 13:29:49 -07:00
w3cjandClaude Opus 5.5 e433e61719 feat(gc): gc --orphans forgets VMs their backend no longer has
A VM deleted outside devvm (limactl delete, smolvm machine delete,
docker rm) left its state, logs, run files, backend files, ssh config
entry and host keys, and gc kept its tools. --orphans finds each VM
whose state names a backend that answers (Check and List, 30 s each)
and that, asked by Inspect, doesn't have it (vm.Leftovers.Find), lists
them with their project folders, asks in a terminal, and deletes what
devvm keeps for each as devvm rm does after its delete (Lifecycle's
tail, now forget), after asking the backend once more. Backends delete
their own leftovers through backend.Forgetter: Lima its port records,
sandbox profile and start record; smolvm its record, proxy file, ssh key
and forwarder files; Docker its relay, networks, ssh keys, labelled
volumes and commit image. Each refuses a VM it has.

Never an orphan, each said with a note: a VM whose backend can't be
asked or isn't this devvm's (gc_orphans_unknown); one made where this
run's backend doesn't look (gc_orphan_elsewhere) - new VMs record
backend_at, a hash of backend.LocationOf: Lima's home (DEVVM_LIMA_HOME),
smolvm's HOME on macOS, Docker's engine ID and name - and a VM without
the record counts only when its backend looks in its default place; one
whose state changed in the last hour, as a VM being made has its state
before its backend has it (gc_orphan_recent). When a backend a VM uses
can't list its images, gc stops before deleting anything, as before.

devvm space: the leftover row says gc --orphans; VMs with devvm's label
that this devvm has no state for (another devvm's, a sandbox's) are
named with their label's data folder (space_stray,
backend.StrayFinder), and never deleted.

Messages: gc_orphans, gc_orphan, forgot_orphan, gc_orphans_unknown,
gc_orphan_elsewhere, gc_orphan_recent, space_stray. Docs: the What
devvm keeps page (leftovers, VMs devvm has no state for, how to delete
one), using/images.md's Cleaning up, the CLI reference.

Review (a backend down, slow or answering garbage; a VM moved between
Lima homes; smolvm under another HOME; Docker Desktop vs a Linux
engine; a VM being made): down, slow (timeout) or unreadable answers
make a backend unknown, never its VMs orphans; moved homes and engines
are caught by backend_at; a VM being made is recent; Forget re-asks the
backend and each Forgetter refuses a VM it has. Tests: gc_orphans.txtar
(a live Lima VM and its files kept, a deleted one forgotten with its
logs, run and port files, a Docker one's volume deleted, a smolvm one,
another Lima home, no record under a non-default home, a recent state,
an unknown backend; no backend delete runs; gc stops when smolvm can't
list); tools.txtar (backend_at recorded).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:57:47 -07:00
w3cjandClaude Opus 5.5 bf03f26221 feat(gc): gc --exports [--older-than AGE] deletes saved exports
Exports (exports/<vm>-<date>-<time>.tar.gz, from devvm export and devvm
rm) were never deleted, and each can be the only copy of a deleted
VM's agent history. --exports deletes them, never as part of gc's
default run; --older-than AGE (state.ParseAge: a whole number of days,
weeks or hours, 30d, 2w, 12h, which retention will read too) keeps those
newer, by the date in their name. Only plain files named as devvm
names them: an export being written (.devvm-export-…), a folder or a
file of the user's in the folder stays. The list names each export's
VM and date (gc_exports, gc_export); it asks in a terminal, goes ahead
without one, never deletes a VM. --older-than without --exports, or an
age devvm doesn't take, is refused.

devvm space's exports row says gc --exports frees them, and counts the
exports as gc does.

Messages: gc_exports, gc_export, deleted_exports,
gc_older_than_needs_exports, gc_bad_age. Docs: coding-agents' History,
using/images.md's Cleaning up, the What devvm keeps page, the CLI
reference.

Tests: TestParseAge; TestExports (names, order, the age boundary);
gc_exports.txtar (the default run keeps them, the flags refused, 30d
deletes the old one only, then every one, nothing else in the folder).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:41:57 -07:00
w3cjandClaude Opus 5.5 e9aba7360d feat(gc): gc --tools [TOOL...] deletes current tool builds no VM has
gc keeps every current tool build, so a toolchain tried once stayed
until a newer version came out. --tools also deletes the current builds
that no VM's state lists (Share.NoVM), on every backend format and C
library; with tool names (the names images use, so node takes pnpm and
bun too) only those. A build whose hash was written in the last hour
stays: a launch builds its tools before it records them in the VM's
state. A tool any state lists stays, a stopped VM's and a leftover
state's included. With --backend, only that backend's builds. Names
without --tools, or a name that isn't a shared tool's, are refused.
Like gc: it lists them first (gc_tools_no_vm, naming each), asks in a
terminal, goes ahead without one, never deletes a VM. A VM that names a
deleted tool builds it again.

devvm space's tool rows say gc --tools frees the rest.

Messages: gc_tools_no_vm, deleted_tools_no_vm, gc_names_need_tools,
gc_unknown_tool. Docs: using/images.md's Cleaning up,
internals/images.md's listing and cleaning up, the What devvm keeps
page, the CLI reference.

Tests: TestNoVM (a VM's, not current, missing hash, built just now,
names); gc_tools.txtar (a leftover state's claude kept, a just-built
codex kept, node's three deleted, names refused without --tools, an
unknown name refused, node built again after).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:36:50 -07:00
w3cjandClaude Opus 5.5 0900ba5372 feat(gc): gc --backend NAME acts on one backend alone
gc reuses the root --backend flag: with it, gc deletes that backend's
images, the current ones too, and its unused tool images (the backend
from the build's .target record; one devvm can't tell is never one),
and leaves every other backend and devvm's own files (old copies of its
files, old mise) alone. Without it gc acts on every backend as before:
g.backend stays empty unless passed, so the default backend file never
narrows a plain gc. An image a smolvm or Docker VM was made from, or on
Linux hosts a Lima image whose disk VMs use, is refused by its backend
and stays (image_in_use, a warning). An unknown name is refused.

devvm space's images rows say gc --backend NAME frees the rest.

Docs: using/images.md's Cleaning up; Cleaning up sections on the Lima
and Docker pages, and smolvm's Cleaning smolvm's caches; the What devvm
keeps page; gc's help and CLI reference.

Tests: gc_backend.txtar: images on Lima, smolvm and Docker; a plain gc
with the default backend file set to smolvm still deletes Lima's stale
image and every unused tool; --backend smolvm deletes only its base and
its plain- tool image; --backend docker only Docker's base; Lima's base
stays; an unknown backend is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:30:17 -07:00
w3cjandClaude Opus 5.5 25930d2252 feat(gc): gc deletes older versions of devvm's own mise
devvm's mise (mise/<version>) is pinned per devvm release, and an
upgrade left the older folder (121M on the user's machine). gc's default
run deletes every folder but this devvm's version
(Versions.StaleMise), except one that changed in the last hour, which
another devvm may be downloading into. mise's data, cache, state and
config are temporary folders per run (miseCmd), so there's no cache to
keep or free. devvm space's mise row shows what gc frees.

Checked first what's kept: mise/<version> holds only the binary; bin/
(devvm-proxy, its key and hash) is written by nothing in this devvm
(the proxy is devvm _proxy, devvm's own binary, which install.sh
prunes in ~/.local/lib/devvm), so gc leaves bin/ alone; Docker's Linux
build is one file, replaced in place.

gc is now a plan (gather, show, ask, run) that the gc options extend.
Messages: gc_mise, deleted_mise. Docs: using/images.md's Cleaning up
(four things), the What devvm keeps page, internals/images.md, the CLI
reference. Tests: TestStaleMise (this version, a recent folder and a
file kept); gc.txtar (an old and a recent mise folder).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:23:35 -07:00
w3cjandClaude Opus 5.5 bfc925e043 feat(space): devvm space shows what devvm keeps and the space it takes
devvm space [--json] lists each kind of thing devvm keeps, on every
backend, with its count, size (allocated blocks, as du), whether devvm
makes it again (remade, only copy, log, state, leftover), what devvm gc
frees of it now and what frees the rest, then a total: VMs and images
per backend, shared tool builds per backend and C library, exports,
network and run logs, devvm's own mise, the copies of devvm's files,
the leftover state of VMs their backend no longer has, and the rest of
devvm's state. The backends' own caches come apart and outside the
total: Lima's download cache, smolvm's caches on macOS (pack disks,
image disks, archives, registry; never its machines' folders) and
Docker's labelled volumes that aren't one VM's own.

backend.UsageReporter (optional): Lima, smolvm and Docker say what their
VMs and caches take. Each backend gets 30 s; one that doesn't answer is
named when a VM's state uses it (space_backend_unknown), and its VMs are
never counted as leftovers.

Each tool build now leaves <image>.target beside it (libc, format), so
listings tell a Lima, smolvm and Docker build of a version apart;
tools.Listed has Target, from the record or the target it's current for;
Share.Delete deletes the record too.

Messages: reading_space, space_failed, space_backend_unknown,
space_caches_note. Stubs: docker volume ls; smolvm machine ls fails with
smolvm-ls-fails. Docs: the What devvm keeps page leads with devvm
space; commands table; images' Cleaning up; CLI reference.

Review: space runs only listings (limactl list, smolvm machine ls and
data-dir, docker info, container ls/inspect --size, system df, volume
ls), each bounded by ctx with a timeout; the txtar checks no call
creates, deletes, starts, stops or edits. Backend caches aren't in the
total. Sizes checked against du on the e2e sandbox data and the user's
caches (Lima 9.1G, smolvm pack disks 20G, both match du -sh). APFS
clones count for both, as the page says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:15:18 -07:00