mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
65
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3c7fbad7a3 |
feat(tools): mise downloaded as its .tar.gz, on the host and in base
mise's raw binary is 147 to 192 MB, its .tar.gz 51 to 63 MB. Both of a first run's mise downloads now take the archive: - the host's mise (internal/tools): the .tar.gz checked against its pinned SHA-256 by fetch.Download as before, into a folder of its own, then hashed again through the descriptor that mise/bin/mise is taken out of with archive/tar and compress/gzip, capped at miseCap. One devvm downloads it at a time (Dirs.MiseDownloadLock, cache/mise/download.lock, mise_waiting), and another takes what it kept. Under the lock, a .download-* folder a killed run left is taken away first (TestHostMise). A failure says its cause (mise_download_failed's Because) in the run log too. - base's mise (layers/base.sh): devvm-fetch's .tar.gz, unpacked with tar in a folder of mktemp's, which every base has (gzip is Essential on Debian and Ubuntu, BusyBox has it): .tar.xz would need xz, which --from images may lack. The pins are the archives' SHA-256s from the release's SHASUMS256.txt, and scripts/bump.sh reads the .tar.gz lines. TestMisePins still checks that base.sh's Linux pins are the host's. Docs: images.md's Versions and overview.md's locks; the release page's A faster first run; the CHANGELOG's Highlights, a first run that downloads less with the cloud image's two lines, now highlights too. Base's key changes (base.sh). Tool images' keys don't: they hash base's mise version, not its checksum. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a8f0517579 |
feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut in its 900 MB fails base's build, and a stall hangs it. devvm now downloads the pinned image itself through fetch.Resumable (ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage), resuming across cuts, stalls and runs, and gives Lima that file. Lima 2.3 checks a local file against the digest before it copies it. - Before downloading, it takes the image from Lima's own download cache when that holds it with the pin's SHA-256: copied into a new file of devvm's own, mode 600, hashed as it's written, capped, stopped by the context, and kept only once it checks out. Lima's cache is never changed, and a base whose dated release Ubuntu may have removed still builds again. - One devvm downloads at a time (images/locks/ubuntu-image), another waiting under ubuntu_image_waiting and looking again under the lock (TestUbuntuImageAfterWait, which fails without that second look). - The download goes through the company proxy and trusts the user's CAs (Lima.Roots, from trust.Pool, which internal/cli passes through the registry), as do the Finder's lookups (TestNewTrustsRoots, and the registry's TestOverrides). An untrusted certificate is ubuntu_untrusted, naming the CAs' folder, one from a trusted CA that's for another host, out of date or not valid yet ubuntu_bad_certificate (check the clock and what answers for the host), and any other that fails to verify (a SHA-1 signature, a CA's name constraints, a key for clients alone) ubuntu_certificate_invalid, naming Go's reason, for the lookups (the listing, the checksums, their signature: TestLookupCertificates) and the download alike (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410) ubuntu_release_gone, which names devvm rebuild base; none is retried. ubuntu_download_failed no longer starts with devvm. - fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a CertificateInvalidError that's Expired) and fetch.Unverified (any failure to verify, with its reason, so every error the other two name), beside fetch.Gone, are the one place that tells a certificate's failures apart: Transient asks Unverified, the lookups and the download ask all three, host mise asks Untrusted, and a forbidigo rule keeps x509's and tls's verification errors in internal/fetch (TestCertificateClasses, TestTransient, testdata/lint, the owners doc's row). - An https address, or a test build's file:// DEVVM_UBUNTU_URL, read from disk the same way; anything else is refused. The CLI tests' sandbox has a stand-in of this host's image in the store. - Base's record keeps the image's address, and the key is as it was: it hashes the pin (release, file, digest), not the location. - devvm gc --caches frees devvm's copies that no record names and that aren't pinned now, unchanged for an hour, a stopped .part and a killed import's .import included, and those of a kept image once its .img is there. A pin it can't read fails it. - Of Lima's cache, it frees only an entry that devvm's own state shows a build of devvm's left: a base record names its address, devvm has its own copy of the image, and the installed Lima's own templates (share/lima/templates beside limactl, Lima.Templates) don't name it. An entry no record names may be the user's own Lima's, so it stays, and none is freed when the templates can't be read, with a line in the run log naming the folder and why. A test build's DEVVM_LIMA_TEMPLATES stands in for the templates folder. - ubuntu.ParseImage reads a record's image as Image.String writes it, and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in place of Lima's own regex. - devvm space shows the copies as a cloud images row, freed by gc --caches, kept as state, as a release Ubuntu removed can't be downloaded again. 0.1.0's frozen state runs the new commands (fixture_v010_cloud_image): devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's base record keeps and never changes the entry, base builds from devvm's own copy, and gc --caches keeps that copy, frees Lima's entry the record names and devvm's own stale copies, and keeps an older entry no record names. Docs: images.md (the download, its failures, the import, gc's rules), space.md, backends/lima.md, settings.md (the lookups and the download trust your CAs), troubleshooting.md, overview.md, testing.md, tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed lines, which later commits make highlights, What to do 5 and 6, and the release page's Ubuntu's cloud image in devvm's folder. New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting, ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate, ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted. Lima.LocalImage is the seam, Lima.ImageClient the client. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b04a1a9f12 |
fix(vm): agent import walks within its bounds, takes turns at the store, applies all or nothing, and refuses links while a state can't be read
The bounded walk: - fs.WalkDir read each folder whole before the import's entry bound applied, so a VM whose project folder is in an agent's folder could make the walk hold millions of entries. safefile.Walk walks as fs.WalkDir does (order, SkipDir, SkipAll, errors) but reads each folder 256 entries at a time, counting every entry it reads against a safefile.Bound, and stops with ErrTooMany before fn sees the folder; it also stops at a folder more than 128 deep or a path past 4,096 bytes, so a deep chain can't make the walk quadratic. - readSettings walks the agent's folder through the folder opened one folder at a time (h.safe), whose FS now opens folders to list them (rootFS.openDir: no follow, no blocking, the folder Lstat saw or ErrSwapped), so a link or a FIFO swapped in for a folder fails the walk. follower.copy walks each link's target the same way; the walks of all links read at most linkMaxWalked (80,000) entries in all, those left out for the bounds included. - The structure test's status-lines rule counts safefile.Walk as a walk. The store's lock: - paths.Dirs.AgentStoreLock (agents.lock in the data folder), held by lockStore, under a status line (agent_store_waiting) while it waits: devvm agent import from its staging to its logins, devvm agent save's writes, and a start's clean of a seed's folder (cleanSeeds, now with ctx), which takes it only once it finds something to take out and looks again under it. - devvm agent save plans again under the lock and saves nothing when the store changed since it showed the diff (agent_save_store_changed), rather than write over an import. All or nothing: - After staging, apply moves aside what it replaces or prunes into the staging folder's replaced folder (a file kept as a hard link, so it's still replaced in one rename), notes the folders it makes, and keeps each change's undo. The logins are saved all or none (secrets.SaveLogins, which reads each file it replaces first, puts them back on a failure, and holds each login's lock, agentlogin.LockLogin, as the proxy does while it refreshes one). - A failure after the first change undoes every agent's changes, going on past an undo that fails; each store it couldn't put back keeps its staging folder, named with it (agent_import_undo_failed). - An interrupted run's cleanup waits on the stage's mutex for an apply that started, and an apply after the cleanup took the staging folder out puts nothing in place. Links through states devvm can't read: - While any VM's state can't be read, the import leaves out every link out of an agent's folder and an agent's folder or login whose path leads through a link, but the links on the way to the home folder itself, naming the state (agent_import_link_unread_state), where before it followed them with only a warning (projectFolders.chosen, with throughVM's check). Tests that fail without their fix: TestWalkBound (fs.WalkDir as the control), TestWalkDepth, TestWalkAsWalkDir, TestWalkErrors, TestRootFSOpenSwapped (a FIFO), TestAgentStoreLock (import, save, a seed's clean), TestAgentSaveStoreChanged, TestAgentImportApplyFailsWhole (a rename and a login failing, files and folders swapping kinds), TestAgentImportUndoFails (two agents, the second's undo failing), TestAgentImportInterruptedApply, TestSaveLogins, TestAgentImportLinksUnreadState (a link out, a linked folder and its login, a login behind a link), TestAgentImportLinkWalked. TestRootFS and TestCleanSeeds* follow the new FS and ctx. paths.Dirs is allowed 63 methods (largeTypes), for agents.lock. Docs: using/coding-agents.md, internals/agents.md, using/space.md, internals/overview.md, Contributing's structure page and the owners doc, the codebase-standards guard for bounds; CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c41ca82f6e |
fix(project): devvm's own folders are compared by identity; a launch warns of a project in an agent's folder
project.Unsafe's Holds and Inside compared a project folder with the home folder and devvm's config, data and Lima folders by name alone (paths.Within, paths.Below), so on a volume that ignores case, as a Mac's does by default, a project at ~/.Config/devvm/layers passed both and its VM got devvm's settings and layer scripts read-write. They now compare by identity too: paths.In, the vm package's isIn moved to its owner, finds the path or a folder above it to be the same folder as the other, by device and inode, and paths.Under is In for the path's folder. An empty folder holds nothing, so an unset one can't match the working folder. sshagent's mountedBy, which refuses a key in a folder a VM mounts, compared by name in the same way and uses paths.In now. Each launch (Launch.Up, beside warnMounted) warns once, in one line, when the project folder it mounts is inside an agent's folder in the home folder or holds one (project_agent_folder), naming every such folder from the agents' registry, with agent_import_project_inside's detection (overlapsAgent). A --clone VM mounts nothing and gets no warning. Tests: TestUnsafeIgnoresCase, TestInAndUnder, TestMountedKeyIgnoresCase, TestWarnAgentFolders; the case checks skip on a volume that tells names apart by case. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
19f9900b86 |
fix(sshagent): a VM reaches its SSH agent only through its proxy's relay
OpenSSH's ssh-agent answers every request a forwarded connection sends, so a VM that forwarded your agent or devvm's own (shared by every VM that uses it) could remove all its keys (ssh-add -D), lock it with a password of its own (ssh-add -x) or add keys without bound, denying the agent to you and to the other VMs. Checked with a throwaway sshd and ssh-agent: all three succeed over ssh -A. Each VM's proxy now relays the agent its start chose on a socket of the VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and the VM's backend, devvm's own connections and the ssh entries for editors name that socket. The relay passes on only SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the [email protected] extension (so destination-constrained keys keep their constraints), answers everything else with SSH_AGENT_FAILURE, reads messages whole up to OpenSSH's 256 KiB, carries at most 16 connections and closes one idle for 2 minutes. A filtering relay rather than an agent per VM: it covers your own agent too, needs no copy of a key or a passphrase per VM, and fronts hardware and app-held keys. - proxy: Config.Agent/AgentSocket (checked together, absolute), the relay in agent.go, listened before the proxy says it's ready; its accept loop backs off after an error that leaves the listener open (EMFILE), 5 ms doubling to 1 s, logging the first. - daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only package the proxy already imports, so the relay, the port forwarder, the link session and a login's forward share one owner. - netpolicy: Prepare takes a start's agent; a running VM's proxy keeps its start's agent from proxy.json (relayedAgent); Stop deletes the relay's socket. - structure: paths.Dirs may have 62 methods (AgentRelay); the relay's goroutines in goroutineSites. - sshagent: Made.Relayed, which RecordStart sets on every start of this devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK included, and ReachOf(st, start): a relayed start gets the relay (or none while it's down), a start devvm didn't record (one outside devvm) gets none, or its proxy's relay, and only an older devvm's recorded start keeps the raw agent until its next start (runningConfinement, finder.inspect, sshconfig). - vm: LeftoverSockets also finds a killed proxy's relay socket for devvm gc --orphans and devvm space. - Tests: relay filter, wiring through Main, bounds and idle close, real ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay, RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar, an outside start in ssh_agent.txtar, and e2e checks that the VM can't remove, lock or add to your agent, nor the VM or an editor's connection remove devvm's agent's keys. - Docs: processes (the SSH agents, listeners), ssh, attack-vectors, security, design, lima, overview, space, structure, proxy README, AGENTS.md, CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f37c70a5cd |
fix(bounds): bound what a VM can make the host hold
Five bounds, each with a test that failed first. Long downloads,
WebSockets, slow streams and SSE are never cut: every bound is on what a
connection holds, never on how long it lasts.
- _qemu connect (Linux): each guest connection to the proxy was a host
process with no cap. Connect now takes one of connectMax (256) slots,
lock files in the VM's run/proxy.slots (paths.VM.Proxy(".slots")),
each process about 7.7 MB, so about 2 GB per hostile VM. A connection
past them gets an HTTP 503 (connectsFullReply) and closes before it
dials; QEMU's stderr says qemu_connects_full at most once a minute,
decided under full.lock so refusals at once say it once. A VM started
before keeps the two-argument form, unbounded until its next start.
No idle timeout or byte bound: the proxy bounds what each carries.
TestConnectSlots.
- The VM proxy (limits.go):
- maxConns (2048, twice maxConnects so a CONNECT still gets its 503
first) counts a connection from its first request with the VM's
password (conns.admit, via httpServer's ConnContext); a request past
it gets 503 and the connection closes. Connections without the
password wait in a pool of maxWaiting (128) where a new one closes
the oldest, so holding connections can't take a VM's room (a host-speed flood still slows it
through the accept queue: listed in design.md).
- maxRequests (2048) requests upstream at once, plain HTTP's and
intercepted tunnels' (requests.take), 503 past it: per-tunnel
HTTP/2 streams alone allowed ~100,000 upstream connections.
- each limit logs once a minute at most (everyMinute).
- httpServer adds IdleTimeout (10 min); a 407 closes its connection;
handleHTTP's WithoutCancel is replaced by whileHeard, which ends a
plain HTTP request once its client has stopped sending and goneWait
(1 min) passes with nothing written, so half-closing clients still
get answers that keep coming; quiet WebSockets aren't cut.
- heardWriter.Unwrap: plain ws:// upgrades got 502 (pre-existing) and
get 101.
- No ResponseHeaderTimeout: non-streaming LLM requests wait minutes
for headers, and a waiting client is counted.
Tests: TestProxyLimitsSet, TestProxyConnectionBounds,
TestProxyConnectionLimit, TestProxyWaitingConnections,
TestUpstreamRequestLimit, TestUpstreamRequestLimitIntercepted,
TestPlainWebSocket,
TestPlainHTTPEndsWithClient.
- serveOne (intercepted tunnels, transparent HTTP, the 403 page) takes
maxHeaderBytes (64 KiB) always, not 1 MiB, and HTTP/2
MaxConcurrentStreams streamsMax (100, not 250). TestServeOneHeaderLimit,
TestServeOneStreamsLimit.
- Accept loops (forwarder, link session, login forward) retried nothing
or at a fixed 100 ms: vmssh.acceptRetry backs off from 5 ms to 1 s and
logs the first error of a run, ending only when the listener closes or
ctx ends. TestAcceptRetry, TestForwarderAcceptRetries,
TestLinksAcceptRetries.
- The login callback (LoopbackForward) carries at most
loopbackConnsMax (16) connections, an ssh each.
TestForwardLoopbackLimit.
Docs: processes, network, ports, lima, design (threat rows),
attack-vectors, the proxy README, CHANGELOG Fixed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
e4ea123927 |
feat(ports): VMs' ssh on ports browsers refuse
Lima listens on a VM's ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as http://localhost:PORT reached a server the VM controls with the cookies of every app on localhost, even in a VM that forwards no ports. - Every VM's ssh port, and every build VM's, is one of the 17 ports every browser engine refuses (ports.SSHPorts): the Fetch standard's bad ports from 1024 up that Chromium's kRestrictedPorts blocks too, which leaves out 4190 and 6679 (headless Chrome 157 loads both). The one allocator chooses it (Allocator.SSH and Build, through freeSSH). A stopped VM keeps its port while it's on the list, free, not listed to forward and not held by another start or build; else it gets one no state records, or else a stopped VM's, which that VM gives up at its own next start. Another VM's listed ports are avoided only while that VM runs or starts. - The proxy and desktop ports never take one (free); one an older devvm chose moves at the VM's next start (Choose's keep path, proxyPort, the desktop's listener; Allocator.SSHOnly). - A forwarder never takes one unless its VM lists it (ports.Reserved), so a guest forwarding every port can't fill them; devvm ports and each launch warn when a VM's list names one, whatever set it (--ports, a devcontainer.json, config.toml's ports) (ports_ssh_listed, ports.SSHListed). - A start holds its port, kept or new, for a minute in the VM's own run/ports.ssh-hold (paths.VM.Forwarder; hold, held, projectHold), which other starts and builds avoid, so none takes it before Lima binds it; it goes with the VM's folder. - A build takes its clone's own port (was) only when no other is free. - Past 17: ports_ssh_limit names the VMs whose recorded ports are in use ("a or b" for a port two states record) with how many are taken otherwise, ports_ssh_limit_all when they have them all, and ports_ssh_limit_others when none of your VMs has one. - Older devvm's ports move at the VM's next start, in startSets' one limactl edit, and the start pins the new host keys (pinHostKeys); a running VM keeps its port until then, and each launch warns of running VMs still on an off-list port (ports_ssh_old, Allocator.OffList, confirmed with the backend's Running). - A test build's own list (DEVVM_SSH_PORTS, registry.Overrides.SSHPorts, the Allocator's and the Proxy's SSHList field), read only by readOverrides in a test build: each CLI test sandbox gets as many ports of its own from below the ephemeral range (sandboxPorts). Frozen 0.1.0 fixture: each launch now makes exactly one limactl edit, of .ssh.localPort alone, onto the sandbox's list, and vm.json changes only in .ports.host.ssh (and the start it records); the fixture's data is untouched. Messages: ports_ssh_limit, ports_ssh_limit_all, ports_ssh_limit_others, ports_ssh_listed, ports_ssh_old. Tests: TestSSHPorts (Fetch's list less Chromium's gaps, SSHListed, SSHOnly), TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild, TestReserved, TestForwardsHeld's reserved counts, TestStartBuildSSHPort, TestPrepareRestartsTheProxy, TestDesktopListener, TestOverrides (DEVVM_SSH_PORTS), ssh_ports.txtar, fixture_v010.txtar, layout.txtar; e2e project: the ssh port, first and after a move, is one browsers refuse. Docs: internals/lima (the ssh bullet, the hold's limit), processes (listener table), design (threat check), ports, overview, contributing/structure and testing (DEVVM_SSH_PORTS), using/ports-size, troubleshooting (Too many VMs at once), safety/attack-vectors (allowed ports, port squatting), CHANGELOG Breaking (17 VMs; forwarding every port leaves the 17 out) and After you upgrade. 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]> |
||
|
|
54cce97049 |
fix(ports): a stopped VM no longer keeps its listed ports from other VMs
Only a running VM holds a host port. Each VM's forwarder records the ports it forwards, and those it tried and couldn't take (run/ports.forwarded: its pid, then each list on a line; an empty one when it starts, and devvm removes it under ports.lock before each start). A forwarder reserves another VM's ports only while that VM has a claim: its forwarder runs, or devvm holds its ports.lock to start one again (the restart window). It never takes the ports such a VM forwards now, nor those it lists unless this VM lists them too. A stopped or crashed VM holds nothing. A reserved port the VM listens on waits and is forwarded once free, so a VM gets its port back within about 20 s of the other VM stopping. The host decides when a port is given up: every forwarder closes a forward whose port is now reserved every 10 s on its own clock (Forwarder.Recheck), so a VM that holds its session open and stops reporting can't keep another VM's listed port, and closing a forward closes the connections it accepted, so a browser's keep-alive connection never reaches the old VM afterwards. Two VMs starting at once are settled by the host's bind. The ports devvm chooses (ssh, proxy, desktop) still avoid every VM's listed ports, running or not. - ports: Used(d) for the allocator; Reserved, Holders and Live for the forwarders - vmssh: Forwarder.Recheck, Note and release; a forward tracks and closes its connections; Forwards.Reserved, Held, Taken, live, recorded and record; a start keeps a port another VM holds in -only and warns ports_held for any holder, listed or every-port; Main takes paths.Dirs - devvm ports warns ports_held and, for a running VM's listed port its forwarder recorded as a program's, ports_taken, reading the forwarder's record and binding nothing; --json adds held_by - backend.CountPorts; the stub's ssh master reports again when guest-ports changes - tests: TestReserved, TestForwarderWaits, TestForwarderGivesUpSilently, TestForwarderClosesConnections, TestForwardsHeld (restart window, every-port holder, no record, Taken from the record alone, another process's or no record), TestForwardsRecordFails, TestForwardsStart (old record removed), ports_stopped.txtar (CJ's case end to end, and an every-port VM leaving a running VM's listed port alone), layout.txtar - docs: ports-size's Two VMs and one port (the browser origin) and its JSON, internals' Ports other VMs forward, design.md's ports note and the listed ports' threat check; CHANGELOG Fixed Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b2b12ee55d |
feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only the folder's own: one walk (hostsafety.Walk, at most 4 folders down and 100 repos, no symlinks, one device) finds them, and each is locked on macOS, pinned on Linux or watched where Linux can't pin, scanned within its own top folder and the mount. A repo counts as covered only when a scan locks its git dir; git dirs follow git's own rule, .git is matched without case on macOS, and a recorded repo stays protected while anything is at its .git. Repos the walk can't protect, that appear, that leave or that look like bare repos are named, with the config keys and hooks a VM-made repo would run. Existing VMs get a one-time notice and opt in with devvm git-protect on. Ownership fails closed under one host lock, so a VM never unlocks what another protects; one scan budget covers every repo, and launches into a running VM check only the top repo. devvm doctor gives a tip to set safe.bareRepository=explicit, reading the user's GIT_CONFIG_GLOBAL when set. Refs #3. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8f6b30a887 |
feat(secret): your own secrets, bound to the hosts you choose
devvm secret set NAME --host HOST[,HOST…] --env VARIABLE [--header H] [--prefix P] [--stdin] saves a secret of your own: the value from a hidden prompt or stdin (never argv) into the Keychain or devvm's secrets folder, and its definition into custom-secrets.json. A VM that uses it (devvm secret use NAME) gets only a per-VM placeholder in VARIABLE, and its proxy puts the real value in that header only for those exact hosts, over TLS on 443; the hosts join that VM's allowlist. Names, hosts, headers, variables and prefixes are checked; wildcards, addresses, internal names and other ports are refused. One placeholder builder serves every secret and login, and the proxy caches values by kind, agent and name. After an independent review, a secret goes in only in four exact shapes (alone; Bearer, Token or a saved --scheme in Authorization; the Basic password; the Basic username only with --basic-user), values are printable ASCII under 3,800 bytes, the proxy checks each binding against its definition, definitions carry IDs and VMs record their hosts, and custom values are stored apart from the known secrets. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2b68a2347c |
feat(gitprotect): .git protection on Linux without root, through a user namespace around QEMU
On Linux, a start of a VM whose protection is on pins .git, its git dirs and every lock path read-only in a user and mount namespace that devvm _qemu pinned makes around QEMU. It keeps the pins while QEMU runs, records each re-pin, refuses hard links and fails closed on watches and records; doctor says why a host can't lock, and such hosts watch .git instead. The pins' events file is read through safefile, and the command-line check takes "devvm lock" in prose as English. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
eaa1706966 |
docs: a unix socket's path has fewer than 104 characters
macOS's sun_path holds 104 bytes, its terminating NUL included, and Lima refuses a socket path whose length is UNIX_PATH_MAX or more, so a path has 103 characters at most. The internals pages (design, overview, ports), AGENTS.md and the comments on paths.SocketMax, the forwarder's control socket and the links' sockets said "at most 104"; they now say fewer than 104, as the Lima backend page and NameMax already did. The figures computed from the limit (a home folder of up to 37 characters, ControlMax) already allowed for the NUL and stay as they are. 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]> |
||
|
|
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]> |
||
|
|
3a2c290d3d |
refactor(msg): messages and comments say network tier and the VM's proxy, not network policy
Every VM runs a proxy and is on one of four tiers, so the proxy's messages name the VM's proxy, the unenforced ones its network tier, and the redaction ones say devvm keeps secrets on this machine on every tier. Message IDs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fcbab78670 |
refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its tier, so even an open VM never holds a real secret: a request that goes around its proxy carries only the placeholder. - vm/sync.go: the open branches of stage go (the agents' logins copied as they are, the ClaudeCopy for unconfined VMs and its MCP warning, real values in ~/.config/devvm/env); stageNet is stageSecrets, run for every VM, and the salt is every VM's. - netpolicy: Prepare readies the CAs, salt and secret files on every tier, and the proxy config carries the CAs and bindings on every tier; dropCA and its caller are gone, so a VM keeps its CAs as its tier changes. - Removed without a caller left: the messages secret_unuse_copied, net_on_old_tokens and claude_mcp_secrets_copied; secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets, claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly. - Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for another host), TestStageSecretsEveryTier (every tier's setup sends the VM's CAs, the guard against a tier's own path); sync, ca, network and secret scripts for open VMs. - e2e: network checks that an open VM holds no real secret (its proxy puts the token in over TLS the VM verifies, a direct request carries only the placeholder and gets a 401); project checks an open VM's placeholder, and its company-CA checks allow for the VM's own CAs in /etc/ssl/devvm.pem. - Docs: safety/network (tiers, secrets), internals/network, the design note's tiers threat check, attack vectors, coding agents, first VM, staying safe, contributing; devvm secret's help. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
317bd8f978 |
feat(agents): devvm's agent store, filled by devvm agent import
Every VM gets its agents' settings and logins from devvm's own store, never from the agents' files in the home folder: settings in ~/.config/devvm/agents/<agent>/, logins in ~/.local/share/devvm/logins/<agent>/ (folders 700, files 600, each agent's logins folder kept out of Time Machine), each laid out as in a home folder. The store's settings folders are mounted read-only and linked into the VM's home; its files and logins are copied in, with network policy as placeholders the proxy fills from the store. devvm agent import [AGENT...] [--force] copies the home folder's agent settings and logins into the store once: only agentDirs, agentFiles and secrets.LoginRel's paths, never history; .claude.json reduced to its settings, account state and MCP servers; read through each agent's folder as an os.Root, so no link out of it is followed (a link to a file inside becomes a copy, any other is left out with a warning, and so is a login file that's a link); Claude Code's plugin records renamed to the store's folders. It asks before replacing what the store has (refused without a terminal, naming --force), replaces in place, keeping the mounted folders, and prunes what the home folder no longer has. - paths: Dirs.AgentSettings, Dirs.AgentLogins - secrets: LoginRel, LoginFile(Dirs, kind), SaveLogin, HasLogin, Store.ExcludeFromBackup; Logins, VMLogin, ClaudeCopy, MCPSecrets and the proxy's Get read the store - vm: agentStore, agentMounts/homeSkips/Inventory.Mounts take Dirs, syncer.stageAgents, AgentImport; the guest's links file holds each folder's home path and its mount's (host_home is gone) - structure: callers takes methods (pkg.Type.Name); Dirs.AgentSettings only in vm/agents.go, Dirs.AgentLogins only in secrets/secrets.go - messages: agent_import_none, agent_import_nothing, agent_import_replace, nothing_imported, agent_settings_imported, agent_login_imported, agent_import_link_left_out, agent_login_read_failed, agent_import_failed; the login refresh messages point at devvm agent import - tests: agentimport_test.go, testdata/script/agent.txtar, sync and network scripts through the store, e2e project and network sections - docs: coding agents (devvm's agent store, importing from this machine), README, getting started, safety, internals, contributing Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3ebb998752 |
fix(vm): a per-folder creation lock from lookup through Create
Nothing held a lock from finding that a folder has no VM until Create, and a second creation's clear deleted the vms/<hash>/ folder of the VM the first had just made; the remake's lock lives inside that folder, so it couldn't help. - paths.Dirs.CreateLock(hash): run/create-<hash>.lock, outside the VM's folder. - Launch.makeHeld: when up finds no VM, or the folder's own unfinished one, it TryLocks the folder's creation lock before the plan's questions, finds the VM again under it (finder.again, sameCreation) and opens one another devvm made meanwhile; create lets go of the lock once created records Created, before the first start. After an interrupt the lock is let go of by a cleanup that runs after undoCreate's. - A second devvm refuses at once (create_running), never waiting on the first one's questions; so does up's remakeUnfinished question. - devvm rm (Rm and rmGone) takes the lock too (holdForRm) and refuses while it's held, or when the VM's state changed once it has it. - The holder deletes the lock file as it lets go, so no file named by the VM stays outside its folder; teardown deletes one a killed devvm left (dropCreateLock). - Tests: TestUpCreateLock (two creations at once: one VM, one state; failed before the fix with two CreateVMs), TestUpMadeMeanwhile, TestUpInterruptedHoldsCreateLock, TestCreateLockRefuses (up's remake-unfinished question and rm by folder and by name refused), TestRmChangedMeanwhile, TestTeardownDropsCreateLock. - Docs: internals overview (a new VM's step 1, run/, the locks section and table), troubleshooting. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
da5bae47f9 |
fix: tighten VM names, validate aliases, make written folders private and choose build VMs' ssh ports under the claims lock
- vmname.IsVM takes a name's folder part only as project.Slug makes it ([a-z0-9-], a letter or digit at each end), so a hand-edited name never carries spaces, slashes, newlines or ssh patterns. TestSlug checks that every name project.New makes is one. - vmname.Short and vmname.IsAlias: a VM's alias is devvm-<folder> of its own name or the name itself. sshconfig.Host, ChooseAlias and project.Named ignore any other alias, so one edited into vm.json never reaches the ssh config's Host line or names a VM. - state's writeFileMode makes a missing folder with PrivateDir (exactly 700, whatever the umask, a link refused); a folder already there keeps its mode. - ports.Allocator.Build chooses a build VM's ssh port on macOS under the claims lock (state.Claims, which VM.Claim now shares), records it in run/build-ports/<name> until limactl start returns, and ports.Used reads those records, so no VM or forwarder takes the port before Lima binds it. Lima's own freePort and platform.PortFree, its only user, go; Lima gets a Ports field (the allocator). paths.Dirs.BuildPorts is new, and Dirs' method limit goes to 54. Tests: TestIsVM, TestIsAlias, TestSlug, TestChooseAlias, TestWrite, TestTargets, TestWriteFileMakesPrivateDir, TestBuild, TestStartBuildSSHPort; layout.txtar lists run/build-ports on macOS. Docs: internals (backends, overview, design), contributing, using/space. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3649978bdb |
feat(build): base's features are devvm's own; your extras are layers
devvm reads base's features only from its own files (assets/features): ~/.config/devvm/features is no longer a folder devvm knows. An extra of your own for every new VM is a layer of yours (devvm layer new), chosen with devvm setup --layers, which each VM's list can uncheck. - build: Features returns devvm's features alone; featureStep gives each its prelude; FeatureScript, the shadowing check and its feature_shadowed warning are gone. A chosen name devvm has no script for is skipped with unknown_feature, as before. - paths: Dirs.Features is gone. - Tests: TestFeatures, TestOwnFeatures, TestPickFeatures, TestSetFeatures, TestBuildRunsFeatures and the key tests use devvm's features only and check that a script in ~/.config/devvm/features is neither a feature nor in any key; features.txtar likewise. - Docs: customizing's Extras of your own (a layer chosen in devvm setup), settings, install, space, overview, internals/images and the landing page drop the user features folder. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d00c42e14 |
fix(netpolicy): a VM's CAs are readied under a lock and deleted once its policy is off, and the proxy refuses minting GitHub credentials in absolute form too
- trust.InitCA takes the caller's ctx and holds the CA folder's lock (paths.CA.Lock, vms/<hash>/run/ca/lock), so two launches of one VM at once never leave a key and a certificate of different runs (TestInitCATogether failed first, TestInitCACancelled, TestInitCAMismatched). - netpolicy.Proxy.Unconfined: a VM's first start without network policy stops its proxy and then deletes its CA folder, keys and all, under that lock; a proxy that won't stop keeps them (TestUnconfined, network.txtar). - The proxy's forwarder refuses GitHub calls that make a lasting credential for every HTTPS request, so absolute-form https:// requests get the 403 that intercepted tunnels got (TestForwarderRefusesMinting failed first); the minting paths also match /repositories/ID and /organizations/ID. Each forwarder's idle upstream connections close when its request or tunnel ends. - e2e: the build proxy check expects the run log's devvm:<key>@ and no proxy key in the log. - Docs: design.md's CA threat check, network.md, overview.md's locks, space.md, safety/network.md. Baselines raised (darwin). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0941219a76 |
feat(build): base's packages recorded per key, replayed from a host cache
base's apt packages are no longer pinned by a snapshot. A key's first build of base records them: assets/layers/apt.sh (a recipe step, as root, before base.sh and after the last feature) points the image's sources at an apt mirror+file: list of config.toml's ubuntu-mirror and then Ubuntu's own archive, so apt checks everything against the archive key whichever server answers, and keeps what it downloads. At the end it gives back each package with apt's entry for it. devvm checks what comes back (regular files only, each named by its own SHA-256, each entry matching a file's size and SHA-256, nothing left over, at most 20,000 entries and 16 GiB), keeps the files in ~/.local/share/devvm/packages/<sha256>.deb and the key's set in packages/sets/<key>.json, before the image's record. Every later build of that key replays the set from the cache, checked on the host first, with apt given only those files: no network for base's packages, and a key's packages never change. A --from base keeps its image's own sources, unpinned. base keeps no package lists, so each layer's recipe starts with apt.sh lists, which fetches them when there are none. - backend.ImageSpec.Packages (Send before the steps, Take after) and backend.PackagesDir; Lima runs both over limactl shell as root. - Fail fast: apt.sh turns apt's retries off and exits 75 when no source answers, which Lima reports as build_sources_unreachable. - packages_missing refuses a replay whose cached file is gone or changed; packages_refused what a build gives back that isn't packages. - config.toml's ubuntu-mirror (settings.UbuntuMirror), checked as an http(s) address without a user, query or spaces (ubuntu_mirror_invalid). - devvm gc deletes the sets of keys neither current nor built, then, under the cache's lock, the files no set names at that moment, and builds' leftover folders over a day old (gc_packages, deleted_packages); devvm space lists the cache. - The snapshot is gone from base.sh, guest/sync.sh and desktop.sh, and scripts/bump.sh's apt step with it. - Tests: recording then replaying, a missing or changed cached file, every refusal of what comes back, gc's view of the cache and its race with a new set, the set record, the mirror setting, Lima's exchange and exit 75, apt.sh's mirrored and record functions, apt.sh in the keys; the limactl stub keeps what's sent and gives back $STUB_DIR/packages-out.tar. 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]> |
||
|
|
8670db2df9 |
refactor(project): trim project to the folder, its VM's name and its unsafe folders
What a folder's files call for (detectFiles) moves to internal/vm's detect.go, beside the parts a new VM gets. The set-id check and SSHRemote move to internal/hostsafety, beside gitprotect. The set-id walk skips .git folders and runs only once the VM is stopped (devvm stop, or a launch that finds it stopped) and when a VM is made, never at a launch into a running VM: measured on APFS at about 5 us a file, 1.0-1.3 s for 220,000 files, 65 ms for a 20,000-object .git alone. internal/paths owns resolving and comparing host paths (resolve.go): Physical (every link, as far as the path exists), PhysicalParent (the folder's links, the last element as named) and, for a path that must exist, filepath.EvalSymlinks itself; Within (the folder or inside it) and Below (inside only). project's Unsafe and Parents, sshagent's mountedBy and recordedPath, Lima's Seatbelt paths and QEMU's PATH search, and the home copy's skips use them. Tests: TestPhysical, TestWithinAndBelow, TestSetIDOnStop (named at creation and stop, not at a launch into the running VM; not in .git), SetIDFiles' .git and missing-folder cases; detect's and hostsafety's tests moved with their code. Docs: when set-id files are named, on the user, safety and internals pages; the contributing page on the resolvers; AGENTS.md's layout 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]> |
||
|
|
1640feb608 |
feat(netpolicy): one CA per VM, with a successor the VM trusts ahead of time
Each VM with network policy has CAs of its own in its run folder, vms/<hash>/run/ca/ (paths.VM.CA, paths.CA: ca.pem/ca.key, next.pem/ next.key; folder 700, keys 600, kept out of Time Machine on macOS), so a leaked key reaches one VM and no proxy can sign for another VM. The shared ~/.local/share/devvm/ca (Dirs.CA) is gone. trust.InitCA(paths.CA) readies the current CA and the next one at each launch: the current one stays while it has over a week left, then the next one (started) takes its place, else a new one; the next one starts a week and an hour before the current one ends and is made again when it doesn't follow it. Each CA lasts 30 days and an hour, and its common name holds its serial, so a VM's two CAs never share a subject. The proxy's config gains ca_next, ca_next_key and ca_next_sha256 (part of Sum); the proxy signs with the next CA from an hour after its start (ca.signer), so the switch needs no launch or new proxy, and a VM not opened again stays verifiable for at least 30 days less an hour after its last launch. /ca.pem serves both certificates. loadCA reads the CA files with readPrivate (no links, a key only the user may read, 64 KiB cap) instead of tls.LoadX509KeyPair. The VM's setup sends both certificates (devvm-proxy.crt, devvm-proxy-next.crt) and no key. Tests: TestInitCA, TestInitCASwitch, TestInitCAReplaced (trust); TestNextCASigns, TestLoadCA, config check rows (proxy); TestPrepare and TestPrepareRestartsTheProxy for the VM's CA files and both sums (netpolicy); TestVMFiles; network, sync and layout txtar; e2e network: a second network-policy VM with different CAs, each VM trusting only its own and holding no key, each proxy serving and presenting only its own VM's CAs, devvm rm deleting one VM's CAs. Docs: internals/network.md (The VM's CA), design.md (A CA per VM, its threat check), safety/network.md, overview.md's per-VM files, space.md, security.md, attack-vectors.md, limits.md, coding-agents.md, contributing, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
314852a8a4 |
fix(layer): a remake holds its VM's lock, records when its new machine is done, and keeps the saved home while it's recorded
The group's review found three ways the remake's resume and undo could delete the only copy of a VM's home folder: - A second devvm in the folder took a remake that was still running for one that stopped, and finished it: the remake now holds the VM's remake lock (paths.VM.RemakeLock, run/remake.lock) from finding the VM until it ends, reading the state again under it, and a second devvm refuses (remake_running). - The undo put the old machine back but could fail to end the remake, leaving Made set and the saved home deleted: putBack now records that the machine by the VM's name is the old one, and clear deletes home.tar.gz only after the section is gone. - An interrupt while the old machine was deleted ran the undo, which deleted the new machine with the home folder: once the home is in, the remake is committed and recorded as done (remake.done) with its new image, and only then is the old machine deleted (dropOld), which the next devvm finishes when it can't. A resumed remake whose old machine is gone is checked again first (makeNew), as the others are. Docs: images.md (another devvm refuses, close other shells first, rebuild then update for a current VM), overview's remake steps, locks and files, design's threat rows. Comments name devvm layer rm beside layer add. Tests: TestRemakeHeld, TestRemakeDone, TestRemakePendingChecked. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c40f9bbf74 |
fix(sshconfig): change known_hosts under its own lock
Pinning or forgetting a VM's host keys takes known_hosts.lock (an OS file lock, paths.Dirs.KnownHostsLock), reads the file again inside it and writes it whole with state.WriteFile, so two devvms at once lose neither's pin. ForgetHostKeys takes its caller's ctx. TestHostKeyConcurrent holds two pins' reads until both have read; it fails on the unlocked code. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cab497bc8f |
feat(layer): devvm layer add makes the folder's VM again with more layers, keeping its home and settings
The one remake in vm's Lifecycle (remake.go): the image built first, the agents' history exported and the home folder saved (home.go: the VM's tar stream filtered on the host), the VM stopped and its machine renamed aside (backend.Backend's Rename, limactl rename, vmname.Aside), the new machine made from vm.json, started, its home put back, then the old one deleted. A failure or interrupt before that puts the old VM back; a killed devvm leaves the remake section, which the next devvm or devvm layer add finishes. The VM keeps its ID (design.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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
6c276af933 |
fix(state): every path in devvm's folders from paths, a VM's folder deleted under its lock, and the state layout review's fixes
paths names the files that were built elsewhere: Dirs.ShareLock (tools.lock), RetentionLock, GroupsLock, ToolImage, QEMUWrapper, DefaultLima and ToolsBuildPrefix, and paths.VM's comment says what backend/ holds. The structure test's owners rule fails a filepath.Join onto a Data or Config field outside internal/paths, and an os.MkdirTemp or os.CreateTemp there with a literal name (pathCases). Fixes: - state.RemoveFolder deletes a VM's folder holding the VM's lock, so a change another devvm is making lands first and none after it; teardown and clear use it (TestRemoveFolder). - Retention at a command's start skipped tool images when tools/.lock existed, a file nothing makes: it asks tools.Env.ShareBusy, which tries the share's lock (TestLockShare). - An image's build VM's folder (its sandbox profile and start record) is deleted once the image is built (TestBuildImageBase; layout.txtar). - doctor says what in vms/ it can't read (vms_unreadable) instead of dropping the error (TestVMFolderProblems). - devvm rm VM checks again after asking: a folder that came back, a VM made again, or an agent VM stopped meanwhile keeps the VM (TestRmVMChecksAgain). Docs: overview's run/ and locks, rm VM's second check, space's run/ row and doctor's findings, images' retention and the share's lock, Contributing's owners table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
628dc11c94 |
feat(state): a layout version for devvm's folders, made_by in its records, the golden listing and doctor's leftovers in vms/
The data and config folders each hold a version file (state.Layout, 1). state.CheckLayout runs before every command but help, completion, version and devvm's hidden commands, under version.lock: the same version goes on, a missing file gets this devvm's, an older one runs the migrations in order (migrations(), empty now), and a newer one in either folder refuses with layout_newer; a file that isn't a version fails with layout_unchecked. made_by, devvm's version, is in vm.json's core fields (set when the VM is made, kept by later changes), image records and tool image records. It's passed from cli's devvmVersion through vm.NewEnv, tools.New and build.Env.Version. testdata/script/layout.txtar makes two network-policy VMs with a forwarded port, a link and a secret, and compares every path under the data and config folders with checked-in listings (macOS and Linux). devvm doctor warns about entries in vms/ that aren't VM folders (vms_stray) and VM folders without vm.json (vm_folder_stateless), changing nothing. Tests: TestMigrations, TestCheckLayout, TestCheckLayoutMigrationFails, TestVMFolderProblems, TestSkipsLayout; made_by checks in TestVMRoundTrip, TestImage, TestToolImage, TestUp, the build and tools tests and scripts; doctor's unit test and script. Docs: internals/overview (the layout version, made_by), using/space, using/settings, using/troubleshooting, internals/images, Contributing (changing the state layout). 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]> |
||
|
|
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]> |
||
|
|
5003d94cfb |
refactor: read HOME once, into paths.Dirs.Home
paths.FromEnv reads HOME, which must be absolute, and keeps it, cleaned,
as Dirs.Home; everything else takes the home folder from there. Six other
reads go: vm.NewEnv's and cli's devvm secret's os.Getenv("HOME"),
gitprotect.New's, Docker's and smolvm's os.UserHomeDir (Desktop's
settings file, the machines' location), and smolvm's Getenv("HOME")
(DiskDirs).
- vm.Env.Home and secrets.Store.Home are gone: both read Dirs.Home.
secrets.NewStore takes the Dirs alone; gitprotect.New takes the home
folder for ~ in git's paths.
- forbidigo bans os.UserHomeDir, with its line in
testdata/lint/forbidigo.go; the structure test's owners check gains
envOwners, HOME read only in internal/paths/dirs.go, with cases for a
read outside it, through a field, in paths and in a test.
Tests: TestFromEnv checks Home (and a HOME cleaned), TestNewHome (~ is
the home New is given, not the environment's), TestDiskDirs checks
Location too. Coverage unchanged.
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]>
|
||
|
|
1cfc8e24f1 |
test: share the stubs sandbox, message checks and recorders across Go tests
internal/stubtest puts testdata/stubs first on PATH with a folder of its own (New, New with only some stubs), reads and writes the stubs' files (Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It replaces the stub setups of the Lima, Docker and smolvm backends' tests, vm's --clone tests and platform's Keychain tests, and the backends' own execRunner, reset and touch copies. The structure test holds it to tests and to importing only internal/msg. msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers and the errors.AsType checks that only read a message's ID or names; msg.Recorder replaces the inline recorders tests set as Info, Warn or Say. backendtest.Stored replaces the four stored fakes with disks. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9c34ad5c69 |
fix: host git reaches ssh alone, a queued git-protect mode is set after the check, and retention's lock is an OS file lock
A review of the recent fixes found three gaps, and an e2e cascade. - hostgit: protocol.allow=never is only the default for protocols with no key of their own, so a repo's protocol.ext.allow=always and a url insteadOf for the VM's URL made a --clone VM's seed push and rm's fetch run a command the repo named on the host. Host git now runs with GIT_ALLOW_PROTOCOL=ssh, which git takes over every protocol setting. TestCommandSSHOnly (failed on the old code). - git-protect: checkGit set a mode saved while the VM ran before it checked .git, so a .git the VM replaced meanwhile became the baseline without git_replaced. It checks under the mode the VM ran with first, then sets the new one. git_protect.txtar's replaced-.git step (failed on the old code). - retention: its lock was a folder taken over after 10 minutes, so a long retention run could be joined by a second devvm and a crash left it held. It's platform.TryLockFile on retention.lock now, and retainLockAge is gone. TestRetainDueAndLock checks an hour-old held lock isn't taken over. - e2e: when the group join's helper server didn't start, gp_refused ran devvm network on for a VM outside the group, which turned its policy on, so six later group and link checks failed too. gp_refused now checks the VM is a member first, and lk_start says which server didn't start. Docs: internals/git-protection (GIT_ALLOW_PROTOCOL, the check's order), using/space (retention.lock). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
07ca65c098 |
feat(cli): devvm host, the tools noun and devvm history
devvm ssh is devvm host. devvm tools shows this folder's VM's shared tools (TOOL VERSION NEWER BUILT, from the lock as it is, never online); devvm tools add/rm TOOL... add and take out shared tools, each a word of its own (joined with + refused: tools_joined; add takes only shared tools: unknown_tool), and devvm tools update moves the VM to the newest. devvm IMAGE on a VM that exists adds nothing and asks nothing: it fails with vm_lacks_tools, naming the devvm tools add command, or vm_lacks_layer, as only a new VM gets a layer. devvm export is devvm history export [FILE]; devvm history lists the exports in the exports folder (FILE VM FOLDER DATE SIZE), the folder from a <export>.folder file written beside devvm's own exports and deleted with them. gc --exports is gc --history, retention's exports.age/count are history.age/count, and devvm space's row is history. The in-place layer machinery goes: Launch.addLayers and runLayers, dockerLayers' inPlace/set/unset, backend.DockerLayerVM.SetDockerLayer and the Docker backend's SetDockerLayer, with the add_in_place, restart_for_mounts, no_terminal_confirm, keeping, adding and add_layer_failed messages. vm.Tools (tools.go) holds Add, Remove, Update and List; tools.VMs.Show lists a VM's tools; tools.Remove takes names as a list; VMs.Update compares a VM's files as a set. New messages: vm_lacks_tools, vm_lacks_layer, has_tools, tools_joined, history_failed, tools_failed; renamed: unknown_tool, gc_history, gc_history_export, deleted_history, gc_older_than_needs_history. Command files: host.go, tools.go, history.go, refreshtools.go (_refresh-tools); ssh.go, remove.go, update.go, export.go and gc_exports.go gone. Tests: TestImageLacks, TestToolsAdd, TestShow, TestCompleteToolNames; history.txtar, gc_history.txtar, host_code.txtar and the e2e tools, docker layer and host checks updated. Docs, the CLI reference, AGENTS.md and the e2e header follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
18eefddc16 |
feat(cli): devvm retention, bare secret and ssh-agent, ssh-agent rm, and setup's network question
- devvm retention [KEY=VALUE...] shows every retention setting (off when
unset) and changes them; KEY=off turns one off, KEY= is refused and
nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
agent's keys once one is added (it starts no agent without one).
devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
refused). In a terminal it also asks for new VMs' network policy (ask,
on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
VMs read unless --network-policy or --no-network-policy is given.
Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c0b9916ff2 |
feat(gc): gc --tools names the tools it keeps for the hour, and --force deletes them
gc --tools prints gc_tools_recent (count, tools) for the current shared tool images no VM has that it keeps because they were built in the last hour, after the same filters as the ones it deletes (TOOL names, --backend, skipped backends): with gc's list, or in place of nothing_to_clean. Plain gc never prints it. --force, only with --tools (gc_force_needs_tools otherwise), also deletes those and skips gc's prompt; gc still lists what it deletes. Tools a VM's state lists stay, the share's lock is held from before the List, and no other category widens. Retention's Idle keeps the hour. The being-made signal: tools.Making, an flock on making.lock in devvm's data folder (platform.LockFileShared, platform.TryLockFile). up's create (every backend, --clone, devcontainers), devvm update and adding a layer in place hold it shared from before they pick tools until the VM's state lists them; gc --tools --force takes it exclusively without waiting, after the share's lock, and holds it through its deletions, else fails with gc_force_making and deletes nothing. The OS releases it when the process ends, and its descriptor is close-on-exec. Tests: TestLockFileShared, TestLockFileKilled (a killed child releases it), TestMaking, TestNoVM's recent ones, TestGCAsks, gc_tools.txtar. Docs: using/images.md, using/space.md, internals/images.md, the CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6f680a6f8b |
feat(proxy): a shared, read-only Nix cache that only the host fills
VMs with network policy and the nix layer share their downloads from cache.nixos.org: the proxy answers http://devvm.proxy/nix/ itself (a reserved endpoint, never forwarded), and the guest setup puts it before https://cache.nixos.org in Nix's substituters, trusted-public-keys left as Nix's own (cache.nixos.org-1). Each VM keeps its own store and daemon; only downloads are shared, and no VM can change what another gets. The proxy (internal/proxy/nixcache.go, -nix-cache DIR and -nix-cache-max BYTES): - takes only GET and HEAD, no query, nothing escaped, of nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no suffix or .xz, .zst or .bz2 (nixPath, FuzzNixPath); 400 otherwise; - makes up nix-cache-info (priority 30, before cache.nixos.org's 40); - fetches from https://cache.nixos.org alone, when the VM's policy allows cache.nixos.org:443, through the floor or the company proxy, with the system's roots and the user's CAs, following no redirect, sending nothing of the VM's request; - keeps a narinfo when its StorePath is the path asked for, its URL is of the pattern and named by its own NarHash or FileHash, and a Sig by the pinned cache.nixos.org-1 Ed25519 key verifies over 1;StorePath;NarHash;NarSize;References (parseNarinfo, against a real narinfo and NAR of cache.nixos.org's in testdata/nix/); - fetches a NAR only after a narinfo it checked names it, never for a HEAD, once however many ask and at most four at once (fetchOnce), and keeps it when its SHA-256 and size are the narinfo's FileHash and FileSize; a cached copy of another size is dropped; - answers 404 to anything that fails, keeping nothing, so Nix goes to cache.nixos.org itself; logs each request as a nix-cache event (hit, fetched, or why not), which devvm log shows as cache; - writes files whole and renames them in, 600 in folders of 700. The cap: the nix-cache.size retention setting, 10 GiB when off (state.NixCacheDefault, proxy.NixCacheDefault), with state.ParseSize (500M, 20G, 1T). Under a flock on .lock every proxy takes a file's room before writing it (reserve, in whole blocks), deleting the least recently used files (by mtime, which a hit sets) down to nine tenths of the cap; a NAR being fetched is made its full size at once and counts, so a fetch the in-flight files leave no room for is refused. devvm gc trims to the cap, devvm gc --nix-cache empties it, and the daily retention run trims it (proxy.TrimNixCache, NixCacheUsage). devvm space has a Nix cache row (GC: what's over the cap, FREED BY gc --nix-cache, RETAIN nix-cache.size), devvm images says what it takes of its cap. netpolicy passes -nix-cache and -nix-cache-max only for images with the nix layer (nixCacheArgs; a retention file it can't read warns and uses the default). The guest setup writes /etc/nix/devvm-cache.conf through !include in nix.conf only with the nix layer and policy on, removes it otherwise, and restarts nix-daemon when it changes. VMs without network policy get no shared cache: they fetch from cache.nixos.org directly, and nothing new runs or listens on the host for them. Review (security-audit skill, on nixcache.go, its callers and the setup): a NAR could be kept under another NAR's name, as the URL isn't signed (fixed: the URL must be named by the narinfo's own hashes, and a hit of another size is dropped); files being fetched didn't count against the cap and blocks weren't counted, so one VM's parallel requests could pass it (fixed: reserve, full-size temp files, block counts, fetchOnce); a HEAD downloaded a NAR (fixed). Ruled out: stored VM input, paths out of the folder, another upstream, parser differences, cross-VM visibility beyond timing, a VM's own nix.conf. Open, documented: timing tells a VM whether some VM fetched a public path, and a VM can fill the cache to its cap. Messages: gc_nix_cache_over, gc_nix_cache, deleted_nix_cache, images_nix_cache; retention_deleted gains nix_files. Paths: Dirs.NixCache (structure limit for Dirs to 40). Flags: devvm gc --nix-cache; the CLI reference regenerated. Tests: TestNixPath, TestNix32, TestParseNarinfo, TestNixCacheServes, TestNixCacheRefuses, TestNixCachePolicy, TestNixCacheFetches, TestTrimNixCache, TestNixCacheCap, FuzzNixPath, TestParseSize, TestRetention, TestNixCacheArgs, TestFormatEvent; nix_cache.txtar (the proxy's endpoint and refusals, space, images, gc, gc --nix-cache, retention); e2e nix: the VM's substituters and keys, hello through the cache, fetched by the host (600/700), a VM's writes and other requests refused and nothing kept, a second VM's hits fetching nothing, no cache after devvm network off. Docs: the design note (internals/design.md), internals/network.md's The shared Nix cache, the VM's setup, logs and flags, internals/security.md, internals/images.md, safety/network.md's Nix and Logs, using/toolchains.md's Nix projects, using/images.md, using/space.md, using/settings.md's Retention, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |