mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
81f3feeecf69f3e29d6de3e4ee213b32905eaaa4
46
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
edce817b4f |
test(cli): cp_exe copies devvm for scripts under the fork lock, no text file busy
On Linux, a child another script forked while testscript's cp held the copy's write descriptor kept it open until that child exec'd, so running the copy failed with ETXTBSY. cp_exe writes it under syscall.ForkLock; upgrade.txtar and release_notice.txtar use it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d44175601 |
refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2545de19f3 |
test(e2e): the Go runner is the entry point, mise run e2e -- FLAGS, and tests/e2e.sh goes
TestE2E already set up the sandbox, slots, locks and flags itself, so the 898-line script only handed over. The run is now `mise run e2e -- FLAGS` (go test -tags e2e from tests/e2e, CGO_ENABLED=0) with the same flags: --only, --from, --clean, --every-feature, --slots, --slot, --newest-base, --golden, plus --reuse. - options: the flags named as the script's options; the hand-over flags (lock-holder, count, total, started, summary) and the ported/unported split are gone. - e2eUbuntuRelease, a const in sandbox_test.go, holds the Ubuntu pin; scripts/bump.sh e2e-ubuntu moves it (get_const), and TestE2EUbuntuPins, bump.txtar and the E2E workflow read it there. - From the script into Go: the OpenSSL-not-LibreSSL host check, and --newest-base's start line and its UPSTREAM DRIFT summary. - The script's leftover bash helpers (perl vm_state, no_leak, ca_*, lima_listens, the retry list, its heartbeat) are gone with it. - mise's e2e:go task merges into e2e; TestCommandLines drops its $D rule. - Docs (contributing, testing, maintaining, internals) and AGENTS.md name mise run e2e; testing.md's "Porting a section" becomes "Adding a section". Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b045eff522 |
feat(cli): say at a launch in a terminal when a newer devvm release is out
A launch in a terminal checks at most once a day for devvm's newest release, with upgrade's Source.Check in the background (5 s at most, the launch waiting at most 1 s more once it's done), and records what it found in the data folder's cache/release.json (latest, checked, tried; an offline try keeps what was known, silently). The next launch says upgrade_available in one line when that release is newer. Nothing without a terminal, with --no-input, for a source build or for a copy neither install.sh nor Homebrew installed. Off with config.toml's release-check = false or DEVVM_NO_RELEASE_CHECK=1. devvm doctor shows the newest release known (doctor_latest_release, --json's release). - upgrade: Known, ReadKnown, Due, Newer, Source.Refresh - settings: ReleaseCheck, KeyReleaseCheck (strict bool) - paths: Dirs.ReleaseCheck (Dirs' limit 58) - cli: releaseNotice in up; doctor's Release - tests: release_notice.txtar, TestKnown, TestRefresh, TestReleaseCheck; the CLI tests set DEVVM_NO_RELEASE_CHECK=1 by default - docs: settings (the release check), install, troubleshooting Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5f7289e6f7 |
feat(cli): devvm upgrade, the newest release the way devvm was installed
devvm upgrade [--check] [--to VERSION] [-f/--force] [--json] installs devvm's newest release the way this devvm was installed, asking first (upgrade_confirm, answered by --force). upgrade is a top-level exception in the cli skill: it acts on devvm itself, not this folder's VM, and it's the name other tools give the verb. It skips the layout check, as a layout a newer devvm wrote is a reason to run it. - install.sh's (<prefix>/lib/devvm/<version>/devvm, which <prefix>/bin/devvm links to): SHA256SUMS and its .minisig over HTTPS, the signature checked against the key built in from packaging/minisign.pub (packaging/key.go embeds the folder; no file, no key, and upgrade_no_key), the archive's SHA-256, unpacked into lib/.<v>.new.<pid>, run (--version), renamed to lib/<v>, the link switched atomically (symlink beside, rename over), run again through the link, rolled back on any failure; then older versions pruned as install.sh does (kept: the one that ran, any a running process names, another upgrade's staging folder). - Homebrew's (a Cellar/devvm/ keg): brew upgrade devvm, asked first, through the run log; --to refused. - Anything else: says how it was installed (a checkout build, go install, a copy elsewhere) and fails. - Already latest says so; a newest release older than this devvm is refused even with --force (rollback); --to installs a named one, older asked about (upgrade_confirm_older). --check and --json install nothing. minisign verification is Go's: ed25519 over blake2b.Sum512 for the default prehashed ED signature (legacy Ed refused), the key ID, the global signature over signature||trusted comment, and the trusted comment "devvm <version>" as scripts/release.sh writes it. Verified against a signature minisign 0.12 made. golang.org/x/crypto v0.58.0 added for blake2b only (approved; depguard allows only golang.org/x/crypto/blake2b); MVS raised x/text to v0.43.0 and x/tools to v0.51.0. mise run vuln: no vulnerability reached; the module-level GO-2026-5932 is x/crypto/openpgp, which devvm doesn't import. New: internal/upgrade (Detect, Source: Latest, Check for the release notice to call, Fetch; ParsePublicKey/Verify; Valid/Compare; Upgrader), internal/upgrade/upgradetest (TLS release server, minisign signer; tests only, a structure layer), fetch.Resolve (where a HEAD's redirects end), fetch.Download's size cap (mise's 256 MiB too). Test-build overrides: DEVVM_REPO_URL, DEVVM_RELEASE_KEY, DEVVM_RELEASE_CA, DEVVM_TEST_VERSION; script command release_server [-badsig]. Security review (security-audit skill, guidance mode, a fresh reviewer): - Prerelease order compared suffixes as text (rc.10 < rc.9), which let an older signed prerelease past the rollback refusal: fixed, semver precedence, with table cases. - No cap on the archive download (a host could fill TMPDIR before the checksum failed): fixed, fetch.Download takes a limit. - Two upgrades at once: prune removed another's staging folder: fixed, .<v>.new/old.<pid> folders are kept while that pid runs. - A failed rollback of the link was silent: fixed, upgrade_rollback_failed names the link and the old devvm, and the new folder stays so the link isn't left dangling. - QEMU's guestfwd names devvm with commas doubled, which the in-use check missed: fixed. - Freeze (a host serving the current version as newest forever): no boundary crossed, inherent without signed expiring metadata; documented in internals/install.md. Checked sound: nothing untrusted runs or unpacks before the signature and SHA-256; versions from the redirect and --to pass Valid before any URL or path; tar takes only regular files in its one folder (no links, subfolders, ..), 512 MiB cap, fixed modes; test overrides are read only by test builds. Tests: minisign (real minisign fixture, tampering, legacy, other key), each install kind against the fake TLS server, bad signature, wrong trusted comment, replaced archive (wrong SHA), bad archives, a new devvm that fails before and after the switch, a failed switch (old kept), a failed rollback, downgrade refused and --to, pruning, Homebrew via a brew script, Check, Latest's failures, Compare; CLI test upgrade.txtar. Docs: getting-started/install.md (Upgrading: how, what it checks, an older release, --json), getting-started/commands.md (This machine row, Upgrading devvm, questions, output for scripts), internals/install.md (devvm upgrade), contributing (release_server), the CLI reference. 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]> |
||
|
|
e93f29333a |
feat(ubuntu): pin the newest signed cloud image at base's first build
devvm's files keep only Ubuntu's release (26.04) and its cloud image key. The first build of base on a machine pins the newest dated release whose SHA256SUMS carry a valid signature from that key and list an image for the host (state.UbuntuPin, images/ubuntu.json), and every later build uses the pin without looking anything up. devvm rebuild base pins the newest again. The pin is in base's recipe, so base's key hashes it. The signature is checked in Go (internal/ubuntu/pgp.go: OpenPGP v4 RSA signatures with SHA-256/384/512, the standard library's crypto), so no gpgv is needed and a host without one is no longer unchecked. - backend.Images gains PinOrigin (backend.Pin: PinFirst, PinNewest, PinOlder); internal/build pins before it keys a build, and says what it pinned (origin_pinned). - Lima: Origin and createFromUbuntu read the pin; PinOrigin finds the newest with ubuntu.Finder (Newest, Release) under images/locks/ubuntu; a --from conversion pins only when nothing is. - Messages: ubuntu_unreachable and no_ubuntu_release; ubuntu_unsigned and ubuntu_checksum_unpinned are gone. - e2e pins its own release (DEVVM_UBUNTU_RELEASE, a test override; scripts/bump.sh e2e-ubuntu moves it); bump.sh's apt moves the package snapshot alone. The gpgv stub is gone. - Tests: the verifier against Ubuntu's real signature and a test key (damaged keys and signatures, packet and subpacket lengths, armor), Newest/Release, PinOrigin, the pin record, and the key covering the pin. 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]> |
||
|
|
8e914b17c9 |
refactor(proxy): one typed, versioned config for every proxy, read as a private file
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON (version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by backend.ProxyStarter) both use. It holds what the flags and the run folder's sidecars held: the address, the VM, the password (proxy.auth), the built-in policies and the user's files (proxy.policy), the logs, the lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix cache and its cap, the links, and the SHA-256 of devvm's binary and CA (proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole, mode 600, before each start, and starts a running VM's proxy again when the config it would start it with has another Sum. ReadConfig reads it as the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat, a regular file owned by the proxy's user that nobody else may read or write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a loopback listen address. The VM's proxy is found by _proxy -config with its own config's path. paths.VM names ProxyConfig, ProxyPID and ProxyStatus. Policy files are read only as regular files of at most 1 MiB (proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong; ErrNotPrivate for the config and the links' list); the proxy keeps a file's last rules and logs why once. hostOK refuses a name with an empty label (evil.test.., evil..test, .evil.test), so no form of a name gets past a deny the policy's own trim would miss. A build proxy that can't be spawned leaves no config behind. Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a folder, group-readable and group-writable files, a long file, other versions, unknown fields, two configs, no password, non-loopback addresses, a CA without its key, a negative cap; ReadRegular and the policy readers on a FIFO, /dev/zero and a big file without hanging; the running proxy keeping its last rules; hostOK and requests with empty labels (failing on the code before); Prepare's config, restarts on a binary change, a missing config and one others may read; concurrent config writes; the build proxy's config and its removal; proxy.txtar, network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the config's mode, password and the proxy's arguments. 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]> |
||
|
|
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]> |
||
|
|
1917072228 |
refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the default backend and smolvm stays experimental. The backend architecture (Backend, Caps, Require, the registry, backendtest.Fake) stays, so another backend is an addition. Removed: - internal/backend/docker, its registry entry and Names/Experimental's docker half; devvm _docker-connect and _docker-ports (internal/cli/dockerssh.go); assets/docker/unpack.sh. - Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS, DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256 ldflags vars and the CLI tests' Linux-build archive (linux_release). - Interfaces only Docker implemented, with their callers: backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix), DiskUser (ls's and size's disk-over warning, size's disk_used and --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover (gc --orphans' volumes, networks, containers and images), DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name. - The docker layer's runtime on a backend that makes VMs for it: vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet returns a bool now), the refusals at start and devvm network on, ls's "(sysbox)" and --json docker_layer, size_disk_default_unused. - The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix). - paths.Dirs.Docker and paths.VM.Lifeline. - assets/guest/tools.sh's linked-folder branch; services.sh's DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd. - Messages: every docker_* the backend used, docker_layer_runtime, net_docker_layer, net_off_docker_layer, committing_image, pulling_image, unpacking_tools, disk_over, size_disk_default_unused, gc_orphan_volume/_network/_container/_image, docker_connect_failed; gc_orphan_elsewhere reworded. - Tests: docker.txtar, the docker stub's engine (its --from half stays), the ssh stub's login-shell branch; e2e's --backend docker, --engine, the docker host VM and Docker Desktop runs. - Release: one GoReleaser pass, no Linux-build pin in the macOS builds, no Linux devvm in the Homebrew formula's libexec. Linux builds stay. - Docs: backends/docker.md and internals/docker.md, design.md's Docker notes, the Docker column of the feature table, and every page's mentions of the Docker backend, Docker Desktop as one, and Sysbox. Kept: the docker layer in Lima VMs, devcontainer docker-in-docker, --from with images only a local Docker has, Docker Hub references. State written by a Docker VM before this reads as an unknown backend (backend_unknown_vm). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
299ddb1476 |
refactor(state): image records in images/<key>/, rebuild counters per backend and --from, tool image records, cache/
- Image records are images/<key>/record.json (JSON, unknown fields ignored; name, chain, from, digest, libc, built). state.Images lists the folders; AnyImage needs a record.json; RemoveImage deletes the folder. Lima's cache cleaner reads records through state.Images. - Rebuild counters are images/rebuilds.json, keyed by (backend, from as given, name), changed under images/locks/rebuilds. image.Inputs takes them through an image.Rebuilds interface. A rebuild on one backend no longer outdates the others' images, and two --from references that wrote the same counter name (node:24, node-24) stay apart. paths.RebuildFile, RebuildName and unsafeName are gone. - Tool images: <file>.sha256, .target and .idle become one <file>.json (sha256, libc, format, backend, built, idle_since; state.ToolImage). BACKEND and LIBC read the record; the fallbacks (format matching, a VM's target, the current target) go, with toolTargets, vmToolTargets, formatBackend and gc's backendTools (toolsOn does it). Share.IdleFor owns reading idle_since. - cache/ (Dirs.Cache) holds mise/, nix-cache/ and from-digests.json. With the cache gone, from.Recorded takes the newest base record's digest for the reference, so no key changes. - Key check: the rebuild counter is the one input that moved and changes keys (deliberately: per backend and exact from). The --from digest moved to cache/ and stays an input, kept stable by the records' fallback. Records, mise and the Nix cache are outputs. - Tests: state's image, rebuild, digest and tool record tests; image key cases per backend and exact from; build.TestRebuildIsPerBackend; from.TestRecordedWithoutTheCache; cli.TestToolsOn; rebuild.txtar (Docker's and smolvm's rebuilds keep Lima's and the other --from's bases), gc_caches.txtar and from.txtar (a missing cache/); the testscript command json_set; e2e reads the JSON records. - Docs: space, images, settings (retention), internals images, overview, network, security, contributing (json_set). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d01a1872ca |
test(smolvm): the listed range in smolvm.txtar is two free ports
smolvm.txtar listed host ports 8000-8001 and expected no ports_ warning, so it failed where a program has port 8000, as a dev server on the Linux test machine does (ports_taken ports=8000). free_port gets -range FIRST LAST, two adjacent ports free here, and the script lists $FIRST-$LAST as it lists $LISTED and $UNLISTED. The other scripts' fixed ports are either guest ports (link publish and add) or lists whose host check nothing asserts (up_size, ports, devcontainer, the sshd and many sections of smolvm.txtar), so they pass whatever holds them. Test: with a listener on 127.0.0.1:8000, the script failed at smolvm.txtar:73 before (ports_taken count=1 ports=8000) and passes after. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6f9259b514 |
test: give each CLI test script its own coverage folder
The CLI tests' devvm is built with -cover, and every script set one GOCOVERDIR. Go names a run's temporary meta-data file by the time (time.Now().UnixNano(), microseconds on macOS) with no process ID, so two devvm runs from parallel scripts that start together write the same temporary file; the first renames it and the second's rename fails, and devvm prints "coverage meta-data emit failed" on stderr, failing any script that checks stderr (seen in ls.txtar and version.txtar). - script_test.go: scriptCoverDir sets GOCOVERDIR to a folder of the script's own (os.MkdirTemp under CLI_GOCOVERDIR). - scripts/test.sh: covdata merge takes the unit folder and every non-empty script folder as one comma-separated -i list, so percent and the baselines read the same counters as before. - Contributing's Coverage section says each script writes to a folder of its own, and why. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2687eec488 |
refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns devvm's background processes: Detach and Spawn (own session, no input, reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status file), Handle (signals through the process started), Proc (a pid file checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL, the pid file removed once stopped), readiness by status file (Ready, WriteStatus, WaitReady: the pid and data, written in one line-ended write, never another start's), Alive and Signal (no pid below 1), and one lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content equality, a bounded wait past what the file held first). It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards' pid, stop and start wait, the build proxy's process and log-read port, links' link-session pid, stop and start, the proxy's watchLifeline and vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess, and the alive copies (netpolicy alive/signal, lima alive, vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go: the proxy and the forwarder say they're ready in a status file, and the build proxy's port comes from its own. forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside internal/daemon and internal/platform, with its line in testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS and puts internal/daemon among the leaves; depguard holds it to the standard library. Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file, groups refused, readiness, lifeline), characterisation tests first for the proxy's, the forwarders', the link sessions' and the build proxy's pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
bdd26779b4 |
fix(cli): only a test build reads the test overrides
DEVVM_HOST_MISE (which replaced the pinned, checksummed mise), DEVVM_KVM and DEVVM_UBUNTU_URL were read in every build, a release's included. One ldflag in a leaf package, internal/testbuild (testBuild=yes, set by tests/e2e.sh and the CLI tests), now marks a test build, and cli's readOverrides is the one place devvm reads every test override, into Overrides (registry.Overrides, with platform.Overrides for the host's size, and HostMise): empty unless testbuild.On(). registry.New takes them; lima.New takes Ubuntu's URL; ubuntu.New takes a URL, not getenv; Lima's and smolvm's KVM default to /dev/kvm; tools.Env has Mise in place of reading DEVVM_HOST_MISE; platform.NewHost takes Overrides. Gone: registry.unreviewed, registry.Host, newFor, hostFor, ubuntu.URLEnv. The documented settings (DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE, DEVVM_NO_TOOL_CHECK, DEVVM_FROM) stay as they are. Tests: TestReleaseReadsNoOverrides (cli: a release reads none, its mise, KVM, unreviewed and host its own), TestOverrides (registry: every override reaches its backend, none leaves the defaults), TestHostOverrides and TestListTimeout (platform) and ubuntu's TestNew moved to the new shapes. Docs: contributing/testing.md's Test builds, contributing's sandbox table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9b7652d347 |
feat(link): links in VMs' lifecycle, and the link backend feature
backend.FeatureLink ("link"), native on Lima, smolvm and Docker, with its
row on internals/backends.md; linkFeatures() returns it, so link add, each
launch, the session and each connection check it with Require.
- Env.Links is guestLinks: an address and a name per target, by address,
none for a target whose policy rule no longer holds.
- Launch (setUpVM, after the ssh config pins host keys): linkRuns.atLaunch
starts devvm _links detached (pid in run/<vm>.links.pid, its log in
logs/<vm>.links.log), warns once per stopped target (link_target_stopped)
and per target whose policy rule broke (link_policy_mismatch) or whose
backend lacks links (link_target_unusable), never starting one, and
reads the new session's log for refused forwards (link_port_taken).
- link add and link rm on a running client send the setup again and make
sure _links runs (linkRuns.apply), reporting a new link the VM refused;
on a stopped one, links_next_start.
- Stopping: Lifecycle.Stop and every Env.start stop the session; a session
killed has its sockets removed; its masters' control sockets go with
their ssh.
- devvm rm (Lifecycle.forget, so gc --orphans and retention too) stops the
session and removes every link to the VM from other clients
(links_target_gone), giving running clients their links at once.
- devvm network off on a target linked by clients with policy
(network_off_linked) and on for a client linked to a target without
(network_on_linked) are refused.
- link unpublish names the clients that link to the withdrawn ports
(unpublished_linked).
- devvm ls has a LINKS column and "links" in --json; devvm doctor lists
link; gc --orphans removes links to VMs without state and link sockets
nothing listens on, which devvm space counts as leftover state.
- net_off_log says devvm logs only a VM's links' connections without
network policy.
- Lima: Start already compares the guest environment, so it edits only
when the links' names change (TestStartSetsLinkNames); lima.md and the
design note say the edit's new host keys are pinned again at the start.
Fixes to the earlier link code: vmssh's masters left their control
sockets when killed; the session's log names a forward the VM refused on
a line of its own (ReadLinksLog).
Tests: vm TestGuestLinks, TestPolicyLinked, TestUnlinkTarget,
TestLinkLeftovers, TestLinkRuns, TestLinksAtLaunch; vmssh TestReadLinksLog;
lima TestStartSetsLinkNames; link.txtar updated, link_life.txtar new, the
stub ssh carries link masters; e2e's project section has a link smoke check
on Lima.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
608d287d00 |
test(cli): devvm space's backend timeout is a test-build setting, so the space script doesn't depend on load
A test build's Host reads DEVVM_TEST_LIST_TIMEOUT (platform.TestListWait):
comma-separated durations, each for every backend ("10m") or one
("smolvm:1s"), one backend's winning. spaceTimeout(backend) reads it
through registry.Host(), so a release always waits 30 s. devvm space's
listings and strays and gc --caches' cache listing use it.
The CLI tests' fakeHost sets 10m for every script. space.txtar adds a
case where smolvm's listing hangs (the stub's smolvm-ls-hangs) past a
1 s smolvm timeout: smolvm is named (space_backend_unknown) and its VM's
state isn't a leftover. TestListTimeout covers the parsing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
7d49772eb4 |
feat(doctor): devvm doctor and the backends' host checks
- backend.Backend gains Problems(ctx) []Problem (Key, Fix, Msg): all that a backend needs and the host lacks. Check is the first of them, so every command that needs the backend stops at the first one. - Lima's Problems (check.go): host OS, arm64/amd64 (arch), macOS 13+ (macos, via sysctl kern.osproductversion: platform.MacOSVersion), Lima missing/broken/older than 2.0 (lima; brew install/reinstall/ upgrade lima when Homebrew is there), on Linux qemu-system-<arch> and qemu-img (qemu; apt-get, dnf, pacman or zypper's command), /dev/kvm missing (kvm) or not openable (kvm-access; sudo usermod -aG kvm USER), Lima's global configs (lima-config). DEVVM_KVM swaps /dev/kvm for tests. - devvm doctor [--backend NAME] [--fixes]: a features table (FEATURE, one column per backend: native, emulated, unreviewed, none; Support gains String), Docker found or not, then doctor_ok or each problem (the last one fails). --fixes prints KEY<tab>FIX<tab>MESSAGE lines and succeeds either way. - Messages: lima_missing_fix, lima_broken_fix, lima_old_fix, qemu_missing_fix, lima_arch_unsupported, macos_old, no_kvm, kvm_access, docker_found, docker_missing, doctor_ok, doctor_failed; kvm and ok are initialisms in the generator. - Tests: TestProblems (23 cases), TestWriteFeatures, TestWriteFixes, TestMacOSVersion, Support's String in TestSupport; doctor.txtar; the script sandbox sets DEVVM_KVM; e2e images checks doctor. - Converted: cli.bats preflight (arm64 and x86_64), doctor (macOS without Lima, Linux without QEMU, x86_64 Linux, limactl that doesn't run), the doctor half of "all there", doctor's half of the Lima global configs case. - Docs: new install.md (requirements, checking them, --fixes keys), lima.md requirements, backends.md, commands.md, contributing.md, README; CLI reference regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6a2b2dcf5a |
feat(features): optional base image features
base runs its chosen features after layers/base.sh, in the order chosen: devvm's own (features/<name>.sh next to the binary) and the user's (~/.config/devvm/features/<name>.sh). The choice is in base-features and in base's key; until there's a file, every feature counts. The first build of anything asks which features base gets, every one chosen to start with: an arrow-key (or j/k) picker in a terminal, showing each script's second line; without a terminal, every feature. The choice is saved and printed. - build: Features (devvm's, sorted, then the user's; a user feature named like a built-in one is ignored), FeatureScript, chosenFeatures (selected_features), chooseFeatures (pick_features) run by Build and Rebuild before any key; Inputs hashes the chosen features and the user's folder; base's spec gets each feature's script, one without a script skipped with a warning. - image: FeatureName. ui: Pick and Choice (raw mode, hidden cursor, control characters dropped from descriptions, Ctrl+C ends the run with 130). - Messages: features_help, base_features, base_features_none, feature_shadowed, unknown_feature; doc links to customizing.md. - Copied: features/ (cli-tools.sh, fzf.sh, omb.sh), unchanged. - Converted: images.bats user features (listing, shadowed, in base's key) and build.bats step counts (two features and one skipped) as features.txtar and Go tests (TestFeatures, TestDescription, TestChooseFeatures, TestBuildRunsFeatures, TestPickKeys, TestPickWithoutTerminal, TestPickCtrlC). Script tests start with an empty base-features file. - e2e: with from selected, base-features holds every feature; images checks base ran base.sh and every feature, and takes base's key from its build or the newest Ubuntu base (no longer a cached --from base); from checks every feature in the node:24 and alpine:3 VMs. - Docs: customizing.md (base image features); images.md, index. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0aec2ece89 |
feat(from): base images from Docker and OCI images
--from IMAGE (default $DEVVM_FROM) starts base from a Debian-, Ubuntu- or Alpine-based container image instead of Ubuntu's cloud image, for new VMs, build and rebuild. base is keyed by the image's digest, looked up once per build and recorded per reference; existing VMs keep their own (from_ignored). - internal/from: ParseRef (registry_ref, with a fuzz target), Valid/ Check (bad_from), Pinned, Name, Recorded (from_digest), Registry.Digest (manifest HEAD, anonymous Bearer token from an https realm only, timeouts, size caps, retries; ErrUnreachable/ErrNotFound), Lookup.Refresh (refresh_from_digest: registry, else Docker's ID, else the recorded digest with a warning), DockerID, DockerRunning. - build.Builder: From and Lookup; Inputs/Key/Chain with the recorded digest; spec.From for base; records keep from and digest on every image above a --from base; rebuild counters per from; building_image_from. - lima: convert (oci_base): devvm-oci-build from Ubuntu's image with only <tmp>/vm (rw) and oci/ (ro) mounted, confined to the internet, runs oci/build.sh; docker save plus exportIs for images only Docker has; checkConverted (regular files, gnu/musl, cmdline charset, raw ext4); base created with --set .images (disk, kernel, cmdline, initrd); the temp folder, build VM and the OCI build lock (lockOCI, pid, stale takeover, oci_waiting) go however the run ends. - cli/vm: global --from flag, state from=, builders with the VM's from in open, update, remove. - Messages: building_image_from, bad_from, from_ignored, from_unreachable, from_not_found, from_cached_unreachable, from_cached_not_found, no_digest, docker_only, exporting_docker, docker_export_failed, docker_image_changed, oci_waiting, converting_in_vm, converting, convert_failed, convert_bad_output; doc links to from.md. - Copied: oci/ (build.sh and README edited: comment, docs link), testdata/stubs/docker; limactl stub gains oci/build.sh outputs and interrupt-on. - Converted: from.bats (registry_ref, registry_digest token, 1/2, https realm, refresh per tag, Docker-only, offline, no Docker, pinned, moved tag, cached keys, build flow, docker save, Ctrl+C, steps, failures, bad outputs, record, export check, lock) as Go tests and from.txtar; oci.bats (libc_for, missing architecture, crane pins) as oci.txtar; cli.bats --from parse_args and project.bats --from input checks. - e2e: from section (--from tier, or --only from): node:24 Debian 12 node+python+claude, alpine:3 musl tools and Docker on OpenRC, base from ubuntu:26.04, no Docker needed. Left out: features, an image only Docker has. - Docs: from.md; images, commands, lima, contributing, index; CLI reference. 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]> |
||
|
|
27905c2413 |
feat(build): build and rebuild images through the backend
devvm build and devvm rebuild build base and the user's layers through Backend.BuildImage. On Lima an image is a stopped instance: base from Ubuntu's cloud image with base.yaml, a layer a clone of its parent, each started confined with no host mounts, its script run, then stopped. Records are written last; an interrupted or failed build deletes its instance through the cleanup stack. Rebuild bumps the rebuild counter and deletes stale images no VM uses. tests/e2e.sh starts here, with its framework and an images section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
218d8d9569 |
feat(lima): Lima backend
The Lima backend behind backend.Backend: limactl on devvm's own Lima home, run from devvm's data folder, refusing Lima's global configs and networks devvm didn't set. Start confines VMs with a Seatbelt profile (macOS) or the QEMU wrapper, devvm _qemu, with restrict=on and a guestfwd to the proxy (Linux), tolerates degraded starts, and records the hostagent for Confined. Clones with qcow2 overlays on Linux, size, ports, mounts, agent forwarding and the ssh target. BuildImage comes with the image build. Adds NameMax and LoggedError to the backend package, a limactl stub, the registry with lima as the default, and the Lima docs page. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
36fb2cb540 |
test: testscript runner and stubs
Run testdata/script/*.txtar against a freshly built devvm, with HOME, the XDG folders, the Lima home and the stub state in a sandbox under /tmp, and testdata/stubs first on PATH. Add the stub_calls command, uname and sw_vers stubs driven by env vars, scripts for the root command and the sandbox, and README sections on writing CLI tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> |