Commit Graph
348 Commits
Author SHA1 Message Date
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 50b4e796b7 fix(daemon): a proxy just started whose arguments read as none yet is still waited for
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]>
2026-11-03 11:18:26 -07:00
w3cjandClaude Opus 5.5 b1fe2ec2a6 test(e2e): ps_unwatch takes no host process sample after it returns
The desktop check that its VNC password is in no host process's arguments
failed now and then, though devvm never puts it in one. ps_unwatch killed
the sampling loop's subshell, but the ps it was running at that moment went
on and appended one more sample to ps.log. That sample could catch the next
check's own bash -c, which holds the password in its command line. Killed
mid-sample, the old watcher recorded a command started after ps_unwatch in
4 of 30 tries on macOS.

ps_watch's loop now runs while $work/ps.on exists, and ps_unwatch removes it
and waits for the loop to finish its sample, so no sample is taken after it
returns (0 of 60 tries). The network section's watcher gets the same fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 11:09:56 -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 ee8146a5e4 fix: scripts and tests work without shasum, and two CLI scripts start Lima outside devvm on bash 5.2's sh
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]>
2026-11-03 07:13:46 -07:00
w3cjandClaude Opus 5.5 34e2e5ef5a feat(cli): devvm WORD naming a toolchain, agent or layer points to its flag
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]>
2026-11-03 07:06:06 -07:00
w3cjandClaude Opus 5.5 da93384f60 fix(lint): fetch.Client is its own type, and forbidigo bans http.Transport, os.Create and O_TRUNC
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]>
2026-11-03 06:43:13 -07:00
w3cjandClaude Opus 5.5 4d863bb749 fix(cli): another part's name in --tools, --agents or --layers names the flag that takes it
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]>
2026-11-03 06:47:59 -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 b8c2b60795 fix(vm): a link session doesn't reuse a lookup its connection cancelled
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]>
2026-11-03 01:38:10 -07:00
w3cjandClaude Opus 5.5 497414fdda fix(tools): retry the pinned mise's download after failures that may pass
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]>
2026-11-03 01:38:10 -07:00
w3cjandClaude Opus 5.5 0c1518509e test(e2e): read only a disk's data in the secret-leak checks
The checks that a build's image keeps no proxy password (the host's
proxy in images, the nix layer behind a company proxy, --from's
company proxy) ran grep -r over each image's folder. Its disk is
sparse, 100G of mostly holes, which grep reads as zeros: 98 s on one
image on the Mac here and over 80 minutes on the MacBook Pro.

no_leak PATH... <STRINGS reads each regular file under PATH... byte
for byte, as grep -raF did, but only its data extents, found with
SEEK_DATA/SEEK_HOLE through perl's sysseek (3 and 4 on Linux, 4 and 3
on macOS), carrying a string's length minus one byte across reads.
A file a string is in, or one it can't read, fails it. The same image
takes 2 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 06:00:21 -07:00
w3cjandClaude Opus 5.5 2b25a0c7dd fix: the shared foundations' review: one Lima host address, a kill only for its own process, and the Linux baselines
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]>
2026-11-02 23:52:51 -07:00
w3cjandClaude Opus 5.5 d01a1872ca test(smolvm): the listed range in smolvm.txtar is two free ports
smolvm.txtar listed host ports 8000-8001 and expected no ports_
warning, so it failed where a program has port 8000, as a dev server on
the Linux test machine does (ports_taken ports=8000). free_port gets
-range FIRST LAST, two adjacent ports free here, and the script lists
$FIRST-$LAST as it lists $LISTED and $UNLISTED. The other scripts'
fixed ports are either guest ports (link publish and add) or lists
whose host check nothing asserts (up_size, ports, devcontainer, the
sshd and many sections of smolvm.txtar), so they pass whatever holds
them.

Test: with a listener on 127.0.0.1:8000, the script failed at
smolvm.txtar:73 before (ports_taken count=1 ports=8000) and passes
after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 23:32:39 -07:00
w3cjandClaude Opus 5.5 dc349717a2 fix(links): a link session's connections to one target share its run
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]>
2026-11-02 23:24:35 -07:00
w3cjandClaude Opus 5.5 c601958355 fix(links): link sessions' and port forwarders' ssh get devvm's limit on open files
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]>
2026-11-02 22:47:16 -07:00
w3cjandClaude Opus 5.5 ae77c7bc45 fix(daemon): a stopped process counts as stopped once it's gone, not once its arguments go
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]>
2026-11-02 22:46:56 -07:00
w3cjandClaude Opus 5.5 51f1dc48e7 test: stubs write each call-log line in one write
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]>
2026-11-02 22:27:07 -07:00
w3cjandClaude Opus 5.5 e9f791bc96 refactor: one owner for the proxy's constants, URLs, variables and tunnels
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]>
2026-11-02 20:51:28 -07:00
w3cjandClaude Opus 5.5 6f9259b514 test: give each CLI test script its own coverage folder
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]>
2026-11-02 22:04:17 -07:00
w3cjandClaude Opus 5.5 36c7578c62 test(e2e): give each file watcher check folders of its own
On the second Mac the VM kept seeing .e2e-watch as gone for over 20 s
after the check before deleted it and this machine made it again, so
the check that this machine's edits pass on no events failed with
"Can't open perl script". Each watch_sees call now writes its script
and log under .e2e-watch-N and watches e2e-sub-N, names the VM never
looked up before, and stops only its own watcher. The VM's 20 s wait
for the script stays, as a bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 21:25:10 -07:00
w3cjandClaude Opus 5.5 b5c51ae9f7 test(e2e): need OpenSSL as openssl, and stop at the start without it
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]>
2026-11-02 21:23:14 -07:00
w3cjandClaude Opus 5.5 5003d94cfb refactor: read HOME once, into paths.Dirs.Home
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]>
2026-11-02 16:07:15 -07:00
w3cjandClaude Opus 5.5 f2a8ddd404 refactor: write every file whole through state, and make private folders with state.PrivateDir
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]>
2026-11-02 15:50:40 -07:00
w3cjandClaude Opus 5.5 f85914db07 test(e2e): the watcher checks wait for watch.pl to show in the VM
On Lima, the check that this machine's changes reach no watcher in the VM
failed on main every time (88 passed, 1 failed): perl couldn't open
.e2e-watch/watch.pl. The check before it deletes .e2e-watch at its end, and
this one writes it again moments later; the VM's virtiofs goes on seeing the
folder as gone for a while, so perl ran before the file showed and the
watcher never got ready.

