mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-06 09:20:34 -10:00
bf03f262218ce824b8cc686d97f18217954bb71f
81
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
e6929a3530 |
feat(disk): check free disk space before builds and new VMs
- platform.FreeSpace: statfs (Bavail * Bsize) on darwin and linux, the nearest existing folder for one not made yet; ErrUnsupported elsewhere - backend.Storage (DiskDirs: Lima's home; smolvm's folder, and HOME on macOS; Docker none), backend.Space Check and Warning, floors FreeBase 12 GiB, FreeImage 8, FreeTools 8, FreeVM 4, each commented with its measurement - builds (base, other images), shared tool builds (also the data folder) and new VMs refuse below their floor before anything is made (disk_low); statfs errors carry their cause (disk_free_unknown); doctor warns below base's floor without failing (disk_low_warning) - FreeSpace fields on build.Env, tools.Env and vm.Env; structure limits Lima 67, smolvm 72 for DiskDirs - docs: ports-size Free space, troubleshooting Not enough free space, install requirements, docker, smolvm, design's open work; doctor's help - tests: backend Space, build, tools, up, smolvm DiskDirs, platform Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
422e409e41 |
test: wait_file waits 60 s, and fails at once when the background command ended
Under the full suite's load the background devvm in build.txtar and up.txtar takes over 10 s to reach the stub call that writes hanging: a dozen limactl stub calls, each bash and its own commands, about 80 ms alone and up to a second under load. wait_file's 10 s ran out while devvm was still on its way (testscript then ended it: exit status 130). wait_file now waits up to 60 s, and fails at once, saying so, when every background command has ended, as nothing is left to write the file. A devvm that hangs before the stub still fails, after 60 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
a54a860e3e |
refactor(build): split images' builder into Env, Builds, Images and Choice
build.Env holds what images on one backend are built with (folders,
assets, backend, review, shared tools, --from, UI hooks) and what the
groups share: image keys and chains, the user's layers, the features
there are and those chosen, base's C library, deleting an image. Builds,
Images and Choice each embed it:
- Builds: building an image and those under it, rebuilding one, warning
when a VM's image is outdated.
- Images: the backend's images with their records, listing and deleting
them.
- Choice: asking which features base gets, or setting them.
cli and vm hold a *build.Env and name the group they use
(build.Builds{Env: b}.Build, build.Images{Env: b}.Delete,
build.Choice{Env: b}.PickFeatures); images' listing keeps each backend's
Images for gc. internal/build.Builder leaves the structure test's
largeTypes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
600d553586 |
refactor(tools): split the shared tools into Env, Versions, Share and VMs
tools.Env holds what the shared tools run with (folders, assets, host,
HTTP client, UI hooks) and what the groups share: the platforms, devvm's
mise.toml, a tool's image file and the share's lock. Versions, Share and
VMs each embed it:
- Versions: the tools lock, resolving it with the host's mise, the daily
check and refresh, the image files of an image name's tools.
- Share: building, listing and deleting the share's tool images.
- VMs: newer tools than a VM's, and moving a VM to them.
vm.Env and build.Builder hold a *tools.Env; callers name the group they
use (tools.Versions{Env: e.Tools}.Files, tools.Share{Env: b.Tools}.List).
internal/tools.Tools leaves the structure test's largeTypes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
548113d726 |
build(lint): enforce contexts, nolint reasons, reassign and function size
.golangci.yml: - forbidigo bans context.Background and context.TODO outside internal/ui and cmd/devvm. - nolintlint requires each //nolint to name its linters and say why, and reports unused ones. - reassign (patterns .*) forbids setting another package's variables, tests included. - revive keeps its default rules and adds function-length (100 statements, 160 lines) and cognitive-complexity (75). Fixes: - Backend.Lifeline takes a ctx: smolvm's machine data-dir lookup runs with the caller's. - The proxy's TLS handshake with a VM uses the request's context, limited to 30 seconds. - OAuth token refreshes run within refreshTimeout (30 seconds). - Tests use t.Context(). - Launch.create is split into plan, newVM.record and undoCreate. - lima's TestStartConfined is split into helpers. - smolvm's Terminal comes from its UI's StdinIsTerminal. - Unused //nolint directives are removed. - Fresh contexts that remain (an in-memory TLS parse, lookups shared by every request, a test cleanup) each carry a nolint saying why. Docs: contributing.md lists which lint rule enforces which convention; AGENTS.md names the linters behind its Go conventions. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
a76ceb6e48 |
refactor(backend): name the package that builds every backend registry
internal/backend/registry builds the registry of every backend devvm has: registry.New(dirs, u) returns the *backend.Registry, and registry.Experimental names the experimental ones. Test builds set registry.unreviewed with -ldflags -X (tests/e2e.sh, the CLI tests, testing.md). The unexported constructor for a given build and DEVVM_UNREVIEWED is newFor. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1e4c772cc5 |
refactor(vm): split Env's commands into types by group
Env holds the shared dependencies NewEnv sets and the helpers every
group uses: finding the folder's VM, starting it, applying its size and
ports, the image builder and the ssh config. The commands are on types
that embed *Env:
- Launch: up, restart, remove, update, ssh and code; a new VM
(up.go), an existing one (existing.go), ssh.go, agents' mounts
- Lifecycle: stop, adopt, rm and export (lifecycle.go)
- Settings: .git protection (settings.go), size (size.go), ports
(ports.go), SSH agent forwarding (sshagent.go)
- Net: network policy, its log and allowlist (network.go), secrets
(secret.go)
- clones (clone.go) and syncer (sync.go), used by the others
env.go holds Env, UI, NewEnv and the shared helpers. cli's commands
call the group they need, e.g. vm.Launch{Env: env}.Up. Tests follow
their code: env_test.go holds the shared helpers, with up_test.go,
lifecycle_test.go, network_test.go and ports_test.go beside them.
The most methods on one type is 24 (Launch).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4bbd35a24b |
refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal flags, run log, status line, cleanup stack and interrupt flag, and its functions are methods. ui.Main makes the run's UI on devvm's own streams, owns signals, recovers Die and runs the cleanups; ui.New makes one on other streams. cmd/devvm passes it to cli.Execute, and every cli command gets it through its constructor. Only cmd/devvm and internal/cli import internal/ui (a depguard rule). Each other package defines the small UI interface it needs, which its constructor takes, filling fields tests set: - gitprotect.New, secrets.NewStore, from.NewLookup: a warn func - ubuntu.New: LoggedCmd, Note - netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its log lines drop control characters themselves (oneLine) - sshagent.New: Info, Note, Warn, LogWriter - tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup - lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run), WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too - backends.Registry: lima's and smolvm's - vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout, LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields - build.Builder: Terminal and LogNote fields - sshconfig.New: its caller sets what it prints and asks ui's tests build their own UI over buffers and run in parallel; other packages' tests use small fakes; cli's unit tests a UI over buffers. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d73c010ec4 |
feat(msg): messages carry the error they report
msg.M.Because(err) returns the message carrying err, and Unwrap returns it, so errors.Is and errors.As see through a message to its cause. The text stays the message's own. Messages made from an error carry it: proxy_failed (secrets and the proxy command), login_copy_failed, run_log_failed and fail's fallback message. TestBecause covers errors.Is and errors.As through a message, through %w wrapping, and through a message in a message. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7fcac40758 |
refactor: test seams on structs, not package vars
Tests set fields; no test outside internal/proxy and internal/ui assigns a package var. - backend.Review: Unreviewed and Warn, with Require and Allowed as its methods; Registry embeds it, set by backends.Registry (a test build reads DEVVM_UNREVIEWED); build.Builder.Review, sshconfig.Config.Review, and Tools.Build takes the review with the backend - netpolicy.Log: Path and Tick (NewLog), with Write and WriteBlocked; Proxy.Terminal for Choose and SelfCheck - vm.Env.Terminal, sshconfig.Config.Terminal - cli: setup's terminal check and backend picker are fields of setup; versionOf takes the release's version - from.Registry.RetryDelay, ubuntu.Finder.RetryDelay, lima.Lima.OCIWait - msg's tests use real messages, not entries added to docs and specs The tests these free run in parallel. AGENTS.md: test seams are fields; internal/proxy's globals and internal/ui's process-wide state are the exceptions. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
86a1466cec |
refactor: print and prompt only from cli
Packages other than cli and ui take what they print and ask as fields, set to ui's by their constructors or by cli: - vm.Env: Info, Warn, Note, Say, Ask, Confirm, PickFeatures (cli sets PickFeatures); AgentMounts, UpdateAgentDirs, warnIgnored, applyAgent, applySize, applyPorts, removeRemote and saveFetched are Env methods - build.Builder: Info, Warn, Say, Confirm, Pick (build.Feature); cli's newBuilder sets them, its pickFeatures asks through ui.Pick - netpolicy.Proxy: Note, Warn, Ask, Confirm; Choose, SelfCheck and Unproxied are Proxy methods - sshconfig.Config: Info, Warn, Say, Confirm - secrets.Store: Warn; LoginKept takes the warn function Tests set the fields and check messages through them. AGENTS.md: only cli calls ui's messages and prompts. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
78e660d93d |
feat(setup): ask for the default backend
In a terminal, devvm setup with neither --backend nor --features asks
for the default backend, then base's features. --backend chooses it
without asking; --features alone, or no terminal, doesn't ask.
- ui.PickOne: a single-choice picker in Pick's style ("( )"/"(*)",
up/down or k/j move the choice, enter confirms), starting from the
choice that's on; Pick and PickOne share pick/pickLoop.
- backends.Experimental: smolvm is marked experimental in the picker.
- setup: pickBackend starts from the current default (lima unless set,
or set to a backend devvm doesn't have); setupTerminal and pickOne
are test seams.
- Messages: backend_help, backend_experimental.
- Tests: TestPickOneKeys, TestPickOneWithoutTerminal,
TestSetupAsksForTheBackend (terminal, current default, unknown
default, no terminal, --backend, --features); setup.txtar checks no
backend is asked or saved without a terminal or with --features.
- Docs: backends.md (setting the default), customizing.md, the CLI
reference; AGENTS.md's pending line removed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
d53bfdb5d1 |
feat(smolvm): network policy through devvm's proxy
egress-proxy is emulated on smolvm, and reviewed: a VM with network policy reaches nothing but its proxy. - smolvm Start (NetProxy): allow list of the gateway alone (--reset-allow-list --allow-cidr 100.96.0.1/32), DNS closed (--allow-host-pattern devvm.invalid), and the start through devvm's decider (--mediated-egress --egress-interceptor, token in SMOLVM_INTERCEPTOR_TOKEN, never in arguments); a start without policy removes them (--net --reset-allow-list --no-egress-interceptor). The proxy's environment goes in by a quiet update, as smolvm prints the values it sets. Confined compares agent.pid with the confined start's and re-checks the allow lists on every call. - The proxy is smolvm's mediated-egress decider (protocol v2, internal/proxy/decider.go, stdlib only): -decider, -decider-to, -decider-token-file; it takes over only connections to its own address in the VM, served with password and policy, and refuses and logs the rest; the token is checked before anything past it is read, first bytes capped at 8 KiB; FuzzPrelude. - Interface: Confinement.Decider/DeciderToken, backend.Decider (UsesDecider); netpolicy.Proxy.Prepare takes the backend, allocates decider_port and a decider_token new at each start. - A running network-policy VM whose proxy can't start again (port taken, start failed) is stopped, on Lima and smolvm (net_proxy_down_stopped; proxy_port_taken reworded); the stop isn't cancelled by an interrupt. - DEVVM_UNREVIEWED=backend:feature lets unreviewed emulations through, warned (backend_unreviewed_used), only in test builds (-X internal/backend/backends.unreviewed=allowed: tests/e2e.sh and the CLI tests). - Tests: decider, prelude and token unit tests; Prepare with a decider; Unproxied; smolvm Start/Confined on the stub (allow lists, decider requirement, env echo); testscript smolvm.txtar (policy VM, no password in run logs, proxy down stops it), network.txtar (Lima: proxy down stops it), doctor.txtar; e2e smolvm network section: proxy and decider, allow list, allowed/blocked hosts, direct connections as root (controls off policy), DNS refused per smolvm's decision log with devvm.invalid as control, UDP and ICMP (UDP allow control), token nowhere, log, policy, a widened allow list unenforced, fail closed with the proxy gone or a fake decider (garbage, silent, allow-direct; take-over as control), no start without a decider, someone else's decider stopped, network off/on. - Docs: design note (how it works, what it relies on, what could break it, not covered: UDP allows the host's user adds, the devvm.invalid DNS channel), smolvm.md, backends.md, security.md, network.md, testing.md (DEVVM_UNREVIEWED, a canary DNS zone check), contributing, limits; AGENTS.md gotchas and a deliberate change. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
31d1f3c78e |
feat(smolvm): an experimental smolvm backend, its native features
A second backend, registered beside Lima: each VM is a smolvm machine (a microVM running its image as a container, no init system), each image a pack in devvm's data folder. - internal/backend/smolvm: images built as packs (pack create --from-vm) from Ubuntu's container image by its registry digest (or --from's, registry images only), base prepared first (prepare.sh: sudo, CA certificates, bash, the host's user and uid); systemctl/rc-update stand-ins while a build's scripts run (shims.sh); project VMs made from a pack with network, CPUs, memory and disk set; after each start the loop devices, the tools' mounts and dockerd (services.sh); Exec as the VM's user with a login's environment; ports, agent folders, size; a record per VM of what smolvm doesn't show. On macOS every machine carries the label devvm.data=<data folder> and nothing without it is touched (smolvm_machine_foreign); on Linux --state-dir too. SMOLVM_USAGE=0, SMOLVM_MACHINE_NAME never passed on. Images used by a VM aren't deleted (their pack is read when a disk grows). - Caps: native for everything but egress-proxy, ssh, ports-all and agent-toggle (none until their emulations are reviewed), refused in one line naming the VM. - Interface: two features, ports-all (every port; new VMs' default) and agent-toggle (forwarding changed after create), each Lima-native; Backend.ToolFormat and ToolsSpec.Format; backend.KeyFiles, the backend's own scripts in base's key; --clone requires ssh. Lima's image and tool keys are unchanged: the format is hashed only when it isn't build.sh's own, and backend files only when there are any. - Tool images: smolvm's tools build runs tools/build.sh unchanged, then remakes each image uncompressed (plain.sh); its format is named by plain.sh's hash. tools.Target (libc and format) replaces the libc argument; devvm images counts an image current for any backend. - The proxy reads only the lifeline's first line (smolvm's has the start time on a second). guest/sync.sh tells a running systemd by /run/systemd/system (Docker's packages install systemctl). - Messages: smolvm_missing(_fix), smolvm_broken(_fix), smolvm_old(_fix), smolvm_host_unsupported, smolvm_machine_foreign, smolvm_update_failed, smolvm_script_failed, smolvm_from_registry_only, smolvm_mount_colon, smolvm_too_many_ports, smolvm_no_agent, creating_from_image, packing_image, pack_failed; doc links to the smolvm page. - Tests: internal/backend/smolvm (caps, ports, create, only ours, start, base build, failed build, set calls, Linux state dir, problems) on testdata/stubs/smolvm; testscript smolvm.txtar; TestE2EExecQuoting for smolvm; tests/e2e.sh --backend smolvm (the smolvm section: 34 checks); existing scripts expect the second backend. - Docs: new smolvm.md; backends.md's column and the two new rows; design.md's smolvm section as built; limits, contributing; AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f42d436350 |
build(release): release.sh around GoReleaser, bump.sh
scripts/release.sh checks the signed tag (git tag -v) and its signer against this checkout's packaging/release-signer, then runs goreleaser release --skip=publish (--snapshot with --head) in a clone of the commit, so only what's committed goes in. .goreleaser.yaml builds darwin/linux x arm64/amd64 archives with the binary and its data files, a source tarball and SHA256SUMS, with -X github.com/w3cj/devvm/internal/cli.version (VERSION's version, for HEAD too). release.sh checks the host's binary prints the version, signs SHA256SUMS with minisign and verifies it, fills in install.sh (release_version, minisign_key) and the Homebrew formula, which builds from the source tarball with Go (brew audit --strict clean). --head takes DEVVM_MINISIGN_PUB for a test key, and skips a missing install.sh; a tag without one is refused. scripts/bump.sh writes the host mise's pins in internal/tools/mise.go. VERSION and a fresh CHANGELOG.md. docs: maintaining.md (pins, releasing). Tests: testdata/script/release.txtar (unsigned tag, no pin, another signer, the checkout's pin, no install.sh), release_head.txtar (unsigned, signed and verified, install.sh and formula filled in, only committed files, wrong key, wrong version, bad install.sh, bad VERSION), bump.txtar (crane, mise in base.sh and mise.go, hostile and missing values, --check control characters, unknown tool). The sandbox sets DEVVM_REPO. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fb2d591b09 |
feat(limactl): devvm limactl runs Lima on devvm's own Lima home
devvm limactl ARGS... runs limactl in devvm's place (exec), with LIMA_HOME set to devvm's Lima home whatever the environment says, from devvm's data folder (as devvm's own limactl commands run, away from lima.REJECTED.yaml in a project folder). Every argument passes through, flags and --help included; input, terminal and exit code are limactl's. The code lives in the lima package (lima.Limactl); the cli command is a thin wrapper, like _qemu. - Messages: limactl_failed (new); lima_missing when limactl isn't on PATH; script_failed now suggests devvm limactl shell --start and drops its lima_home field. - Tests: testdata/script/limactl.txtar (Lima home, LIMA_HOME ignored, data folder as cwd, arguments and --help passed, stdin, exit code, default home, no Lima); build.txtar, build tests and e2e updated for script_failed; e2e images checks devvm limactl list and its exit code. - Docs: lima.md "Running limactl", commands.md row, images.md's failed build hint; CLI reference regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
06780fee5d |
feat(ssh): devvm ssh and devvm code, VS Code's Machine settings kept
devvm ssh gets this folder's VM ready for ssh and editors, as a launch does without its shell, then names the host they reach it by; devvm code does the same, then opens the folder in VS Code over Remote-SSH. - vm: launch (from open: .git and set-id checks, a stopped VM's size, ports and agent forwarding, the user's agent checked, run with its self-check) and setUpVM (from setUp: sync, ssh config, a --clone VM's clone) shared by launches, SSH and Code; reach requires the backend's ssh, then offers the Include line (EnsureInclude). Code runs code --remote ssh-remote+HOST DIR in devvm's place with the environment devvm started with (Env.Environ), so the editor keeps the user's SSH_AUTH_SOCK. - sshconfig: Host (the alias among every backend's project VMs), with the listing shared with Write. - cli: ssh and code commands; CLI reference regenerated. - Messages: ssh_host_info, no_code_command (linked to ssh.md), ssh_failed, code_failed. - Tests: ssh_code.txtar (no VM, usage, a stopped VM started and set up without a shell, the Include line shown not added, a pending size waiting, code's arguments and agent, two folders named alike, no code on PATH, a direct route stopping the VM); guest.txtar's VS Code Machine settings case; a stub code. e2e: devvm ssh on a stopped VM and ssh reaching it, the Machine settings set and set again, devvm code with a stub code; network: devvm ssh's self-check, passing and stopping a VM started outside devvm. - Docs: ssh.md (devvm ssh and devvm code, VS Code), commands.md, security.md, clone.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
44e256d51a |
feat(stop): devvm stop stops this folder's VM and its proxy
devvm stop needs a finished VM made for this folder (no_vm, vm_other_folder, vm_unfinished). It stops the VM (Backend.Stop, the "stopping" step), says stopped, or already_stopped for a VM that was, then stops its network policy proxy at once instead of waiting for it to notice the hostagent is gone. With the VM stopped, .git is checked and locked as on a launch that finds it stopped, and on Linux set-id files are named (not for a --clone VM); the ssh config is rewritten, so the VM's entry goes. Messages: stopped, already_stopped, stop_vm_failed; git_protect_running now says to run devvm stop first. Tests: testdata/script/stop.txtar (no VM, usage, a running network policy VM and its proxy, locks after stop on macOS, the ssh config entry, already stopped, a folder made again). e2e: project's stop (status, ssh entry; on macOS a submodule git folder reported and locked by devvm stop), network's stop (the proxy gone at once, both back on the next launch). Docs: commands.md (Stopping a VM), git-protection.md, network.md, ssh.md, contributing.md; the CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5304e9a2b7 |
feat(export): devvm export saves a VM's agent history
devvm export [FILE] saves this folder's VM's agents' history (the same paths and login excludes as rm's export) to FILE, relative to the current folder, or to a new <vm>-<date>-<time>.tar.gz in the exports folder. A stopped VM is started for it. It needs a finished VM made for this folder. The export is now written to a temporary file beside its target (mode 600) and renamed into place once complete, for rm's export too: a failed export leaves no file and an existing FILE as it was. Messages: history_not_exported (logged) and export_failed (reason) for devvm export; rm's is now rm_export_failed. Tests: TestExport (default folder, a new folder for FILE, a failed export keeping FILE); testdata/script/export.txtar (no VM, usage, a stopped VM started, the script, a relative FILE, a failure keeping FILE and the VM); e2e's project section exports a stopped agent VM's history to a file, without its logins. Docs: coding-agents.md#history, commands.md, the CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |