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]>
On Linux, a process devvm has just started shows empty arguments in
/proc/<pid>/cmdline for a moment: exec lets the parent go on once the new
program replaces its memory, and the kernel sets the argument area only
once the program has loaded. Proc.Ready took that moment as the proxy
having ended, so a start under load failed at once with
proxy_start_failed while the proxy ran on, its log and status empty.
Ready now counts the process as running while its pid file names it, it
is alive, and its arguments are its own or can't be read yet
(Proc.starting); an ended one is reaped by Detach, so it stops counting.
Tests: TestReadyArgsUnread (fails on the old code).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
~/.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]>
- 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]>
Fedora 43 has sha256sum but no shasum (Perl's Digest::SHA), and its /bin/sh
is bash 5.3, which runs the last command of an `a && b` -c string in sh's
place.
- install.sh's check_host stops with "needs sha256sum or shasum" before
downloading; its sha256 already used either. install.txtar covers
shasum alone, both, sha256sum alone and neither, with made-up sums.
- scripts/release.sh and scripts/bump.sh get a sha256 helper (sha256sum,
else shasum -a 256) in place of four shasum calls.
- gc_orphans, release, release_head and tools scripts hash with sha256sum,
else shasum. tools' old fallback never fell back (the pipeline's
status was cut's).
- ls and existing_agents restart a VM outside devvm with
`sh -c '... && limactl start ...; exit $?'`: without the exit, bash's
sh exec'd the stub, whose ha.pid then named the test runner (the pid
devvm recorded), so the VM still looked confined.
- The install page lists sha256sum or shasum among the script's needs.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm node said "Did you mean devvm code?", which misleads anyone who
means the tool. When the unknown word, or each name in it joined with +
or a comma, is a toolchain, an agent or a layer (devvm's own or the
user's), the usage error is no_command_part, with the flags that choose
them: devvm node+claude -> devvm --tools node --agents claude. Any other
word keeps the did-you-mean over the commands (msg.Closest). The names
come from partNames, which checkPartFlag reads too.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fetch.Client was an alias of http.Client, so &fetch.Client{} got past
NewClient's timeout and HTTPSOnly. It is now a struct only NewClient fills:
Do sends with the client's policy, Transport returns its own transport for
callers to change (ubuntu's file://, the public registry's dialer), and any
other Client fails every request with ErrNoClient, which isn't transient.
forbidigo's HTTP rule also bans http.Transport, and http.Client's Transport
field, outside fetch, the proxy and tests.
The os.WriteFile rule also bans os.Create and os.O_TRUNC, so a
truncate-in-place write outside state needs a nolint saying why. The four
left are not files written whole from memory, or are the standard library
only: tools' check log and a link session's log (a process writes them as
it runs), fetch.Download's file (streamed, removed on failure) and
daemon's pid and status files (one write, which readLine and readStatus
take as missing until its line ends). state's doc says so.
Tests: TestClientMadeByNewClient (nil and zero Clients send nothing and
aren't retried; NewClient's transport is its own); from's and build's
tests use the registry's own client trusting the TLS test server.
Fixture lines: http.Transport, os.Create, os.O_TRUNC.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The picker change's review:
- --tools claude, --layers node, --agents node and the like are refused
with part_other_flag, which names the flag that takes the name, as in
devvm --agents claude; a name no part has keeps unknown_part or its
did-you-mean. checkPartFlag checks the three parts' names together.
TestCheckFlagValue, up.txtar, up_checks.txtar and setup.txtar cover it.
- image.ToolName is back, with its TestValuePatterns row: ToolFile and
ParseToolFile check a tool's name with it.
- internals/design.md's Docker layer checks name parts_flags_ignored for
--layers docker on a VM that exists, as e2e checks, in place of a
message that's gone.
- The home page and the README give the Claude Code token before
claude's first start, the home page's list says which rows it shows
checked, and the FAQ says the agents' config comes from your machine.
The README says the first run asks for new VMs' size and agents before
the list.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
targetRuns stored a lookup whose context ended as the target's run, with
no start, so for linkRunFor every other connection to that target, those
waiting on it and those coming after, was refused as
link_target_stopped though the target ran. A lookup cut short is now
marked and dropped from the cache before it's done: the connection that
cancelled finds the target stopped, and the waiters look again, one of
them leading the new lookup.
- targetRuns.get split into lookup (find or make, under the lock) and
run (look, then keep or cut).
- TestLinkRunCancelled: one waiter cancels, another waiting on it and a
third in the same second get the run, from two lookups.
- internals/ports.md and design.md say a cut-short answer isn't shared.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HostMise's download of devvm's pinned mise was a single request, so one
dropped connection or a 5xx from GitHub's release host failed the tools
lock's resolve. It now runs in fetch.Retry, tried again up to three
times after fetch.Transient failures (no answer, 408, 429, 5xx), one
second first and doubling; a 4xx, a refused redirect or a checksum
mismatch fails at once.
- Env.RetryDelay: the delay seam, time.Second from New.
- TestHostMiseRetry: two server errors then the file, a 429, and 404
and 403 answered once.
- internals/images.md says how the download is retried.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The consolidation pass over the shared foundations:
- Lima's host address on its user-mode network, 192.168.5.2, is one
constant, limaHost, which the VM's proxy URL and the build proxy's
both use (proxyHostDarwin and buildProxyHost went).
- platform.LockFileShared had no caller: LockFileSharedWaiting with no
waiting does its job, and its tests use that. image.ToolName had none
either, and goes until the tools picker needs it. mise run deadcode
lists only what AGENTS.md names.
- tools' writeNew, a third whole-file writer, goes: the share's .sha256,
.target and idle files are written through state.WriteFile.
From the security audit of the phase:
- daemon.Proc.Stop sends SIGKILL only to a process whose arguments still
say it's this one. A process still ending, whose arguments can't be
read, is waited for; so is another process given the pid since whose
arguments can't be read either (a setuid one, on macOS), which would
have been killed. TestProcStopKillsOnlyItsOwn fails without it.
- forbidigo's signalling rule also bans os.Process's Kill and Signal
outside daemon and platform; tests signal their own children, and
devvm desktop's ssh child, not yet waited for, says why with a nolint.
testdata/lint has a line for each. Contributing's checks table says so,
and internals/network.md says which process SIGKILL goes to.
testdata/coverage/linux.txt is measured again with mise run coverage on
the x86_64 Linux host: it had no lines for fetch, shell and vmname, so
mise run test failed on Linux, and daemon was set by hand. arm64 (the
Linux host VM) agrees within a point. darwin.txt: daemon 97.8, tools
89.2.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each connection a link session carried asked the target's backend
whether it runs, its start and its ssh (Inspect, StartID, SSH). On
smolvm each of those runs smolvm machine ls, and a burst of 256
connections ran them all at once, which answered wrongly for some, so
connections were refused as link_target_stopped or ssh: vm_not_running.
linkCheck gives a session targetRuns: one lookup in flight for each
target (by name and ID), its answer reused for linkRunFor (one second),
so a burst asks the backend once on every backend, and a target that
stops is noticed within that second. The links state, CheckLink and the
policy check as the target runs (policyEnforced) are still made for
each connection.
e2e's lk_stopped connects again until the stop is seen, as a
connection within that second may reuse the target's run.
Tests: TestLinkCheckBurst (256 concurrent checks run one Inspect and
one SSH; failed with 256 of each before), TestLinkRunReused.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A link session carries up to 256 connections at once through an ssh
master to each target, which takes in two descriptors (stdin, stdout)
for each connection's ssh -W. Go raises devvm's own soft limit on open
files but gives the processes it starts the one it started with, 256 by
default on macOS (and for launchd jobs, as the remote e2e runs are), so
the master ran out of descriptors well before 256 connections
("mm_receive_fd: recvmsg: Message too long") and closed those it
couldn't take: e2e's 256-connection check failed,
and as it returned early it left its link to db:47241 in place, so the
group checks after it found other links than they expected. A shell
with a higher limit (this Mac's) never showed it.
- platform.ShareFileLimit sets the limit to what it is now, so the
processes devvm starts from then on get it; vmssh.Links.Run and
vmssh.Forwarder.Run call it first. TestShareFileLimit starts a child
test at a soft limit of 256 and checks its own child gets more (fails
without it: 256).
- e2e: the link section runs devvm at a soft limit of 256, so it fails
without the fix on any Mac (it did, deterministically, on this one).
lk_cap ends its hold server and removes its link whatever came of its
checks, and shows the reasons of its refusals. lk_start waits until the helper listens or has ended (its
wrapper writes "exited N"), and on a failure says so with "failed: ",
lists its files, shows its output and the VM's TCP listeners. gp_join
publishes and starts its server, then the three join whatever came of
the server (gp_joined), so a server that doesn't start fails that
check alone.
- docs: internals/ports.md (the ssh processes' limit), contributing
(the link section's limit).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A proxy restarted on a running VM (its company proxy settings changed,
say) was stopped with SIGTERM, and Proc.Stop took it as stopped as soon
as its arguments could no longer be read. An ending process loses its
memory before its files: on macOS kern.procargs2 fails some milliseconds
before its listening socket closes (every time, in a test of 30 stops),
and on Linux /proc/PID/cmdline reads empty. When Stop looked in that
window, Prepare found the VM's proxy port still taken, failed the launch
with proxy_port_taken and stopped the VM (Unproxied): e2e's company
proxy checks 15 and 17 failed in turn, and the checks after them found
the VM stopped.
- daemon.Proc.Stop waits until no process has the pid, or another
process does (Proc.ended); one whose arguments can't be read is still
ending.
- platform.ProcessArgs on Linux returns an error for an empty cmdline
(an ending or unreaped process), as macOS does, never [""].
- Tests: TestProcStopWaitsForTheEnd (fails before the fix: Stop returned
while the process still ran) and TestProcessArgsEnded.
- e2e: check prints a failed check's "failed: " lines first, then its
last lines (5, or check_lines); checks 15 and 17 are functions
(corp_through, corp_direct) whose steps each name themselves, then
corp_why shows the VM's status, its proxy, the launch's output, the
proxy's log and events, and the company proxy's log and events.
- docs: internals/network.md says when the old proxy counts as stopped.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stubs logged with echo "x $*" >> "$STUB_LOG", which bash can write
in pieces for a long line, so a stub running at the same time could put
its own line in the middle. Every stub now appends through
testdata/stubs/stub-log, a Perl script that writes the whole line with a
single syswrite to the file opened for appending: the call log and the
stubs' shared lists ($STUB_DIR/containers-made, unpacked, scripts,
tm-excluded). The stubs run it from their own folder (${0%/*}), and
stubtest.New links it too when it puts only the named stubs on PATH.
TestCallLinesWhole runs two open stubs at once with 100 KB arguments
while the test appends short lines of its own to the log, and checks
every call landed whole; it failed on every run with the old stubs.
TestStubsLogWithStubLog fails on any stub that appends to $STUB_LOG or
$STUB_DIR with the shell's >>.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The proxy owns the links' addresses and domain and the proxy user:
proxy.IsLinkAddr, proxy.LinkAddr, proxy.LinkDomain and proxy.ProxyUser
replace vm.IsLinkAddr, vmssh.IsLinkAddr, vm.LinkNet, vm's linkNetAddr,
vm.LinkDomain, netpolicy.LinkDomain and the proxy's own isLinkAddr and
linkDomain. TestLinkAddrsAgree goes, because there's nothing left to agree.
The proxy's link list now refuses an IPv4-mapped address too, as vm's
parser already did.
backend owns the guest's view of a proxy: ProxyUser (proxy.ProxyUser),
ProxyURL, GuestProxyVars, ClientProxyVars and NewProxyPassword replace
four URL builders (BuildProxy.URL, Lima's, Docker's and smolvm's), the
user written out in three places (netpolicy.ProxyUser, buildProxyUser,
Docker's proxyUser), the guest's variable list in three (Lima's inline
loop, smolvm.proxyVars, Docker's proxyVars) and the client's in two
(limaProxyVars, Docker's noClientProxy list), and the two password
generators. Confinement.ProxyUser goes: Docker ignored it, and every
backend now uses ProxyUser. A new VM's proxy key is NewProxyPassword's
64 hex digits, as a build proxy's was; a VM keeps the key it has.
doctor reads HTTPS_PROXY through backend.ReadHostProxy.
In the proxy, hijack and splice replace the three CONNECT copies
(tunnels to allowed hosts, tunnels to links, interception's hijack) and
the relay's pipe. A tunnel passes the bytes as they are, passes on the
end of what the client sent, and ends, closing both connections, when
the server's bytes end or the client has gone. A relayed connection now
ends with the proxy's side too, where before it waited for both.
Tests: splice_test.go characterises the allowed-host tunnel, the link
tunnel and the relay (a megabyte of every byte value, a half-close
answered, a client that goes away ending the tunnel), written against
the code before this change; TestSpliceEnds, TestHijack and
TestIsLinkAddr (every LinkAddr) are new, and so are TestProxyURL,
TestNewProxyPassword and TestProxyVars. TestLinkListRefused gains a
mapped address.
e2e: the relaunch without a company proxy says which step failed, with
the launch's output, the VM's status and the proxy's log, and a link
helper that doesn't start shows its output.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CLI tests' devvm is built with -cover, and every script set one
GOCOVERDIR. Go names a run's temporary meta-data file by the time
(time.Now().UnixNano(), microseconds on macOS) with no process ID, so two
devvm runs from parallel scripts that start together write the same
temporary file; the first renames it and the second's rename fails, and
devvm prints "coverage meta-data emit failed" on stderr, failing any
script that checks stderr (seen in ls.txtar and version.txtar).
- script_test.go: scriptCoverDir sets GOCOVERDIR to a folder of the
script's own (os.MkdirTemp under CLI_GOCOVERDIR).
- scripts/test.sh: covdata merge takes the unit folder and every
non-empty script folder as one comma-separated -i list, so percent and
the baselines read the same counters as before.
- Contributing's Coverage section says each script writes to a folder of
its own, and why.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CA checks serve HTTPS with openssl s_server, and macOS's LibreSSL
cuts the VM's OpenSSL client off mid-request. e2e now checks openssl
version before it builds anything and stops in one line naming
brew install openssl@3 (Homebrew's keg first on PATH) when openssl is
LibreSSL or missing. The contributor docs list OpenSSL among e2e's
needs on macOS; devvm itself never runs openssl on the host, so doctor
and the user requirements stay as they are.
Tested by hand: a stub openssl printing "LibreSSL 3.3.6" first on PATH,
one printing nothing, and PATH=/usr/bin:/bin (macOS's LibreSSL) each
stop tests/e2e.sh --only project at once with exit 1, before the
sandbox or the build is touched.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
paths.FromEnv reads HOME, which must be absolute, and keeps it, cleaned,
as Dirs.Home; everything else takes the home folder from there. Six other
reads go: vm.NewEnv's and cli's devvm secret's os.Getenv("HOME"),
gitprotect.New's, Docker's and smolvm's os.UserHomeDir (Desktop's
settings file, the machines' location), and smolvm's Getenv("HOME")
(DiskDirs).
- vm.Env.Home and secrets.Store.Home are gone: both read Dirs.Home.
secrets.NewStore takes the Dirs alone; gitprotect.New takes the home
folder for ~ in git's paths.
- forbidigo bans os.UserHomeDir, with its line in
testdata/lint/forbidigo.go; the structure test's owners check gains
envOwners, HOME read only in internal/paths/dirs.go, with cases for a
read outside it, through a field, in paths and in a test.
Tests: TestFromEnv checks Home (and a HOME cleaned), TestNewHome (~ is
the home New is given, not the environment's), TestDiskDirs checks
Location too. Coverage unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/state is the one writer of whole files outside the proxy:
state.WriteFileMode joins state.WriteFile for another mode (0700 for
the QEMU wrapper and Docker's copies of devvm's Linux build), and
state.PrivateDir makes a folder the user's alone (700), refusing a file
or a symbolic link there, as vmssh's runDir did.
- Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's
writeFile (the Seatbelt profile, the QEMU wrapper, the start record),
vmssh's writeWhole and runDir, Docker's copyFile, the Linux build
fetch's temporary file (fetch.Open's body is read whole, its SHA-256
checked, then written with state.WriteFileMode), and Resolve's
.tmp-and-rename loop. The host's mise stays fetch.Download's.
- os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions'
mise.toml, the checked file, the tools build's files), sshagent (two),
ubuntu's checksum files, docgen's pages and backendtest's fake tool
images.
- state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders):
the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and
socket folder, lima's run folder and the exports folder. MakePrivate
and ~/.ssh keep following a link: where they live is the user's choice.
- The proxy's writers are one, writeAtomic: the login files' writeJSON
and the Nix cache's size file use it, its temporary files named
.<name>.tmp-* as state's are.
- forbidigo bans os.WriteFile outside internal/state, internal/proxy,
internal/msg/gen, internal/stubtest and tests, with its line in
testdata/lint/forbidigo.go.
Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder
refused, its folder's mode unchanged), TestWriteAtomic; mode checks on
the Seatbelt profile and Docker's Linux build copy. Coverage baselines
raised: lima, netpolicy, proxy, secrets, ui.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/fetch (standard library only) owns how devvm reaches the web:
NewClient(timeout, HTTPSOnly|SameScheme) on a clone of net/http's
default transport, the Client alias other packages name, Retry and
Transient/TransientStatus (no answer, 408, 429, 5xx; never a refused
redirect, a bad request, a body over its cap or a SHA-256 mismatch),
ReadCapped, Open, Get, and Download, which keeps a file only when its
SHA-256 matches and leaves nothing on any failure.
- from: NewRegistry uses fetch.NewClient(HTTPSOnly); its own NewClient,
httpsOnly, errRedirect and transient go; the token GET is fetch.Get;
retry wraps fetch.Retry, keeping ErrNotFound and ErrUnreachable.
- ubuntu: NewClient is fetch.NewClient(SameScheme) with file://
registered; sameScheme and errRedirect go; fetch is fetch.Retry over
fetch.Get.
- tools: mise's client is fetch.NewClient(HTTPSOnly); its download is
fetch.Download, which checks the pin before the file is kept.
- docker: devvm's Linux build is fetched with a client of its own
(HTTPS-only redirects, a Client seam on linuxFinder) instead of
http.DefaultClient, and retried twice on a failure that may pass or
an archive cut short; an archive without a devvm (errArchive) isn't.
forbidigo bans http.Client, DefaultClient, DefaultTransport, Get, Head,
Post and PostForm outside internal/fetch, internal/proxy and tests; its
line in testdata/lint/forbidigo.go fires. internal/fetch is a leaf in
the structure test's layers.
Tests: fetch's TestRetry, TestRetryUnanswered, TestRetryCanceled,
TestTransient, TestRedirects, TestReadCapped, TestDownload; first,
characterising the callers, from's TestDigestRetries and tools'
TestHostMiseRedirect; docker's TestFetchLinuxRetries. Coverage
baselines: fetch 95.2 (new), from 87.1 to 91.3, ubuntu 88.7 to 92.5,
tools 87.9 to 88.6, docker 80.8 to 81.1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/daemon (standard library only, so devvm _proxy uses it too) owns
devvm's background processes: Detach and Spawn (own session, no input,
reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status
file), Handle (signals through the process started), Proc (a pid file
checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL,
the pid file removed once stopped), readiness by status file (Ready,
WriteStatus, WaitReady: the pid and data, written in one line-ended
write, never another start's), Alive and Signal (no pid below 1), and one
lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content
equality, a bounded wait past what the file held first).
It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards'
pid, stop and start wait, the build proxy's process and log-read port,
links' link-session pid, stop and start, the proxy's watchLifeline and
vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess,
and the alive copies (netpolicy alive/signal, lima alive,
vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go:
the proxy and the forwarder say they're ready in a status file, and the
build proxy's port comes from its own.
forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside
internal/daemon and internal/platform, with its line in
testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS
and puts internal/daemon among the leaves; depguard holds it to the
standard library.
Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file,
groups refused, readiness, lifeline), characterisation tests first for
the proxy's, the forwarders', the link sessions' and the build proxy's
pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.
internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.
Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.
netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.
The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
backend owns port lists: ValidPort, ParsePortRanges, FormatPortRanges
and Ports.Has. They replace vmssh.ParseRanges and FormatRanges,
vm.portsValue, vm.ParsePorts's own regex and range checks, smolvm's
lists, netpolicy's forwarded parsing, publishedIn's and the forwarder's
range loops, and the 1-to-65535 checks in ParseLinkPort, desktop's
listener, the build proxy's log reader and Docker's checkProxy. The
proxy and devcontainer keep theirs for their layer rules. vm.ParsePorts
keeps only all, none and port_invalid.
fix(vm): PortsBackend ignored Atoi errors, so a bad entry in a ports
value (a state file edited by hand) became port 0, or a range ending at
0. It now returns port_invalid: a VM whose state holds one doesn't
start, devvm ports rm parses the old value first, and group links and
Published read such a value as none. TestPortsBackend's bad entries and
TestAddRemovePorts's rm case failed on the old code; TestStartBadPorts
covers the start.
Tests: TestValidPort, TestParsePortRanges, TestFormatPortRanges,
TestPortsHas; TestFlags checks a bad -only is refused. internal/backend's
coverage baseline is raised to 95.8.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Ctrl+C while Lima's start waited for a VM with network policy left the
VM running: the hostagent runs on its own from early in the start, and
an interrupt skips everything after the backend's Start, so the proxy
kept running and the VM had no record of its confined start. devvm ls
then showed it unenforced, and the next launch asked to restart it
confined. Env.start now registers a cleanup around the backend's Start
for a NetProxy start (undoStart): interrupted, it stops the VM and its
proxy and says so (interrupted_start). Lima's Stop stops a VM it reports
as Broken (a start cut short before its hostagent answers) with
limactl stop --force, which plain limactl stop refuses.
Tests: net_interrupted.txtar (tools add on a VM with network policy,
its start hanging with the VM running, Ctrl+C: VM and proxy stopped,
state kept, ls --json net on, the next launch confined and unasked);
TestStartInterrupted (vm); TestStubStopBroken (lima). The limactl stub
gains start-hangs-running. e2e network: Ctrl+C during the start stops
it and its proxy, and ls shows its policy on. Coverage baselines raised
for backend/lima, cli and msg.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
AGENTS.md gets the rule, linking Contributing's new "One owner for each
concern" section: the checks on owners, agreement tests and the
consolidation pass the reviews run.
- forbidigo: testbuild.On only in internal/cli (readOverrides).
- testdata/lint/forbidigo.go breaks every forbidigo rule once on a line
marked "// want forbidigo"; lint:code fails unless forbidigo reports
exactly those lines.
- The structure test's owners rule, as forbidigo can't see arguments:
exec.Command/CommandContext of "git" (literal or constant, any import
name) only in internal/hostgit, tests aside; a Getenv/LookupEnv call
(any function or field of that name) of a DEVVM_ variable only in
internal/cli/overrides.go, or where envSettings lists it
(DEVVM_NO_TOOL_CHECK, DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE,
DEVVM_FROM, DEVVM_MESSAGES, DEVVM_LOGIN_SALT, DEVVM_GUESTFWD), a listed
file that stops reading its variable failing. TestRulesFail's
ownerCases break and keep both.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The same tests can cover a little less from run to run, with timing or the
tools a machine has, so mise run test fails a package only when it is more
than a point below its baseline (COVERAGE_TOLERANCE, 1 by default). A package
within that point passes and keeps its line, so a baseline still never goes
down. coverage.txtar covers within, beyond and a tolerance of 0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN
and CFG by default, and adds stub_reset, catg (the one file a glob
matches), vm_name VAR NAME (the folder's VM) and project NAME [git];
script_cmds.txtar checks each. Every script is rewritten onto them, its
assertions kept; TestCommandLines leaves the scripts' own commands out.
mise run test runs scripts/test.sh: the tests as before, with the CLI
tests' devvm built with -cover for every package (CLI_GOCOVERDIR),
merged with the Go tests' counters by go tool covdata, then
scripts/coverage.sh holds each package to testdata/coverage/<os>.txt.
mise run coverage raises the baselines; coverage.txtar checks the
comparison. The macOS baseline is recorded from this tree.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/stubtest puts testdata/stubs first on PATH with a folder of its
own (New, New with only some stubs), reads and writes the stubs' files
(Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It
replaces the stub setups of the Lima, Docker and smolvm backends' tests,
vm's --clone tests and platform's Keychain tests, and the backends' own
execRunner, reset and touch copies. The structure test holds it to tests
and to importing only internal/msg.
msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers
and the errors.AsType checks that only read a message's ID or names;
msg.Recorder replaces the inline recorders tests set as Info, Warn or Say.
backendtest.Stored replaces the four stored fakes with disks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A review of the recent fixes found three gaps, and an e2e cascade.
- hostgit: protocol.allow=never is only the default for protocols with no
key of their own, so a repo's protocol.ext.allow=always and a url
insteadOf for the VM's URL made a --clone VM's seed push and rm's fetch
run a command the repo named on the host. Host git now runs with
GIT_ALLOW_PROTOCOL=ssh, which git takes over every protocol setting.
TestCommandSSHOnly (failed on the old code).
- git-protect: checkGit set a mode saved while the VM ran before it
checked .git, so a .git the VM replaced meanwhile became the baseline
without git_replaced. It checks under the mode the VM ran with first,
then sets the new one. git_protect.txtar's replaced-.git step (failed
on the old code).
- retention: its lock was a folder taken over after 10 minutes, so a
long retention run could be joined by a second devvm and a crash left
it held. It's platform.TryLockFile on retention.lock now, and
retainLockAge is gone. TestRetainDueAndLock checks an hour-old held
lock isn't taken over.
- e2e: when the group join's helper server didn't start, gp_refused ran
devvm network on for a VM outside the group, which turned its policy
on, so six later group and link checks failed too. gp_refused now
checks the VM is a member first, and lk_start says which server didn't
start.
Docs: internals/git-protection (GIT_ALLOW_PROTOCOL, the check's order),
using/space (retention.lock).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Linux hosts, deleting an image first lists the VMs whose disks are
overlays of it, reading each disk's backing file with qemu-img info. A
running VM's QEMU holds its disk's write lock, which refused that
("Failed to get shared \"write\" lock"), so devvm gc and devvm images rm
failed whenever a project VM was running. diskInfo now passes -U, which
shares the disk; its format and backing file don't change while it runs.
TestDeleteImageInUse's fake runner now refuses qemu-img info without -U,
as QEMU's lock does. e2e's gc checks pass on the Linux host again.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Linux hosts setup creates linuxhost with `.user.uid=1000`, and says
why: Lima gives the VM's user the Mac's uid (501), while most Linux
hosts' first user, and the user that images such as Ubuntu's ship, have
uid 1000. With it, e2e's from section meets that clash as devvm does on
most Linux hosts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
go test's default of 10 minutes a package timed the CLI tests out on a busy
machine, where they run the built binary against many stubs. Contributing
says why.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The accept loop handed each batch off on its own goroutine: it took a
slot or logged link_limit for every connection before it accepted
again. With 257 accepted, the 256 relays it started and the refusal's
event kept it from accepting while the client went on connecting, and
under load the socket's backlog of 128 filled and refused the next
connection unlogged (TestLinksBurst at connection 386, 257 + 129).
serve now hands each batch to a goroutine of its own that takes or
refuses each connection (take), and goes on accepting meanwhile: a
batch past linkSettleMax waits for the last to be taken, tried again
after linkSettle, and the loop waits for it only with maxLinkConns+1
of the next batch accepted, so a flood stays at most two batches ahead
of its refusals. take logs link_limit before it closes the connection,
so a client that sees it closed finds why.
Tests: the fake's link_limit event can be held (slow); TestLinksBurst
holds it until the burst is dialed, so a loop that waits for its
refusals fails at once, without load, and checks each connection from
the client's side, carried or closed without a word, with the cap
carried at once and never more. dialMany, used by TestLinksBurst and
TestLinksCap, tries a dial the backlog refuses again for up to 5 s:
a busy host can keep the loop from running long enough for a dialer
in the same process to fill the backlog, whatever the loop does.
Docs: the design note's link connections and threat check row.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The proxy read policy files with a laxer parser than devvm network allow's
check: a line that wasn't a rule was dropped without a word, or kept as a
rule that matched nothing (example.com:x became a host of that name, a
rule's trailing dot never matched), so a hand-edited deny could lapse
unseen. proxy.ParsePolicy is now the one parser: it returns each line
that holds more than a comment, with its number and whether it's a rule,
and a line is a rule only when ValidRule takes it, which is what devvm
network allow and deny take. parseRule is strict: ports 1 to 65535 in
digits, printable ASCII names with no empty label, brackets for IPv6
alone, no address under *., IPv4-mapped prefixes as their IPv4 ones, and
one trailing dot dropped, as requests' are.
A line that isn't a rule but starts with ! (proxy.BrokenDeny) fails
closed: while any of a VM's policy files has one, its proxy denies every
name and address, each request getting 403 and a refused block that names
the file and line, with no allow advice (block honours Refused;
policy.verdict and checkRefused carry it). Other lines that aren't rules
are skipped. The proxy logs each one, devvm network marks it (its control
characters dropped, msg.OneLine) and --json lists it in not_rules.
netpolicy.PolicyWarnings warns of each (policy_broken_deny or
policy_not_rule): at each launch with network policy (Proxy.Prepare),
after devvm network allow, deny and rm for the file they change, and in
devvm doctor for the files you edit (NotRules). AddRule and RemoveRule
find rules through ParsePolicy, so ruleOf is gone. A policy file that
comes back after it was missing is read again whatever its mtime, an
error other than a missing file keeps its last rules and broken deny, and
a leading byte-order mark isn't part of the first line.
Docs: rules, broken denies and devvm network's output (safety network),
the parser and the fail-closed policy (internals network), doctor's
warnings (install, internals install), the e2e network section
(contributing), the proxy's README.
Tests: TestParsePolicy, TestPolicySkipsBadLines, TestPolicyBrokenDeny,
TestPolicyFileBack,
TestValidRule's new cases and FuzzParseRule's agreement and host
properties (proxy); TestBuiltinPolicies, every policy file devvm ships,
TestNotRules, TestPrepareWarnsPolicy, TestWriteRules and
TestAddRemoveRule's new cases (netpolicy); TestDoctorReport and the
network JSON shape (cli); network_rules.txtar's mark, not_rules and the
warnings on a change, a launch and in doctor; e2e network: a broken deny
makes the running proxy refuse an allowed host until it's gone.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The proxy keeps the CA it started with, because its VM trusts no other,
so a VM that runs past its CA's end without a launch can't verify the
proxy's certificates. Leaves were minted for a day whatever the CA had
left, so they could outlast it, and once it ended every intercepted
tunnel failed its handshake with a misleading reason. leafFor now caps a
leaf's NotAfter and NotBefore at the CA's, keeps a leaf that ends with
the CA until then, and mints none once the CA has ended (errCAEnded);
a CONNECT that would be intercepted then gets 403 before its tunnel opens
(caEndedRefusal), logged as a refused block, so no allow rule is
suggested, with a reason that says to open the VM again, which makes a
new CA, installs it and starts the proxy again.
Docs: how a VM trusts the CA and what happens at its end (internals
network and security, safety network), the proxy's README.
Tests: TestLeafWithinCA, TestInterceptCAEnded (proxy).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
bootify.sh made the VM's user with the host's uid, but Ubuntu's container
images have their own user, ubuntu, at uid 1000, the uid a Linux host's
first user usually has, so useradd failed ("UID 1000 is not unique") and
the conversion failed (convert_failed). Confirmed on the Linux test host
as a uid-1000 user: devvm --from ubuntu:24.04 failed before and boots
after, its user at uid 1000. bootify.sh now removes another user with the
uid first, as container/prepare.sh does, on both families.
Tests: none automated; the Linux test host's user has the Mac's uid
(501), so e2e's from section never meets the clash.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
With no init system (smolvm, Docker's containers), a launch that changed
Docker's proxy settings killed whatever process /run/docker.pid named.
/run outlives a stop there, so that could be another process that took
the pid. The restart now kills the pid only when /proc/PID/comm is
dockerd, as services.sh checks, and deletes the pid file and /run/docker
before dockerd starts, as a boot would.
Tests: e2e smolvm, on the Alpine docker-layer VM with network policy
(the base whose /etc/conf.d/docker the restart reads): a stale pid file
naming another process and a left-over run folder, then a launch that
restarts Docker's daemon; the other process lives, the run folder is new
and dockerd runs. It fails on the code before (the other process gone).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm space counted a Docker VM's engine volumes (<vm>-docker,
<vm>-containerd), but DiskUsed, behind devvm size, devvm ls and the
launch's over-limit warning, counted only the home and clone volumes, and
by name rather than devvm's label. vmDisk is now the one count: the
container's writes and the VM's own volumes with devvm's label (home,
clone, the engine's), which DiskUsed and Usage both call.
Tests: TestDiskUsed (the engine's volumes counted, someone else's volume
with the clone volume's name not, Usage agreeing with DiskUsed); e2e
docker_layer: 600 MB written into the engine's volume raises devvm size's
disk_used by at least 0.5 GiB.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
mise's settings (python.compile, experimental) change what a tool build
installs, but the key hashed only the lock entry, build.sh, the libc and
the format, so a changed setting kept the old images. The key now hashes
the [settings] table, read as TOML and written as JSON with its keys
sorted, so comments, the [tools] table (whose holds the lock entry
already reflects) and other ways of writing the same settings leave it
as it is. A missing or unreadable mise.toml is an error.
Tests: TestToolFile (a changed setting, an added setting; a tool's hold,
a comment and the settings written another way keep the key),
TestToolFileRefuses (no mise.toml, one that isn't TOML).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A VM whose folder part is another member's name (its folder part or the
name it joined with) would reach itself at that name, so devvm group join
now refuses it whatever --as it gives (group_name_hostname), naming the
fix: the member leaves and joins again with another --as NAME, or the
project uses a folder with another name. It replaces the
group_link_name_host warning, which is gone; groupLinks still makes no
link by the client's own hostname or localhost.
Joins, leaves, publish and unpublish's group sync and devvm rm's group
part hold a host-side flock, ~/.local/share/devvm/groups.lock
(platform.LockFileWaiting, saying group_waiting after 200 ms), from
reading the members' states to writing them. A join checks before it asks
to widen a parent folder's VM and again under the lock with its state read
again, so two VMs joining at once, one with network policy and one
without, can't both get in.
- vm: checkJoinName (pure: localhost, the joiner's hostname, taken names),
checkJoin returns the members, Join split into rejoin and join,
lockGroups, Groups.lock, syncOthers, Groups.forget; groupClash lost Own.
- Messages: group_name_hostname, group_waiting; group_link_name_host gone.
- Docs: links.md Names in a group and Groups and network policy; the
design note's names rule, a Joins take turns rule, the Not covered
bullet now only link add/rm racing a group change (those don't take the
lock), the threat check rows; groups.lock in the state tables; the
--as example; the CLI reference.
Tests: TestCheckJoinName, TestLockGroups (waits, says so, gets it once
let go; a context that ends first doesn't), TestGroupJoinsAtOnce (ten
rounds of two joins at once, one with policy and one without: exactly one
gets in; it fails without the lock), TestGroupLinks updated; group.txtar:
the refused join with and without --as, the fix, a folder named as a
member's --as, and two joins at once with one getting in; e2e
gp_hostname.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm ran git on the host bare: --clone's git status could run a repo's
core.fsmonitor or filters, its push, fetch, update-ref and remote remove
the repo's hooks, and git could ask on devvm's terminal or follow
GIT_DIR from devvm's environment. internal/hostgit is now the one runner
(Command, Output, Status), with its settings as GIT_CONFIG_COUNT pairs:
core.fsmonitor=false, core.hooksPath=/dev/null,
core.alternateRefsCommand=true, hook.EVENT.enabled=false for every
githooks(5) event, protocol.allow=never with protocol.ssh.allow=always;
and, for a command with -C DIR, hook.NAME.enabled=false and
filter.NAME's clean/smudge/process emptied with required=false for
each hook and filter driver DIR's config names. It drops every GIT_*
variable and relative PATH folders, and sets GIT_TERMINAL_PROMPT=0,
GIT_NO_LAZY_FETCH=1 (a repo that says it's a partial clone fetches
nothing, with its core.sshCommand or ssh), GIT_SSH_COMMAND=false (no ssh
but gitSSH's) and GIT_SSH_VARIANT=ssh; maintenance.auto=false and
gc.auto=0. Status adds --no-optional-locks and --ignore-submodules=all.
Callers: gitprotect (git, ignoreSubmodules), project.SSHRemote, vm/sync's
gitConfig, vm/clone (hostGit, gitSSH, saveFetched, the uncommitted-changes
status). gitSSH takes the VM: ssh with BatchMode, StrictHostKeyChecking,
devvm's known hosts only, HostKeyAlias=VM, ForwardAgent=no and
ClearAllForwardings=yes, so a url.*.insteadOf reaches only the VM with
its pinned key. The seed push adds --no-verify, --no-recurse-submodules
and --no-signed; rm's fetch --no-recurse-submodules.
Not neutralized: an include.path can make gitConfig read
user.name/email from another git-config file (sent to the VM as its
identity), and a FIFO as a config file hangs git until Ctrl+C; neither
runs code. A VM swapping the repo's config between repoOff's listing and the command
could hide a filter from it, and a --clone VM's root (its host key)
working with another VM that writes the repo could send the push to a
server of theirs; both documented in internals/git-protection.
Tests, each with plain git first running what the hardened one doesn't:
hostgit's TestCommandNoFsmonitor, TestCommandNoHooks (reference-
transaction, pre-push, from .git/hooks and a core.hooksPath; path,
file:// and ext:: pushes refused), TestCommandNoConfigHooks (hook.NAME.*),
TestCommandIgnoresGitEnv (GIT_DIR, GIT_WORK_TREE; environ),
TestCommandNoLazyFetch (a partial clone's core.sshCommand),
TestStatusNoFilters (clean, process, required, names with dots, = and
capitals), TestStatusNoSubmodules; vm's TestHostGitNoFsmonitor and
TestCloneRunsNoHooks (seed push and rm's fetch, update-ref and remote
remove); clone.txtar's push ssh options.
Docs: safety/attack-vectors (devvm's own git commands),
internals/git-protection.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Env.ensureRunning, which history export, rm's export and rm's check of a
--clone VM use to start a VM, started it without launch's safety steps:
no .git check or re-lock, no network policy self-check, and no refusal of
a VM whose state has both network policy and the docker layer. It now
goes through Launch.startChecked, split out of Launch.launch: checkGit
(.git and set-id files, not for a --clone VM), size and SSH agent
forwarding applied, the user's agent checked, then run (the refusals, the
start, the proxy and the self-check). launch keeps the devcontainer.json
check and the disk warning around it. A running VM gets the proxy check
and the self-check too, where it got only the unchosen-agent check.
When rm's clone check can't start the VM, devvm says what kept it from
starting, then fails with clone_check_not_started, which names devvm rm
--no-clone-check and carries the refusal (logged, when the refusal was).
Tests: TestExportStartsAsLaunch (.git locked again on a stopped VM; the
self-check stops a running and a stopped VM that get out directly; the
docker-layer refusal before any Start), TestCloneRmStartsAsLaunch (the
self-check stops a stopped clone VM, which is kept; net_direct_route is
warned, rm fails with clone_check_not_started carrying it, and nothing
but the self-check runs in the VM).
Docs: coding-agents (history), clone (deleting the VM), internals
overview, network (the self-check) and git-protection (on each launch).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The share's lock was a folder in the share (tools/.lock) removed only by
devvm's cleanup, so a devvm that crashed or was killed left the next one
waiting ten minutes and then failing with share_lock_held. The --from
conversion lock on Lima was a folder holding its devvm's pid, taken over
from one that had ended.
Both are now platform.LockFileWaiting on a file in devvm's data folder
(tools.lock, outside the share VMs mount; oci-build.lock), which the system
lets go of when devvm ends, however it ends. Another devvm waits until the
holder lets go or the run is interrupted, saying so after 3 s
(share_waiting, oci_waiting).
- share_lock_held is gone, with the try count, the cleanup and the pid
takeover; tools.Env's ShareWait and Lima's OCIWait are ShareNote and
OCINote, how long before devvm says it's waiting.
- Docs: Building tools and How it's converted describe the locks; the
state tables list tools.lock, oci-build.lock and images/locks/<key>.
Tests: tools TestLockShareKilled (a killed holder's lock is taken at
once; it failed with share_lock_held before), TestLockShare rewritten
(waits, says so, gets it once let go, the lock outside the share);
lima TestLockOCI rewritten (a lock file nothing holds is taken at once,
a held one is waited for, saying so); from.txtar converts with a lock
file left as a crashed devvm leaves it, and no wait.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Lima a build in progress is a recordless image with its final name, so
a second build, devvm rebuild or devvm gc took it for a leftover and
deleted it. Each build now holds an OS lock per image key
(images/locks/KEY) from before it looks for the image until its record is
written; the system lets go of it when devvm ends, however it ends.
- A second build of the same image waits for the lock, saying so after 3 s
(image_build_waiting), then finds it built.
- An image without a record is unfinished only while its lock is free;
while held it's listed as building (devvm images, --json state).
- gc (and gc --backend) and rebuild skip building images; images rm and
DeleteKey refuse them (image_building). Deleting an image removes its
lock file while holding it.
- platform: LockFileWaiting and LockFileSharedWaiting (call a func once
after waiting a while), LockHeld; a lock whose file was removed while
held is taken again on the new file. tools.Making.Hold uses the shared
helper instead of its own two-step wait.
- state.ImageLock: a key's lock path, the key checked.
Tests: build TestBuildInProgress, TestBuildTakesTurns; platform
TestLockFileWaiting, TestLockFileRemoved, TestLockHeld; state
TestImageLock; build.txtar checks a hanging build is listed as building,
kept by gc and refused by images rm.
Co-Authored-By: Claude Opus 5.5 <[email protected]>