watch_sees now has the VM wait up to 20 s for the script before running it,
and a script still missing fails naming the file as before. With it, --only
project passes, 89 of 89.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 19:41:12 -07:00
w3cjandClaude Opus 5.5 b4402a74e8 refactor: every HTTP client through internal/fetch
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]>
2026-11-02 18:28:01 -07:00
w3cjandClaude Opus 5.5 2687eec488 refactor: one background-process helper, internal/daemon
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]>
2026-11-02 18:34:18 -07:00
w3cjandClaude Opus 5.5 82566e9010 refactor: shell quoting, the VM-name grammar and value patterns each in one place
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]>
2026-11-02 16:07:18 -07:00
w3cjandClaude Opus 5.5 32aa8fe3e6 refactor: one parser and formatter for port lists, and a bad entry is refused, not port 0
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]>
2026-11-02 15:46:14 -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 088f180842 fix(vm): an interrupted start under network policy stops the VM and its proxy
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]>
2026-11-02 16:27:05 -07:00
w3cjandClaude Opus 5.5 06bed70fc7 test: record the Linux coverage baseline, and fix two tests that failed on Linux
testdata/coverage/linux.txt is each package's coverage from mise run
coverage on a Linux host (Ubuntu 24.04 arm64), so mise run test checks
Linux runs too.

Two tests failed there:
- secret.txtar checked that --no-input saved nothing by asking whether
  the secrets file existed, but on Linux an earlier step had saved one.
  It now checks that github keeps the token saved earlier, on both
  systems.
- smolvm's TestStartSSH looked for the proxy password "pw" in the
  arguments, which also held a random ssh public key whose base64 can
  contain "pw". The password now has a "!", which base64 never has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:06:29 -07:00
w3cjandClaude Opus 5.5 cefb7b9472 chore: extend the owner, don't copy it: the rule, the consolidation pass and the owners' checks
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]>
2026-11-02 15:06:16 -07:00
w3cjandClaude Opus 5.5 b5742dca2c build: a package's coverage may sit up to a point below its baseline
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]>
2026-11-02 15:06:25 -07:00
w3cjandClaude Opus 5.5 82d8e1f594 build: the test task's comment names the per-system coverage baselines
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:26:59 -07:00
w3cjandClaude Opus 5.5 ddbc377f8f test: testscript commands for the scripts' setup, and a coverage baseline per package
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]>
2026-11-02 14:25:09 -07:00
w3cjandClaude Opus 5.5 1cfc8e24f1 test: share the stubs sandbox, message checks and recorders across Go tests
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]>
2026-11-02 13:24:43 -07:00
w3cjandClaude Opus 5.5 42fb9828fe test(proxy): TestDecider waits for the refusal it checks in the event log
The decider logs each refusal as it answers it, so on a busy machine the test
could read the log before the last refusal's line was written. It now waits
for that line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 09:59:30 -07:00
w3cjandClaude Opus 5.5 9c34ad5c69 fix: host git reaches ssh alone, a queued git-protect mode is set after the check, and retention's lock is an OS file lock
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]>
2026-11-02 07:31:24 -07:00
w3cjandClaude Opus 5.5 56ae2360aa fix(lima): read a running VM's disk info with qemu-img info -U
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]>
2026-11-02 09:21:07 -07:00
w3cjandClaude Opus 5.5 92dd813852 docs(contributing): make the Linux host VM's user uid 1000
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]>
2026-11-02 09:21:07 -07:00
w3cjandClaude Opus 5.5 a62641c7a1 build: mise run test gives each package 30 minutes
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]>
2026-11-02 09:01:21 -07:00
w3cjandClaude Opus 5.5 16d44275d0 test(link): TestLinks waits for a link to be marked failed
A link is marked failed only after its forward command returns, so on a
busy machine the test could check the failed list right after the third
forward was recorded and find it empty. It now waits for the failure, as it
waits for the forwards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 09:01:21 -07:00
w3cjandClaude Opus 5.5 524669a93f fix(link): keep accepting a link's connections while a burst is carried or refused
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]>
2026-11-02 04:34:52 -07:00
w3cjandClaude Opus 5.5 487366d186 fix(netpolicy): one strict parser for policy files, lines that aren't rules named, broken denies fail closed
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]>
2026-11-01 18:23:22 -07:00
w3cjandClaude Opus 5.5 aa24efe2e7 fix(proxy): certificates never outlast devvm's CA, and a CA that ended is named
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]>
2026-11-01 17:58:56 -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