mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 14:33:17 -10:00
main
38
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e4b44b5994 |
fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.
The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.
TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6fd1d846d6 |
fix(lima): cache a Linux VM's project folder with 9p's none
Linux's 9p client loses data with Lima's default cache=mmap for a writable share: a stat() during an extending write() takes the host's stale size and writeback drops the data, so files reach the host empty or cut to 4096 bytes even after fsync (Claude Code's Edit sets it off); and on devvm's Ubuntu 26.04 guest kernel, a lock after a write makes the next read return zeros, which breaks SQLite in any journal mode and Gradle's daemon. macOS's vz VMs use virtiofs and aren't affected. - New VMs on a Linux host record cache mode none in a new mount section of vm.json, and their project folder is made and started with it, as is the folder devvm clone off mounts. VMs whose state has no mode (0.1.0's, and every VM made before this) keep Lima's mmap untouched, with no limactl edit, and each launch warns (mount_cache_unchosen) until devvm mount-cache none. - devvm mount-cache [none], with --json: none is the only mode devvm sets, so any other value is a usage error (mount_cache_invalid); a stopped VM gets it in its next start's one edit, a running one after the restart devvm offers. macOS refuses (backend_lacks), and so does a Linux VM whose folder isn't a 9p mount (mount_cache_no_choice). No -g or config.toml key: every new VM gets none. - The start that changes the mode mounts the folder again in the guest, as cloud-init rewrites fstab only after systemd has mounted it, through the logged runner with a minute's limit (output pipes closed a second after), then checks it with mountpoint and findmnt, reading 4 KiB at most and only the last line: a folder left unmounted stops the VM and fails the start before its shell (mount_cache_unmounted), and so does a check that gets no answer (mount_cache_unchecked); one still mounted with the old mode is warned of (mount_cache_remount_failed), any mode but none or mmap named unknown. An interrupt meanwhile, on any tier, leaves a cleanup that stops the VM, the one stop then. A launch into a running VM asks the guest, in words, whether its folder is a mount point, and refuses one that isn't (project_unmounted) or whose check fails or gives no answer (project_unchecked). A stored mmap, from a build before none alone, reads as none chosen, and devvm clone off records none for its new mount; any other mode is refused naming vm.json. - backend: FeatureMountCache (native on Linux, none on macOS, built on project-mount), Want.ProjectCache, Instance.ProjectCache, CacheModes. - lima: mount rewrites keep only the sshfs and 9p settings devvm knows where they differ from Lima's defaults, and drop the rest for Lima to fill in, so lima.yaml never freezes a default; same() compares the cache where devvm sets one. Build VMs' writable output folders (tools, --from) get none. - tools: an EROFS tool image that ends before its superblock does, or is shorter than its superblock says, as a build under mmap could leave one, counts as not built, so the next build makes it again; a build's short output is refused. The fakes' tool images are a page (backendtest.ToolImage). - The limactl stub lists QEMU's vmType, fills in 9p cache defaults on Linux, and answers the remount's check. - Docs: backends/lima (the project folder's cache, when it changes, programs that map files for writing, SQLite), using/limits, using/clone, commands, internals/lima, internals/backends, the design note (both mmap bugs, why none alone, the remount, tool images, the e2e findings), the CLI reference and the cli skill. - Tests: TestProjectCache, TestMountRoundTrip, TestStartSetsProjectCacheOnce (the remount's outcomes), TestCutShort, TestBuiltCutShort, TestGuestMountOptions, TestFilledMounts, TestUpCacheMode, TestWarnMountCache, TestCacheAtNextStart, TestSwitchCache, TestSetMountCache, TestCheckStateCache, the mount_cache CLI test, clone_switch and the 0.1.0 fixture on Linux, and e2e's projectMountCache (findmnt, a stat-while-write loop, SQLite's journals, a shared writable mmap refused, the opt-in switch of an unchosen VM, what mmap does reported, macOS unchanged). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2865158e02 |
feat(network): learn the hosts a new VM needs, then lock it to them (#22)
--network learn runs a VM on the internet tier while it records the hosts it reaches beyond its allowlist, shown as internet (learning). devvm network lock picks which of them go into the VM's own rules, ticking only reviewed registries on 443 and listing risky hosts apart, then gives the VM the allowlist tier at once. learn is per VM only. The lock command names its docs page in its about. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
33ec9eb0dc |
refactor(tools): one definition per toolchain
Each toolchain is one image.ToolDef in image.SharedTools, which also holds its guest environment, its PATH folders and its version files. They leave base's devvm-tools.sh for /etc/devvm/toolchains.sh, which every launch writes, so base.sh changes and every image rebuilds once. The structure test's names rule fails on a toolchain's name as a literal outside internal/image, TestToolchainsComplete checks the toolchains page, and Contributing gains Adding a toolchain. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cda2d09f42 |
feat(gitprotect): on Linux, warn at each launch and report .git hooks and config that changed (#20)
Linux hosts have no unprivileged immutable flag, so devvm can't lock .git there. It now warns at every launch of a VM that mounts a folder with a .git (git_unprotected), unless it's a --clone VM or the user chose devvm git-protect off (git.chosen), and it names, after the fact, the hooks and config that changed (git_changed). It sums what a lock would cover, .git/commondir, include.path targets and the folder core.hooksPath names, never through a symlink out of the project folder and within bounds (git_watch_blind names what it can't fully watch), at each launch that finds the VM stopped and at devvm stop. A check on such a host runs protect's reports without locking: git_replaced, git_commondir, stray worktrees, git dirs that appeared, core.hooksPath and delegations into the project folder, and a submodule's folder that isn't a git dir (git_gitdir_not_git), in which nothing is created and which the watch doesn't sum as a git dir. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d8da01037 |
feat(tools): dotnet, the .NET SDK, as a shared toolchain (#7)
Adds `dotnet`, the .NET SDK, as a fifth shared toolchain next to node, python, rust and go. `--tools dotnet`, `devvm tools add dotnet` and the picker offer it, and a folder with `*.sln`, `*.slnx`, `*.csproj`, `*.fsproj` or `global.json` at its top level suggests it in the new VM's summary, the way `package.json` suggests node. Refs #2. Thanks to @jsskeen-utah for the detailed request. Co-authored-by: Claude Opus 5.5 <[email protected]> |
||
|
|
d94929523d |
feat(vm): a new VM shows a summary, then asks whether to customize it
Before devvm makes a new VM it shows a summary of what the VM gets: each toolchain, coding agent and layer with why (the file that calls for it, devvm setup, config.toml or the flag that gave it), its size, network tier and ports, and the devcontainer.json it's made as. Where the picker shows (CanPick) and something is left to choose, it asks "Customize it? [y/N]": Enter makes the VM as shown; y opens the picker (a part a flag gave greyed out), then the network tier question when no tier is given or saved, then the VM's CPUs and memory (for this VM alone). Without a terminal or with --no-input the summary ends with the flags that choose others. The summary replaces new_vm_gets and devcontainer_using. devvm's first run asks its size and agents first, as before, then shows the summary. A test build's DEVVM_PICK_ON_PIPE shows the picker with a terminal on stdin alone, so testscript's ttyin reaches it (up_customize.txtar). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ceda0bf925 |
feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).
The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.
devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.
Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c0f4b8fb5c |
feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none, in its state's net section (netpolicy.Tier), in place of on/off. Every VM has its proxy. Confined tiers start on NetProxy; open starts on the backend's own network with its proxy set in the guest (Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off. The proxy: Config.Open (every host and address, no floor, no policies), Config.DenyPolicies (files whose denies alone apply), the rule port :* (any port), and ** matching address literals (the floor still holds). Policies per tier (netpolicy.PolicySet): internet is network/internet.policy (**:*) plus your denies; none is the agents' built-in policies, the secrets' hosts and your denies; open none. Links: a client links only to a target on its tier or a stricter one, and a group's VMs are all on one tier. The self-check per tier: open asks its proxy through the guest's settings and warns (net_proxy_unreachable). devvm ls and devvm network show the tier. A backend without egress-proxy offers open alone (net_tier_backend). devvm network on/off and --network-policy/--no-network-policy map to allowlist/open. Design note, threat check and docs; e2e in the network and link sections. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9ca7a4859 |
feat(vm): a moved or renamed project folder keeps its VM
A VM's files and machine are keyed by its name's hash, which stays; what moves is the state's dir. The finder finds a folder's VM by the state that records its path (finder.state: the path's hash first, then every state, recorded), so a VM moved there is found from the new path alone, and links by path (project.ForDir) match the recorded dir. When the folder has no VM, the finder looks through the states for one made for this folder at another path (moveHere, move.go; the match is here.movedFrom): the same folder identity (device, inode, birth time), the folder this user's, its identity unique (platform.UniqueFolderID: an ID with a birth time, and on macOS APFS or HFS+), another recorded path that's gone on the folder's device or only a symlink to here, its creation finished, not a --clone VM. One match is offered: in a terminal move_vm, [y/N]; without one vm_moved_here, naming devvm adopt; devvm adopt --force moves it without asking. Several matches warn (vms_moved_here) and move none. Never automatic. The move (finder.move) refuses a folder no new VM may have (checkUnsafe), holds the creation locks of the VM and of the folder's would-be new VM, checks again that no state records the folder and that the folder is still the one asked about (move_folder_changed), stops a running VM as devvm stop does, then records the path and identity under the VM's lock, refusing a state that changed meanwhile (create_running); vm_adopted says so. .git protection's record is kept: .git, its identity and its uchg locks move with the folder. The project folder's mount is now part of backend.Want (Want.Project, Instance.Project, Apply), so the next start mounts the folder where it is: Lima's wantEdits rebuilds .mounts in its one edit when the project mount or the agent folders differ (mount.project). A VM running with another path asks to restart (Y/n) and otherwise warns (next_start_folder, folder_next_start). A new VM at the old path can't use the moved VM's folder, so newName takes the first of the path's names whose VM folder holds no state (project.Nth: the hash of the path, then of the path and n). devvm adopt [VM]: with VM (by name or alias, as devvm rm VM), moves a VM whose folder is gone or not connected to this folder, for a copy on another disk (a new inode, never matched on its own): adopt_move_vm [y/N], --force, adopt_move_refused without either; refuses a --clone VM (adopt_clone), a lost machine (rm_vm_lost), an unfinished VM, a folder still there (adopt_folder_there) and a folder with a VM of its own (adopt_has_vm). It clears .git protection's record, as the copy's .git is another. rm_vm_state_mismatch is gone, as a dir needn't hash to the name any more: devvm rm VM acts as devvm rm only on the folder's own VM (finder.folderVM), and a VM whose state names a folder with another VM of its own is refused as one whose folder is there. macOS's FolderID has the folder's birth time too, as Linux's has. Security review (security-audit skill, focused, with an independent read): inode reuse needs a unique identity (birth time; APFS/HFS+ on macOS), the same device (in the ID) and the old folder gone; another user's folder never matches (its owner checked); a copy has a new inode and never matches; links and groups go by name and stay, and links by path take the recorded dir, a move refused when another VM records it; a symlinked cwd is resolved first, and a symlink at the old path counts only when it resolves here; .git protection's record stays for a move and is cleared for a copy; agents' mounts are unchanged (only the project mount changes); a VM can rename only folders inside its own mount, which it already writes. Fixed from the review: a folder swapped at the path while devvm asked was moved to (now move_folder_changed); macOS device:inode could collide with a later volume given the same device number (birth time added); a running VM kept the old path's share, which a new folder made there would reach (the move stops it first); a move to the home folder or into devvm's own folders (now checkUnsafe). FolderID's format change makes VMs and .git records made before it look like other folders (adopt them, or make them again). Tests: TestMovedFrom (table: gone/present, same/different device and inode, a non-unique ID, another user's, a clone, unfinished), TestMovedAway (gone, a folder, symlinks here/elsewhere/dangling), TestMoveHere (refused, no, yes, found by its dir, stopped, the new mount at start, a restart for a running old mount, a new VM at the old path by its next name), TestMoveFolderChanged, TestAdoptMoved, TestMoveHereSeveral, TestAdoptVM, TestUniqueFolderID, ForDir and Nth in project, wantEdits' moved project, the conformance start's moved project; move.txtar (refused, no, yes, found, Lima's mounts edit, a new VM at the old path, adopt VM of a copy); rm_vm.txtar's hand-edited dir; e2e project: mv, refused, a yes in a terminal (script), the home file kept, the new path mounted alone, moved back with adopt --force. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
39c2ff4f4e |
test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of them) are one Go binary, internal/stubtest/stub, which acts as the command it's run as (argv[0]): limactl, docker, security, ssh, ssh-add, ssh-agent, ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags, tmutil, sw_vers, uname, open, code and mise, and stub, scripts' commands on the stubs' state. stub-log is gone: each stub logs its call itself, in one write to $STUB_LOG, its arguments on no other process's command line. - internal/stubtest builds the binary once, into $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link per command, which every test process and later run reuses until the sources change; a day-old folder of another build is removed. stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs' VM, Size, VMs, Keychain and SetKeychain on the state. - internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json, typed JSON under a file lock (Lima's instances with their status, size and config, the Keychain, the SSH agent and its keys, Time Machine's exclusions, the tools build VM's folder). The instances file wasn't locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes at once. - guest.go is the VM behind limactl shell and ssh alike: a --clone VM's git on vmfs, a remake's home, a base build's packages, the setup's tar, the direct connection, host keys, a forwarder's ports, link forwards. - A link session's master listens with a backlog of one and never accepts, as the Perl one did, so a killed session's socket reads as stale once probed (link_life). TestScript's cleanup stops the sandbox's masters by their -M -S arguments. - Structure: the stubtest layers cover internal/stubtest/..., the binary and its state import nothing else of devvm's; execSites lists internal/stubtest/build.go and internal/stubtest/stub/process.go. Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state: instances, size-<vm>, config-<vm>, keychain/<account>, agent-up, agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size, keychain, keychain-set, agent and agent-stop instead (build, existing, from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm, secret, size, space, ssh, ssh_agent, up). Tests: stub_test.go (every stub in-process, TestShellWords), stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima, platform, vm, tools and build tests use the state helpers and stubtest.Command. Coverage: internal/stubtest/stub and stubstate added, stubtest, build and tools raised (and lima, netpolicy on Linux). Docs: contributing (Stubs: the binary, logging, the state and the stub command, switches, the guest, adding a stub or a switch; Go test helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
50b0db2f7e |
refactor(vmssh): one host-key record per VM per start, which every ssh of devvm's checks
vmssh owns a VM's host keys: PinHostKeys reads them from the running VM through its backend (at most 64 KiB within 30 s) once for each start, into one record in the VM's folder, vms/<hash>/run/known_hosts (paths.VM.KnownHosts), whose first line names the start it was read for (backend.Run.ID). A record of another start is read again, keys read while the VM started again aren't recorded, and ErrNoHostKeys says none can be pinned. KnownHostsFor returns the record for the current start without reading, for links' sessions; ForgetHostKeys removes it before each start. ParseHostKeys is the one parser, for every key type: a line is kept only when its key decodes, names its own type and has more after it, and certificates, markers, patterns and anything else are dropped. The ssh config's entries, the port forwarder (-known-hosts), links' sessions and a --clone VM's git all check the VM against that record. sshconfig's own parser, recordHostKeys, changeKnownHosts, HostKey and ForgetHostKeys go, with the shared known_hosts and its lock (Dirs.KnownHosts, Dirs.KnownHostsLock): a record per VM, each written whole, loses no other VM's keys. The forwarder's ports.known_hosts copy and Forwards.HostKey go, and teardown leaves the record to the VM's folder. paths.Dirs's method limit drops to 47. Tests: TestParseHostKeys, TestPinHostKeys, TestPinHostKeysNone, TestPinHostKeysTogether (vmssh); TestForwardsStart and TestForwardsRun use the record; TestWrite reads keys again after a start, TestWriteUnreadableRecord (sshconfig); TestLinkConn refuses a target without a record and never reads one; up_test's call lists. The limactl stub shows a wire-format ed25519 key per VM. testscripts ssh (a launch keeps the record, a restart reads it again), up, existing, host_code, clone and layout updated; e2e's project and link checks read the VM's record. Docs: internals/security.md, design.md, overview.md, ports.md, lima.md, backends.md, git-protection.md, using/ssh.md and space.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bdc95ef6ee |
refactor(ports): port forwarding out of the backends, one owner in vmssh
The port forwarder is devvm's on every backend. vmssh (moved out of internal/backend) holds it, the link sessions, and its one owner, vmssh.Forwards: the lock, stop and start of a VM's forwarder, which ports it forwards read from vm.json (ports.Forwarding) each time, the listed ports a host program has left out (ports_taken), the host key devvm pins, and the backend's new ForwardTarget (user, key, host loopback port) and Lifeline. One hidden command, devvm _ports (cli/forwarder.go, vmssh.Main), replaces _lima-ports. The backend no longer forwards: SetPorts, Want.Ports, Confinement.Free, Confinement.HostKey and Confinement.Forwarded go; Lima keeps its own forwards off and gives ForwardTarget (Lima's ssh port on 127.0.0.1, Lima's user, _config/user). Lima's Stop and Delete no longer touch the forwarder, and Lima's Forget goes with the backend/ folder: the forwarder's files are in the VM's run/ (ports.pid, .status, .lock, .known_hosts) and logs/ (ports.log), its control socket run/port-<hash>.ctl. vm starts the forwarder after each start and on devvm ports of a running VM; devvm stop, rm, gc --orphans and an interrupted start stop it. vm/ports.go's hand rollback goes: the state changes first, and a forwarder that can't start only warns. A structure-test layer keeps backends from importing vmssh. Tests: TestForwardsStart, TestForwardsRun, TestForwarderMain, TestSplitPorts (vmssh); TestForwardTarget (lima); TestForwarding (ports); TestStartPorts, TestSetPortsRunning (vm); testscripts up, ports, layout, gc_orphans updated. Docs: internals/ports.md, backends.md, lima.md, design.md (Ports on Lima), overview.md, using/space.md, contributing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
51007fe851 |
refactor(backend): declarative Start, one Lima edit of what differs
Start takes what a VM's state asks of it, backend.Want (its size, agent folders, agent forwarding and ports), beside its Confinement, and a stopped VM's start changes only what differs, in one limactl edit with the confinement's own edits. CreateVM makes the VM as its spec's Want says (VMSpec embeds Want). SetSize, SetAgentDirs and SetAgentForwarding go, and with them vm_not_stopped: devvm size, ssh-agent and the agent mounts save to the state, and the next start applies them. A pure backend.Validate keeps the early refusal (disk_shrink) before anything changes. Lima's ports record (vms/<hash>/backend/ports) goes: which ports a VM forwards is vm.json's ports.forward alone, passed in Start's Want and in SetPorts, which now changes only a running VM's forwarder. Tests: backend TestValidate, TestFakeStartValidates; lima TestWantEdits, TestStartWantInOneEdit, TestSetPortsNoEdit, TestCreateVM and the forwarder tests on Want's ports, the real-Lima scenario's combined edit; vm tests read Start's Want; size, ports, up, up_size, layout and gc_orphans scripts. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f6f62d28a |
refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name, alias, image, chain, from, dir, folder, backend, backend_at, created) and one section per package, each a json.RawMessage its owner decodes into its own type (state.Section, state.SetSection), what was asked for at its top level and what devvm made under "made": net (netpolicy), git (gitprotect), ports (the new internal/ports), agent (sshagent), tools (tools), secrets (secrets), and size, clone, devcontainer, desktop and links (vm, internal/vm/state.go). - state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the file again, applies a change and writes it once; a failed change, or write, writes nothing. VM.Set and its calls are gone; read-modify-write of lists (links, publish, secrets, tools, size, ports) happens inside Update. VM.Claim also holds run/claims.lock, after the VM's own; VM.Create writes a new VM's whole record once, its alias chosen (sshconfig.ChooseAlias) under the claims lock. Reads take no lock. - created replaces "net unset" as unfinished (VM.Finished). - internal/ports: the ports section (forward, host.ssh/proxy/desktop), ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy and desktop ports under the claims lock (desktop allocated without one before; run/ports.lock and netpolicy's own ports key are gone). - gitprotect: mode recorded before the backend makes the VM (NewMode; clone for --clone, which ls and git-protect share as gitprotect.Mode); made.git_id (platform.FolderID), one git_dirs list for modules and embedded git dirs, delegations, protected; Unlock takes the union of recorded and current git dirs. - links' entries, git dirs, tools and devcontainer commands are JSON lists, not strings in values; the key=value parser is gone. - vm.checkState reads every section of the folder's VM as it's found. - registry.For drops its unused Dirs. - Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate, TestVMUpdateTogether (two writers on one VM and on crossed VMs), TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether, TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded, TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d2dc8c74b6 |
feat(layers): desktop is a built-in layer, not one of base's features
devvm --layers desktop (or desktop under the picker's Layers heading) gives a VM the Xfce desktop devvm desktop opens; base no longer has it. - assets/features/desktop.sh moves to assets/layers/desktop.sh, with a built-in layer's header, and assets/layers/desktop.policy (no rules: its packages come from the distribution's archive, which base's policy has). - image.DesktopLayer joins image.Builtins (desktop, docker, nix, sorted): reserved, listed under Layers, taken by --layers and completion, its policy read by netpolicy.Policies. - build: desktopFeature and chosenFeatures' special case are gone; until a choice is made, base gets every feature. devvm setup --features desktop is no_feature. - devvm desktop: desktop_no_feature becomes desktop_no_layer (devvm rm, then devvm --layers desktop), linked to the desktop page. The picker's row: pick_layer_desktop. - apt snapshot: base.sh's /etc/apt/apt.conf.d/50devvm-snapshot stays in base's image, and only guest/sync.sh (project VMs) removes it, so a layer built on base installs from the same snapshot and package lists; said in base.sh, desktop.sh and internals/images.md. - No backend feature: desktop builds and runs like any layer on Lima. base's image key changes (desktop leaves the features, base.sh's comment changes), so base rebuilds, now about 400 MB smaller without the desktop on the --from tier's every-feature base, and for anyone who chose it. Tests: TestBuiltins; TestOwnFeatures (devvm's features without desktop, every one until chosen, desktop refused); TestLayersAndCheckLayers, TestCompleteParts, TestPartFlags and TestUpPicker list desktop under Layers; TestBuiltinPolicies allows desktop.policy alone without rules; testscript: desktop.txtar (a base VM refused with desktop_no_layer, its build without the layer's script; --layers desktop builds the desktop image), setup.txtar (--features desktop is no_feature), the layer lists in build, layer, up and up_checks. e2e: the desktop section checks a base VM has none of the desktop's programs and is refused, then makes its VM with --layers desktop; from's Alpine VM gets the desktop layer too. Docs: using/desktop.md, using/images.md (built-in layers, desktop), using/customizing.md, using/from.md, using/_index.md, getting-started/commands.md, internals/desktop.md, internals/images.md (the desktop layer, the snapshot in layers), internals/design.md, contributing; the CLI reference for devvm desktop. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ffbc139969 |
test(lima): a contract test of the limactl stub against real Lima
TestLimactlStubContract runs scenario on dummy instances twice, through the real limactl and through testdata/stubs/limactl, and after each step compares every instance as devvm reads it from limactl list --json: their order, status, size, mounts, agent forwarding, ssh port and networks, and the edits each kind of start would make (startSets). The stub had drifted from Lima, and now matches it: - create ignored --cpus= and --memory=: every image was 4 CPUs and 8 GiB. - clone started from an empty config: Lima's keeps its source's config, size and lima.yaml (env), then --mount-none, then each --set. - Only --set .portForwards, .ssh.localPort and .env were kept: the mounts, .ssh.forwardAgent, .propagateProxyEnv, .hostResolver and .dns were dropped, so each start edited them again. The stub keeps any --set (and del()) in $STUB_DIR/config-<name>/, on create too. - delete left the VM's size and $LIMA_HOME/<name> (its lima.yaml). - list gave instances in the order they were made: Lima sorts them. devvm relied on the clone drift: a project VM keeps its image's propagateProxyEnv: false (from the build's start), so its first start without network policy edited it, where the CLI tests said it edits nothing. CreateVM now sets .propagateProxyEnv=true at the clone. And rebuild.txtar relied on the list order: it compares the deletes sorted, as Lima lists images by name. On Linux a layer's or the tools build's VM, cloned from a built image, keeps the config its image's build made, so Start edits nothing (no ssh port there) and the build's step count was one too many: cloneEdits counts the configure step only when Start edits (TestCloneEdits). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f4fd373439 |
refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend, Caps, Features, Review/Require, the registry, backendtest.Fake), so another backend is an addition. State from a smolvm VM reads as an unknown backend (backend_unknown_vm, gc_orphans_unknown); nothing migrates it. The image keys of layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images rebuild once. Lima's port forwarder moves off smolvm's files first: newForwarderCmd and forwarderMain from internal/cli/smolvmports.go to limaports.go, and assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder at run time, so no image key changes). Removed: - internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its registry entry, registry.Experimental and backend_experimental. - The decider: backend.Decider/UsesDecider, Confinement.Decider and DeciderToken, internal/proxy/decider.go and its test, the proxy's -decider, -decider-to and -decider-token-file, netpolicy's KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in vm's forwarding and UsedPorts. - backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and agent_unchosen_stop. - vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped). - paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing called (a test helper now). - ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and bump.sh's ubuntu_image, with its part of bump.txtar. - assets/smolvm/ and assets/container/; the no-init-system branches of layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in features/desktop.sh and guest/ca.sh. - Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh, creating_from_image, packing_image, pack_failed, backend_experimental, agent_unchosen_stop; descriptions naming smolvm reworded. - Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a failing or hanging Lima listing instead (the limactl stub's list-fails and list-hangs); the --backend smolvm examples; e2e's --backend smolvm and its section (about 1,130 lines), the smol_* helpers and the link section's backend switch. - Coverage: internal/backend/smolvm's lines in both baselines. - Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm notes (Ports on Lima now holds the forwarder's description), the backends table's smolvm column, every page naming smolvm, the README, the home page's backends art, and AGENTS.md's smolvm rows and gotchas (and the Docker bind-mount gotcha, which nothing refers to). Kept: the docker layer, on Lima; --from's local Docker; --backend, the BACKEND column and setup's backend choice, which the next commit removes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d8a7d4de7f |
refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/, where <hash> is the 14-hex hash of the project folder's path that the VM's name ends with: its state, its own rules (policy), its backend's files (backend/: record.json, key, known_hosts, proxy, ports and the port forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb, started, lifeline.pid, secrets.*, links.*) and its logs (logs/: network.jsonl, proxy.log, links.log). Build VMs keep the same layout in run/builds/<name>/. The top-level run/ holds only what isn't one VM's or must be short: the hashed control sockets, links' link-<hash>.sock/.ctl, the QEMU wrapper and the ports lock. A folder's VM is found by its path's hash (state.ReadHash), with the name and backend its state records, so devvm --backend docker then devvm in the same folder opens the one VM, and a backend's name limit applies to new VMs only. The state records the VM's name and its ssh alias, chosen once at creation (sshconfig.ChooseAlias) and never recomputed. Links' targets match recorded names, aliases and folders (project.Targets). One teardown (vmFolders.teardown) replaces Lifecycle.forget, undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's leftoverFiles: it stops the proxy and link session, then the pieces outside the folder (clone remote or .git locks, other VMs' links and the group, host keys, the backend's leftovers), removes the folder, and writes the ssh config. Each backend's Delete and Forget remove the VM's backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier one's folder was left clears it first. devvm space counts an orphan's whole folder as leftover state and the other VMs' logs as network logs. Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files (secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog, LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file, vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the user's cache folder for Lima's and smolvm's caches is Dirs.UserCache, from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and DockerVM go. vmname.HashOf and IsHash, project.Hash. The proxy takes the links' sockets' folder (-link-sockets, devvm's run folder) apart from the links' list, which is in the VM's run folder. Tests: a VM made and removed (rm, gc --orphans) leaves nothing under vms/, and with network policy has no file named for it outside its folder (TestTeardownLeavesNothing); a new VM over an old folder starts clean; lookup finds a VM made on another backend with a long folder name and makes no second one (TestLookupOtherBackend, and in docker.txtar); the alias stays put when a second VM shares the folder name (TestChooseAlias, ssh.txtar); every socket fits under a 35-character home with the longest VM name (TestSocketsFit); space counts an orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by hash and name; the proxy refuses a socket in the list's own folder. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
dd3f0deb3f |
feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).
internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.
devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.
ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.
Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4d863bb749 |
fix(cli): another part's name in --tools, --agents or --layers names the flag that takes it
The picker change's review: - --tools claude, --layers node, --agents node and the like are refused with part_other_flag, which names the flag that takes the name, as in devvm --agents claude; a name no part has keeps unknown_part or its did-you-mean. checkPartFlag checks the three parts' names together. TestCheckFlagValue, up.txtar, up_checks.txtar and setup.txtar cover it. - image.ToolName is back, with its TestValuePatterns row: ToolFile and ParseToolFile check a tool's name with it. - internals/design.md's Docker layer checks name parts_flags_ignored for --layers docker on a VM that exists, as e2e checks, in place of a message that's gone. - The home page and the README give the Claude Code token before claude's first start, the home page's list says which rows it shows checked, and the FAQ says the agents' config comes from your machine. The README says the first run asks for new VMs' size and agents before the list. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a134e0d8a6 |
feat(cli): choose a new VM's toolchains, agents and layers in a picker or with --tools, --agents and --layers
devvm takes no IMAGE word any more than any other: in a terminal a new VM's toolchains, coding agents and layers are checked in one picker, under three headings, before the network-policy question; --tools, --agents and --layers (each an exact list, or none) skip it, and a part left out takes its default: the detected toolchains, devvm setup's agents, no layers (a devcontainer.json's features still count). Without a terminal, or with --no-input, the VM gets the defaults and new_vm_gets says so in one line. devvm setup --agents (and its first-run question) chooses new VMs' agents. devvm tools in a terminal opens the same picker for the VM, its layers fixed, and turns the changes into tools add and rm. An image is base and layers only: tools are the VM's tool_names state key. build, rebuild and images rm refuse a shared tool (tool_not_layer), and devvm build builds no tool images. devvm ls gains a TOOLS column and --json tools. gc's --tools is --tool-images, so --tools has one meaning. Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or no_command_like, did-you-mean over commands, msg.Closest), the lacks path in internal/vm/existing.go, and the messages vm_lacks_tools, vm_lacks_layer, layer_is_command, layer_name_command, no_image_for, no_command_or_image*, tools_not_images, tools_not_images_rm, detected, vm_is_now (vm_tools_now), secret_with_image (secret_with_claude). New: ui.Pick takes headed sections with fixed rows, ui.CanPick, vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go), state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents, project.DetectFiles. Image keys are unchanged in form: images never held tools; docker.sh's and nix.sh's comments changed, so those layers rebuild. Docs: the home page's quick start steps, diagram (sandbox.svg), cards and FAQ; README; getting started; using (images' What a new VM gets, coding agents' Running an agent, settings' agents); internals; contributing; the cli skill; AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f71adb5a04 |
refactor: devvm's own files stay in the binary
assets.FS is the only copy of devvm's own files: nothing writes them to
~/.local/share/devvm/assets/<hash> any more, so an edit on disk can't
widen running proxies' allowlists or change a --from base its key
doesn't describe.
- Proxy: -builtin-policy NAME,... names policies in IO.FS (cli's _proxy
passes assets.FS; proxy stays stdlib-only). Built-ins are parsed once
at start (readBuiltins), ahead of -policy's files in the union, never
re-read; a missing one, or one with a line that isn't a rule, refuses
to start. -policy carries only the user's files.
- netpolicy: PolicyFiles(d, assets, vm, img) becomes Policies(d, vm, img)
(builtin, files); Proxy.PolicyFiles and AssetsInUse go. .proxy.policy
records both lists, a line each, for the restart check. ReadRules takes
built-ins from an fs.FS; RuleFile.Builtin.
- devvm network: built-ins labelled "# devvm: layers/base.policy";
--json entries carry "builtin": NAME or "file": PATH ("version": 1).
- Lima: createArgs ends in "-" and create() feeds base.yaml on stdin;
convert writes oci/ and, with company CAs, guest/ca.sh into its own
temp folder beside vm/ (writeScripts, state.WriteFile), mounted
read-only and deleted by the existing cleanup. Lima.assets() goes.
- Deleted: internal/state/assets.go and its test (WriteAssets,
StaleAssets, AssetsHash), paths.Dirs.Assets, gc's stale-assets plan
and the gc_assets/deleted_assets messages, space's devvm's files row.
- Tests: proxy built-ins (order, not re-read, missing/invalid refuse,
Main refuses before listening), Policies, the restart check on either
list, ReadRules/WriteRules labels, JSON shape, createArgs and create's
stdin, writeScripts' files and modes; CLI scripts check
$XDG_DATA_HOME/devvm/assets never appears after up, build and --from,
base.yaml on create's input (the limactl stub keeps it), the
conversion's mounts and script paths in its temp folder.
- Docs: design (One binary), install, overview, space, images (gc),
internals network, images and lima, safety/network, proxy README,
the network command's Long and its CLI page; AGENTS.md rule.
- Coverage baselines (darwin) raised: cli 88.2, netpolicy 87.2,
proxy 88.2, state 91.8. Dirs' method cap lowered to 41.
Image keys are unchanged: they already hash the embedded files.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
ddbc377f8f |
test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN and CFG by default, and adds stub_reset, catg (the one file a glob matches), vm_name VAR NAME (the folder's VM) and project NAME [git]; script_cmds.txtar checks each. Every script is rewritten onto them, its assertions kept; TestCommandLines leaves the scripts' own commands out. mise run test runs scripts/test.sh: the tests as before, with the CLI tests' devvm built with -cover for every package (CLI_GOCOVERDIR), merged with the Go tests' counters by go tool covdata, then scripts/coverage.sh holds each package to testdata/coverage/<os>.txt. mise run coverage raises the baselines; coverage.txtar checks the comparison. The macOS baseline is recorded from this tree. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f9e14e9b37 |
feat(cli): usage errors as devvm messages, checked before anything runs, exit code 2
Every argument and flag error is a devvm message naming what the command expected, followed by usage_help naming that command's own --help, and exits with 2. Arguments and flag values are checked in Args, before the root's PersistentPreRun and any VM lookup. - internal/cli/args.go: noArgs, exactArgs, maxArgs, minArgs (argsN, with ValidArgs), argsOf (the arguments in Use), checkCommands (wraps every command's Args with checkFlags and marks RunE's errors as ranError), checkFlagValue (--cpus, --memory, --disk, --ports, --lifetime, --older-than), exclusive (flag groups checked first, then Cobra's own required flags and groups), flagError (SetFlagErrorFunc: pflag's NotExist, ValueRequired, InvalidValue, InvalidSyntax errors). - Execute: 0, 1 for a failure (RunE's error: a message, or output_failed), 2 for a usage error; usage_error is only the fallback. - Checked early: ports LIST and add/rm LIST (vm.ParsePortList), network allow/deny RULEs, network on/off(/ask with -g), layer new NAME (build.CheckLayerName), retention KEY=VALUE (state.CheckRetention), setup --features '', secret NAME, completion SHELL, git-protect and ssh-agent values. - ui.UI.Error prints an error without ending the run (UI's method limit 44). - Messages: usage_help, arg_missing, args_too_many, args_none, arg_not_choice, no_subcommand, flag_unknown, flag_needs_value, flag_bad_value, flag_bad_switch, flags_exclusive, output_failed; usage_error reworded; doc links to troubleshooting. - Tests: TestUsageErrorsEveryCommand, TestRanErrorIsAFailure, TestArgsOf, TestFlagErrors; txtars check message names; e2e checks a bad port list exits 2. - Docs: troubleshooting (a command refused before it runs, exit codes), contributing (command arguments), AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
e76cb894b5 |
fix: verify the core on macOS and Linux
Full e2e (default and --from) on macOS and --from on a nested Linux host, plus deadcode. Fixes: - ui: a logged command a signal ended (or exited 128+) waits up to 1 s for devvm's own interrupt, so Ctrl+C that ends the command first no longer prints its failure (seen on Linux in from.txtar's Ctrl+C case; TestACommandEndedByTheSameSignalPrintsNothing, TestKilled). - mise.toml: minisign only where it has builds (no linux/arm64), so mise run works on arm64 Linux. - up.txtar: the .git protection warning is checked in devvm's stderr, not after stub_calls (it never matched on Linux, and macOS's negative check was vacuous). - up_size.txtar: a default memory of 5 GiB, not 16, which a 16 GiB host reports as 15. - qemu.txtar: "no real QEMU" no longer has /usr/bin on PATH, where Linux hosts have QEMU. - TestUp: its protector is macOS's, as its Env. - e2e: pgrep patterns are [_]proxy (Linux's pgrep -f matched the check's own shell: the proxy-gone check failed, the proxy-runs check passed vacuously); a cached base's key comes from the fixture's chain, not the newest record (another selection's base); base's features check is counted as SKIP when base is cached, so runs compare their counts. Deadcode removed: ui.Logged (callers use LoggedCmd; tests get a helper), paths.rootOf (its tests now test resolve), tools.Lock.Tools (moved into the tests). Kept for their commands: backend.Emulated, state.WriteSize/WritePorts/WriteBackend/writeValue/ReadAgentKeys/ WriteAgentKeys, tools.Lock.Version, Tools.All, Tools.Garbage, backendtest. New mise task: deadcode (x/tools v0.52.0). Docs: testing.md (platform table, Linux host setup as verified, x86_64, the manual check for an image only Docker has); contributing links it and lists deadcode and SKIP. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f2aa210bf7 |
feat(up): existing VMs, restart, remove, update, adopt and rm
devvm opens a VM that exists instead of refusing it: unfinished VMs (no state or no network choice) are refused before anything; --backend, --network-policy, --no-git-protect, --cpus/--memory/--disk and --ports are ignored with a warning each; an IMAGE naming what the VM lacks adds it in place after asking (tools built and listed, a layer's script run in the VM, new agents' folders mounted with a stop first); outdated images and newer tools are warned about, the daily tools check runs, agent folder mounts follow the host's, .git is checked per run, set-id files are named on Linux, a stopped VM gets the size and ports its state asks for (a running one is told they apply at its next start); then it is started if stopped (a running VM with network policy keeps its proxy), the self-check runs (a failure stops the VM), and it is set up and its shell opened. Commands: restart (stop, then open), update (newest shared tools, built from base, then open), remove TOOLS (out of the image and tool list, then open), adopt (a VM made for an earlier folder at this path, after asking; .git protection restarts as appeared), rm [-f] (exports the agents' history first unless -f, a failed export keeps the VM; a VM of an earlier folder only after asking, without export; deletes the VM, state, proxy, rules, run files, logs, .git locks, host keys and ssh config entry, also when the delete failed but left no VM). Inventory: - vm: find/findExisting/existing, sameFolder, open, run, setUp, warnIgnored, checkSetID, applySize, applyPorts, addLayers, wantedImage, runScript, buildTools; Restart, Remove, Update, Adopt, Rm, export, delete; start refuses vm_unfinished and stops a leftover proxy for VMs without network policy - gitprotect: Protector.Check (replaced, appeared, new submodules in the tree and .git/modules, unlocked hooks, commondir, delegations on change; locks only while stopped; unset protection set up as new), Locked field; platform.Immutable - tools.Update takes a build func; build.Builder.LayerScript exported - cli: restart, remove, update, adopt, rm; withEnv; root Long - messages: vm_other_folder (reworded), vm_other_folder_rm/_adopt, delete_other_folder_vm, adopt_vm, vm_adopted, vm_already_here, no_vm, vm_unfinished, backend/net/git_protect/ports_flag_ignored, size_flags_ignored, size_next_start, ports_next_start, add_in_place, restart_for_mounts, no_terminal_confirm, keeping, adding, add_layer_failed, vm_is_now, exported, export_failed, deleted, rm_failed, adopt_failed, git_replaced, git_appeared, git_embedded_new, git_hooks_unlocked; net_unenforced_stop says devvm starts it again confined; vm_exists removed - tests: testscript existing.txtar, existing_agents.txtar; Go tests for Check (five per-run reports, replaced/appeared, off/unset), open with network policy, addLayers, Rm, Adopt, remove/update/restart; limactl stub: delete-fails, Exec-fed scripts - converted bats: delete (vm_unfinished, rm cleans up after a failed delete, rm deletes only this VM), project (folder made again, update twice, remove twice, five .git per-run reports), ports (applied once, restart warning), size (restart warning), cli (rm forgets host keys) - e2e: project (stop and relaunch, running relaunch, restart with host keys, swapped .git, new submodule locked, rm unlocks; agent folder added/removed on restart, rm exports history without logins), tools (update, remove), network (relaunch confined, unenforced relaunch stops it, rm -f) - docs: commands.md (existing VM, adding, deleting, a folder made again), coding-agents.md (mounts on launch, history), git-protection (on each launch), images, network, security; CLI reference Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4bdb3ea843 |
feat(ssh): ssh config and pinned host keys
Each running project VM can be reached as devvm-<folder> (or by its full name when two folders share a name) through ~/.config/devvm/ssh_config, which up rewrites after the VM's setup. Every entry checks the VM's own host keys, kept in ~/.config/devvm/known_hosts and read from the VM through its backend, and sets StrictHostKeyChecking yes, ForwardAgent no (unless the VM forwards), and its own connection. Only Lima's login options are copied. Host keys are dropped before each start, and when an interrupted new VM is deleted, so they're read again. Ported: write_ssh_config (sshconfig.Write), record_host_keys, forget_host_keys (ForgetHostKeys, in vm start and the interrupt cleanup), ensure_ssh_include (EnsureInclude: asks with [Y/n] on a terminal, else says to add the line; no caller yet: --clone and devvm ssh/code), ssh_alias (Alias), is_project_vm (project.IsVM), check_ssh_agent (vm checkAgent, run when a new VM forwards the agent). Backend.SSH's SSHTarget gains Options (Lima: identityfile, identitiesonly, preferredauthentications, batchmode, compression, gssapiauthentication, ciphers). Registry.All, state.WriteFile. Messages: ssh_include_needed, ssh_include_yourself, add_it_now, ssh_include_added, no_ssh_agent, ssh_agent_empty, load_key, key_loaded, key_loaded_keychain, load_key_with. Doc links: ssh_remote_hint, ssh_include_yourself. Converted bats cases: cli.bats "ssh config: only running VMs, each with its own host key checked; Lima's unchecked settings left out" (ssh.txtar, lima TestSSH, sshconfig TestWrite; the rm half waits for rm), delete.bats "ls and the ssh config include a project VM named like an image" (ssh config half: ssh.txtar, TestWrite), project.bats "ssh_alias: short name unless two folders share it" (TestAlias, ssh.txtar). New: TestWriteUnchecked, TestParseHostKeys, TestEnsureInclude, TestCheckAgent, TestIsVM. Stub limactl: Lima-like ssh.config at start, host keys from shell, sshLocalPort/sshConfigFile in list. e2e: project checks the hostname, the entry, pinned host keys, ssh devvm-web through an ~/.ssh/config of the run's own (Include plus Host * ForwardAgent yes), no agent forwarded (a throwaway agent), a changed host key refused; network checks ssh devvm-net. Nothing touches the real ~/.ssh. Docs: ssh.md (from the ssh page), linked from the index, commands, security, images and contributing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ff57370ffb |
feat(network): network policy for VMs
A new VM can get network policy: --network-policy, else a question in a terminal (no by default), else off. devvm makes its CA, writes the VM's secret bindings, starts the VM's proxy (devvm _proxy, its password in a file) and starts the VM confined to it, then runs the self-check before the setup and the shell: a VM that isn't held to its proxy is stopped. Tokens stay on the host; the hidden devvm secret get reads them for the proxy, from the Keychain or a file. e2e gets a network section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
42d3fd4356 |
feat(tools): shared tools
The toolchains and agents an image name holds (node, python, rust, go, claude, codex, opencode) are shared tools: resolved per user into the tools lock by devvm's pinned, checksummed mise, built once into read-only EROFS images in a throwaway VM from base, and mounted into every VM that names them. The lock is checked again daily, in the background through devvm _refresh-tools, and before a new VM when due. Copies tools/ and guest/tools.sh, and the shared tools part of guest/sync.sh, which a new VM runs once it starts. e2e gains a tools section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
53c37e4dee |
feat(up): create a project VM and open a shell
devvm [IMAGE] in a folder creates its VM: the folder checked (its path, unsafe folders, a folder made again), its size and ports, the image named or detected and built, cloned with only the folder mounted, its state, .git hooks and config locked (macOS), started, then the backend's shell in place of devvm. Network policy isn't there yet, so a VM is created only with --no-network-policy; an existing VM is refused for now. Ctrl+C before the first shell deletes the VM and unlocks .git. Global flags: --backend, --network-policy/--no-network-policy, --cpus, --memory, --disk, --ports; up's own --unsafe-folder, --no-git-protect. tests/e2e.sh gains a project section, with Lima's Exec quoting checked on a real VM. New docs: commands, security model, .git protection. Co-Authored-By: Claude Opus 5.5 <[email protected]> |