mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
52
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cb7177b32c |
feat(ui): waits for another devvm's lock show a status line; a project folder devvm can't read says so
Lock waits: - platform.LockFile and LockFileShared take a platform.Waiting, called once they find the lock held, never when it's free, whose end they call once the wait ends; LockFileWaiting, LockFileSharedWaiting and their delays (ShareNote, OCINote, WaitNote, groupsNote, makingNote) go. - msg.Waiting makes one from a Reporter's Status and a label; msg.WithStatus and msg.StatusOf carry the run's Status in its context for the two packages that take no Reporter, internal/state and internal/trust, which cli's execute sets; forbidigo keeps StatusOf to them, and AGENTS.md says so. - Every lock that waits shows its own label: vm_state_waiting (a VM's state, its deletion), claims_waiting, layout_waiting, git_lock_waiting, ca_waiting, packages_waiting, rebuilds_waiting, ubuntu_pin_waiting, custom_secrets_waiting, forwarder_waiting, agent_store_waiting, and the waits that printed a line after a delay, which now show theirs as a status line: share_waiting, oci_waiting, image_build_waiting, group_waiting, making_waiting. - An agent's login file's lock (agentlogin's lockLogin, a folder's flock that a VM's proxy holds while it refreshes the login) tries first without waiting and shows agentlogin.File's Waiting (agent_login_waiting) while it waits; secrets fills it from its Reporter, for SaveLogins, Claude Code's logins folder and every File. - The structure test's status-lines rule counts a LockFile or LockFileShared whose waiting is nil as slow work; the build port's record, a file just made that never waits, is listed in statusSites. - Without a terminal, or with -v, a status line draws nothing, so the waits that printed an info line after a delay no longer print it there; the CHANGELOG and the troubleshooting page say so. from.txtar's check that a free conversion lock printed no wait goes, as TestLockOCI checks it. The layout's migration runs under a status line (layout_migrating), only when there are migrations to run. Backend calls outside a launch: TestCommandStatusLines runs devvm ls, ports, size, network, tools, git-protect, history export, stop and rm on a running and a stopped VM and fails on a backend call with no status line showing, with a control that each makes one. A project folder devvm can't open and read (vm_folder_unreadable) was taken for another folder's VM (vm_other_folder, which offers rm and adopt, and adopt went on); the finder now keeps why (target.unread), and every command on the folder's VM, from the folder or a subfolder of it, names the folder and why; devvm rm VM run elsewhere goes by the VM's name as before. platform.UniqueFolderID had no caller but its test: FolderStat.Unique, from the open folder, replaced it; it goes, and its test checks StatFolder's Unique instead. Tests: TestLockFileWaiting (rewritten: called only when held, its end once got or given up, shared too), TestVMLockWaits, TestCheckLayoutWaits, TestCheckLayout (migrations under layout_migrating, nothing shown otherwise), TestLockGroups, TestLockShare, TestMaking, TestLockOCI and the build lock's test (status lines, not info lines), TestLockLogin, TestInitCACancelled (ca_waiting), the status-lines rule's lock cases, TestCommandStatusLines, TestUnreadableFolder (a subfolder of it too), TestStatFolderUnique. Docs: Contributing's CLI page (Status lines) and structure page, the cli and codebase-standards skills (the guards), AGENTS.md's Go conventions, internals/images.md and design.md (the waits), using/troubleshooting.md, using/vms.md (a folder devvm can't read); CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3101c85260 |
fix(vm): a failed agent import leaves the store as it was; the import's bounds count every entry and cap a file; a login's terminal is put back
devvm agent import wrote each settings file into the store as it read it, so a file that failed to read partway (changed since it was listed, or past the bounds) left the store half replaced. The import now reads and writes every agent's settings into a staging folder of the agent's store first (.devvm-import-<random>, beside the agent's folder, so no VM mounts it), and only once all of them are staged, and the run isn't interrupted, moves each file into place, prunes what the home folder no longer has and then saves the logins. A failure or an interrupt while staging leaves the store as it was: the staging folder goes, through discard, or through a cleanup for an interrupted run, which reaches it by a root of its own. A failure after that (a rename, a login) can still leave the store partly replaced, which internals/agents.md says. A killed import's leftover staging folder counts as nothing of the agent's (inStore), so it never makes the import ask, and the next import of that agent takes it out first (sweepStages). The import's bounds on an agent's own folder now match devvm agent save's: the walk counts every entry it meets, links, sockets and FIFOs included, not only the folders and files it keeps, and a file of more than 16 MiB, as listed or as read, fails the import as the 128 MiB does. Claude Code's plugin records are copied with the store's longer paths, and what the copy grows counts against the same bounds (hostAgent.grew), naming the folder, or the link a file came through, so the store never gets more than the import checked. The two handles on an agent's folder, the os.Root it lists through and the folder opened one folder at a time that it reads through, are checked to be one folder (sameFolder), failing the import otherwise. A VM state the import can't read is a warning (agent_import_states_unread), naming the file, rather than silently dropping that VM from the project-inside warnings and the link checks; the follower takes the VMs the import read at its start instead of reading them again. state.WriteFileIn and writeFileMode share one tail (finishTemp). clearKind takes the root the import opened once, rather than opening the store for every path, and pruneStore's walk is pruneIn, which the import calls on the same root. Cursor's changing verbs (proxy's cursorChanges), checked again against the 1,463 methods of DashboardService, AutomationsService and BackgroundComposerService in 2026.11.17-f532c45, read and not run. generate goes: it matched only GenerateGrokCollectionDescription, which only returns a draft, and GenerateTeamGrokBotScimIdpSigningKey, which cursorCredential refuses anyway; no other method changes between refused and passed. test stays, justified in its comment: it matches TestAutomationFilter, a dry run that only reads, but also TestTeamCustomerTelemetryDestinationConnection, which has Cursor's servers send a request with any headers to any address. park, hand, decline, replace and resend match only methods that cursorCredential refuses too (as rotate, link and invite do), and stay, justified in the comment, for the methods Cursor adds. Every cursorRoutes path the CLI's login goes to is checked against the proxy by agentlogin's TestCursorCapture (proxy can't import agentlogin, which imports it); TestCursorChangingVerbs now says so. devvm agent login on a terminal saves the terminal's state before the login (ui.Terminal, through vm.Env.Terminal, which now returns a restore) and puts it back once the login and endLogin are done, or in a UI cleanup if the run ends first, so an ssh that a signal killed in raw mode doesn't leave the host terminal raw. Tests that fail without their fix: TestAgentImportFailsWhole (a failed import leaves the store's own files and no staging folder), TestAgentImportTooMuch (rewritten: its dead want field gone; exactly 20,000 entries and 128 MiB list whole, one more entry or byte fails, a link and a FIFO count, a file of 16 MiB and a byte fails), TestAgentImportPluginsGrow, TestSameFolder (the helper, and the import with its folder swapped between the two opens), TestAgentImportStageLeftover, TestAgentImportInterrupted (the ctx check before apply, and the interrupt cleanup on its own), TestAgentImportProjectInside (beside a broken state), TestCursorChangingVerbs (GenerateGrokCollectionDescription passes), TestAgentLoginTerminal (put back once, after the login ended, interrupted included), TestTerminalRestores. Tests that pin what already held: TestNarrowNotesBesideBroken (devvm network's -g allowlists beside a VM state that can't be read), TestWriteFileIn (a failed rename leaves no temporary file), and TestCursorChangingVerbs' TestTeamCustomerTelemetryDestinationConnection. The finder now checks fst with found, so nilaway no longer reports fst's flow, and all of fst's lines in its baseline go. Docs: using/coding-agents.md, internals/agents.md, internals/network.md; CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
da872a6550 |
fix(vm): a renumbered folder's volume is checked until it's read; folder identity is read once
When a boot numbered a project folder's disk anew and its volume couldn't be read at that launch (diskutil failing or slow), recordFolder recorded the new device with the old volume, and from then on the identity matched byte for byte, so no launch compared the volume again: a copy of the disk with a volume ID of its own, mounted at the folder's path later, would have kept the VM. It now records the folder unchecked (state.VM.SetFolderUnchecked, vm.json's folder_unchecked), so each launch looks the volume up again; Env.keepsVolume compares it while the record is unchecked, as for a renumbered one, refusing another volume (vm_other_folder), and the first lookup that finds the recorded volume clears the mark (folderRecord). A move matches an unchecked record only on its volume (here.same), and a move whose lookup fails keeps the recorded volume, bound to the inode and birth time a move keeps, unchecked (recordMove). On Linux, where the volume is read in the process (volumeFree), every launch compares it, so a Btrfs snapshot or a ZFS clone mounted at the folder's path is another folder even on the original's device; after a volume's UUID changes, devvm adopt gives the folder its VM again. The finder's sameFolder and madeFor share one body (madeForOpen), and the folder is opened once: platform.SameOpenFolder is SameFolder for a folder StatFolder already read, platform.RecordedAs is its exact match, and keepsVolume, recordFolder and here.same take that read rather than open the folder again (here's id and unique are its stat's). madeFor, which the checks that ask which VM mounts a folder use, falls back to the folder's stat when it can't be opened, as when code in a VM that mounts it took away its read permission, so no VM hides from clone_repo_mounted or project_in_vm_folder that way. recordFolder compares again under the state's lock with the same folderRecord. The structure test's folder-ids rule now finds a map literal keyed by a folder's identity whose type is a named map type of the module's, a generic one included, or elided in a map's or a slice's literal whose elements are maps. Docs: a Btrfs rollback at the folder's path, or a volume's new UUID, needs devvm adopt; a Mac volume that ignores ownership makes every folder yours to the offer's check; the unchecked mark and Linux's check at every launch (internals, overview's vm.json fields). Tests: TestUncheckedOnAnotherVolume, TestKeepsVolume, TestRecordFolder (unchecked, then checked), TestRecordFolderUnderLock, TestRecordMoveVolume, TestMovedFrom (unchecked), TestMountedByUnreadableParent, TestSameFolder (SameOpenFolder, RecordedAs), folder-ids' named, generic and elided map cases, and fixture_v010_renumbered's unchecked steps on 0.1.0's state. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bb0df957a0 |
fix(doctor): a broken VM state hides no other VM's warnings; Cursor's account services refuse more changing verbs
doctor's policy warnings (netpolicy.NotRules) listed the VMs with state.VMNames, which fails whole for one state it can't read, so one broken vm.json made doctor skip every VM's policy warnings. So did devvm network's warnings about every VM (allowlists for -g, and OtherBinaries). They now use state.ReadableVMs, the VMs whose state reads, which leaves the broken one out and the rest in; VMNames stays strict for what must count every VM, such as ports. A VM folder doctor can't read got two warnings, vms_unreadable from state.VMFolderProblems and vm_state_broken from vm.StateProblems; VMFolderProblems now leaves it to the latter, which names the VM and why. cursorChanges, the verbs refused in Cursor's DashboardService, AutomationsService and BackgroundComposerService, gains merge, fork, write, pin, unpin, rerun, confirm, request, release, acquire, activate, deactivate, notify, make, open, ensure, park, copy, bulk, advance, abort, wake, snapshot, seed, reply, opt, hand, fail, use, skip, decide, unshare, undelete, unpublish, unprepare, unresolve, enroll, unenroll, upgrade, suspend, switch, duplicate, dismiss, deregister, deliver, decline, convert, close, append, execute, provision, mutate, inject, finish, finalize, reassign, reinstall, reject, renew, reorder, reparent, replace, resend, rmdir, report and record. Each was checked against all 1,463 methods of those services in 2026.11.17-f532c45, read and not run: every one of the 102 methods they match changes something, none only reads, and the CLI calls none (Submit, Resolve, Check, Batch and the like stay off, as their methods read or the CLI calls them). fixture_v010_logs' capped.sh loop and network.txtar's sleeps around the squatting proxy now wait with wait_until. Tests: TestNotRules and TestOtherBinaries (beside a state that can't be read), TestVMFolderProblems, doctor.txtar (an unreadable VM folder, one warning), TestCursorChangingVerbs. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c901b920ef |
fix(agents): the agent store is written only through roots, an import is bounded, and projects overlapping agents' folders get a warning
devvm agent import and save checked each path they wrote in the store by path (storeGuard), then wrote by path (os.MkdirAll, state.WriteFileMode), so a link swapped into the store between the check and the write could lead the write elsewhere. They still check every path first, so a link fails the command, naming it, before the store changes; they now write only through the agent's folder in the store opened from devvm's config folder as a root (makeStoreDir, which makes it and the folders on its way through the config folder as a root, then openStoreDir), with state.WriteFileIn, a whole-file write through an os.Root. An import copied whatever an agent's folder held, one file at most 128 MiB, so a VM whose project folder is inside an agent's folder could fill the store that every VM with the agent mounts. Each agent's folder now gets agent save's bounds in all, 20,000 files and folders and 128 MiB: the walk stops at 20,000 (errFolderTooMany), the sizes as listed are counted (hostAgent.tooMuch), and a folder over either fails the import before anything is written, naming the folder and what to do (agent_import_too_much); the files' reads share the 128 MiB (h.read), so files that grew since the listing fail too. Before it reads anything, the import warns of each VM whose project folder is inside an agent's folder or holds it (agent_import_project_inside). A project folder that holds an agent's folder, such as ~/.pi for pi's ~/.pi/agent, let its VM put a link in the agent folder's place, which the import followed, copying whatever it led to, such as the home folder's files, into the store: the import now resolves the folder's path one link at a time (linkHops), leaves it out with agent_import_link_via_vm when a link in a VM's project folder leads it out of that folder (throughVM, shared with the link follower), its login with it (pi's auth.json), and reads the folder where the path led. Every agent's login file but Claude Code's ~/.claude.json, which was already a capped, regular-file read, was os.ReadFile by path, so a VM whose project folder held it could swap in a link to another file, a FIFO or an endless file between the check and the read: its path is now resolved once (linkHops), left out when a link in a VM's project folder leads it out of that folder (throughVM), and read where it led, through its folder opened with no link and never resolved again (openPhysical), opened without following one, a regular file of at most 128 MiB (claudeHostLogin), so a folder swapped for a link since fails the read. Tests: TestWriteFileIn, TestAgentImportTooMuch, TestAgentImportReadBudget, TestAgentImportProjectInside, TestAgentImportProjectHolds (a folder and a login led elsewhere), TestAgentImportLoginNoFollow, TestStoreOpsRefuseLinks (makeStoreDir). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ba510eec1f |
feat(vm): a folder moved across a restart keeps its VM, by its volume
A project folder's identity was its device, inode and birth time, and since #60 a folder at its recorded path matched on another device. A folder that moved while a restart gave its disk another device number matched nothing, so plain devvm made it a second VM, and folderOf took a renumbered disk for an unmounted one ("not connected"), so movedAway was false too. Each VM's state now records the folder's volume, which no renumbering changes, as folder_volume, "<kind>:<value>:<ino>:<btime>", bound to the folder it was read with (platform.VolumeOf, RecordedVolume): macOS's volume UUID from diskutil (platform.VolumeUUID, only for the mount point and device read from the folder opened with no link, its answer checked against both), Linux's f_fsid on ext4, Btrfs and ZFS (StatFolder, read from the open folder); none on a read-only volume or a snapshot, or elsewhere. state.VM's folder is unexported: Folder(), FolderVolume() and SetFolder(id, vol), the one writer, which creation, adopt, a move and recordFolder (renumbered's successor, at each launch) use; a launch records the volume of a VM made before, once it can (1 s at a launch, 5 s at an adopt or a move, one failure a run stops the rest, through Env.Volumes and its run's cache). moveHere matches a moved folder by its volume, inode and birth time (platform.MayHaveMoved, MovedFolder), looking the volume up only once the rest matches, with the identity it matched and records both read from the folder opened with no link (hereOf), and folderOf compares the parent's volume where the state records one (platform.OnRecordedDisk), through Env.folderState for a move or an rm. The folder-ids rule now also reads Folder() and FolderVolume() calls, FolderDevice, locals assigned from any of them, switches and strings/slices comparisons. An older devvm keeps folder_volume as it is (checked with 0.1.0's own reader in a temp copy of its tree). A rename keeps the inode, so the binding stays right; when an older devvm adopts another folder for the VM, or a move across volumes copies it, the binding names another inode, so the record names no volume and is recorded again. DEVVM_VOLUME stands in for diskutil, and for Linux's f_fsid, in test builds (VolumesOnly). Tests: TestFolderOf (not connected after a renumbering), TestMovedFrom (moved and renumbered, and a split between the read that matched and the one recorded), TestRecordFolder (made, a VM made before at its next launch, a failed lookup, a renumbering keeping the bound volume), TestVolumeOfCache, TestVolumeOf, TestMovedFolderAndRecordedDisk, TestStatFolder(AndVolumeUUID), TestPlistStrings, the folder-ids rule's new cases, fixture_v010_renumbered.txtar (0.1.0's VM records its volume, then moved and renumbered it's offered, never a second VM), and e2e's projectRenumbered (hdiutil, macOS) and the project section's volume check. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ba5613e1ed |
fix(project): a folder name's run of separators becomes one dash in its VM's name
A folder named x--y, "foo (copy)" or "C++ stuff" failed to get a VM (#52): project.Slug turned each character other than a-z and 0-9 into its own dash, and Lima's instance-name grammar refuses separators in a row. Slug now writes one dash per run. - vmname: the project-VM grammar refuses dashes in a row ([a-z0-9]+(-[a-z0-9]+)*); HasRuns recognises the names releases up to 0.1.1-rc.3 made for such folders. - state: a vm.json whose name HasRuns and that has no created time is read as no state. Only a create that Lima refused leaves one (vm.json is written before limactl clone), so the folder's next VM, in the same hash folder, replaces it, rather than every read failing as corrupt. One with created set is still corrupt. - The limactl stub refuses names Lima refuses on create and clone; TestLimactlStubContract gains a refused clone, checked against real Lima. - Tests: TestNamesLimaTakes (Lima's regex as the oracle), TestHasRuns, TestVMWithRuns, TestLimactlRefusesNames, name_runs.txtar (a new VM for x--y, and an older release's leftover state replaced). - Docs: internals/backends.md's VM names; CHANGELOG Unreleased Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0b85f5f557 |
fix(size): a size that isn't a number is refused, never read as 0
Size.Backend dropped strconv's errors, so a VM's size in vm.json that isn't a number, such as "cpus": "four" after an edit by hand, read as 0, the image's, and the VM started with the image's size without a word. Backend now reads each part with the check that took it (settings.CPUCount, settings.GiB, which ParseCPUs and ParseGiB now use), and returns an error naming the key and value. storedSize turns a stored one into size_stored_invalid, naming the VM. Every start (bringUp, before anything runs), a restart's stop (stopToStart, so a running VM keeps running, as a refused proxy start leaves it), devvm size and a remake's check refuse with it; devvm size --KEY sets it again. ParseCPUs and ParseGiB also refuse a number too big for an int or a float64, which for --disk reached Lima as +Inf. Lima's originOf read base's disk with ParseFloat and dropped its error: "NaN", "Inf" and "1e400" passed its check of a size above 0. Only devvm's own Origin writes that step (gibString of BaseDiskGiB), so no user, VM or limactl output reaches it; it now reads it with settings.GiB and fails naming the value. Every other discarded strconv error outside tests goes too: - hostgit.Bool reads a boolean as git does (yes, on, whole numbers) and says when a value isn't one; GIT_CONFIG_NOSYSTEM, which strconv.ParseBool read as false for "yes", uses it, as does the clone's copy of a repo's config (gitBool, which had its own copy). - image.GlibcOlder checks both versions itself and reports ok, so one that isn't a version is never read as 0. - leaktest and state's lock order panic on a goroutine number runtime.Stack doesn't print today, rather than reading it as 0. - cli's test-build overrides fail on a number that isn't one (a test build's panic), the stub limactl refuses a size it can't read, and opencodeMajor's fallback to 0 is explicit. Tests: TestSizeBackend, TestStoredSizeInvalid (a stopped VM and a running one's restart), TestSizeNumbers, new TestParseSizes and TestOriginOfRefuses cases, TestParseUnknownFormat, TestBool, TestUserFilesOf's git booleans, TestGlibc's invalid versions; each fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
90a64a44d1 |
fix(races): lock order checked, sandboxes' own ports, pins that meet a rename, daemons' groups stopped
- state: test builds and tests check the state locks' order (state.held, CheckLockOrder): a second VM's lock, a VM's lock under the claims lock, or a lock taken again panics before waiting. - platform: PinBeneath opens the path again when a rename takes the file away before move_mount (ENOENT), so the keeper no longer reports a false lost pin (TestPinsInNamespace's 'f lost / f pinned-again'); TestPinWhileRenamed. - daemon: Proc.Stop signals the process group (SignalGroup), so forwarders' and link sessions' ssh masters and relays end with them; ui.UI.StopsItsOwn makes _ports and _links wait for their ssh on an outside SIGTERM. - vm: gc --orphans and devvm space count forwarders' leftover control sockets (vmssh.ControlGlob). - CLI tests: each sandbox claims a block of ports below devvm's range and the ephemeral range (claimPortBlock, /tmp/devvm-test-ports); free_port, the fixtures' ports and DEVVM_SSH_PORTS come from it, and the sandbox's devvm chooses from its own range (DEVVM_PORT_RANGE override). Fixtures' forwarded ports and settings ports are rewritten too (FIXTURE_PORT_<port>). - netpolicy and vm tests: the fake proxy's stop waits for its reap, and fake daemons run until the test ends, not 30 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6fd1d846d6 |
fix(lima): cache a Linux VM's project folder with 9p's none
Linux's 9p client loses data with Lima's default cache=mmap for a writable share: a stat() during an extending write() takes the host's stale size and writeback drops the data, so files reach the host empty or cut to 4096 bytes even after fsync (Claude Code's Edit sets it off); and on devvm's Ubuntu 26.04 guest kernel, a lock after a write makes the next read return zeros, which breaks SQLite in any journal mode and Gradle's daemon. macOS's vz VMs use virtiofs and aren't affected. - New VMs on a Linux host record cache mode none in a new mount section of vm.json, and their project folder is made and started with it, as is the folder devvm clone off mounts. VMs whose state has no mode (0.1.0's, and every VM made before this) keep Lima's mmap untouched, with no limactl edit, and each launch warns (mount_cache_unchosen) until devvm mount-cache none. - devvm mount-cache [none], with --json: none is the only mode devvm sets, so any other value is a usage error (mount_cache_invalid); a stopped VM gets it in its next start's one edit, a running one after the restart devvm offers. macOS refuses (backend_lacks), and so does a Linux VM whose folder isn't a 9p mount (mount_cache_no_choice). No -g or config.toml key: every new VM gets none. - The start that changes the mode mounts the folder again in the guest, as cloud-init rewrites fstab only after systemd has mounted it, through the logged runner with a minute's limit (output pipes closed a second after), then checks it with mountpoint and findmnt, reading 4 KiB at most and only the last line: a folder left unmounted stops the VM and fails the start before its shell (mount_cache_unmounted), and so does a check that gets no answer (mount_cache_unchecked); one still mounted with the old mode is warned of (mount_cache_remount_failed), any mode but none or mmap named unknown. An interrupt meanwhile, on any tier, leaves a cleanup that stops the VM, the one stop then. A launch into a running VM asks the guest, in words, whether its folder is a mount point, and refuses one that isn't (project_unmounted) or whose check fails or gives no answer (project_unchecked). A stored mmap, from a build before none alone, reads as none chosen, and devvm clone off records none for its new mount; any other mode is refused naming vm.json. - backend: FeatureMountCache (native on Linux, none on macOS, built on project-mount), Want.ProjectCache, Instance.ProjectCache, CacheModes. - lima: mount rewrites keep only the sshfs and 9p settings devvm knows where they differ from Lima's defaults, and drop the rest for Lima to fill in, so lima.yaml never freezes a default; same() compares the cache where devvm sets one. Build VMs' writable output folders (tools, --from) get none. - tools: an EROFS tool image that ends before its superblock does, or is shorter than its superblock says, as a build under mmap could leave one, counts as not built, so the next build makes it again; a build's short output is refused. The fakes' tool images are a page (backendtest.ToolImage). - The limactl stub lists QEMU's vmType, fills in 9p cache defaults on Linux, and answers the remount's check. - Docs: backends/lima (the project folder's cache, when it changes, programs that map files for writing, SQLite), using/limits, using/clone, commands, internals/lima, internals/backends, the design note (both mmap bugs, why none alone, the remount, tool images, the e2e findings), the CLI reference and the cli skill. - Tests: TestProjectCache, TestMountRoundTrip, TestStartSetsProjectCacheOnce (the remount's outcomes), TestCutShort, TestBuiltCutShort, TestGuestMountOptions, TestFilledMounts, TestUpCacheMode, TestWarnMountCache, TestCacheAtNextStart, TestSwitchCache, TestSetMountCache, TestCheckStateCache, the mount_cache CLI test, clone_switch and the 0.1.0 fixture on Linux, and e2e's projectMountCache (findmnt, a stat-while-write loop, SQLite's journals, a shared writable mmap refused, the opt-in switch of an unchosen VM, what mmap does reported, macOS unchanged). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d44175601 |
refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e6f64dae31 |
refactor(vm): one VM inventory per run
vm.Inventory (internal/vm/inventory.go) holds each project VM's state, backend and Instance, read in one place: ReadStates for the states alone, ReadInventory (UsedBackends or AllBackends) for the backends' lists too, each within the host's list wait (30 s), with the backend's Check saying why a list failed. It replaces Env.mounts, recordedVMs, vm.List and vm.ToolsInUse, linkstate's clientStates listing, the secret list's, Leftovers.Find's (and backendVMs), cli/space.go's two (backendRows' list, vmFolders), images' state.Backends and sshconfig's running list: sshconfig.Write takes the inventory's Running VMs. state.ReadAll reads each VM folder on its own (only the inventory calls it, a structure-test callers rule); state.Backends and Registry.Used go. One failure policy: - a backend that can't list fails a listing (Inventory.Err) only when some VM's state names it: devvm ls and the ssh config fail, and the ssh config stays as it was rather than lose that backend's entries; space and gc --orphans name it and leave its VMs alone; - an unreadable vm.json is its own row: ls lists the VM with its name and status alone and warns (vm_state_unreadable); links, the secret list, rm VM and link targets leave it out; gc --orphans never takes it for an orphan; ToolsInUse and Mounts (images, gc, space, the SSH agent's mounted-key check) fail on it, naming the file; - FolderOf is bounded (5 s): a folder on a hung share is there. Mounts come from the states alone, stopped VMs and agents' folders included, so the mounted-key check asks no backend. ui.Table shows every cell through msg.OneLine, so ls's cells can't move the cursor or break a row. Docs: internals/overview's listing, troubleshooting's file devvm can't read, ssh's mounted keys, contributing's owners table. 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]> |
||
|
|
d9d169e972 |
fix(tools): a --from base never builds tool images other VMs mount
gnu tool images, which any VM whose tools need their key mounts, always build in a clone of devvm's own Ubuntu base on the VM's backend, never in a --from image, whose code runs as root in its build. --from Debian and Ubuntu VMs mount those images, and tool_needs_glibc still refuses a base too old for one. When devvm's own base isn't built yet, devvm says so (tools_need_own_base) and builds it first, pinning the cloud image on its first build as usual. musl tool images build in the VM's own --from base, and their keys hash that base's digest (image.Tool.Base, tools.Target.Base, from the base's record), so they're only ever another VM's on the same container image. Their records keep it (base). devvm tools add, tools update and update build a musl VM's base first, its digest looked up, so the keys they work out are those of the base the images build in. Every gnu key hashes devvm's own base, so no image built in a --from base under an earlier key is mounted again. Share.Build reads the record of the base it's about to clone and refuses any but the one the images are for (buildsFor, tools_wrong_base): base from Ubuntu's cloud image for gnu, a --from base with the target's digest for musl. Tests: TestBuildOnlyInItsBase (hostile --from gnu and musl bases, a layer, no record), TestUpFromTools, TestToolsAddFrom, TestToolFile's musl digest, TestToolFileRefuses, TestToolTarget's digest; from.txtar: the clone of devvm's own base, a base record that says it came from a container image refused (tools_wrong_base), and tools_need_own_base before devvm's own base is built; e2e from checks where the Debian and Alpine VMs' tool images built and the musl records' digest. Docs: internals/images.md (building tools, keys, the share, listing), using/from.md, using/images.md, using/space.md, internals/design.md, internals/security.md, contributing's e2e list, AGENTS.md's tool-key rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1f2e4a0edc |
feat(tools): refuse a shared tool that needs a newer glibc than its --from base
Each shared tool is its project's prebuilt release, built against a glibc it needs at least, so a --from gnu base older than that ran the tool into a loader error. Now devvm measures both sides and refuses the tool clearly. - A tool image's build measures the newest GLIBC_ version its ELF programs and libraries need (shared-tools/build.sh's glibc_needs: readelf's version needs, testdata folders left out), writes it to FILE.glibc, and devvm keeps it in the image's record (glibc), taken only as a plain file holding one version (tool_bad_output). - A --from conversion records the image's glibc version (getconf GNU_LIBC_VERSION in a chroot; oci/build.sh's glibc output, checked by checkConverted), in base's record and every image's on it (backend.Built.Glibc, state.Image.Glibc). Ubuntu's own base has none and isn't checked; musl needs none. - tools.Target carries the base's glibc (not hashed: a gnu tool image is the same on every base); a VM's state records it (tools.made.glibc); Launch.buildTools checks every tool with tools.Share.Runs after building, for new VMs and devvm tools add/update and devvm update: tool_needs_glibc names the tool, its version and both glibc versions. - image.ValidGlibc and image.GlibcOlder own the version's shape and order. build.Env.ToolTarget reads base's record once (BaseLibc gone). - Measured minimums, current releases (arm64 / amd64): node 2.28/2.28, pnpm 2.18/2.18, bun 2.17/2.17, python 2.17/2.17, uv 2.28/2.17, rust 2.17/2.17, go none (its 2.34 came from Go's own testdata), claude 2.17/2.17, opencode 2.17/2.17, codex 2.28/2.28 (its voice helper). - Tests: TestGlibc, TestBuildGlibc, TestBuildGlibcRefused, TestRuns, TestGlibcNeeds (build.sh's function against debug/elf, where readelf is), TestToolTargetGlibc, checkConverted's glibc cases; from.txtar: an old base refuses node at launch and at devvm tools add, keeps go, and records 2.24; e2e: the Debian base's record and VM state hold the VM's real glibc, no tool image needs a newer one, and Ubuntu's tool images record a glibc; the stubs write FILE.glibc and glibc. - Docs: using/from.md (Shared tools and glibc), using/toolchains.md (Which bases they run on), internals/images.md, assets/oci/README.md. Every tool image's key changes once (build.sh), so each is built again. 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]> |
||
|
|
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]> |
||
|
|
ae0fd533fc |
refactor(msg): names mode is the UI's, read once with each stream's style
A msg.M always renders as its text: String, Error, Parts and Segments no
longer read DEVVM_MESSAGES, and Line is gone. internal/ui reads names mode
in newStyle, with each stream's color, and shows messages as names through
the style (message, segments, line, valueParts). ui.New takes the function
it reads the environment with, so tests make a names-mode UI without
t.Setenv. Messages shown as data go through UI.Text or Table.Text (doctor
--json, ls's image cell, setup's network choices); vm.PickRow.Desc is a
msg.M that cli renders. A config.toml value's refusal keeps its message
(state.CorruptError.Msg, Shown), so fail shows its names in names mode.
Tests: ui TestNamesMode; state TestFiles covers Msg and Shown; Go tests
compare NamesOf or Names, and drop t.Setenv("DEVVM_MESSAGES") outside ui,
msg's TestNames and the testscript runner. The structure test lists
DEVVM_MESSAGES in internal/ui/style.go only; ui.UI's method limit is 47
(Text).
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]> |
||
|
|
da93384f60 |
fix(lint): fetch.Client is its own type, and forbidigo bans http.Transport, os.Create and O_TRUNC
fetch.Client was an alias of http.Client, so &fetch.Client{} got past
NewClient's timeout and HTTPSOnly. It is now a struct only NewClient fills:
Do sends with the client's policy, Transport returns its own transport for
callers to change (ubuntu's file://, the public registry's dialer), and any
other Client fails every request with ErrNoClient, which isn't transient.
forbidigo's HTTP rule also bans http.Transport, and http.Client's Transport
field, outside fetch, the proxy and tests.
The os.WriteFile rule also bans os.Create and os.O_TRUNC, so a
truncate-in-place write outside state needs a nolint saying why. The four
left are not files written whole from memory, or are the standard library
only: tools' check log and a link session's log (a process writes them as
it runs), fetch.Download's file (streamed, removed on failure) and
daemon's pid and status files (one write, which readLine and readStatus
take as missing until its line ends). state's doc says so.
Tests: TestClientMadeByNewClient (nil and zero Clients send nothing and
aren't retried; NewClient's transport is its own); from's and build's
tests use the registry's own client trusting the TLS test server.
Fixture lines: http.Transport, os.Create, os.O_TRUNC.
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]> |
||
|
|
f2a8ddd404 |
refactor: write every file whole through state, and make private folders with state.PrivateDir
internal/state is the one writer of whole files outside the proxy: state.WriteFileMode joins state.WriteFile for another mode (0700 for the QEMU wrapper and Docker's copies of devvm's Linux build), and state.PrivateDir makes a folder the user's alone (700), refusing a file or a symbolic link there, as vmssh's runDir did. - Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's writeFile (the Seatbelt profile, the QEMU wrapper, the start record), vmssh's writeWhole and runDir, Docker's copyFile, the Linux build fetch's temporary file (fetch.Open's body is read whole, its SHA-256 checked, then written with state.WriteFileMode), and Resolve's .tmp-and-rename loop. The host's mise stays fetch.Download's. - os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions' mise.toml, the checked file, the tools build's files), sshagent (two), ubuntu's checksum files, docgen's pages and backendtest's fake tool images. - state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders): the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and socket folder, lima's run folder and the exports folder. MakePrivate and ~/.ssh keep following a link: where they live is the user's choice. - The proxy's writers are one, writeAtomic: the login files' writeJSON and the Nix cache's size file use it, its temporary files named .<name>.tmp-* as state's are. - forbidigo bans os.WriteFile outside internal/state, internal/proxy, internal/msg/gen, internal/stubtest and tests, with its line in testdata/lint/forbidigo.go. Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder refused, its folder's mode unchanged), TestWriteAtomic; mode checks on the Seatbelt profile and Docker's Linux build copy. Coverage baselines raised: lima, netpolicy, proxy, secrets, ui. 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]> |
||
|
|
20c9fdbadd |
fix(build): a build holds its image's lock, so concurrent builds, gc and rebuild leave it alone
On Lima a build in progress is a recordless image with its final name, so a second build, devvm rebuild or devvm gc took it for a leftover and deleted it. Each build now holds an OS lock per image key (images/locks/KEY) from before it looks for the image until its record is written; the system lets go of it when devvm ends, however it ends. - A second build of the same image waits for the lock, saying so after 3 s (image_build_waiting), then finds it built. - An image without a record is unfinished only while its lock is free; while held it's listed as building (devvm images, --json state). - gc (and gc --backend) and rebuild skip building images; images rm and DeleteKey refuse them (image_building). Deleting an image removes its lock file while holding it. - platform: LockFileWaiting and LockFileSharedWaiting (call a func once after waiting a while), LockHeld; a lock whose file was removed while held is taken again on the new file. tools.Making.Hold uses the shared helper instead of its own two-step wait. - state.ImageLock: a key's lock path, the key checked. Tests: build TestBuildInProgress, TestBuildTakesTurns; platform TestLockFileWaiting, TestLockFileRemoved, TestLockHeld; state TestImageLock; build.txtar checks a hanging build is listed as building, kept by gc and refused by images rm. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7929eafaf5 |
fix(msg): every message value renders without control characters
A value a VM made reached the terminal unfiltered wherever a caller forgot msg.Shown, such as the errors passed as err.Error() and a link's name. Four cleaners did the job in different ways: msg.Shown (quoting), ui's printable and oneLine, netpolicy's oneLine and the port forwarder's log (which let C1 through, in UTF-8). msg.Printable and msg.OneLine are now the one cleaner: they drop C0 but newline and tab (OneLine drops those too), DEL and C1, in UTF-8 or as a lone byte. Every message value goes through OneLine as the message renders, in Text, Segments and names mode, so no caller can forget it, and msg.Shown is gone with its 68 calls. The status line, the run log's end and verbose output, Pick, devvm network log, the forwarder's log and a clone's status lines use them too. Tests: TestPrintable and TestValuesArePrintable (internal/msg), the hostile-value segments test, TestLogLimit (internal/backend/vmssh) with C1 in UTF-8 and as a lone byte; TestCheckLinks and TestNewVMOtherRepoAndCommondir expect the cleaned values. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4ea141b918 |
feat(link): devvm link, link add, rm, publish and unpublish, with their state and checks
Links between VMs' commands and state, without anything carrying a connection yet. - state: every VM gets a random ID (KeyID, "id") when CreateVM makes it. - vm: Links (links.go) lists, adds and removes the folder's VM's links (KeyLinks, "links": NAME,PORT,TARGET,TARGET_ID,ADDR entries) and publishes and withdraws its ports (KeyPublish, "publish"). Each target gets one address in 127.77.0.0/16 per client, the lowest free. CheckLink says why a link doesn't apply (gone, replaced, unpublished, policy). - project: Matching (which sshconfig.Alias now uses), IsPath, ForDir and Targets resolve a link's TARGET: a path, a VM's name or a folder name. - cli: link.go, in the Links between VMs group; --json on devvm link and devvm link publish; --as checked with the other flag values. - Messages: no_vm_link, link_failed, link_port_invalid, link_ports_invalid, link_unknown_target, link_ambiguous_target, link_self, link_not_published, link_policy_mismatch, link_name_invalid, link_name_host, link_name_taken, link_target_named, link_exists, link_added, link_trust, link_removed, link_not_found, link_port_taken, published, unpublished, port_not_published. - Docs: the Links between VMs table on the Commands page, the CLI reference, AGENTS.md and the cli skill's tree. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e782de9ae8 |
feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory, --disk, --ports, --network-policy, --no-network-policy) are the root's own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown flags. build, rebuild and images rm take --backend and --from; images, gc and space take --backend as a filter of their own (images and space now filter: only that backend's rows); doctor takes --backend; restart and tools take none. ports -g is local on ports, ports add and ports rm. No command has a persistent flag. One name, one meaning: network log --follow loses -f (-f is --force's, and gc --force gains it); the hidden secret get's --force becomes --to-terminal. Flag defaults name the setting command (devvm size -g, devvm ports -g, devvm setup --backend); descriptions lose then/also openings. Special values are words: an empty flag value (flag_blank) or an empty argument (arg_blank) is refused everywhere, replacing features_empty. Durations: state.ParseDuration (a whole number and m, h, d or w) for gc --older-than, retention's ages and ssh-agent add --lifetime (which also takes forever, via sshagent.CheckLifetime), with one message, bad_duration, replacing gc_bad_age and agent_lifetime_invalid. Blanks are checked with the other usage errors (checkCommand, before checkFlags), and an unknown --backend NAME is a usage error checked first too (checkFlagValue, against registry.Names, which a test keeps equal to the registry's own). Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning, TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root, setup, images, space, gc_history, retention, ssh_agent and network_log scripts. Docs: commands.md (Flags and values), from.md, install.md, images.md, space.md, settings.md, ssh.md, network pages; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f9e14e9b37 |
feat(cli): usage errors as devvm messages, checked before anything runs, exit code 2
Every argument and flag error is a devvm message naming what the command expected, followed by usage_help naming that command's own --help, and exits with 2. Arguments and flag values are checked in Args, before the root's PersistentPreRun and any VM lookup. - internal/cli/args.go: noArgs, exactArgs, maxArgs, minArgs (argsN, with ValidArgs), argsOf (the arguments in Use), checkCommands (wraps every command's Args with checkFlags and marks RunE's errors as ranError), checkFlagValue (--cpus, --memory, --disk, --ports, --lifetime, --older-than), exclusive (flag groups checked first, then Cobra's own required flags and groups), flagError (SetFlagErrorFunc: pflag's NotExist, ValueRequired, InvalidValue, InvalidSyntax errors). - Execute: 0, 1 for a failure (RunE's error: a message, or output_failed), 2 for a usage error; usage_error is only the fallback. - Checked early: ports LIST and add/rm LIST (vm.ParsePortList), network allow/deny RULEs, network on/off(/ask with -g), layer new NAME (build.CheckLayerName), retention KEY=VALUE (state.CheckRetention), setup --features '', secret NAME, completion SHELL, git-protect and ssh-agent values. - ui.UI.Error prints an error without ending the run (UI's method limit 44). - Messages: usage_help, arg_missing, args_too_many, args_none, arg_not_choice, no_subcommand, flag_unknown, flag_needs_value, flag_bad_value, flag_bad_switch, flags_exclusive, output_failed; usage_error reworded; doc links to troubleshooting. - Tests: TestUsageErrorsEveryCommand, TestRanErrorIsAFailure, TestArgsOf, TestFlagErrors; txtars check message names; e2e checks a bad port list exits 2. - Docs: troubleshooting (a command refused before it runs, exit codes), contributing (command arguments), AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
452e7bf80a |
fix(state): devvm's data and settings folders are the user's alone on every run
Before every command, the root command's PersistentPreRun runs state.MakePrivate: it makes the data folder ($XDG_DATA_HOME/devvm) and the settings folder ($XDG_CONFIG_HOME/devvm) when they're missing and sets both to mode 700, whatever mode they had, so a wider mode on anything beneath them opens nothing to others. When it can't, devvm warns (folders_not_private, linked to what devvm keeps) and goes on; without an absolute HOME there are no folders, and the command says so itself. The per-folder 700s (exports, logs, run logs, run, CA, secrets) stay as they are. Tests: state's TestMakePrivate (made, made private from 777, a folder inside keeps its mode, one that can't be made fails) and folders_private.txtar (modes after a run, the warning's fields). Docs: using/space.md's data folder, using/settings.md's state and internals/overview.md's state section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7cd15a0862 |
feat(retention): retention settings for what devvm keeps, all off by default
~/.config/devvm/retention holds key=value lines, written by devvm space set KEY=VALUE... (KEY= turns one off; a bad key or value is refused before the file is written; all off removes the file). Every setting is off unless set: - logs.runs: run logs kept (20 when off; ui.KeepRunLogs). - exports.age, exports.count: exports that old deleted, then all but the newest count. - tools.unused-age: current shared tool images no VM's state lists, counted from when retention first found them so (an <image>.idle record in the share, dropped when a VM lists it again). - orphans.age: what devvm keeps for VMs their backend no longer has (vm.Leftovers, as gc --orphans), once their state hasn't changed for that long. Ages as state.ParseAge (30d, 2w, 12h). Not the backends' caches (gc --caches only), and never a VM, an image, or a tool any VM's state lists. devvm's commands apply the settings at their start at most once a day (data/retention.run; again at once after a clock that went back), under a lock so two devvms never apply them at once (a dead one's lock is taken over after 10 minutes), skipping the tools while a build holds the share's lock; it says what it deleted in one line on stderr (retention_deleted). orphans.age needs the backends asked, so only devvm gc --retention applies it; gc --retention applies all of them at once. space, gc, completion and devvm's internal commands don't apply them on their own. A bad line names the file and the line, and then none applies (retention_unreadable). devvm space shows each setting beside its row (RETAIN), with what it would free now. Not done here: logs.network.size and logs.network.files, which override the proxy's log rotation defaults: rotation is another task's (the proxy rotates its logs), not on this branch; space set refuses them until it is. Messages: retention_deleted, retention_off, retention_busy, retention_unreadable, retention_failed, retention_bad, retention_saved. Docs: using/settings.md (the file, each setting, all off), the What devvm keeps page (what each setting does, RETAIN), using/images.md's Cleaning up, the CLI reference. Review (deletes only what it's told to): no file or an empty one deletes nothing (txtar, unit); a VM, an image and a tool any VM's state lists are never retention's (Idle builds on NoVM: a stopped VM's and a leftover state's tools stay until orphans.age deletes that state); two runs at once (lockRetention); a clock that jumps (retainDue, Idle and the age checks skip a negative age); the one-line report on every deletion. Tests: TestRetention (parser, set, off, bad lines), TestIdle, TestExportsToRetire, TestRetainDueAndLock; retention.txtar (refusals, space set and RETAIN, the automatic run once a day and again after a day, gc --retention with tools, a VM's tool kept). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bf03f26221 |
feat(gc): gc --exports [--older-than AGE] deletes saved exports
Exports (exports/<vm>-<date>-<time>.tar.gz, from devvm export and devvm rm) were never deleted, and each can be the only copy of a deleted VM's agent history. --exports deletes them, never as part of gc's default run; --older-than AGE (state.ParseAge: a whole number of days, weeks or hours, 30d, 2w, 12h, which retention will read too) keeps those newer, by the date in their name. Only plain files named as devvm names them: an export being written (.devvm-export-…), a folder or a file of the user's in the folder stays. The list names each export's VM and date (gc_exports, gc_export); it asks in a terminal, goes ahead without one, never deletes a VM. --older-than without --exports, or an age devvm doesn't take, is refused. devvm space's exports row says gc --exports frees them, and counts the exports as gc does. Messages: gc_exports, gc_export, deleted_exports, gc_older_than_needs_exports, gc_bad_age. Docs: coding-agents' History, using/images.md's Cleaning up, the What devvm keeps page, the CLI reference. Tests: TestParseAge; TestExports (names, order, the age boundary); gc_exports.txtar (the default run keeps them, the flags refused, 30d deletes the old one only, then every one, nothing else in the folder). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
edc0c865ed |
fix(vm): launches ask only the backends a VM's state names
A launch lists VMs (the ssh config, the SSH agent's folder checks) only on backends some VM's state names, so a Lima user's launch never runs docker or smolvm, and a wedged or missing engine never slows one down. - state.Backends: the backends the VMs' states name; Registry.Used: the registered ones among them, sorted. ls and images use state.Backends to fail only on a backend a VM's state names (vm.BackendUsed goes). - Env.mounts and sshconfig ask Registry.Used; sshconfig.Config.Backends is a function read at each write, and Write fails on unreadable state. - up.txtar: a new and an existing Lima VM's launches run neither docker nor smolvm; registry_test covers Used. - tests/e2e.sh: the from section's launches make no docker call but image inspect. - docs: backends.md says which backends a launch asks. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
851e39ef86 |
build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/, shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which cli passes to every constructor; backends, the builder, the shared tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts reach VMs on stdin (backend.Script carries their contents). What needs a path (limactl create's base.yaml, oci/ mounted into the conversion VM, the proxies' policy files) is written out to ~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders 700; devvm gc deletes older copies no VM's proxy was started with (gc_assets, deleted_assets). Release archives hold the binary with README.md, CHANGELOG.md and LICENSE, and the formula installs the binary alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b03293b7d7 |
feat(setup): devvm setup chooses base's features and the default backend
devvm setup asks which features base gets, starting from the current
choice (every feature until there's one; kept without a terminal), or
takes them from --features LIST without asking ('' for none), saved in
the features' run order. A name that isn't a feature is no_feature and
saves nothing. --backend NAME saves the default backend new VMs get
(~/.config/devvm/backend, read by the registry), checked against the
backends devvm has; alone, it leaves the features as they are.
A changed choice prints base_will_rebuild, and gc_old_hint once any
image record exists. base_features and base_features_none name devvm
setup. --features completes feature names, setup's --backend backend
names.
- build: PickFeatures, SetFeatures (the first build's choice goes
through PickFeatures)
- state: AnyImage
- messages: no_feature, base_will_rebuild, gc_old_hint,
default_backend, setup_failed
- tests: setup.txtar, completion.txtar; TestPickFeatures,
TestSetFeatures, TestAnyImage
- docs: customizing.md (choosing features), backends.md (choosing a
backend), the CLI reference
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
a8a20a085e |
feat(policy): devvm policy, the allowlist of a folder's VM
devvm policy shows the policy files of this folder's VM that have rules, in order, comments left out. devvm policy allow|deny|rm RULE... edit the VM's own file, or with -g/--global the user's file for every VM; the VM's proxy re-reads a changed file, so changes apply at once. - proxy.ValidRule: the rules devvm policy takes (host, *.host, **, an address or CIDR, optional port and !); AllowRule's suggestions are valid (FuzzRequest checks it), and FuzzParseRule checks valid rules parse. - netpolicy: Rule, AddRule, RemoveRule, WriteRules; files rewritten whole through a link; duplicates and rm match in any case, comments aside. - vm: Env.Policy and Env.PolicyChange; net_off_policy for a VM without network policy. - state.VMNames skips <vm>.policy files. - Messages: net_off_policy, no_vm_policy, not_a_rule, rule_added, rule_added_global, rule_present, rule_removed, rule_removed_global, rule_missing, policy_failed. - testdata/script/policy.txtar: allow/deny/rm, -g, IPv6 rules, refused rules, the rules shown per file, a VM without network policy, and a new VM not inheriting rules of one deleted outside devvm. - e2e network: the allow command devvm log --blocked suggests applies at once on the running proxy; rm blocks again. - Docs: network.md (Changing rules), commands.md, CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e5df9e22df |
feat(ls): list project VMs with a BACKEND column
devvm ls lists the project VMs on every backend, sorted by name: NAME, STATUS, IMAGE (base (from node:24) for a --from base), GIT (on, off, or clone for a --clone VM), NET (on, off, or unenforced: a failed self-check, or running but not confined by devvm), BACKEND and FOLDER. Images and build VMs aren't listed; a project VM named like an image is. What a VM's state lacks is -. A backend that can't list fails ls only when a VM's state names it. - vm.List, netpolicy.Listed, state.VMNames - messages: image_from, ls_failed - bats cases converted: delete.bats "ls and the ssh config include a project VM named like an image" (ls half), network.bats "ls shows network policy: off, on, unenforced" and the ls check of the direct route case (testdata/script/ls.txtar, Go table tests) - e2e: ls checks in project and network - docs: commands.md (Listing VMs), network.md, lima.md, CLI reference Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4bdb3ea843 |
feat(ssh): ssh config and pinned host keys
Each running project VM can be reached as devvm-<folder> (or by its full name when two folders share a name) through ~/.config/devvm/ssh_config, which up rewrites after the VM's setup. Every entry checks the VM's own host keys, kept in ~/.config/devvm/known_hosts and read from the VM through its backend, and sets StrictHostKeyChecking yes, ForwardAgent no (unless the VM forwards), and its own connection. Only Lima's login options are copied. Host keys are dropped before each start, and when an interrupted new VM is deleted, so they're read again. Ported: write_ssh_config (sshconfig.Write), record_host_keys, forget_host_keys (ForgetHostKeys, in vm start and the interrupt cleanup), ensure_ssh_include (EnsureInclude: asks with [Y/n] on a terminal, else says to add the line; no caller yet: --clone and devvm ssh/code), ssh_alias (Alias), is_project_vm (project.IsVM), check_ssh_agent (vm checkAgent, run when a new VM forwards the agent). Backend.SSH's SSHTarget gains Options (Lima: identityfile, identitiesonly, preferredauthentications, batchmode, compression, gssapiauthentication, ciphers). Registry.All, state.WriteFile. Messages: ssh_include_needed, ssh_include_yourself, add_it_now, ssh_include_added, no_ssh_agent, ssh_agent_empty, load_key, key_loaded, key_loaded_keychain, load_key_with. Doc links: ssh_remote_hint, ssh_include_yourself. Converted bats cases: cli.bats "ssh config: only running VMs, each with its own host key checked; Lima's unchecked settings left out" (ssh.txtar, lima TestSSH, sshconfig TestWrite; the rm half waits for rm), delete.bats "ls and the ssh config include a project VM named like an image" (ssh config half: ssh.txtar, TestWrite), project.bats "ssh_alias: short name unless two folders share it" (TestAlias, ssh.txtar). New: TestWriteUnchecked, TestParseHostKeys, TestEnsureInclude, TestCheckAgent, TestIsVM. Stub limactl: Lima-like ssh.config at start, host keys from shell, sshLocalPort/sshConfigFile in list. e2e: project checks the hostname, the entry, pinned host keys, ssh devvm-web through an ~/.ssh/config of the run's own (Include plus Host * ForwardAgent yes), no agent forwarded (a throwaway agent), a changed host key refused; network checks ssh devvm-net. Nothing touches the real ~/.ssh. Docs: ssh.md (from the ssh page), linked from the index, commands, security, images and contributing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
27905c2413 |
feat(build): build and rebuild images through the backend
devvm build and devvm rebuild build base and the user's layers through Backend.BuildImage. On Lima an image is a stopped instance: base from Ubuntu's cloud image with base.yaml, a layer a clone of its parent, each started confined with no host mounts, its script run, then stopped. Records are written last; an interrupted or failed build deletes its instance through the cleanup stack. Rebuild bumps the rebuild counter and deletes stale images no VM uses. tests/e2e.sh starts here, with its framework and an images section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |