Commit Graph
148 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 ffbc139969 test(lima): a contract test of the limactl stub against real Lima
TestLimactlStubContract runs scenario on dummy instances twice, through
the real limactl and through testdata/stubs/limactl, and after each step
compares every instance as devvm reads it from limactl list --json: their
order, status, size, mounts, agent forwarding, ssh port and networks, and
the edits each kind of start would make (startSets).

The stub had drifted from Lima, and now matches it:
- create ignored --cpus= and --memory=: every image was 4 CPUs and 8 GiB.
- clone started from an empty config: Lima's keeps its source's config,
  size and lima.yaml (env), then --mount-none, then each --set.
- Only --set .portForwards, .ssh.localPort and .env were kept: the
  mounts, .ssh.forwardAgent, .propagateProxyEnv, .hostResolver and .dns
  were dropped, so each start edited them again. The stub keeps any
  --set (and del()) in $STUB_DIR/config-<name>/, on create too.
- delete left the VM's size and $LIMA_HOME/<name> (its lima.yaml).
- list gave instances in the order they were made: Lima sorts them.

devvm relied on the clone drift: a project VM keeps its image's
propagateProxyEnv: false (from the build's start), so its first start
without network policy edited it, where the CLI tests said it edits
nothing. CreateVM now sets .propagateProxyEnv=true at the clone. And
rebuild.txtar relied on the list order: it compares the deletes sorted,
as Lima lists images by name. On Linux a layer's or the tools build's
VM, cloned from a built image, keeps the config its image's build made,
so Start edits nothing (no ssh port there) and the build's step count
was one too many: cloneEdits counts the configure step only when Start
edits (TestCloneEdits).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 14:11:57 -07:00
w3cjandClaude Opus 5.5 3da8ffa208 fix: Lima-only review: docs and messages describe Lima alone, doctor --json drops backend_source
- doctor --json: backend_source goes (it could only be built-in).
- AgentWhileRunning and the agent_on_risk_running and
  agent_devvm_risk_running messages go: nothing sets the field.
  Confinement.SSH, NoAgent and AgentFixed stay, as the generic
  emulation contract for ssh and agent-toggle.
- The unused experimental badge goes: its shortcode, Markdown version,
  partial, CSS, llms.txt filter and flask icon.
- Messages: space_backend_unknown, space_stray, gc_backend_skipped and
  gc_orphans_unknown start with "The lima backend" instead of a
  lowercase name; backend_lacks and backend_unreviewed point at doctor's
  features, not other backends; space_caches_note says Lima's caches;
  setup_in_config's description no longer names a backend key.
- Docs: "on every backend" and similar leftovers go (limits, devcontainer,
  images, ports, lima, design, the docs index); space's "Lima's caches";
  safety/network and security say every Lima VM can have network
  policy; images says a docker-layer VM keeps it; ports.md says devvm
  records every VM's ssh port; security's set-id paragraph says where a
  root-owned file comes from; Contributing lists the invariants a new
  backend's threat check covers.
- AGENTS.md: msg.IDOf, now used only by tests, joins deadcode's list.

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 12:46:28 -07:00
w3cjandClaude Opus 5.5 e720d2def5 fix(tools): Debian --from bases boot the generic kernel, which has 9p, and the tools build waits for its folder
On an x86_64 Linux host, a --from base made from a Debian image (node:24)
booted Debian's cloud kernel, which has no 9p (CONFIG_NET_9P is not set).
Lima mounts with nofail, so every mount was an empty folder, and the
shared tools' build VM failed at `cd /mnt/devvm-tools/.build`. Not a race
and not nesting: it fails every time on that image, on the Debian 13 KVM
guest and on bare-metal Fedora alike.

- assets/oci/bootify.sh: Debian gets linux-image-$arch on every
  architecture (the generic kernel, already used on arm64 for gpio_keys),
  and net.ifnames=0 on its kernel command line: with the generic kernel
  udev's enp0s4 came up from Lima's MAC match before cloud-init's rename
  to eth0, which failed as busy and stopped its init stage, leaving no
  ssh host keys.
- assets/shared-tools/build.sh: wait_share waits up to 60 s for
  .build/mise.lock, mounting the folder again from fstab while it isn't
  mounted, then fails naming the folder and mount's last error.
- tools.txtar: wait_share there at once, mounted late, never mounted.
- docs: internals/images.md (the wait), internals/design.md (the cloud
  kernel's missing 9p, the rename).

Both scripts are in image keys: --from bases and every tool image
rebuild.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:37:36 -07:00
w3cjandClaude Opus 5.5 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 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 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 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 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 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 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 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 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 9454d3b2c5 fix(group): refuse a join whose member's name is the joiner's own hostname, and take turns on a lock so all or none holds
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]>
2026-11-01 23:28:21 -07:00
w3cjandClaude Opus 5.5 9c2511117b fix(hostgit): host git runs no program a repo names, nothing of devvm's environment, and ssh only to the VM
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]>
2026-11-01 19:13:43 -07:00
w3cjandClaude Opus 5.5 512793cd69 fix(tools): the share's lock and the --from conversion lock are OS file locks, so a crash never leaves them held
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]>
2026-11-01 19:51:26 -07:00
w3cjandClaude Opus 5.5 20c9fdbadd fix(build): a build holds its image's lock, so concurrent builds, gc and rebuild leave it alone
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]>
2026-11-01 19:39:11 -07:00
w3cjandClaude Opus 5.5 7929eafaf5 fix(msg): every message value renders without control characters
A value a VM made reached the terminal unfiltered wherever a caller
forgot msg.Shown, such as the errors passed as err.Error() and a link's
name. Four cleaners did the job in different ways: msg.Shown (quoting),
ui's printable and oneLine, netpolicy's oneLine and the port
forwarder's log (which let C1 through, in UTF-8).

msg.Printable and msg.OneLine are now the one cleaner: they drop C0 but
newline and tab (OneLine drops those too), DEL and C1, in UTF-8 or as a
lone byte. Every message value goes through OneLine as the message
renders, in Text, Segments and names mode, so no caller can forget it,
and msg.Shown is gone with its 68 calls. The status line, the run log's
end and verbose output, Pick, devvm network log, the forwarder's log and
a clone's status lines use them too.

Tests: TestPrintable and TestValuesArePrintable (internal/msg), the
hostile-value segments test, TestLogLimit (internal/backend/vmssh) with
C1 in UTF-8 and as a lone byte; TestCheckLinks and
TestNewVMOtherRepoAndCommondir expect the cleaned values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:19:23 -07:00
w3cjandClaude Opus 5.5 5f9e2e2408 fix(rm, git-protect): messages whose advice looped now name what works
- rm_export_failed names devvm rm --no-export, the flag that skips the
  export, in place of devvm rm -f.
- devvm rm --no-clone-check deletes a --clone VM without checking its
  clone, after warning that its unfetched commits and uncommitted changes
  go with it (clone_check_skipped). clone_check_failed names it.
- devvm git-protect on, strict or off on a running VM (macOS) is saved
  in the VM's state (git_protect_next) and applied the next time devvm
  finds the VM stopped: devvm stop, devvm restart, or the next launch of
  a VM stopped some other way, before it starts (git_protect_next_stop).
  So git_protect_flag_ignored's advice, devvm git-protect off, works on a
  running VM, and git_protect_running is gone. gitprotect owns the key
  (Next, SetNext; Set drops it); vm's checkGit applies it, then the
  .git check and set-id files, for devvm stop and every launch.

Tests: TestSetNext (internal/gitprotect); git_protect.txtar (a running
VM's choice saved, replaced, applied by devvm stop and by the next
launch); clone.txtar (clone_check_failed, then --no-clone-check);
e2e project's git-protect check and clone's rm check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:16:47 -07:00
w3cjandClaude Opus 5.5 665b9f3b22 feat(group): devvm group, group join NAME and group leave: VMs that reach each other's published ports by name, through links
A group's links are links in each member's state, marked as the group's
(a sixth field, ,group), so the link session, the proxy's list and every
connection check treat them as any link. Membership is each member's own
state (group, group_as), so a VM made again is in none.

- internal/vm/groups.go: Groups (Show, Join, Leave), groupLinks (pure:
  the user's links kept and taking precedence, a link per published port
  of each other member, one address per member kept across changes),
  sync/syncVM/change (records, names what each member gains and loses,
  applies to running members), clashes warned.
- All or none: join refused by network policy (group_policy_on/off);
  devvm network on/off refused for a member (group_policy_mixed).
- One group at a time (group_other); names unique in a group
  (group_name_taken, group_name_host); a member whose hostname is
  another's name gets no links to it (group_link_name_host).
- CheckLink refuses a group's link once the two aren't in one group
  (ungrouped); leave removes the leaver's own group links first; join
  again works every member's links out again; link rm refuses a group's
  link that still applies (link_from_group).
- Publish/unpublish, link add/rm and devvm rm reach the group's links.
- Docs: using/links.md Groups, the Commands page, safety/network.md,
  internals/ports.md, the design note's Groups section and threat check;
  the CLI reference.
- Tests: groups_test.go, testdata/script/group.txtar, JSON shape; e2e:
  three VMs in a group and the all-or-none refusals in the link section
  on every backend.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 16:01:54 -08:00
w3cjandClaude Opus 5.5 99c6faeda4 feat(link): devvm link add, link publish and the client's launch warn of a target whose network policy isn't in force
A client with network policy has each connection to a running target
whose network policy isn't in force refused (unenforced). devvm now warns
of such a target before that, refusing nothing, with the connection's own
check: link_target_unenforced names the target and the client and says to
run devvm restart in the target's folder. A stopped target isn't warned
of, as its policy applies when it next starts.

- internal/vm/linksession.go: policyUnenforced (policyEnforced's verdict
  for a warning), Links.warnUnenforced (the target's backend, running,
  then policyUnenforced)
- internal/vm/links.go: Add warns for a new link and for one that exists;
  Publish warns, through publishUnenforced, for each client with network
  policy that links to a port published now and not before
- internal/vm/linkrun.go: warnTargets, at the client's launch, warns of a
  running target whose policy isn't in force
- locales/en.toml, internal/msg/docs.go: link_target_unenforced, linked to
  using/links#links-and-network-policy
- TestWarnUnenforced (enforced, unconfined, self-check failed, stopped,
  a client without policy; agrees with the connection's check),
  TestLinksAtLaunch's unenforced target; link.txtar: add, link_exists and
  publish warn, a client without policy isn't warned
- tests/e2e.sh: lk_policy_unenforced also checks link add's and the
  client's launch's warning
- docs: using/links.md, safety/network.md, the design note, contributing's
  link section

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:38:24 -08:00
w3cjandClaude Opus 5.5 133a4d3cdb feat(guest): what a client VM needs for links: sshd's rule, low ports, /etc/hosts and NO_PROXY
Every VM's sshd (base.sh's 00-devvm.conf, services.sh) allows remote
forwards of TCP ports only on 127.77.0.0/16: AllowTcpForwarding all,
GatewayPorts clientspecified, PermitListen 127.77.*:*. Remote socket
forwards, tunnels and X11 stay refused. The setup sets
ip_unprivileged_port_start to 0 where it's 1024, writes the VM's links in
a marked /etc/hosts block in place (Docker's is a bind mount), and puts
DEVVM_NO_PROXY in every NO_PROXY it writes.

The links come from Env.Links (nil: none), a list of GuestLink {Addr,
Names}, checked on the host by checkLinks (link_setup_invalid) before the
start's NO_PROXY (netpolicy.LinkEnv) and the setup's hosts file. design.md,
security.md, smolvm.md and docker.md describe the sshd rule; e2e checks
it with rfwd_links on every backend, and low ports on Alpine and smolvm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 07:03:24 -08:00
w3cjandClaude Opus 5.5 6805d194bd feat(link): devvm _links, the host side that carries a client's links, and the forwarder skipping links' addresses
vmssh.Links runs a running client VM's link session: one ssh master of
its own to the client (never the forwarder's), started with
ClearAllForwardings=yes and -N, to which each link is added with
-O forward -R 127.77.x.y:PORT:<socket> and from which it's removed with
-O cancel, read again every second (Want). Each forward is its own, so
one the client refuses fails that link alone (Failed, which warns with
link_port_taken through Link.PortTaken). Each link's end on the host is
a unix socket, mode 600, in the run folder (made 700), named
link-<hash of client, address, port>.sock; masters' control sockets are
link-<hash>.ctl (the session's; a target's by target and start). A
stale socket is replaced, anything else refused, and sockets go with
their link or the session.

Each connection is checked again (Check), then carried by
ssh -S <target master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT
through a master kept per target and start: a channel goes through the
master or nowhere. At most 256 at once, then refused (link_limit).
Events (link, link_refused, link_target_stopped, link_limit) go to the
client's event log. The session ends once the client no longer runs its
start, or has no links.

vm.Links.Session builds it from the state and the backends: the
client's and targets' ssh from Backend.SSH, the key its first
IdentityFile, host keys devvm's pinned known_hosts (HostKeyAlias), only
on a host loopback port or through the backend's ProxyCommand, FeatureSSH
allowed. linkConn re-reads the states per connection: the link still in
the client's state (removed), CheckLink (gone, replaced, unpublished,
policy), the link features on the target's backend, the target running
(Inspect, StartID: link_target_stopped otherwise; it never starts one),
its ssh (ssh). devvm _links VM (hidden, one argument) runs it, failing
with link_session_failed or vm_not_running.

The port forwarder never forwards a listener in 127.77.0.0/16 (dialAddr,
vmssh.IsLinkAddr), on any VM; a test keeps vmssh.IsLinkAddr equal to
vm.IsLinkAddr on every link address and around them.

netpolicy.AppendEvent writes devvm _links's events beside the proxy's,
mode 600, rotating past 10 MiB; events carry target, which FormatEvent
and devvm network log --json show.

Tests: TestLinkArgs, TestLinkFiles, TestListenSocket, TestLinks,
TestLinksSessionLost, TestLinksCap, TestIsLinkAddr, TestListeners
(range exclusion) in vmssh; TestLinkAddrsAgree, TestLinkConn,
TestSessionLinks, TestLinkEvents in vm; TestAppendEvent and link cases
in TestFormatEvent; link_session.txtar for _links's argument and
refusals; e2e's project section checks a server on 127.77.0.1 isn't
forwarded while the VM's own on 127.0.0.1 with its port is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 06:48:11 -08:00
w3cjandClaude Opus 5.5 4ea141b918 feat(link): devvm link, link add, rm, publish and unpublish, with their state and checks
Links between VMs' commands and state, without anything carrying a
connection yet.

- state: every VM gets a random ID (KeyID, "id") when CreateVM makes it.
- vm: Links (links.go) lists, adds and removes the folder's VM's links
  (KeyLinks, "links": NAME,PORT,TARGET,TARGET_ID,ADDR entries) and
  publishes and withdraws its ports (KeyPublish, "publish"). Each target
  gets one address in 127.77.0.0/16 per client, the lowest free. CheckLink
  says why a link doesn't apply (gone, replaced, unpublished, policy).
- project: Matching (which sshconfig.Alias now uses), IsPath, ForDir and
  Targets resolve a link's TARGET: a path, a VM's name or a folder name.
- cli: link.go, in the Links between VMs group; --json on devvm link and
  devvm link publish; --as checked with the other flag values.
- Messages: no_vm_link, link_failed, link_port_invalid, link_ports_invalid,
  link_unknown_target, link_ambiguous_target, link_self,
  link_not_published, link_policy_mismatch, link_name_invalid,
  link_name_host, link_name_taken, link_target_named, link_exists,
  link_added, link_trust, link_removed, link_not_found, link_port_taken,
  published, unpublished, port_not_published.
- Docs: the Links between VMs table on the Commands page, the CLI
  reference, AGENTS.md and the cli skill's tree.

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:13:27 -08:00
w3cjandClaude Opus 5.5 16b4ad8771 feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no
question is asked or read. The ui's prompts (Ask, Confirm, Answer,
Secret, Pick/PickOne in a terminal) show the question, then fail with
no_input naming what answers it (msg.AnswerFor, by the question's ID),
or no_input_terminal for a question only a terminal answers. ui.Flags
and SetFlags carry -v and --no-input.

Answers: --network-policy/--no-network-policy, --here, devvm size -g,
devvm setup --features/--backend, devvm network -g, devvm ssh-agent add,
devvm restart, --ssh-config (new, on devvm, host and code: the Include
line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude),
--stdin, and --force.

--force (-f) only skips a confirmation, and destructive commands need it
without a terminal (force_needed, a failure, not a usage error): rm (new
rm_confirm), gc (it went ahead without a terminal), gc --caches (now
allowed without a terminal with --force), images rm (images_rm_confirm),
secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images
are built on the one rebuilt (build.Env.Force). rm --no-export skips the
export; rm's parent-folder, earlier-folder and --clone confirmations are
terminal-only and --force never answers them (vm.RmOptions). gc --tools
--force splits: --recent (only with --tools, gc_recent_needs_tools)
drops the hour's hold and keeps the refusal while a VM is being made
(gc_recent_making); gc_tools_recent names devvm gc --tools --recent.
gc_caches_need_terminal goes.

Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt
(--force), TestRebuild (force_needed, then Force); secret, rebuild,
images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images
rm/secret rm/rebuild with --force (and --no-export where rm -f skipped
the export), and the clone section's rm with its checks. Docs:
commands.md (Questions devvm asks, rm, flags), first-vm, clone, images
(cleaning up, --recent), space, coding-agents, internals overview and
images; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:51:27 -08:00
w3cjandClaude Opus 5.5 a7b605f0c0 feat(cli): -v/--verbose streams the run log
A global -v/--verbose (persistent on the root, the only one with
--help): each line the run log gets, numbered steps, the redacted
command lines and the commands' output, also goes to stderr as it's
written, without control characters (a C1 control split across writes
too) and dim where stderr is colored, with no status line. The run log
is still written. A logged failure while verbose names the log
(log_details) instead of printing its end again. DEVVM_VERBOSE is gone.

ui: SetVerbose; stream (printable, dim) and logTo tee LoggedCmd's and
LogWriter's output; a streamed command's pipe gets WaitDelay
(streamWait, 2s) so a process it leaves running can't hold devvm, and
ErrWaitDelay alone isn't a failure. --version stays root-only, and
version.txtar checks -v isn't it.

Tests: TestStreamIsPrintable, TestDieLoggedVerbose, the logged-command
and status tests; build.txtar streams a build with -v. Docs:
troubleshooting (A command fails), settings (colors, environment),
commands (Flags and values), contributing (styles); CLI reference.

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:06:56 -08:00
w3cjandClaude Opus 5.5 fe32d2a01c feat(cli): reserved command names, and did-you-mean for devvm WORD
A word after devvm that's neither a command nor an image (no +, and not
base, a shared tool or a layer) is a usage error, exit 2, suggesting the
closest command (Cobra's SuggestionsFor, distance 2) and the closest image
name. devvm help WORD and devvm WORD --help fail the same way instead of
printing the root's help. Layers can't take a word devvm keeps for its
commands.

- internal/image/reserved.go: Reserved (every command and subcommand
  name, hidden ones and help, and link, group, join, leave, publish,
  unpublish kept for later), IsReserved; LayerName refuses them, so
  Layers() and completion leave such files out.
- build.CheckLayerName refuses one (layer_name_command); CheckLayers
  refuses a layer file named with one wherever an image names it
  (layer_is_command, naming the file).
- internal/cli/word.go: checkWord (the root's Args), closest and
  levenshtein, addHelp (devvm's own help command, and a help func that
  panics with wordPanic for execute to recover), helpTarget, printUsage.
- Messages: layer_name_command, layer_is_command, no_command_or_image,
  no_command_or_image_command, no_command_or_image_image,
  no_command_or_image_both, with doc links.
- Tests: TestEveryCommandReserved, TestImagesNotReserved,
  TestLevenshtein, TestUnknownWord; layer.txtar and up_checks.txtar; e2e
  checks a mistyped command exits 2 with its suggestion.
- Docs: customizing (layer names), commands (devvm WORD), contributing,
  AGENTS.md.

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 3b1959efd2 feat(network): network policy rules and log under devvm network, and network -g for new VMs
devvm network allow|deny|rm RULE... [-g] and devvm network log [-f] [-n N]
[--blocked] replace devvm policy and devvm log. Bare devvm network shows the
VM's network policy, then its allowlist file by file. devvm network -g shows
or saves whether new VMs get network policy (ask, on or off), through the
network file devvm setup also writes; --network-policy and
--no-network-policy beat it and skip reading it, a saved off makes a VM
without the docker-layer and backend warnings, and with ask and no terminal
a new VM gets it.

The proxy's block messages, devvm-why's, network log --blocked's ALLOW WITH
and the VM's setup note name devvm network allow. New messages:
net_default_failed, net_ask_global; -g reports with network_default. Docs,
the CLI reference, txtars (network_rules, network_log, network), e2e
(bare devvm network's first line) and AGENTS.md follow.

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:38:54 -07:00
w3cjandClaude Opus 5.5 9b2650e089 fix(gc): gc --tools and retention keep current tools while a VM is being made
A new VM can pick a tool built long before that no VM has, so the hour
alone didn't keep it from plain gc --tools or retention's
tools.unused-age between picking it and its state listing it. Both now
try the making lock without waiting, after the share's lock, and hold it
until they're done.

While any VM holds it, plain gc --tools keeps every current tool no VM
has, after the same filters, and names them (gc_tools_making), deleting
the rest of its list; retention deletes no tool images that run and
leaves their idle records, then applies its other settings. A devvm
that starts to make a VM while either holds the lock waits, saying so
after 200 ms (making_waiting). gc_force_making gives one action.

Tests: TestMaking (the wait message), gc_tools.txtar (a hanging up keeps
an old tool through plain gc --tools, the kill releases it),
retention.txtar (a hanging up keeps the tools, the rest runs). Docs:
using/images.md, using/settings.md, internals/images.md, the CLI
reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 00:39:23 -07:00
w3cjandClaude Opus 5.5 c0b9916ff2 feat(gc): gc --tools names the tools it keeps for the hour, and --force deletes them
gc --tools prints gc_tools_recent (count, tools) for the current shared
tool images no VM has that it keeps because they were built in the last
hour, after the same filters as the ones it deletes (TOOL names,
--backend, skipped backends): with gc's list, or in place of
nothing_to_clean. Plain gc never prints it.

--force, only with --tools (gc_force_needs_tools otherwise), also
deletes those and skips gc's prompt; gc still lists what it deletes.
Tools a VM's state lists stay, the share's lock is held from before the
List, and no other category widens. Retention's Idle keeps the hour.

The being-made signal: tools.Making, an flock on making.lock in devvm's
data folder (platform.LockFileShared, platform.TryLockFile). up's create
(every backend, --clone, devcontainers), devvm update and adding a layer
in place hold it shared from before they pick tools until the VM's state
lists them; gc --tools --force takes it exclusively without waiting,
after the share's lock, and holds it through its deletions, else fails
with gc_force_making and deletes nothing. The OS releases it when the
process ends, and its descriptor is close-on-exec.

Tests: TestLockFileShared, TestLockFileKilled (a killed child releases
it), TestMaking, TestNoVM's recent ones, TestGCAsks, gc_tools.txtar.
Docs: using/images.md, using/space.md, internals/images.md, the CLI
reference.

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:56:53 -07:00
w3cjandClaude Opus 5.5 415e77c773 test: docker's and smolvm's forwarding scripts use free ports and look for their own forwarders
docker.txtar and smolvm.txtar gave the VM's servers fixed host ports
(47327-47329), so another run of the same script on this machine (a gate in
another worktree) could hold them, and the forwarder refused them as taken.
Each script now takes its ports from free_port, writes them into the stub's
guest-ports in hex, and expects them throughout. The ps checks of a running
forwarder match only this run's, by its key in the run's data folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:46:07 -07:00
w3cjandClaude Opus 5.5 3c4a77349c fix(clone): rm checks every worktree inside a --clone VM's clone
devvm rm on a --clone VM ran git status only in the clone's main
checkout, so uncommitted changes in other worktrees in the VM went with
it unasked. It lists the clone's worktrees (git worktree list
--porcelain -z, at most 1 MiB read) and checks each one's status,
showing the changes under each worktree's path, 20 in all.

The list comes from the VM, so only clean absolute paths inside the
clone are used, each once, and bare or prunable ones are skipped; a
worktree whose folder is gone has nothing to lose. Paths go to the VM
only as an argument and are shown through msg.Shown. At most 100
worktrees are checked; past that devvm says so and asks anyway.

- internal/vm/clone.go: cloneChanges, cloneWorktrees, insideClone,
  showChanges, cloneExec, worktreeStatus, cloneWorktreesMax
- messages: clone_worktree_dirty, clone_worktrees_unchecked (linked
  to using/clone#deleting-the-vm)
- tests: TestCloneWorktrees, TestCloneRmWorktrees,
  TestCloneRmTooManyWorktrees; clone.txtar's dirty worktree; the
  limactl stub's git worktree list and worktree status; e2e clone's
  dirty-worktree check
- docs: using/clone.md's Deleting the VM and a new section, Several
  agents in one VM; internals/overview.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:28:06 -07:00
w3cjandClaude Opus 5.5 36f4d0ab21 feat(gc): a backend that can't list its images is skipped with a warning
When a backend that a VM's state names can't list its images, gc warns
(gc_backend_skipped, linked to Cleaning up) with its Check's error, else
its listing's, and leaves everything of that backend's alone: its
images (not listed), its unused and current shared tool images and
those whose backend devvm can't tell, its orphans (moved to the backends
that couldn't be asked, so gc_orphans_unknown names it) and, with
--caches, its cache. gc goes on with the other backends and succeeds.
devvm images still fails, as it lists every backend's or none.

listImages returns an imageListing (images, tools, unlisted backends);
images uses its failUnlisted, gc's planGC its skip, withoutSkipped and
the skipped set gcRun hands to gcCaches.

Tests: TestWithoutSkipped; gc_skipped.txtar (Lima's stale image and
tool deleted, smolvm's and an unknown backend's tool kept, the smolvm
VM's state kept, gc succeeds, devvm images fails); gc_orphans.txtar's
end. Docs: using/images.md's Cleaning up, using/space.md's leftovers,
gc's help and the CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 16:50:19 -07:00