Commit Graph
96 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 7cd15a0862 feat(retention): retention settings for what devvm keeps, all off by default
~/.config/devvm/retention holds key=value lines, written by devvm space
set KEY=VALUE... (KEY= turns one off; a bad key or value is refused
before the file is written; all off removes the file). Every setting
is off unless set:

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 13:29:49 -07:00
w3cjandClaude Opus 5.5 5bfb89c371 feat(gc): gc --caches frees devvm's share of the backends' own caches
Lima's download cache (9.1G on the user's machine) and smolvm's caches
(22G) are filled by devvm's builds but are the backends' own and hold
the user's own downloads too. devvm never prunes them on its own and
never runs limactl prune, smolvm pack prune or smolvm machine prune
(each reaches the user's own entries). gc --caches, only in a terminal
(gc_caches_need_terminal otherwise, before anything is deleted), then
lists devvm's share of each backend's cache with sizes and asks for
each backend apart (backend.CacheCleaner):

- Lima: entries of download/by-url-sha256 whose url hashes to the
  folder's name and is Ubuntu's cloud image at the address devvm
  downloads base from, for its release, a dated release, that no image
  record names, unchanged for an hour (a build may be downloading).
  Lima copies a VM's disk out of the cache, so no VM needs an entry.
- smolvm (macOS): the disks smolvm unpacks of each pack
  (vms/_pack-storage-seeds/v2-<sha256 of the .smolmachine>-auto, found
  on the user's machine: 20G of the 22G), tied to devvm's packs by their
  SHA-256 - packs devvm has, and every pack it makes from now on, which
  smolvm/packs records - that no machine of devvm's was made from,
  unchanged for an hour, with their lock files. Disks of packs that
  are gone and unrecorded can't be tied to devvm and stay; so do the
  machines' folders and smolvm's other caches. On Linux smolvm's state
  is devvm's own folder: nothing listed.
- Docker: volumes with devvm's label that no VM has, not the tools'
  volume, not one of a VM devvm has state for (a VM being made makes
  its volumes before its container). Never an unlabelled one, never a
  prune.

Each delete checks the entry again first. With --backend, only that
backend's cache.

Messages: gc_caches_need_terminal, gc_cache, gc_cache_entry,
gc_cache_confirm, deleted_cache. Docs: the What devvm keeps page (the
backends' caches, Lima, smolvm, Docker), backends/smolvm.md's Cleaning
smolvm's caches, backends/lima.md, the uninstall steps,
using/images.md's Cleaning up, the CLI reference.

Review (touches nothing of the user's): limactl prune empties the
whole cache and isn't used; --keep-referred would see only devvm's
Lima home. smolvm pack prune removes any unused cached extraction,
the user's own packs' included, and machine prune works on a named
machine's images; neither is used. Lima entries are tied by address
and hash, smolvm disks by the SHA-256 of devvm's own packs, Docker
volumes by devvm's label. Tests: lima TestDevvmCache (your download, a
recorded release, one being written, a wrong layout, another file
kept); smolvm TestDevvmCache (a VM's pack, someone else's, a recent
disk, a machine's folder kept; a recorded deleted pack's disk freed;
Linux lists none), TestPackRecorded; docker TestDevvmCacheVolumes (a
VM's, the tools', one being made, someone else's kept); gc_caches.txtar
(refused without a terminal before anything is deleted; the default run
leaves the caches).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:23:35 -07:00
w3cjandClaude Opus 5.5 60d59c46f3 feat(images): the tool table shows each build's backend and C library
devvm images's tool table has BACKEND and LIBC columns, so a Lima and a
smolvm build of one version no longer look alike: from the target
record each build leaves beside it (its format matched to the backend
that has it, or one of the same kind), else the target it's current
for, else a VM's state that lists it, else -. The output ends with the
disk the images and tools take in all, pointing at devvm space
(images_total).

Docs: using/images.md's tool table and the line after the tables;
internals/images.md's listing section (the .target record and how
BACKEND is found); the CLI reference.

Tests: TestWriteImagesTools (rows, - for what a row lacks); images.txtar
(the columns from a record and from a VM's state, the total); gc.txtar.

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:15:18 -07:00
w3cjandClaude Opus 5.5 91a429108f feat(images): a built-in nix layer with Nix, direnv and nix-direnv, pinned
nix is a layer devvm ships, as docker is: devvm nix, devvm node+nix, devvm
build nix, or added to an existing VM in place. A folder with flake.nix,
shell.nix or devenv.nix at its top level, or a default.nix that makes a
shell (mkShell), gets it after its toolchains, so package.json and flake.nix
give node+nix.

- assets/layers/nix.sh: Nix 2.35.4's release tarball (releases.nixos.org),
  its version and SHA-256 per arch at the top, checked against the
  tarball's .sha256 files and nixos.org/nix/install, fetched with
  devvm-fetch; 2.35.3 fixes GHSA-hf6w-2rg9-v84g (store ownership in the
  scripted installer) and CVE-2026-110450 (store corruption through the
  daemon's repair flag). The tarball's own install --daemon --yes
  --no-channel-add, with experimental-features = nix-command flakes,
  trusted-users = root, sandbox = true and sandbox-fallback = false. The
  installer runs without proxy variables (it writes any it finds into a
  systemd override for nix-daemon, which would put a build's proxy into
  the image) and with NIX_SSL_CERT_FILE at the system's bundle. The layer
  checks the store is root's, adds Nix's default profile to the end of
  sudo's secure_path (/etc/sudoers.d/devvm-nix, checked with visudo), and
  appends Nix's profiles to BASH_ENV's PATH. direnv 2.38.2 (per arch) and
  nix-direnv 3.2.0's direnvrc, pinned the same way; direnv's hook in
  ~/.bashrc.d/direnv.sh, which loads before mise.sh so direnv's prompt hook
  runs after mise's and a dev shell's PATH comes first; a direnv lib file
  puts each project's layout under ~/.cache/direnv/layouts, so nix-direnv
  writes no .direnv into the project folder. Without systemd the script
  refuses in one line.
- assets/layers/nix.policy: cache.nixos.org, channels.nixos.org,
  releases.nixos.org (GitHub is in base.policy).
- assets/guest/sync.sh: nix-daemon gets a systemd drop-in with the VM's
  proxy (http_proxy, https_proxy, no_proxy) under network policy, removed
  when it's off, the daemon restarted when it changed.
- image.NixLayer in Builtins; project.Detect's nix marker (a default.nix is
  read only as a regular file, at most 64 KiB); backend.FeatureNixLayer
  (nix-layer), needed by a VM of an image with the layer and by building
  one: Lima native, smolvm and Docker none, so both refuse in one line
  (backend_lacks); dockerLayers.choice returns every layer feature of the
  image, so docker+nix on Docker needs nix-layer too.
- scripts/bump.sh: nix (the version nixos.org's installer names, the
  sums Nix publishes; it fails when the installer names no tarball, as
  Nix's Rust installer will), direnv, nix-direnv.
- Docs: using/images (built-in layers, detection), using/toolchains (Nix
  projects), safety/network (the layer's hosts; source builds' hosts
  blocked), internals/images (the nix layer), internals/network (the
  daemons' drop-ins), internals/backends (nix-layer), internals/design
  (the nix layer beside Instead of Nix), backends, customizing,
  coding-agents, contributing (the e2e section); the CLI reference;
  AGENTS.md's assets/ and e2e lines.
- Tests: Detect (markers, default.nix with and without a shell, a linked
  one), layer and environment lists, layer new nix reserved, nix-layer in
  ImageSpec and ImageFeatures, caps tests, up_checks.txtar (node+nix
  detected under an agent), docker.txtar (nix refused for a VM and a
  build). e2e nix section: the layer built behind a company proxy leaves
  no proxy settings and no password on its image's disk; a node+nix flake
  VM with network policy: pins, a root-owned store, sandbox without
  fallback, trusted-users root and an untrusted substituter ignored, the
  daemon's drop-in, nix run nixpkgs#hello, sudo nix and nix over ssh, the
  flake's node ahead of the shared node prompt after prompt through
  direnv, no .direnv in the folder, a blocked fixed-output fetch named by
  devvm-why, and the drop-in gone after network off.

Review (security-audit skill, guidance mode, against the review task's
list): the tarball and direnv's files are pinned in devvm's source and
checked before tar or install runs; nothing from the host goes into the
image (no proxy override, e2e greps the disk); the drop-in holds only the
VM's own proxy URL, devvm's value, and goes when policy is off;
trusted-users stays root and an untrusted user's substituters are
ignored (the VM's user has sudo, so that guards an honest VM and the
allowlist is what holds); secure_path gains only the root-owned default
profile, last; /nix is on the VM's own disk and nothing mounts a host's
or another VM's store. Found and fixed in review: Nix's default
sandbox-fallback would build unsandboxed without a word where the kernel
can't sandbox, so it's off. No confirmed findings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:22:02 -07:00
w3cjandClaude Opus 5.5 e2e3c70d81 feat(desktop): a desktop feature and devvm desktop, over VNC, on every backend
The desktop feature (assets/features/desktop.sh, not chosen until you
choose it, about 370 MB) installs Xfce and TigerVNC's Xvnc from base's
package snapshot, and devvm-desktop, which starts Xvnc on display :1 on a
socket of the VM user's own (/run/devvm-desktop/vnc.sock, 0600 in a 0700
folder), with no TCP port (-rfbport -1, -nolisten tcp) and no password of
its own, the clipboard on or off as asked (vncconfig on a running one),
then an Xfce session in a D-Bus session of its own. Nothing starts it at
boot: devvm desktop does, on every backend.

devvm desktop gets the VM ready as devvm ssh does, refuses a VM without
the feature (desktop_no_feature), starts its desktop (desktop_start_failed),
and serves it on 127.0.0.1 alone until Ctrl+C or the VM stops
(desktop_vm_stopped), on the VM's own port (desktop_port, among
netpolicy.UsedPorts, so no forwarder or new VM takes it), showing the
address and password (desktop_ready) and opening vnc://127.0.0.1:PORT in
Screen Sharing on macOS (--no-open; desktop_open_failed). --clipboard
shares the clipboard both ways for that run.

internal/desktop's Relay is the guarantee, not the VM's server: it speaks
RFB 3.3/3.7/3.8 as a server, offers VNC authentication alone, checks the
answer against the VM's password (8 characters of 31, about 40 bits,
crypto/rand, kept in the VM's state as desktop_password, never sent to the
VM) one check at a time with a second's wait after a wrong one, and only
then opens an ssh -W channel to the VM's socket through devvm's ssh config
(pinned host key, no session, agent or forwarding), closed by its input
first so the VM's sshd ends its side. Without --clipboard it drops every
ClientCutText (extended ones too) and ends a connection on a message type
it can't size. At most 8 connections.

Also: vm.Desktop (Open, serve, listener, dial), vm.ready (devvm ssh's
launch without the Include prompt), Env.OpenURL; build's chosen features
leave desktop out until it's chosen; messages desktop_failed,
desktop_no_feature, desktop_start_failed, desktop_ready,
desktop_open_failed, desktop_vm_stopped, with doc links.

Tests: internal/desktop (passwords, Response, wrong passwords refused with
no dial, 3.3/3.7/3.8, not a viewer, the clipboard dropped or carried, an
unknown message ending the connection, a VM server asking for a password),
internal/vm (the password kept and remade, the listener's port kept and
replaced, ssh's arguments), internal/build (desktop off until chosen),
testdata/script/desktop.txtar (no VM, no feature, a stopped VM started,
the forward asked for with the clipboard off and on, the same port and
password, Screen Sharing opened or failing, the VM stopping, the start
failing), setup.txtar, docgen; tests/e2e.sh's desktop section (Lima, with
network policy) and checks in the smolvm and Docker sections;
TestE2EDesktop.

Docs: using/desktop.md (new), customizing.md's features, commands.md,
internals/desktop.md (new), design.md's note on the desktop,
contributing/testing.md's manual Screen Sharing check, the CLI reference.

Review (security-audit skill, guidance mode, local IPC and loopback
listener classes), against the review's list:
- another local user or process reaching the port: 127.0.0.1 alone,
  without address reuse; VNC authentication checked on the host before any
  ssh, constant-time, about 1 guess a second globally (thousands of
  years); the password in the VM's state (0600 file, 0700 folder), shown
  only on stdout with the address, never in open's arguments or the run
  log (e2e: no run log, no host process's arguments);
- never in an image or the VM: the VM's server has no password; e2e greps
  the VM's files for it (found the first time only in the VM's journal,
  from the check's own sudo command line, now fed on its input);
- the server on no address but loopback on each backend, even if root
  changes it: Xvnc has no TCP listener (e2e on each backend), the relay
  is the only way in and lives on the host; root's own server without a
  password (e2e, Lima) still gets no viewer without devvm's password;
- clipboard off really off: the relay drops the viewer's clipboard
  whatever the server accepts (e2e: root's server records a key event but
  never the clipboard); the VM's clipboard to the viewer can't be filtered
  without decoding screen updates, documented, Screen Sharing's setting;
- nothing from the VM toward the host: a local ssh -W channel, which ssh's
  client asks for; the VM reaches neither the relay's port nor anything
  new (e2e: with network policy, no direct connection out, nor to the
  port); a VM that reaches host loopback (no policy, Docker Desktop) meets
  the password like anyone;
- network policy unchanged: no policy file or allowlist changes; the
  self-check passes with the desktop running (e2e).
Left as documented residuals: the VM's clipboard sent by a changed
server; a local process or VM keeping the relay's 8 slots busy or failing
checks (availability only).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:49:23 -07:00
w3cjandClaude Opus 5.5 37d843c285 fix(test): the CLI tests fake the host's CPUs, memory and free space
The CLI tests read the real host's CPUs, memory and free disk, so they
failed on GitHub's small ubuntu-latest runner (2 vCPUs, 7 GiB, ~10.8 GiB
free) and passed on larger machines.

internal/platform: Host (CPUs, Memory, FreeSpace) is the only way to read
them; the raw reads are unexported (memory, freeSpace). NewHost(test,
getenv) gives a test build's Host, which reads DEVVM_TEST_CPUS,
DEVVM_TEST_MEMORY_GIB and DEVVM_TEST_FREE_GIB (platform.TestCPUs,
TestMemoryGiB, TestFreeGiB) in place of the host's; an unset one leaves
the host's, a bad GiB value is an error. The zero Host reads the host.

The gate is registry.unreviewed, the same -ldflags -X variable as
DEVVM_UNREVIEWED: registry.Host() and newFor pass build == "allowed" into
NewHost, so platform has no package var. backend.Registry gets a Host
field; lima.New, smolvm.New and tools.New take a platform.Host;
vm.ThisHost takes one; vm.NewEnv, doctor, setup, build and
_refresh-tools read the registry's (or registry.Host()). Docker reads
only its engine's NCPU and MemTotal and checks no host free space, so it
has no host reads to route.

forbidigo bans runtime.NumCPU, unix/syscall Statfs, Fstatfs, Sysinfo and
unix.SysctlUint64 outside internal/platform.

script_test.go sets a large host in every script (8 CPUs, 16 GiB, 500
GiB free). small_host.txtar sets 2 CPUs, 7 GiB and 1 GiB free and checks
doctor's disk_low_warning, host_memory_low and host_cpus_few, disk_low on
a build, base_fitted with Lima's --cpus=2 --memory=3.5 and smolvm's --cpus
2 --mem 3584, too_many_cpus have=2 and too_much_memory have=7 max=5. The
host-relative regexes in build, from, setup, size, up_size and smolvm
are now the fake host's exact values.

Docs: contributing/testing.md's "A host of any size" (the overrides, that
only test builds read them, the large host script_test.go sets, how a
script asks for a small one, what stays the Linux CI job's), and the
sandbox table in contributing/_index.md.

Review: GoReleaser's ldflags (both builds) and the Homebrew formula set
only cli.version, linuxURL and linuxSHA256, never registry.unreviewed, so
release binaries ignore the overrides (TestReleaseHostIgnoresOverrides;
a release build checked by hand ignored DEVVM_TEST_CPUS=1,
DEVVM_TEST_MEMORY_GIB=1 and DEVVM_TEST_FREE_GIB=0.5 in doctor and size
while the test build honoured them). No caller outside internal/platform
reads runtime.NumCPU, memory or statfs (grep, and the forbidigo rule
checked against a probe file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:22:01 -07:00
w3cjandClaude Opus 5.5 f196357f43 feat(netpolicy): the proxy rotates a VM's network logs past 10 MiB, one old file each
A VM's <vm>.jsonl and <vm>.proxy.log grew without limit. The proxy, their
only writer, now rotates each before a line would take it past 10 MiB
(logLimit), keeping one old file:

- the event log (-log) is the proxy's alone: renamed to <log>.1 (the
  previous .1 dropped) and a new one opened, 600;
- the proxy's own log is also the process's stdout/stderr, which netpolicy
  opens, where Main's last error and a crash go. A new -proxy-log flag
  names that file: the proxy's logger writes through a rotating writer
  that copies it to <log>.1 (written whole, 600) and truncates it, so the
  O_APPEND writes that bypass the rotation still reach the current file.
  The HTTP servers' and the reverse proxy's ErrorLog is the proxy's
  logger, so their lines go through the rotation instead of straight to
  stderr. Stdlib only.

Writes are serialized and each is a whole line, rotated before the write,
so no line is lost, split or duplicated. A log deleted while the proxy
runs starts again at the limit. The start check (logged) finds the
listening line across a rotation (the rest of <log>.1 and the new log).
devvm log reads <vm>.jsonl.1 before <vm>.jsonl (opened after the log, and
skipped when it's the same file, so a rotation while opening reads
nothing twice); --blocked counts both; -f reads a renamed log to its end,
checked before the drain so no late line is missed, then follows the new
one from its start; a just-rotated empty log with a .1 isn't log_empty.

Review (log rotation): lost or duplicated lines across a rotation (none:
mutex, rotation before the whole-line write; TestRotateConcurrent: 16
writers, every line once across both files); a VM writing faster than
rotation (rotation is inline in Write, so it can't fall behind; a
follower misses a file only if two rotations, 20 MiB, happen within one
250 ms tick); devvm log -f across a rotation (TestWriteLogFollowRotated);
modes 600 after a rotation, a log left 644 tightened at open
(TestRotateRenames, TestRotateCopies); rm deleting every rotated file
(existing.txtar: .jsonl.1 and .proxy.log.1 gone). Copy rotation can lose
only a write that bypasses the logger between the copy and the truncate:
a runtime crash's output.

Tests: proxy unit tests (rotation at the limit, one old file, a long line,
a deleted log, concurrent writes, the copying rotation), netpolicy reader
across a rotation and following one, logged across a rotation, log.txtar
(rotated history and blocks, a just-rotated log), existing.txtar (rm).
Docs: internals/network.md's Log files and -log/-proxy-log flags,
safety/network.md's Logs, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:16:48 -07:00
w3cjandClaude Opus 5.5 080d57dd28 fix(netpolicy): builds reach a company proxy through a proxy of their own; ** refuses names the host can't resolve
From an independent review of the company-proxy change.

1. Builds never get the company proxy's credentials. Each build behind
   a company proxy goes through a devvm _proxy of its own on the host
   (backend.ProxyStarter / BuildProxy, shared by Lima and Docker; Docker
   Desktop's build proxy moved into it): policy **, a new random password,
   the company proxy in its -upstream file, -lifeline on the build VM's
   hostagent or the container's docker container wait. Builds get only
   http://devvm:<one-time>@<host>:<port> (each variable the host sets) and
   the host's NO_PROXY.
   - Lima: image builds, the tools build and --from's conversion VM reach
     it at 192.168.5.2; on macOS the build's Seatbelt profile allows that
     one loopback port (NetInternet + ProxyPort), so a loopback company
     proxy works for macOS builds too. guestProxyURL is gone. limactl runs
     without the host's proxy variables (Lima logged them, password and
     all, into devvm's run log; found by the new e2e check); only a
     NetDirect start gets them back for propagateProxyEnv.
   - assets/oci/build.sh: the /etc/os-release probe runs under env -i;
     chroot_run passes only the build proxy's variables (bootify.sh's
     downloads behind a company proxy).
   - Docker: buildNet takes Desktop's path (own network, relay, build
     proxy) on any engine behind a company proxy; hostProxyEnv is gone.
     A Linux engine's build behind one needs devvm's Linux build.
   - Settings the proxy can't go through are refused before anything is
     made (upstream_proxy_scheme, reworded for builds too).
2. noClientProxy on the tools' unpack container and the relay.
3. floorUpstream: a name the host can't resolve goes upstream only when
   an allow rule names it (itself or *.domain: policy.byName); with only
   ** it's refused (errUnresolved, logged as the reason).
4. CONNECT replies are read through a 64 KiB io.LimitReader
   (maxConnectReply); bytes after the answer stay the tunnel's.

Tests: backend (TestProxyStarter, TestProxyStarterFails,
TestListeningPort, TestBuildProxyStop), lima (TestBuildImageHostProxy on
linux and darwin with the Seatbelt port, TestBuildImageHostProxyRefused,
TestConfineProxyEnv), docker (TestBuildHostProxy for a Linux engine with
and without a company proxy, unpack's empty proxy pairs), proxy
(TestUpstreamUnresolved, TestUpstreamConnectReplyLimit). CLI: docker.txtar
(a Linux engine's build behind a company proxy; every container create
and run, kept by the stub in containers-made, sets the empty -e pairs),
from.txtar (builds' proxy folders gone). e2e: images (a build sees only
its own proxy), from (a --from alpine:3.21 base with every feature and a
layer behind a company proxy with a password: the registry, Alpine's
mirror and the layer reach it through the builds' proxies; the password
is in no converted disk, image, log, build file or process's arguments);
corp_start/corp_stop shared with network.

Docs: internals/design (A company proxy: the ** case, builds, checks;
build confinement), safety/network, internals/network, images, lima,
docker, using/troubleshooting, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 09:53:45 -07:00
w3cjandClaude Opus 5.5 2f559eaaa5 feat(netpolicy): network policy behind a company proxy; host proxy credentials kept out of images
Behind a company proxy, network policy's proxy connected to servers itself
and reached nothing. It now reaches allowed hosts through the host's
HTTPS_PROXY / HTTP_PROXY, still deciding each request by the name the VM
asked for.

Step 1, credentials (traced in the code and the backends' published docs;
not yet proven on a real build, which the new e2e checks do):
- Lima: build VMs (images, the tools build, --from's conversion VM) started
  with propagateProxyEnv on, its default. Lima's 07-etc-environment.sh
  writes the propagated settings into the guest's /etc/environment between
  #LIMA-START/#LIMA-END on each boot, and a stopped build VM's disk keeps
  it, so an image built with HTTPS_PROXY=http://user:pass@... kept the
  password. Fixed: propagateProxyEnv is on only for NetDirect; build scripts
  get the variables exported on their input (a loopback proxy as
  host.lima.internal), and /etc/sudoers.d/devvm-build-proxy keeps them for
  sudo until the scripts end.
- Docker: the CLI puts ~/.docker/config.json's proxies into every container
  it creates, and a commit keeps them (Docker's docs). Fixed: every
  container devvm makes sets each proxy variable empty (noClientProxy); a
  Linux engine's build gets the host's settings from an env file
  (hostProxyEnv); Desktop's build proxy goes through the company proxy.
- smolvm: passes the host's proxy only with --use-host-proxy, which devvm
  doesn't use: nothing to fix.

The upstream:
- backend.HostProxy (new): ReadHostProxy (capitals, then lowercase), None,
  Upstream (the proxy's -upstream file; only http:// proxies:
  upstream_proxy_scheme, upstream_proxy_invalid), Env.
- internal/proxy/upstream.go (new): -upstream FILE; ParseUpstream,
  ErrUpstreamScheme; NO_PROXY as Go reads it; localhost, *.localhost and
  loopback/unspecified addresses always direct; CONNECT by name with
  Proxy-Authorization: Basic for tunnels and for the TLS connections that
  put secrets in (checked against the system roots and -upstream-cas);
  plain HTTP in absolute form, canonical host, credentials only in the
  header to the upstream; floorUpstream: addresses judged as before, a name
  refused when the host's resolver answers with any internal or denied
  address, unjudged when it can't resolve; Event.Upstream (host:port), and
  devvm log's "through host:port".
- hostOK refuses shorthand addresses (127.1, 2130706433, 0x7f000001),
  which a company proxy may read as inet_aton does (found in review).
- netpolicy: Proxy.Getenv, run/<vm>.proxy.upstream (mode 600), stale()
  (a changed upstream starts the proxy again), writeUpstream for both files.

Also, from a review of the company-CA change: a proxy that needed starting
again and didn't end within 2 s of SIGTERM was kept, with its old roots,
silently. Stop now sends SIGKILL after 2 s and reports whether it ended;
Prepare fails with proxy_stop_failed instead of keeping it (Proxy.Signal
seam).

Messages: proxy_stop_failed, upstream_proxy_scheme, upstream_proxy_invalid,
with doc links.

Tests: proxy (TestParseUpstream, TestNoProxy, TestUpstreamTunnel,
TestUpstreamNoProxyDirect, TestUpstreamPlainHTTP, TestUpstreamIntercept,
shorthand hosts in TestOddHostsRefused), backend (TestHostProxy), lima
(TestBuildImageHostProxy, TestGuestProxyURL, propagateProxyEnv
expectations), docker (TestBuildHostProxy, create's empty proxy variables),
netpolicy (TestPrepareUpstream, TestPrepareStopsTheOldProxy, FormatEvent's
upstream). e2e: images (a layer built with a fake proxy password: its
script and sudo see it; the image's disk, Lima's files and devvm's logs
don't), network (a devvm _proxy as the company proxy: allowed hosts through
it by name, blocked ones never reach it, its password nowhere, and back to
direct).

Docs: safety/network (Behind a company proxy, Without network policy),
using/troubleshooting (Behind a company proxy), internals/network (Through
a company proxy, restarts, -upstream), internals/design (A company proxy:
what an upstream changes, credentials, builds, checks), internals/images,
internal/proxy/README.md.

Review (security-audit skill, independent pass over the proxy change):
the shorthand-address bypass, fixed; a VM-controlled name can force the
unjudged branch, documented; refusals name the company proxy's address
(no credentials), accepted as on the direct path; a loopback company proxy
isn't reachable from macOS builds, documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 00:20:33 -07:00
w3cjandClaude Opus 5.5 1812867162 fix(vm): a subfolder's lookup stops at the nearest parent with state; widening a parent's VM asks
The parent-folder lookup passed over a parent whose VM was made for an
earlier folder or that its backend had lost, and went on to a VM further
out. A VM can rename a nested project folder through its mount (a new
device and inode), so devvm skipped the nested folder's VM and acted on
the outer one, the VM that replaced it. parentVM now stops at the first
parent folder with state of its own: its VM is used only when its backend
has it and it was made for that folder, else the folder devvm runs in has
no VM (no_vm; devvm makes a new one). Only folders without state are
passed over.

Commands that give a parent folder's VM more access, run from a
subfolder, ask first ([y/N]), naming the VM and its folder, and refuse
without a terminal: devvm secret use, ssh-agent on and devvm, network
off, policy allow, policy rm of a deny, and git-protect off (found.widen).

Messages: widen_parent_vm (the prompt), widen_parent_vm_refused (linked
to getting-started/commands#a-subfolder).

Tests: TestLookupParents (a parent's lost VM and another folder's VM stop
the search: no VM, no_vm), TestWidenParentVM (each command refused
without a terminal, a no changing nothing, a yes changing it; taking
access away asks nothing), subfolder.txtar (the refusals without a
terminal).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:51:07 -07:00
w3cjandClaude Opus 5.5 c9436eca97 fix(tools): bound the unmounted-tools read, drop a stale report first
After a failed setup, devvm reads /run/devvm/tools-unmounted from the VM
with a command of its own. Root in the VM could make that read hang, so
it now has its own 10 s timeout (unmountedWait, readUnmounted), after
which no tool counts and the error is sync_failed.

guest/sync.sh removes that report as its first command, so a report left
from the VM's boot isn't read after a failure that comes before
devvm-tools runs.

Tests: TestReadUnmountedWait (a read in time counts; a hung one gives up
after its wait); guest.txtar checks sync.sh's first command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:50:26 -07:00
w3cjandClaude Opus 5.5 c65ab1f507 fix(install): find Homebrew's devvm without running brew
check_brew ran brew list --formula devvm on every install, and Homebrew's
wrapper can download its own Ruby when it runs. The script now looks for
a devvm keg (Cellar/devvm/<version>) in the Cellar next to the brew on
PATH, in HOMEBREW_CELLAR and HOMEBREW_PREFIX/Cellar, and in
/opt/homebrew, /usr/local and /home/linuxbrew/.linuxbrew (brew_prefixes,
which the tests set). --force and the refusal stay as they were.

path_hint resolves paths with readlink -f --, so a PATH entry starting
with a dash isn't read as an option.

Tests: install.txtar's brew stub only logs; a Cellar folder fixture
stands for the keg (next to brew, HOMEBREW_CELLAR, HOMEBREW_PREFIX, a
usual prefix, an empty rack, no brew on PATH), and brew is never run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:50:17 -07:00
w3cjandClaude Opus 5.5 7f9f1316ec feat(doctor): warn on small hosts; builds say when base's size was fitted
devvm doctor warns when this machine has less than 8 GiB of memory or
fewer than 4 CPUs, the host devvm recommends. The warnings go to stderr
in doctor's normal output only: doctor's exit status and --fixes are
unchanged. Its checks move into a doctor type with field seams (Path,
Free, Host) and a run method returning the last problem, which the
command dies with as before. Long also names the warning about another
devvm first on PATH.

When fitting base to the host gives it fewer CPUs or less memory than
base.yaml's, the backend returns that size in backend.Built's Fitted
(backend.Fitted), and the build says so once (base_fitted) before
image ready. Lima's buildSize returns base.yaml's size and the fitted
one; smolvm's and Docker's base.yaml reading becomes baseYAML(fs.FS),
with fitted(fs.FS, cpus, mem), as functions to keep their types' method
counts.

install.sh runs devvm doctor when nothing is missing too, so a new user
sees its warnings.

- messages: host_memory_low, host_cpus_few (doc link
  getting-started/install#requirements), base_fitted
  (using/ports-size#size-and-ports)
- docs: install's Requirements (a recommended-host row in both tables,
  what devvm does on less) and Checking what devvm needs; internals'
  install (doctor after the fixes, warnings have no --fixes keys);
  ports-size's size paragraph; the doctor CLI page
- tests: TestSmallHost, TestDoctorSmallHostWarnsOnly, TestFitted,
  TestBuildSaysFitted; Lima's TestBuildImageSmallHost, smolvm's
  TestSmallHost and Docker's TestBaseSize check Fitted; install.txtar
  checks doctor runs when nothing is missing
- smolvm.txtar: the ports check matches only forwards of 22 and 3000,
  not a random ssh port starting with 22

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:44:35 -07:00
w3cjandClaude Opus 5.5 28e289c190 feat(setup): ask for new VMs' CPUs and memory at first run and in devvm setup
The first run, in a terminal, before base's features are first chosen,
asks for the CPUs and memory new VMs get, when no default size is saved
and neither --cpus nor --memory is given; devvm setup asks after the
backend and features, and --cpus/--memory choose without asking (with
only them, the backend and features stay). Each question starts from the
saved size, else base.yaml's fitted to this machine (FitCPUs/FitMemory);
Enter keeps it, a value Size.Check refuses is warned and asked again.
Only typed values are saved, in the size file devvm size -g writes
(a saved disk kept); keeping both writes nothing. Without a terminal
nothing is asked.

- internal/vm/sizechoice.go: SizeChoice (Ask, Set, Fitted), writeDefaultSize,
  creation.firstRunSize; SetSize -g uses SizeChoice.Set
- internal/vm/size.go: baseSetting (BaseDisk on it), readDefaultSize
- internal/vm/env.go: Env.Answer and Env.Interactive (stdin and stdout
  terminals); vm.UI gains Answer and StdoutIsTerminal
- internal/vm/up.go: plan asks before reading the default size
- internal/ui: UI.Answer, a line prompt; largeTypes allows UI 41 methods
- internal/cli/setup.go: setupChoice, --cpus/--memory, saveBackend,
  saveFeatures; Short/Long updated
- messages: size_question, size_cpus_prompt, size_memory_prompt
  (refusals reuse too_many_cpus, too_much_memory, cpus_not_number;
  size_defaults after saving)
- tests: TestSizeChoiceAsk, TestSizeChoiceSet, TestFirstRunSize, setup's
  size prompts; setup.txtar (--cpus/--memory, refusals, no terminal),
  up_size.txtar (first run without a terminal)
- docs: first-vm (paragraph, diagram), ports-size (Choosing new VMs'
  size), customizing, backends, settings; CLI reference regenerated

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 23:44:33 -07:00
w3cjandClaude Opus 5.5 23c8dedaba feat(vm): devvm in a subfolder uses the parent folder's VM
A folder with no VM and no state of its own uses the VM of the nearest
folder it's inside that has one. The lookup stops before the home folder
(by its physical path) and the root, and skips a parent whose VM was made
for an earlier folder at its path (sameFolder).

- devvm (up): in a terminal it asks whether to open the parent's VM in
  the subfolder ([Y/n]; no makes a new VM). Without a terminal it opens it,
  with an info line. --here and --clone make the subfolder's own VM
  without asking. An IMAGE adds to the parent's VM in place after the
  same question.
- stop, restart, update, remove, export, log, network, policy, secret,
  ssh-agent, git-protect, size, ports, ssh and code use the parent's VM,
  naming it and its folder first. rm never deletes it unasked: in a
  terminal it asks ([y/N]) even with -f, which still skips only its
  checks; without one it refuses, saying to run it in the parent's
  folder. adopt acts only on this path's VM.
- A repo of its own below the parent's folder (a .git folder or file in
  the subfolder or a folder between): up asks use_parent_vm_repo [y/N],
  the default a new VM, and makes one without a terminal; the other
  commands never reach up and say no_vm.
- The shell, devvm ssh's folder and devvm code open the subfolder; in a
  --clone VM, the subfolder when the clone has it, else the clone's top.
- project.Parents; Env.lookup and Env.inspect (find split); found.sub,
  found.shellDir; useParent; Options.Here and the --here flag.
- Messages: use_parent_vm (dir, parent, vm), using_parent_vm (dir, vm),
  delete_parent_vm (dir, vm), rm_parent_vm (dir, vm), use_parent_vm_repo
  (dir, parent, repo, vm); all but the delete_parent_vm prompt linked to getting-started/commands#a-subfolder.
- Tests: TestParents; TestLookupParents, TestUpInSubfolder, TestShellDir,
  TestCommandsInSubfolder, TestSubfolderRepo; testdata/script/subfolder.txtar; up_checks'
  "My App" folder is made at $WORK, where the script meant it. e2e: the
  project section opens the VM from a subfolder (pwd in the VM).
- Docs: first-vm (coming back to it), commands (--here, A subfolder),
  using/clone (Subfolders), internals/overview (A subfolder's VM),
  internals/security; the CLI reference for devvm and devvm rm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:57:42 -07:00
w3cjandClaude Opus 5.5 906d598954 feat(trust): VMs, builds and the proxy trust a company's CAs from ~/.config/devvm/ca
Behind a proxy that inspects TLS, VMs and build VMs couldn't make TLS
connections. The CA certificates in ~/.config/devvm/ca (*.pem, *.crt) are
now read at each launch, build and proxy start, checked, and trusted;
images never keep them.

- internal/trust (new): Read parses every PEM block with crypto/x509 and
  refuses anything but CA certificates (ca_not_certificate, ca_not_ca,
  ca_invalid, naming the file); only the re-encoded certificates leave the
  host. Env/GuestEnv (NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem,
  SSL_CERT_FILE, REQUESTS_CA_BUNDLE, PIP_CERT, UV_SYSTEM_CERTS), Build
  (a build's Add/Remove root scripts from guest/ca.sh), Script (Env
  exported at a build script's start), Name, Bundle.
- assets/guest/ca.sh (new): installs exactly DIR's devvm-*.crt into
  /usr/local/share/ca-certificates (update-ca-certificates --fresh), or
  into the bundle file itself when there's no update-ca-certificates (the
  old bundle kept and put back), writes /etc/ssl/devvm.pem; without DIR,
  removes all of devvm's. sync.sh runs it with the proxy's CA
  (ca/devvm-proxy.crt) and the user's (ca/devvm-extra-N.crt).
- backend: ImageSpec.Trust and ToolsSpec.Trust (backend.Trust{Add,
  Remove}); VMSpec.Env. Lima runs Add after the start and Remove after the
  scripts (runScript's root mode, sudo sh), the --from conversion VM runs
  Add and oci/build.sh runs ca.sh in the image's chroot around bootify.sh
  (guest/ mounted read-only, CA_SH argument); smolvm and Docker run Add
  before prepare.sh and Remove after sshd.sh; tools builds run Add only.
  Lima's clone sets the guest environment, so starts edit nothing.
- vm: every project VM starts with trust.Env (netpolicy.Env keeps only the
  proxy's variables); the setup sends ca.sh and ca/; Dirs.TrustedCAs.
- proxy: -upstream-cas FILE adds CAs to the system roots for its own TLS
  connections; netpolicy writes run/<vm>.proxy.cas and restarts a proxy
  whose bundle changed.
- doctor: doctor_proxy_ca when HTTPS_PROXY is set and the folder has no
  CAs (Say), a refused folder warned about.
- Tests: internal/trust unit tests (folder reading, scripts, ca.sh run in a
  stand-in root with and without update-ca-certificates); ca.txtar; sync,
  up, network, smolvm txtars and the limactl stub (clone's .env, list
  shows lima.yaml's env); e2e: images (a layer built with a test CA, its
  key unchanged, its image's copy without CA files), project ("a company's
  CA" section), tools (node fetch), smolvm and docker build checks.
- Docs: using/settings (a company's CA), using/troubleshooting (TLS errors
  behind a company proxy), internals/network and internals/images,
  safety/network, design (assets written out), oci README, doctor's help.
- Structure: Dirs at 38 methods, trust.Env a table, trust above backends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:54:01 -07:00
w3cjandClaude Opus 5.5 b33b0a9b4c fix(tools): a shared tool that doesn't mount fails the launch
A tool image missing from the share, or one the VM couldn't mount or
link, used to be skipped with a line on stderr, and mise's auto_install
then downloaded the same version into the VM on first use. Now the
launch stops with a message naming the VM and the tools.

- assets/guest/tools.sh: tries every listed image, removes a failed
  one's empty mount point, says why on stderr, lists the failed files
  in /run/devvm/tools-unmounted (removed at the start of each run) and
  exits 1. Link failures (Docker's unpacked folders) count too.
- assets/guest/sync.sh: its devvm-tools call failing fails the setup.
- assets/container/services.sh: a devvm-tools failure doesn't stop a
  smolvm or Docker start; the launch's setup reports it.
- internal/vm/sync.go: after a failed setup, syncer.unmounted reads the
  VM's report with its own Exec (capped at 16 KiB, unmountedMax), and
  reported keeps only whole lines that are one of the VM's own tool
  files from its state, so the message carries devvm's values, never
  the VM's text. The setup's output still goes straight to the run log
  (a pipe would wait on processes the setup leaves running).
- internal/tools: label is exported as Label; VMs.Update builds the
  VM's tool images that the share lacks even when they're the newest,
  so devvm update repairs a missing image.
- Message tools_unmounted (tools, vm), linked to
  using/troubleshooting#a-shared-tool-doesnt-mount.
- Docs: troubleshooting "A shared tool doesn't mount"; images.md's
  shared tools and devvm update; internals/images.md "The share" has
  the mechanism; design.md says why.
- Tests: TestReported (internal/vm), TestUpdate rebuilds a missing
  newest image, guest.txtar runs tools.sh with stubbed mount commands,
  sync.txtar checks tools_unmounted and that other report lines don't
  count (limactl stub: $STUB_DIR/sync-fails-with), e2e's tools section
  moves node's image out of the share and back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:54:05 -07:00
w3cjandClaude Opus 5.5 6a168ed23a fix(size): the size check keeps memory for the host, as base's fitting does
Size.Check refused only memory above the host's total, so --memory 8 on
an 8 GiB host passed, though a VM asking for all of the host's memory
doesn't start. It now refuses more than backend.MaxMemory allows, the
limit of the rule base's memory is fitted by: the host's whole GiB less
2, or half of them on a host of 4 GiB or less. Whatever FitMemory gives
always passes. CPUs stay limited to the host's count.

Check runs for a new VM, devvm size and devvm size -g only: a VM whose
recorded size is over the limit still starts.

Changes:
- internal/backend/fit.go: MaxMemory(hostBytes uint64) float64 beside
  FitMemory, with TestMaxMemory (which also checks FitMemory never
  exceeds it).
- internal/vm/size.go: Check uses MaxMemory (Host.memoryBytes converts
  the whole GiB); too_much_memory gets max, the largest --memory that
  works (fields have, max, want).
- locales/en.toml, messages_gen.go: too_much_memory's text and
  description.
- Tests: TestSizeCheck's cases updated (32 GiB host: max 30), and new
  ones: 8 GiB refuses 8 and 7, allows 6; 4 GiB allows 2, refuses 3;
  3 GiB allows 1.5. up_size.txtar expects max.
- Docs: using/ports-size.md says the most memory a VM can have, for
  new VMs, devvm size and devvm size -g, what devvm says when it's too
  much, and that VMs already over it still start; internals/images.md's
  Base's size section says the check shares the rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 18:40:19 -07:00
w3cjandClaude Opus 5.5 d55dae5386 fix(build): fit base's CPUs to the host, as its memory is
Base asked for base.yaml's 4 CPUs whatever the host had. It now gets
base.yaml's CPUs, or the host's count when the host has fewer, by the
same shared rule as its memory.

What happens above the host's count (from published docs, not checked
on a VM):
- Lima accepts cpus above the host's count: its template's default is
  min(4, host CPU cores), and its proposed check that refused more than
  runtime.NumCPU() (lima-vm/lima#2309) was closed unmerged. On vz, a
  VM given more CPUs than the Mac has can start so slowly that ssh never
  comes up (lima-vm/lima#1621, open).
- Apple's Virtualization framework only requires cpuCount <=
  VZVirtualMachineConfiguration.maximumAllowedCPUCount, whose docs don't
  tie it to the host's count.
- smolvm and libkrun document no limit for --cpus.
- Docker refuses --cpus above its engine's machine's count ("Range of
  CPUs is from 0.01 to N.00, as there are only N CPUs available").

Changes:
- internal/backend/fit.go: FitCPUs(want, hostCPUs int) int and
  FitMemory(wantGiB float64, hostBytes uint64) float64, pure and
  exported; fitMemory's rule moved there from Lima, with table tests.
- Lima: buildSize replaces buildMemory and reads base.yaml's cpus and
  memory; limactl create gets --cpus and --memory for base and the
  --from conversion VM (createArgs). A CPUs field (runtime.NumCPU) is
  the host-CPU seam beside Memory.
- smolvm: baseSize fits CPUs and memory with the shared rules, for
  base's build, tool builds and VMs given no size; a CPUs field is the
  seam. spec.Size.CPUs still wins.
- Docker: the engine's NCPU is read from docker info beside MemTotal
  (engineSize replaces engineMemory), and baseSize fits both.
- Image keys are unchanged: neither the fitted memory nor CPUs are in
  them.
- Tests: TestFitCPUs, TestFitMemory, Lima's TestBuildImageSmallHost and
  "no CPUs" case, smolvm's TestSmallHost, Docker's TestBaseSize; the
  build and from testscripts expect --cpus.
- Docs: using/ports-size.md and using/images.md say what a small
  machine gets; internals/images.md has a Base's size section on the
  mechanism; internals/smolvm.md and internals/docker.md match it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:55:30 -07:00
w3cjandClaude Opus 5.5 effcdfece0 feat(install): install.sh and doctor catch a second devvm
Installing with both Homebrew and the install script left two devvms, and
the one first on PATH ran without a word while brew upgrade might update
the other.

- install.sh: before downloading, check_brew stops (exit 1, in a terminal
  or not) when brew is on PATH and brew list --formula devvm succeeds;
  brew runs with stdin from /dev/null and its output discarded, only its
  exit status read. --force (in the usage, the header and the parser)
  installs anyway.
- install.sh: path_hint, after installing, warns when ~/.local/bin is on
  PATH but command -v devvm resolves (readlink -f) to another copy, naming
  it and what to do; it only looks the path up, never runs it. When
  ~/.local/bin isn't on PATH it prints only the existing hint.
- devvm doctor: warns (u.Warn, not a backend.Problem) when the devvm first
  on PATH isn't this binary, both resolved with filepath.EvalSymlinks;
  skipped when devvm isn't on PATH, and never with --fixes; exit status
  unchanged. Seams: onPath's LookPath and Executable fields.
- Message devvm_other_first (first, self), linked to
  getting-started/install#one-devvm.
- Tests: TestOnPathOther (this copy by either link, another copy, none on
  PATH, a broken link); install.txtar: a stub brew reporting devvm makes
  the script refuse before downloading, --force goes on, another devvm
  earlier on PATH gets the warning and isn't run, a link to the installed
  copy gets none; the stub brew answers list from $BREW_DEVVM.
- Docs: Installing's One devvm section (one way, the refusal, --force,
  switching through Uninstalling's step 4, the PATH warnings), --force in
  the options, doctor's warning; Installing and updating: the Homebrew
  check, the PATH check and doctor's check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:54:04 -07:00
w3cjandClaude Opus 5.5 bd124472e9 refactor(msg): warnings and errors don't repeat devvm after its prefix
Warn, Die and DieLogged print "devvm: " before a message, so the 73
warnings and errors whose text started with devvm read "devvm: devvm
couldn't ...". They now lead with what failed or what they're about,
with the same fields. The 20 that only Info, Note or a prompt print keep
their text. The docs-voice skill gets the rule and a tropes example, and
qemu.txtar matches qemu_refused's new wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 11:04:31 -07:00
w3cjandClaude Opus 5.5 d3948f0933 test: CLI scripts expect the docs-voice wording of usage errors and qemu_refused
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 10:33:53 -07:00
w3cjandClaude Opus 5.5 ee06f051ff refactor(msg): remaining messages in the docs voice
Rewrites the messages outside the prompt, network policy, secrets, project folder, .git, --clone, backend, host, image, build and shared tool groups (agent_, ssh_, ports_, size_, disk_, vm_, no_, devcontainer_ and the rest) as full sentences: what happened first, then one action as a command, without chained colons and semicolons. Status steps and short ==> result lines stay as they are, and every template keeps its fields.

Adds doc links for the actionable warnings and errors that had none: no_devcontainer_flag_ignored, no_ssh_agent, ssh_agent_empty, load_key_with, no_vm_ssh_agent, agent_key_not_found, agent_load_failed, agent_start_failed, mounts_next_start, no_feature, no_image_named, no_image_named_from, not_an_image, no_vm, no_vm_size, no_vm_ports, no_vm_git_protect, no_vm_policy, no_token, bad_secret_service, start_failed, stop_failed, delete_failed, vm_create_failed, sync_failed and pack_failed.

msg_unknown's wording is checked by TestValuesAsGiven and msg.txtar, which follow it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 10:26:23 -07:00
w3cjandClaude Opus 5.5 9cf45cc5e0 feat(net): network policy on by default; a warning where a VM can't have it
A new VM gets network policy unless it's turned off. In a terminal devvm
shows the tradeoff and asks yes by default ([Y/n]); without a terminal
it's on. A VM that can't have network policy gets no question, only a
warning, and is made without it: on a backend without egress-proxy (or
with it unreviewed), and a Docker VM made for the docker layer, whether
named or from a devcontainer.json's docker-in-docker. An explicit
--network-policy on such a VM is still refused (net_docker_layer, or
backend_lacks from Require). Existing VMs keep their state's choice.

- netpolicy.Proxy.Choose: no terminal gives on; in a terminal net_about,
  then Confirm (yes by default). Proxy's Ask field and netpolicy.UI's Ask
  removed (unused); vm.UI asks Ask itself.
- vm.creation.chooseNet: --no-network-policy first; the docker layer
  warns (net_off_docker_layer) or refuses --network-policy; a backend
  Registry.Allowed doesn't let egress-proxy through warns
  (net_off_backend); otherwise Choose.
- Messages: new net_off_docker_layer, net_off_backend (with doc links);
  net_about rewritten as the two-line tradeoff with a doc link
  (safety/network#turning-it-on-or-off); net_ask is "Turn it on?" (no
  fields); devcontainer_docker_net removed (no caller).
- --network-policy's help: secrets, default on, asked in a terminal; CLI
  reference regenerated.
- Tests: TestChoose (flags, terminal yes/no, no terminal on, what's said);
  TestChooseNet replaces TestChooseNetDockerLayer (docker layer named and
  from the file, no egress-proxy, unreviewed egress-proxy, flags, with and
  without a terminal); TestUpWithoutEgressProxy (backend_lacks for
  --network-policy, the warning and net=off by default).
  network.txtar: --no-network-policy for the off VM, and a VM made without
  a flag or terminal gets net=on. docker.txtar: another machine's engine
  (backend_lacks, then the warning and net=off), and the sysbox VM's
  warning. e2e's docker sysbox check expects the warning.
- Docs: first-vm, commands, safety/network (the prompt, the VMs that
  can't have it), security, attack-vectors, devcontainer, backends index
  and docker, design notes, README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 08:45:55 -07:00
w3cjandClaude Opus 5.5 8439cbdb8c ci: the tests pass on Linux runners; workflows linted with actionlint and zizmor
The tests assumed a macOS host with 4 or more CPUs:
- size: the stub VM has 2 CPUs, which any host running the tests has
- ls, images: smolvm's --state-dir on Linux
- docker: .git protection is off on Linux
- the limactl stub's delete forgets the VM's port forwards and ssh port,
  as Lima does, so from's second conversion VM is configured again
- TestStartForwarder confines Lima's start as the host does (no
  sandbox-exec on Linux)
- TestProcessArgs runs sh, which ignores the extra arguments GNU sleep
  exits on

lint:code runs actionlint and zizmor (offline) on the workflows; ci.yml's
paths are written out, without a YAML anchor, and the deploy job's
permissions say why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 08:01:37 -07:00
w3cjandClaude Opus 5.5 fd6170c7f7 fix(lima): the sandbox refuses the hostagent's port binds; ssh ports recorded
On macOS, a network-policy VM's hostagent Seatbelt profile denies every
network bind but TCP on its ssh port and unix sockets in its Lima
folder, so Lima forwards none of the guest's ports even if its ignore
rules were bypassed. Lima's host resolver is off for these VMs, as on
Linux: it binds a random port the profile can't allow.

Every VM's ssh port is chosen and recorded before create (VMSpec.SSHPort,
Lima's .ssh.localPort), under a lock so two VMs can't choose the same
one, and checked free by a bind as well as a connect. Other VMs'
forwarders reserve it, so none can take it while Lima boots, when
Lima's unpinned ssh would reach whatever has it.

Design note: the sandbox's binds, how they were found, the threat check.
e2e: the profile's rules, binds refused around Lima's rules, a taken
ssh port, a direct VM's recorded port.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 01:14:22 -07:00
w3cjandClaude Opus 5.5 70f472eacd feat(ports): port changes apply to running VMs
devvm ports on a running VM records the ports and starts only its
forwarder again, on every backend: the VM runs on, and connections
open through the old forwarder close (ports_forwarding). SetPorts
takes the VM's Confinement (host key, proxy and decider ports, Free,
which leaves out and warns ports a host program has); Env.forwarding
builds it for starts and changes alike. State is written first, so
other VMs' forwarders reserve the new ports, and put back if the
backend fails. A per-VM lock (platform.LockFile, Forwards.Lock) keeps
two runs from leaving a forwarder nothing stops; Stop kills a
forwarder that outlives SIGTERM by 2 s. A smolvm or Docker VM started
outside devvm gets ports_no_ssh.

Removed: ports_set, applyPorts, startPorts, ports_pending,
ports_next_start. ports.txtar takes free ports (free_port) instead of
fixed ones a host program can hold.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 00:04:38 -07:00
w3cjandClaude Opus 5.5 5fe850e1b2 feat(smolvm): forward listed ports through devvm's forwarder
smolvm's listed ports go through devvm's forwarder (Spec.Only), as
Lima's and Docker's do: smolvm itself forwards only the VM's ssh. The
record keeps the list (listed_ports); create and SetPorts pass no -p.
That lifts smolvm's 64-forward limit and its reach of servers on all
addresses only, and allows listing 22. smolvm's ports are emulated,
reviewed: design note with a threat check for listed ports, e2e (a
listed port on the VM's loopback reaches the host, an unlisted one
doesn't, the machine publishes only its ssh, a network-policy VM's
listed ports).

Removed: smolvm_too_many_ports, smolvm_port_ssh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 22:47:03 -07:00
w3cjandClaude Opus 5.5 b27cd9b9b3 feat(lima): forward ports through devvm's own forwarder
Lima VMs forward their ports, every port and listed ones, through
devvm's forwarder (devvm _lima-ports), as Docker's do: loopback only,
exclusive binds, every port from 1024 up, never a port a host program
or another VM's record holds. Lima's own portForwards are ignore rules
for TCP and UDP on every address. The port choice is a record
(lima-vms/<vm>.ports), so changing it edits no Lima config and keeps
the VM's host keys. The forwarder pins the host key devvm pins
(Confinement.HostKey, sshconfig.HostKey) and ends with the hostagent
(the shared lifeline in vmssh). Lima's ports and ports-all are
emulated, reviewed: design note, threat check, e2e.

Docs: the forwarding rules for every backend, UDP not forwarded and
the socat alternative, in the docs voice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 21:43:10 -07:00
w3cjandClaude Opus 5.5 cf5a7db974 fix(images): pin Lima's Ubuntu cloud image with base's snapshot
Lima's base starts from a pinned dated Ubuntu cloud release (release-20261016) with each architecture's SHA-256, checked against Ubuntu's signed SHA256SUMS; another checksum is refused (ubuntu_checksum_unpinned). The pin is in base's image key (Lima's KeyFiles). scripts/bump.sh apt moves it with the snapshot and container digest: the newest release dated before the snapshot, its SHA256SUMS checked with gpgv against Ubuntu's cloud key.

e2e: default tier 146/0, --only from 13/0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 05:13:12 -07:00
w3cjandClaude Opus 5.5 3da0d6b0a6 feat(devcontainer): a project's devcontainer.json as input for new VMs
A new VM gets what the folder's .devcontainer/devcontainer.json (or .devcontainer.json) says, on every backend: image as --from (only an image its registry gives anyone, asked anonymously, pinned to that digest, never a registry on this machine or its network), features devvm has layers for (docker-in-docker as the docker layer, node, python, rust, go), forwardPorts as far as the user's ports allow, containerEnv and remoteEnv in the VM's environment, onCreate/updateContent/postCreate commands once and postStartCommand at each start, in the VM as its user. --no-devcontainer skips it; the command line wins. Later launches only warn when the file changed.

Nothing from it runs on or reaches the host: initializeCommand never runs, ${localEnv} and the host-folder variables are refused, builds, Compose and docker-outside-of-docker are refused, mounts, runArgs and privileged ignored. The file is read through os.Root, without blocking, at most 1 MiB. A docker layer only the file asks for still asks about network policy on Docker.

Reviewed with the security-audit skill (FuzzParse, design note); e2e: project 69/0, docker linux 135/0, smolvm 131/0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 04:33:54 -07:00
w3cjandClaude Opus 5.5 7259ad13a1 feat(docker): the docker layer on Docker VMs with Sysbox
Docker's engine runs inside a Docker VM only under Sysbox, on a Linux engine of this machine's: its own user namespace, its own network with nothing else on it, volumes of its own for Docker's and containerd's files, dockerd started after each start. Made with the layer or given it in place (its container made again from a commit); a failed add in place makes the VM as it was. Elsewhere refused in one line (docker_layer_no_sysbox, docker_layer_needs_vm); devvm never runs a container --privileged.

No network policy for it at any step (net_docker_layer): root in it controls its own network. A bridge routing to this machine's loopback (Docker's userland proxy off), or one whose setting can't be read, is refused at creation and each start (docker_route_localnet, docker_bridge_unreadable).

Set-id files of root's, or root's group's, in the project folder are named apart as running as root (setid_root_files); setid_files says the rest run as their owner. Root in any Docker VM writes the folder as the host's root.

Reviewed with the security-audit skill; e2e on the Linux engine with Sysbox 0.7.1 (135/0) and Docker Desktop (115/0, the refusal).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 03:17:36 -07:00
w3cjandClaude Opus 5.5 fcbea2c744 feat(docker): network policy, and build confinement on Docker Desktop
A Docker VM with network policy sits alone with a relay container on an
internal network of its own (inhibit_ipv4). The relay, devvm's own Linux
build in an empty imported image (read-only, every capability dropped),
copies the VM's connections to a unix socket of devvm's proxy on the
host, so tokens, the Keychain, the CA key and agents' logins never enter
Docker. On and off is docker network connect/disconnect at the next
start. Desktop builds run on a network and relay of their own, through a
host proxy allowing any host on ports 80 and 443.

- every Docker VM drops NET_RAW; it's in the config hash, so containers
  are made again from their commit
- confined: the start's ID, the VM alone on its network with the relay
  by its recorded container ID, the network still internal; a foreign
  member is docker_network_shared, at start and on removal
- proxy: -listen-unix, -relay/-relay-to; a lifeline pid file written
  after the proxy started whose process has gone ends it
- macOS fetches the release's Linux build on first use, checked against
  a SHA-256 the two-pass release.sh bakes in; builds without the pin use
  devvm-linux-<arch> beside devvm or refuse
- the build proxy is stopped through the process devvm started
- reviewed: design notes and threat check in design.md; e2e on the
  Linux engine and Desktop: dropped capabilities, network members and
  options, no IPv6 beyond the bridge's link-local, no DNS query leaving
  (captured, with an unconfined control), direct connections refused

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 05:08:03 -07:00
w3cjandClaude Opus 5.5 edc0c865ed fix(vm): launches ask only the backends a VM's state names
A launch lists VMs (the ssh config, the SSH agent's folder checks) only
on backends some VM's state names, so a Lima user's launch never runs
docker or smolvm, and a wedged or missing engine never slows one down.

- state.Backends: the backends the VMs' states name; Registry.Used: the
  registered ones among them, sorted. ls and images use state.Backends
  to fail only on a backend a VM's state names (vm.BackendUsed goes).
- Env.mounts and sshconfig ask Registry.Used; sshconfig.Config.Backends
  is a function read at each write, and Write fails on unreadable state.
- up.txtar: a new and an existing Lima VM's launches run neither docker
  nor smolvm; registry_test covers Used.
- tests/e2e.sh: the from section's launches make no docker call but
  image inspect.
- docs: backends.md says which backends a launch asks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 01:49:13 -06:00
w3cjandClaude Opus 5.5 2b413028e6 fix(images): pin Ubuntu's container image with base's package snapshot
smolvm's and Docker's base start from Ubuntu's container image by a
digest pinned in internal/ubuntu (ContainerDigest), not the tag's digest
looked up at build time. base's key hashes it (each backend's KeyFiles),
and base's record names it. The image is never newer than
assets/layers/base.sh's snapshot: an image with newer packages leaves apt
unable to install what depends on their exact versions (the docker
layer's docker-ce, through systemd's libsystemd0).

- internal/ubuntu: ContainerRepo, ContainerDigest, ContainerRef,
  ContainerOrigin; the backends' Digest fields and UbuntuImage go.
- base.sh: apt_snapshot 20261026T000000Z, with the image's digest
  sha256:19fcd1bf268f (built 2026-10-25).
- scripts/bump.sh: apt moves the snapshot and the image's digest
  together (the index's digest hashed from what the registry sent), and
  refuses an image built after the snapshot; bump.txtar covers both.
- tests/e2e.sh: timings per selection and Docker engines, so an
  --engine linux run isn't compared with one that included Desktop; the
  Linux engine's run pulls the pinned Ubuntu image before recording what
  Docker has without the sandbox's label; base's records are checked
  against the pin; smolvm's TSI check takes any of this machine's
  resolvers; the from section allows devvm's labelled VM listing.
- docs: smolvm, Docker, images, maintaining, contributing; design.md's
  smolvm notes describe the reviewed emulations as they are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 01:16:57 -06:00
w3cjandClaude Opus 5.5 db07c9a43d fix(ssh-agent): the ssh config's agent follows the VM's running start
A VM's ssh config entry, devvm's own SSH_AUTH_SOCK and its key reloads
use the agent choice the VM's current start was made with; a stopped
VM, or one started outside devvm, follows the stored choice. Turning
forwarding on or off for a running VM reaches ssh by name, editors and
devvm's shell at its next start, as agent_next_start says.

- Backend.StartID: Lima's hostagent pid file, smolvm's lifeline, the
  container ID and StartedAt on Docker; the fake counts starts
- state: ssh_agent_started=<mode>_<hash of the start>, written after
  each start; sshagent.Running reads it
- tests: TestRunningAgent, TestWriteAgentStarted, ssh_agent.txtar,
  docker.txtar, smolvm.txtar; e2e on Lima, smolvm and Docker

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 23:11:51 -06:00
w3cjandClaude Opus 5.5 6f597d7e1f feat(docker): ssh, ports and agent forwarding over docker exec
Docker VMs get ssh for editors, listed ports, every port, agent
forwarding and agent toggling, all over one transport: devvm's ssh
config reaches a VM through `devvm _docker-connect`, which runs
`sshd -i` in the labelled container by ID with docker exec. The
container publishes nothing and runs no listening sshd.

- internal/backend/vmssh: VM keys, host-key parsing, the port
  forwarder and its processes, shared by smolvm and docker
- `devvm _docker-ports`: every port, or the listed ones; ports a host
  program has are skipped (ports_taken)
- the agent goes only to ssh sessions (ForwardAgent, IdentityAgent);
  no socket is mounted
- --clone on Docker, its clone in a per-VM volume
- platform.ListenExclusive keeps SO_REUSEADDR on Linux; UsedPorts
  leaves out the VM's own listed ports
- messages: vm_no_ssh, vm_no_sshd, ports_no_ssh, ports_forward_failed,
  forwarder_failed, docker_ssh_path, docker_connect_failed
- reviewed: design notes and threat check in design.md; e2e checks for
  a hostile sshd config, host ports kept on every address family, and
  ports not forwarded off loopback or listed by another VM

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 10:33:41 -06:00
w3cjandClaude Opus 5.5 9ec1601801 feat(docker): an experimental Docker backend, its containers and native features
Each VM is a container from an image devvm builds by running its scripts
in a container and committing it. A container is not a VM: on Linux it
shares the host's kernel, on macOS Docker Desktop's one VM; docker.md says
so first.

- internal/backend/docker: build-image (docker commit; base from Ubuntu's
  image by digest, prepared by the container scripts smolvm shares, now in
  assets/container), from (any image Docker has or pulls), clone,
  project-mount and agent-folders (bind mounts), tools-share (tool images
  unpacked into a volume by a network-less container, linked by
  guest/tools.sh; ToolFormat dir-<unpack.sh>), cpus and memory (docker
  update). Build confinement native only on a rootful engine of this
  Linux machine; Docker Desktop and other engines build nothing yet.
- Containers run --init and a sleep; services.sh after each start, without
  Docker's daemon. Mounts and network are hashed into a label; a start that
  finds them changed commits the container and makes it again under the
  same name (flattened past 100 layers), its home a per-VM volume.
- The VM's user has the host's uid, and on Linux its gid. A --clone VM's
  clone gets a volume (VMSpec.CloneAt).
- Disk none: DiskUser reports what a VM holds (devvm size's disk_used),
  warned past base's disk by launches and ls; a default disk size is left
  out of a new VM on such a backend, said.
- Everything labelled devvm.data=<data folder>; only labelled resources
  are touched; names Docker shares between users carry its hash.
- Problems: docker on PATH, a reachable engine (or the docker group fix),
  29.1+, Linux containers, this machine's arch; Report names the engine and
  Docker Desktop's file sharing, which CreateVM checks.
- ssh, ports, ports-all, agent forwarding and toggling, egress-proxy, disk
  and the new docker-layer feature are none: refused in one line. Builds
  ask for build features only when they build, so a built image works
  where it couldn't be built.
- testdata/stubs/docker: a stateful engine; docker.txtar; unit tests;
  tests/e2e.sh --backend docker on a Linux engine in a Lima VM e2e keeps
  (~/.lt-e2e-go-docker) and on Docker Desktop, with images copied from the
  Linux run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 08:54:04 -06:00
w3cjandClaude Opus 5.5 e6681035b2 feat(images): a built-in docker layer
Docker is a layer devvm ships, docker, chosen per VM like any layer
(devvm node+docker, devvm build docker) and added to an existing VM in
place. base installs no Docker.

- Built-in layers: image.Builtins (docker) and IsBuiltin; a name is
  looked up in devvm's assets/layers first, so a user's docker.sh is never
  read; devvm layer new docker is refused (layer_name_reserved); an
  image's key hashes the shipped script (own file, must exist); Layers,
  Environments, completion and unknown_layer/no_image_for list it;
  Env.LayerData reads either kind's script.
- assets/layers/docker.sh: Docker's apt repository (pinned key, pinned
  package versions; Alpine's own packages, rc-update, the docker group),
  the daemon started now too (OpenRC, or with no init system as
  services.sh does) for a VM it's added to in place. scripts/bump.sh's
  docker pins read it.
- assets/layers/docker.policy: Docker's packages and the registries,
  applied to VMs with the layer (netpolicy.PolicyFiles); base.policy
  keeps OS packages (Alpine's too), mise and GitHub.
- Adding layers in place sets the new image in the VM's state before
  their scripts run, so a network-policy VM's proxy allows their hosts;
  a failing script sets it back.
- smolvm's sshd.sh keeps the snapshot's package lists, for layers'
  apt-get install.
- Docs: images (base, built-in layers, keys), customizing, commands,
  network, smolvm, from, install, maintaining, design, coding-agents,
  contributing; the CLI reference; AGENTS.md's assets/ line.
- Tests: key, layers, build, policy files, in-place add (devvm's script,
  image during the run, set back on failure), layer new docker; e2e:
  a base VM has no Docker (Lima, smolvm), the docker layer on Debian 12
  and Alpine (from), and smolvm's network-policy VM is a docker VM whose
  Docker pulls through the proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 07:18:30 -06:00
w3cjandClaude Opus 5.5 a9459a8c9c fix(ports): never forward a listed port a host program has
A listed port's forward (Lima's hostagent, smolvm's -p) listens on
127.0.0.1/::1 with SO_REUSEADDR, so on macOS it took a port a host
program held on *:PORT, and that program's localhost connections with it
(checked on both backends). Now each start checks the VM's listed ports
first and leaves out those in use, warned; the VM starts all the same,
and the next start that finds a port free forwards it again.

- platform: ListenLoopback (moved from smolvm's forwarder), PortFree and
  PortInUse, which listen on 127.0.0.1 and ::1 without SO_REUSEADDR (a
  port held only by ended connections counts as free; one that can't be
  bound for another reason, such as below 1024 on Linux, isn't in use).
- vm: start checks the backend's listed ports (ports_set) with
  Env.PortInUse, warns ports_taken, and passes the rest in the new
  Confinement.Ports; every port and none pass nil.
- Lima: Start parses portForwards from limactl list and sets them only
  where devvm's rules differ (guestIP compared for ignore rules alone),
  so a start edits, and the VM gets new host keys, only when a port is
  left out or comes back.
- smolvm: Start updates -p where the machine's ports differ
  (listedPorts); the ssh port choice (freePort, PortFree) and Lima's
  confined ssh port use platform.PortFree.
- Lima's forwards of every port aren't checked (Lima makes them as guest
  servers start): documented as a limit.

Message: ports_taken. Docs: images.md (ports), lima.md, smolvm.md,
security.md, design.md, limits.md, contributing.md. Tests: platform
TestListenLoopback, vm TestSplitPorts and TestStartPorts, lima
TestStartSetsPorts, smolvm TestStartListedPorts; ports.txtar and
smolvm.txtar with a host listener (listen_any); the limactl stub keeps
the portForwards clone and edit set. e2e: a host program on *:PORT
keeps its port while the VM lists it, and the port is forwarded again
once freed (project and smolvm sections).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 01:12:58 -06:00
w3cjandClaude Opus 5.5 75652b3097 feat(smolvm): turn ssh-agent forwarding on or off for an existing VM
smolvm forwards an agent only if the machine was made with --ssh-agent,
and reads SSH_AUTH_SOCK at each start. agent-toggle is now an emulation,
reviewed:

- Every new smolvm VM is made with --ssh-agent. Each start points
  SSH_AUTH_SOCK at the user's agent (on), devvm's agent (devvm), or a
  path no socket can exist at, /dev/null/devvm-no-agent (off): nothing
  listens, so off VMs share no agent to add keys to or sign with.
  Every other smolvm command runs without SSH_AUTH_SOCK.
- Off wins whenever the record or Confinement.NoAgent says so, so starts
  for exports and clone checks give no agent either.
- A VM made without forwarding can't be turned on (agent_fixed).
- Each start records the machine's lifeline; a running VM whose lifeline
  differs and whose mode isn't on (started outside devvm, with whatever
  agent that shell had) is stopped at launch, ssh, code, restart and
  export (agent_unchosen_stop), through backend.AgentStarter.

Docs: smolvm.md (SSH agent forwarding), backends.md, ssh.md,
security.md, limits.md, testing.md, design.md (the design note and
threat check). e2e: each mode, toggling on an existing VM, devvm's agent
ending, a start outside devvm stopped; direct starts in the network
checks pass an agent path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 00:39:10 -06:00
w3cjandClaude Opus 5.5 293c3a82ca feat(smolvm): forward every port, loopback-only servers included
smolvm forwards only listed ports, and only to servers on the guest's
0.0.0.0. ports-all is now an emulation, reviewed:

- devvm _smolvm-ports, started with the VM and ended with its lifeline,
  holds one ssh master connection to the VM's sshd (its key alone, the
  host key pinned, no agent, no forwarding asked) and relays each host
  connection as an ssh -W channel, so every connection starts on the host.
- assets/smolvm/ports.sh reports the guest's TCP listeners; the host
  parses the report as untrusted (sizes capped, loopback addresses only,
  applied at most every 500 ms).
- Ports from 1024 up, at most 256, bound on 127.0.0.1 and ::1 with
  platform.ListenExclusive: never a port another host program holds, nor
  any VM's ssh, proxy, decider or listed ports (netpolicy.UsedPorts).
- Its log is rate- and size-limited; reads through smolvm exec (host
  key, the sshd probe) are capped at 64 KiB and 30 s.
- sshd's AddressFamily is any, for channels to the guest's ::1.
- vm checks the VM's port features at every start.

Messages: smolvm_ports_no_ssh, smolvm_ports_failed,
smolvm_forwarder_failed. Docs: smolvm.md (every port), backends.md,
security.md, design.md (the design note and threat check), limits.md,
testing.md. e2e: the smolvm section's every-port checks, and its fake
decider reads smolvm's request before closing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 23:32:00 -06:00
w3cjandClaude Opus 5.5 851e39ef86 build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/,
shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which
cli passes to every constructor; backends, the builder, the shared
tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts
reach VMs on stdin (backend.Script carries their contents). What needs
a path (limactl create's base.yaml, oci/ mounted into the conversion
VM, the proxies' policy files) is written out to
~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders
700; devvm gc deletes older copies no VM's proxy was started with
(gc_assets, deleted_assets). Release archives hold the binary with
README.md, CHANGELOG.md and LICENSE, and the formula installs the
binary alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 18:12:37 -06:00
w3cjandClaude Opus 5.5 9f24d2639e refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/,
shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and
oci/. devvm reads them from assets/ beside its binary (paths.Root,
paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e
put them there. Image keys hash them by their names in assets/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:08:33 -06:00