mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
188
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
592076cfda |
fix(lima): taking base's packages out says why it failed, in the run log
The tar that streams the packages base downloaded out of its build VM had its standard error dropped, and neither its failure nor the host's reading of the stream reached the run log, so packages_take_failed left nothing to go on. Its error output now goes to the run log, with a line naming either side's failure. The CHANGELOG's Fixed and the release page's Base's packages that don't come out say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
dd46dd7a0f |
feat(tools): tool images build side by side
A first run built its tool images one after another, each paying a build VM's boot (5.7 s on vz, 9.3 s on QEMU) before a download of a few seconds to a minute. Share.Build now hands the images out to up to four slots (buildAll), each slot's builds one after another in a build VM of its own: - slots: as many as the host's memory, less what the backend's running VMs have, and its CPUs give a build VM of 2 GiB and 2 CPUs each after keeping 6 GiB and 2 CPUs, at most backend.MaxToolSlots (4) and the number of images; one alone keeps base's size. A backend that can't list its VMs builds one at a time. A running VM's memory counts whole (7.5 GiB, not 7): TestBuildSlotsFit's running VMs fail when it isn't counted or is truncated. - plan lowers the slots until the backend's disks have room: Floors.ForTools counts Tools once for each build VM at once, as on a disk without copy on write each is a whole copy of base. - backend.ToolsSpec gets Slot, Slots, Size and Hold; Lima's slot VMs are the constants ToolsVM to ToolsVM4, sized with --cpus/--memory, and the first slot's build deletes what a killed run left in the slots this run doesn't use. Builds hold the share's lock, so one devvm uses the slots. - A failed build's VM goes in the run's cleanup, which runs after the build let go of the share's lock: it deletes the VM only once it has the lock again (ToolsSpec.Hold, Env.holdShare's TryLockFile), and leaves it while another devvm holds it (a build, gc or the daily refresh) (TestBuildToolsCleanupHolds, TestBuildHoldsShareForCleanup). The next tools build deletes what it finds in the slots, and so does devvm gc, which holds the share's lock: backend.Images' DeleteToolsLeft, Lima's deleting the slots' build VMs that are there and no other VM, which gc asks of every backend first, without asking, a backend that can't being a run log line. It returns what it deleted, which gc names in one line (tools_build_vms_deleted), and gc then never says nothing_to_clean or nothing_deleted (gc_tools_build.txtar, TestDeleteToolsLeft in lima and vm, the fake's ToolsLeft). The cli skill's judgment.md names this exception to "gc --force deletes exactly what gc lists". The conformance suite's delete-tools-left checks that it deletes no other VM, not even the project VM of a folder named tools (devvm-tools-<hash>), and no image (TestConformanceFinds: deletesAllVMs, deletesImage, deletesByPrefix). The share's lock is the data folder's, so devvms with their own data folders and one Lima home don't exclude each other's builds: the docs say not to build tools or run gc in two at once (a lock per build VM in the Lima home would close it, but it would replace Hold and needs e2e). - Side by side, one status line covers the builds (building_tools_together), and their commands' lines in the run log are tagged with their tool (msg.WithLogTag): the UI's LoggedCmd prefixes them and shows no status line of its own. Every write starts with the tag, as does every line in it, one ended by "\r" included, so no build can pass a line off as another's (TestTaggedWrites), and a tool's lines are found after another's "\r" (taggedLines splits there, a progress bar's updates staying one line: TestTaggedLines). The first failure cancels the others and is what Build returns, tagged (backend.LoggedIn), so ErrorLogged shows that tool's lines' end. - A test build's DEVVM_TOOL_SLOTS caps the slots; the CLI tests set 1, so the stub's calls keep their order, and tools_side_by_side.txtar sets 3, with an interrupt that leaves no build VM. The stub keeps each build VM's folder by its name, and the fake backend's BuildTools runs its builds outside its lock, as a real backend's would, passing ToolsBuild its context. Docs: images.md's Building tools and Free space, ports-size.md, space.md, images.md (using) and gc's help (the build VMs gc deletes), settings.md (one Lima home for two data folders), extending.md, testing.md and tests.md; the cli skill's judgment.md; the CHANGELOG's first highlight and the release page's A faster first run. New messages: building_tools_together, tools_build_vms_deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a8f0517579 |
feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut in its 900 MB fails base's build, and a stall hangs it. devvm now downloads the pinned image itself through fetch.Resumable (ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage), resuming across cuts, stalls and runs, and gives Lima that file. Lima 2.3 checks a local file against the digest before it copies it. - Before downloading, it takes the image from Lima's own download cache when that holds it with the pin's SHA-256: copied into a new file of devvm's own, mode 600, hashed as it's written, capped, stopped by the context, and kept only once it checks out. Lima's cache is never changed, and a base whose dated release Ubuntu may have removed still builds again. - One devvm downloads at a time (images/locks/ubuntu-image), another waiting under ubuntu_image_waiting and looking again under the lock (TestUbuntuImageAfterWait, which fails without that second look). - The download goes through the company proxy and trusts the user's CAs (Lima.Roots, from trust.Pool, which internal/cli passes through the registry), as do the Finder's lookups (TestNewTrustsRoots, and the registry's TestOverrides). An untrusted certificate is ubuntu_untrusted, naming the CAs' folder, one from a trusted CA that's for another host, out of date or not valid yet ubuntu_bad_certificate (check the clock and what answers for the host), and any other that fails to verify (a SHA-1 signature, a CA's name constraints, a key for clients alone) ubuntu_certificate_invalid, naming Go's reason, for the lookups (the listing, the checksums, their signature: TestLookupCertificates) and the download alike (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410) ubuntu_release_gone, which names devvm rebuild base; none is retried. ubuntu_download_failed no longer starts with devvm. - fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a CertificateInvalidError that's Expired) and fetch.Unverified (any failure to verify, with its reason, so every error the other two name), beside fetch.Gone, are the one place that tells a certificate's failures apart: Transient asks Unverified, the lookups and the download ask all three, host mise asks Untrusted, and a forbidigo rule keeps x509's and tls's verification errors in internal/fetch (TestCertificateClasses, TestTransient, testdata/lint, the owners doc's row). - An https address, or a test build's file:// DEVVM_UBUNTU_URL, read from disk the same way; anything else is refused. The CLI tests' sandbox has a stand-in of this host's image in the store. - Base's record keeps the image's address, and the key is as it was: it hashes the pin (release, file, digest), not the location. - devvm gc --caches frees devvm's copies that no record names and that aren't pinned now, unchanged for an hour, a stopped .part and a killed import's .import included, and those of a kept image once its .img is there. A pin it can't read fails it. - Of Lima's cache, it frees only an entry that devvm's own state shows a build of devvm's left: a base record names its address, devvm has its own copy of the image, and the installed Lima's own templates (share/lima/templates beside limactl, Lima.Templates) don't name it. An entry no record names may be the user's own Lima's, so it stays, and none is freed when the templates can't be read, with a line in the run log naming the folder and why. A test build's DEVVM_LIMA_TEMPLATES stands in for the templates folder. - ubuntu.ParseImage reads a record's image as Image.String writes it, and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in place of Lima's own regex. - devvm space shows the copies as a cloud images row, freed by gc --caches, kept as state, as a release Ubuntu removed can't be downloaded again. 0.1.0's frozen state runs the new commands (fixture_v010_cloud_image): devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's base record keeps and never changes the entry, base builds from devvm's own copy, and gc --caches keeps that copy, frees Lima's entry the record names and devvm's own stale copies, and keeps an older entry no record names. Docs: images.md (the download, its failures, the import, gc's rules), space.md, backends/lima.md, settings.md (the lookups and the download trust your CAs), troubleshooting.md, overview.md, testing.md, tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed lines, which later commits make highlights, What to do 5 and 6, and the release page's Ubuntu's cloud image in devvm's folder. New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting, ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate, ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted. Lima.LocalImage is the seam, Lima.ImageClient the client. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
de502f7840 |
fix(vm): rm's read of a --clone VM's clone gives up past 8 MiB or 2 minutes
readClone stopped keeping the VM's answer past cloneStateMax (8 MiB), but took the rest and waited for the command to end, with no time limit, so a VM that wrote without end, or never answered, kept devvm rm and devvm clone off waiting until Ctrl+C. The read of the agents' worktrees already had the bounds; workCheck.answer is now the one read for both, taken from agentTrees: at most cloneStateMax bytes, past which the bounded writer cancels the command, within answerWait (2 minutes, treesWait before), an interrupt returned as ctx's error. A failed, over-long or late answer is the check's failure, clone_check_failed or trees_check_failed, which keeps the VM and names the flag that skips the check, and a hostile one is parseCloneState's, as before. readClone fails before parsing on a bad answer, so its result is never a nil list (the nilaway baseline loses that line) and gosec sees its loop bounded by both lists. On Lima the time limit didn't hold for either read: a cancelled limactl shell leaves its ssh child holding the command's output pipes, so os/exec's Wait waited for the VM's command to end. Exec now goes through the lima package's bounded (WaitDelay, a second), as the remount's commands do, so it ends a second after its context does; output a child held past limactl's own success is exec.ErrWaitDelay, an error, so an answer cut short is never taken as a whole one. That bounds every Exec, devvm paste's time limit and the history export included. treeGlobs returns a list that's never nil: nilaway took its nil for one parseAgentTrees slices into, a false positive (agentTrees returns before it without patterns, and parseAgentTrees indexes pats only below nextRecord's len(pats)), which the CI job reported on main. Tests that fail without the fix: TestWorkCheckBounded (TestAgentTreesBounded, now a table over both reads: an endless answer cancelled, a silent VM given up on after 2 minutes in a synctest bubble, an interrupt kept as the interrupt), whose clone case isn't cancelled and then deadlocks its bubble; TestExecHeldOutput, a real limactl stand-in that leaves a child holding its output, killed and after a success, which waits 30 s each, the success read as one, without bounded. TestParseAgentTrees checks treeGlobs with no patterns. Docs: clone's --no-clone-check names a VM that doesn't answer within 2 minutes, How it works' deleting a VM gives the clone read's bounds, the Lima page's A command's output, the clone design note's cost and threat drop the wait that's gone, and internal/vm's map names answer. The changelog gets an If you use --clone block with the line, the release page its section under Fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e4b44b5994 |
fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.
The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.
TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
947decb301 |
fix(vm): VMs get the host terminal's COLORTERM (fixes #54)
limactl shell asks ssh to send COLORTERM (SendEnv), but its session rides Lima's shared ssh connection (ControlMaster), opened without it, and the master filters a session's environment by its own SendEnv, so the variable never reached the VM (lima-vm/lima#2208, #1481). Closing that connection would end every session and the VM's SSH agent relay, so devvm now sets COLORTERM in the command it runs in the VM instead: - backend.ShellOpts and ExecOpts get ColorTerm. Lima's Exec runs `cd D && export COLORTERM=<quoted> && exec argv`, and its Shell, with a ColorTerm, runs `sh -c 'export COLORTERM=<quoted> && exec "$SHELL" --login'`, as limactl shell does without a command; without one, the argv is as it was. colorTerm (lima) quotes the value with shell.Quote and links Lima #2208, so it can go once Lima sends it. - vm's colorTerm is the one allow-list: only truecolor and 24bit pass, anything else or none is "". target.shell (devvm's shell) and AgentLogin.loginOpts (an agent's login on a terminal) fill it from Env.Getenv; no other command in the VM gets it. - devvm's ssh config entries add `SendEnv COLORTERM`, so plain ssh by name (ControlMaster no) sends it: the e2e showed the base's sshd has AcceptEnv COLORTERM. It adds to a Host *'s SendEnv. Tests, each failing without the fix: TestExecAndShellColorTerm (lima), TestColorTerm (vm: the shell's and the login's value for allowed, near-miss and injection-shaped values), testdata/script/colorterm.txtar (the stub limactl's argv for the shell and an agent's login), ssh.txtar and sshconfig's pinned lines, and e2e: a fresh VM's first shell, a login shell on a terminal in the folder (24bit, and none for another value) and ssh devvm-web. The structure test's dynamicScripts lists both new built scripts. Docs: Managing VMs, ssh access by name, How it works' Lima (A shell's colors) and security (the ssh entries), and CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2de3e31a6c |
fix(vm): devvm ports shows a status line as it restarts a running VM's forwarder, and every lock's wait is tested for its label
Lock waits: - Tests record the label of each lock's wait that had none, the lock held as by another devvm and the wait ended by a cancel, a deadline failing one that shows nothing rather than hanging: git_lock_waiting (TestGitLockWaits; .git protection's Serial is gitSerial, so a test can reach it), packages_waiting and rebuilds_waiting (TestImageLocksWait), ubuntu_pin_waiting (TestPinOriginWaits), custom_secrets_waiting (TestYoursLockWaits) and forwarder_waiting (TestForwardsLockWaits). - A test build's locks panic on a nil platform.Waiting (platform.CheckWaiting, which the root's run calls in every test build beside state.CheckLockOrder), so the CLI tests and e2e catch a nil wait the structure test can't see, such as a zero agentlogin.File's; a msg.Waiting given a nil status shows nothing and stays review only. msg.Waiting with no status gives a wait that shows nothing, never nil; platform.NoWait is the Waiting of a lock that never waits (the build port's record, which passed nil), and the status-lines rule holds it to statusSites as it does nil (TestCheckWaiting, TestWaiting, the rule's NoWait case). - forbidigo refuses syscall.Flock and unix.Flock outside internal/platform, internal/proxy/rotate.go, the stubs and tests (testdata/lint, both). - TestLockFileWaiting runs in a synctest bubble and checks the wait shows while held, not before (its counters under a mutex, which the race detector needs, as only the file's lock orders them). Status lines: - TestCommandStatusLines runs the setters too: devvm ports LIST and ports add, size --cpus, network open, allowlist, transparent off and on, learn and allow, git-protect off and on, ssh-agent off. It found devvm ports on a running VM starting its forwarder again (ssh and a command in the VM) with no status line; that step now shows ports_restarting. The folder named twice: - vm_folder_unreadable's why was the open's error, the folder's path in it; folderUnreadable gives the system's reason alone when the error is about the folder itself (TestUnreadableFolder checks the whole message). - platform.OpenNoLinks and StatFolder return a link on the path as an fs.PathError about the folder too (ErrLinkOnPath still matches), so that case names it once as well (TestStatFolderUnique). Docs: Contributing's CLI page (status lines) and structure page, the codebase-standards guards; CHANGELOG (devvm ports' status line). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
2b176c92b3 |
feat(ui): every slow step shows a status line, and messages and questions never land on it
Any work that can take noticeable time now runs under the UI's status line: a Reporter's Status with a label message, or a LoggedCmd step. The UI: - status lines are a stack: a Status or LoggedCmd inside another shows its own line, then the outer one is drawn again, where before it ended the outer one for good - a message (Info, Warn, Note, Say, data on Stdout/Stderr) clears the line, prints and draws it again below; an unended line holds it - a question (Ask, Confirm, Answer, Secret), the picker and ui.Terminal hold it until they're done - no status line starts once the run is interrupted, as nothing would clear it - the run log's path is read without the log's lock, as the status line reads it under outMu Covered, by site and label: - finder.target: finding_vm; Lima's limactl --version: checking_backend - bringUp's checks (seeds, instance, recordFolder, hostChecks, ssh, requirements) and a running VM's go-on (proxy, pins, mount check): checking_vm; startOnce after the agent: starting; the self-check's probes: checking_network; pinHostKeys: reading_host_keys - setUpVM (sync, ssh config, links, clone seed): setting_up_vm; each devcontainer command: running_script; makeMachine: creating; buildOnce: checking_image; paste's count and rm: reading_pasted - volumeOf's lookup (diskutil), for launch, adopt, move, ls and rm: looking_up_volume - vm.ListAll (devvm ls): reading_vms; devvm doctor's checks: doctor_checking - devvm agent import: agent_import_reading (walk, links, opencode), agent_store_saving (copy, marketplace git checks, tmutil); devvm agent save: agent_save_reading, agent_save_comparing, agent_store_saving - devvm stop (from its pins check on): checking_vm; a delete, an orphan's teardown and Lima's DeleteImage: deleting; devvm git-protect and clone on/off's .git work (leftBehind, mountFolder, unmountFolder): git_protecting; git-protect's re-read: finding_vm - devvm clone add: clone_reading, clone_adding; clone fetch: clone_fetching; planClone: clone_planning; the clone check before rm or a remake: clone_checking; history export and import: history_exporting, history_importing; a remake's home: saving_home, restoring_home - devvm upgrade's install: upgrade_installing; the shared tools' step back and .NET's downloads: resolving_tools; gc's caches: reading_space; the retention settings (daily and in gc): retaining Work that takes the terminal stays off: the shell, ssh-add's passphrase (checkAgent, Agent.Ensure, reloadAgent) and an agent's login. Tests and guard: - msg.Fake: OnStatus and Showing; its LoggedCmd shows its step - backendtest.Fake: OnCall - TestLaunchStatusLines: every backend call of a new, running and stopped VM's launch runs under a status line but the shell's and Running's (pid files) - TestSSHAddOffStatusLine: ssh-add, on the user's agent or devvm's, never runs under one; chflagsCalls fails a .git lock or unlock with none - the structure test's status-lines rule (statusSites, statusFree) - TestStatusLinesNest, TestMessagesClearTheStatusLine, TestQuestionsHoldTheStatusLine, TestSecretAndPickerHoldTheStatusLine, TestTerminalHoldsTheStatusLine, TestNoStatusLineOnceInterrupted, TestFakeStatus, TestAgentImportStatus, TestAgentSaveStatus, TestDoctorReport, TestProblems, TestList, TestListLooksUpVolumesOnce, TestVolumeOfCache, TestWithSDKDownloads, TestRetainStatus, TestSetCloneOn, TestTeardownLeavesNothing The rule is written in the cli skill (rule 14, checklist, review), the codebase-standards skill (Show what devvm waits for, its checklist line and rules.md's row), Contributing's CLI page (Status lines), its tests and structure pages, and the troubleshooting page. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6965efcc0a |
fix(vm): devvm agent login claude --setup-token shows Claude Code's address (#57)
An agent's login in the VM ran with devvm's own writers as its output, so os/exec gave limactl shell pipes, Lima added no ssh -t, and claude setup-token, which draws full-screen, showed nothing and waited. When devvm's stdin and stdout are terminals and both output streams are files, the login now gets stdout and stderr as the files they are (ui.Terminal, set by cli as vm.Env.Terminal), so Lima gives it a terminal in the VM, as devvm's shell has. Without a terminal it keeps pipes, and --setup-token warns first (setup_token_no_terminal). Its output reaches devvm's output alone, never the run log, as before. On a terminal, Ctrl-C goes to the login in the VM, which ends, and devvm says the login ended or saved nothing. - internal/ui: Terminal, over Files, never a half pair; TestTerminal. - internal/vm: Env.Terminal; AgentLogin.loginOpts; the warning; why an interrupted login's cleanup stays as endLogin's backstop; endLogin's comment for a login on a terminal; TestAgentLoginTerminal (fails without the fix). - internal/backend: ExecOpts says a terminal's files pass on as they are; Lima's TestExecStreamsAsGiven. - internal/cli: vmEnv sets Terminal; agent_login.txtar checks the warning. - locales/en.toml, internal/msg: setup_token_no_terminal. - tests/e2e: OnTTY, out of TTYRun; network's check that devvm agent login claude --setup-token on a terminal shows the address, waiting for its devvm to end before the next login. - Docs: internals/network.md, using/coding-agents.md, contributing/extending.md and tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2c0a894a1c |
fix(vm): a project folder's VM works after a boot renumbers its disk
macOS numbers its disks' devices in the order they appear at boot, so after a restart an unchanged project folder's identity (dev:ino:btime) can have another device. The finder then refused its VM as made for an earlier folder (vm_other_folder), a stopped VM's start refused it as replaced (project_folder_changed), and the next .git check called it replaced (git_replaced). platform.SameFolder is now the one comparison of two folder identities: the same ID, or at the same path the same inode and birth time on another device. On another device the ID must also be the one read from the folder opened at the path with no link followed (OpenNoLinks, then fstat and fstatfs on it: openFolderID), on a file system whose IDs are their folder's alone, so a link swapped in while the caller read the ID can't pass a copy's (a snapshot's, a cloned disk's) off as the folder's. A folder at another path (moved) matches only exactly. platform.Renumbered says when the record needs the folder's ID as it is now. The finder's sameFolder, here.movedFrom, gitprotect's protectRepo and the strict conversion's checks use it. A start records the project folder's identity as it is now under the VM's state lock (renumbered, in bringUp) before the backend mounts it by Want.ProjectID, so vz's /.vol/<dev>/<ino> mount names the current boot's device, in the one limactl edit; folderChanged's checks after it then compare exactly. A .git check that accepts a renumbered .git records its current identity. The move's check stays exact, as both its IDs are read in one run. The structure test's folder-ids rule fails on == or != on a field named Folder or GitID, or a call of FolderID or folderID, outside internal/platform and tests, unless exactFolderIDs lists the function with why: the agents' and exports' Folder paths, recordMove's unchanged-state check and folderChanged. Tests: TestSameFolder (platform), TestRenumberedFolder (vm), TestReportsRenumbered (gitprotect), a renumbered vz case in TestProjectMountByInode (lima), existing.txtar's renumbered folder, and fixture_v010_renumbered.txtar on the frozen v0.1.0 state, through the new renumber script command and stubtest.Renumbered. 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]> |
||
|
|
941c63c696 |
feat(proxy): the proxy's child runs under Seatbelt on macOS
On macOS the broker starts devvm _proxy-child through /usr/bin/sandbox-exec -p PROFILE, by devvm's real path, with a deny-default profile, so the child is confined from its first instruction: devvm's binary to run and read, its folder's metadata, dyld-support.sb, /usr/lib and /System/Library, the time zone and resolver files, its logs folder and the shared Nix cache (regular files only, no hard links, no folder removed, no flags, ACL, owner, set-id or xattr changes), stat alone on the watched files and every link on the way, trustd and trustd.agent, mDNSResponder's socket, TCP and UDP out (loopback left to the floor: a rule for a loopback port applies at once, which a profile fixed at the start can't follow), sysctl but kern.proc, signals to itself. No home folder, no devvm folder but its own, no Keychain, no other unix socket, no bind, fork, exec, signal to or look at another process (process-info, the process list). - internal/seatbelt: the shared owner of Seatbelt (Exec, String, Path, Links, ChildProfile, Sandbox.ProxyChild); sbString, sbPath and sandboxExec move here from the Lima backend, which uses them. ChildProfile refuses a relative path and the root. - internal/proxy/confine.go: the confinement report every platform shares (Confinement, ParseConfinement, ReadConfined: one line of fixed words in run/proxy.confined, refused unless it parses, and unless it fits what the broker started the child with), the child's self-check (checkConfined: its broker's config must be refused), and the in-process hook (confineSelf, confineself_linux.go and confineself_other.go) for the Landlock follow-up. - internal/proxy/childstart.go: startChild, childSandbox, childNeeds; IO.Seatbelt, set by devvm _proxy on macOS. A missing sandbox-exec, or one that failed before devvm's code ran (exit 65 or 71, or SIGABRT or SIGKILL, before the child answered, decided before the broker's own stop), starts the child again unconfined within the broker's 4 seconds, with a warning in proxy.log; any other failure fails the start. The broker makes the Nix cache's folders first. start carries how the broker started the child (Spawned). - watched.get: a stat refused for want of permission reads through the broker each time (a watched link pointed elsewhere after the start). - daemon.Handle.ExitCode and ExitSignal. - devvm doctor warns for each running VM whose proxy's child isn't fully confined (netpolicy.Unconfined; proxy_unconfined, proxy_unconfined_unsupported, _no_sandbox, _sandbox_failed, _check_failed). - Tests: TestParseConfinement, TestCheckConfined, TestReadConfined, TestStartChildSandbox (an over-claiming ready, SIGTERM), TestSandboxFailed, TestChildNeeds, TestWatchedStatRefused, TestUnconfined, TestString, TestLinks, TestChildProfile, TestProxyChild, TestChildProfileConfines (the test binary run again under the profile on macOS: flags, rmdir, the process list), doctor's report, ExitCode and ExitSignal; e2e network checks run/proxy.confined is full seatbelt on macOS. - Docs: How it works' The child's sandbox, Processes, the design note's confinement and threat check (loopback as open work, other processes' details and kern.procargs2, the shared folders' flags, mDNSResponder's records, trustd.agent's trust settings, the fallback's signals, a ready that claims more), Troubleshooting's The proxy runs without a sandbox, Staying safe's escaping the VM, doctor's checks, Contributing's packages, the proxy's README, AGENTS.md, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
63bb1ff9a8 |
fix(network): a confined VM's programs ask 127.0.0.1 directly, so names fail at once
With transparent mode off or stopped, a confined VM's only name server, 127.0.0.1 (Lima's DNS setting), has nothing listening. glibc asked it through systemd-resolved's stub, which could keep retrying it over UDP and TCP without answering, so a lookup such as getent's waited out its timeout instead of failing at once (seen on a Linux host: e2e network's checks of DNS with transparent mode stopped and off). Each launch's setup now replaces /etc/resolv.conf, the stub's link, with devvm's own file on a confined VM: nameserver 127.0.0.1 alone, the stub's search line, timeout:1 attempts:2. glibc gets a refusal at once with nothing listening, and dnsmasq's answer through transparent mode's nftables rule when it runs, as musl on Alpine does. An open VM gets the stub's link back. Only systemd guests that have the stub's file and whose /etc/resolv.conf is its link or devvm's own are touched. Root cause, as far as it could be pinned down: with resolved's stub in the path, a lookup depended on resolved's retry loop over a server that refuses everything (24 attempts, flipping UDP and TCP feature levels), and on the linux host that loop sometimes never answered the stub within getent's 3 s. It didn't reproduce on demand (a base run on the linux host passed both checks, and bursts of 200 parallel lookups and stops mid-lookup all failed in under 2 s), so the fix takes resolved out of glibc's path rather than tuning it. Going back to open restarts systemd-resolved: it reads a /etc/resolv.conf that isn't its own link as global servers and search domains, so it had taken 127.0.0.1 and "~." from devvm's file, and kept them once the link was back, which left an open VM unable to resolve names (caught by e2e network's open checks on the linux host and ubuntu). Review folded in: no change of a foreign or dangling link when the stub's file is missing; two attempts; Docker's user-defined networks in the docs. Second review: devvm's file alone is enough to go back on an open VM (a warning when the stub's file is missing); a failed write says so in one line and the launch goes on; troubleshooting's "An open VM resolves no names after a downgrade"; tests for resolved's own resolv.conf link, an open VM without the stub, a non-systemd guest with devvm's file and a failed write. workerd under wrangler dev, checked by hand on fedora with transparent mode off: its fetch fails at once (Temporary failure in name resolution), so the "about 40 seconds for each lookup" sentence is gone from lima.md, safety/network.md and troubleshooting.md, and testing.md's manual check covers it. testdata/coverage/darwin.txt: internal/sshagent's baseline rose with mise run coverage (unrelated to this change). - backend.Confinement.Resolver: the one owner of a confined guest's name server; Lima's start sets .dns from it, sync.go sends it to the setup as DEVVM_RESOLVER; sync.go's setupInputs as mise run fmt writes it. - assets/guest/sync.sh: resolver_conf; its unit test runs the function (internal/vm/resolver_test.go). sync.sh runs at each launch and goes in no image, so no image key changes. - CLI tests: DEVVM_RESOLVER on confined (transparent on and off) and open VMs. e2e network: the stopped-transparent check also checks the file. - Docs: network.md's The VM's resolver, lima.md, design.md, tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aeea3135b2 |
feat(proxy): the proxy's broker and its child
A VM's proxy runs as two processes, as design.md's "The proxy's broker"
says: devvm _proxy, the broker, which keeps what only the host should
do, and devvm _proxy-child, which reads the VM's network and can be
confined by the follow-ups.
- wire.go: the protocol over one socketpair (close-on-exec from the
start: SOCK_CLOEXEC on Linux, ForkLock elsewhere), length-prefixed JSON
frames of at most 2 MiB, unknown fields refused, bytes as base64, one
descriptor on a frame's first bytes (SCM_RIGHTS, MSG_CTRUNC breaks the
rules), wire types for every secret (redact.Secret at once).
- broker.go: newBroker, the start (handshake: version 1 and each side's
executable's SHA-256, within 4 s), the answers (value through lookups,
kept 30 s or 5 min, a failure 5 s, dropped when the bindings change;
file by number; link connected by the broker and passed as a
descriptor; token exchanged by the broker), each by something in its
own config, with caps 1/8/4/256; live: the lifeline closes the socket
and kills the child 6 s later, SIGTERM stops it within a second, a
child that ends ends the broker, a rule broken stops the child.
- child.go: the start (startOf), the child's server (newChildServer),
the broker as hostSide over the socket (brokerClient), runChildOn;
ready only after it reads the host's addresses (kept: the last good
read), roots and time zone loaded first.
- process.go: Main(ctx, ...) and ChildMain; the child spawned with
/proc/self/exe on Linux, PR_SET_PDEATHSIG from a locked thread
(daemon.Cmd.DieWithThread), descriptors 3 and 4, and TZ, SSL_CERT_*
and GODEBUG with updatemaxprocs=0 alone; run/proxy-child.pid and
run/proxy.confined ("none" until the follow-ups); KeepLogs in the
broker. ChildMain refuses to start unless descriptors 3 and 4 are a
unix socket and an IP one (checkInherited): run by hand, without
them, those numbers can be the Go runtime's own, which closing
crashed it (signal_recv: inconsistent state).
- capture.go: a captured token request goes to the broker
(captureToken, exchanger), so a login's real tokens never enter the
child; an error reply passes up to 1 MiB, longer gets 502.
- watched.go: the child stats each changing file and asks the broker
for it once it changed, keeping the stamp of what the broker read.
- rotate.go: proxy.log rotated by both through its descriptor, under a
lock of a description of its own; OpenLog opens a log never through a
link, one link, yours, replacing what a child left in its place.
- nixcache.go: the trim and its count through a safefile.Root, nar/
only as a folder, links deleted as themselves; reads never through a
link; the lock tried for 5 s (ErrNixLocked, nix_cache_locked).
- daemon: Cmd.Err, Files, Env, DieWithThread; Handle.Kill, Exit;
WritePID.
- netpolicy: Proxy.Stop also stops a child that outlived its broker
(run/proxy-child.pid, _proxy-child -for); proxy.log opened with
OpenLog; a refused launch keeps a running VM only while both run.
devvm network log and lock read the event log through safefile.
- vm, vmssh, vmlog: links.log and ports.log opened with OpenLog, read
through safefile, trimmed only as a regular file with one link.
- backend: the build proxy's logs in a logs/ folder of their own.
- cli: _proxy-child; _proxy waits for its child on a signal
(StopsItsOwn); the child reads none of devvm's folders (no
makePrivate); ui.Files.
- Tests: FuzzBrokerFrames, the frames' rules, the handshake and the
pair's end in synctest bubbles, the caps, the broker naming its own
alone, the client over a real socketpair with a passed descriptor,
ChildMain, TestInheritedSocket and proxy.txtar's child run by hand,
the frozen 0.1.0 configs starting a broker and child,
two writers rotating once, planted links, FIFOs and hard links; the
testscript runner stops _proxy-child too; e2e: broker and child, their
arguments, descriptors and environment, stop, SIGKILL either, planted
files in the logs folder and the Nix cache, build proxies gone.
- Review fixes: the lifeline closes the socket and starts the kill's
timer before logging; every log lock (proxy.log's, the event log's
rotation) is tried without blocking for 200 ms (flockWithin, which the
Nix lock shares), then written without or the rotation skipped; a
copied log's rotation streams at most twice its limit from a line's
start (copyFrom, copyAtomic); a reply too long to send goes as
too_long; kept token headers capped at 1 KiB; the child gives up on a
request whose context ended, dropping its late reply and holding its
slot until then; a write deadline on the start frame; errors reach the
child as codes (not_found, refused, busy, too_long, failed), their
text in the broker's log; FuzzFrameStreams, and FuzzBrokerFrames
writes from a goroutine; nix_cache_locked links to How it works.
- Docs: processes, network, overview, design (with threat rows for the
logs' locks and a log made huge), troubleshooting, the proxy's
README, structure, testing; CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
9c74dac11e |
fix(logs): a VM's logs are held to their caps while it runs
internal/vmlog owns every log a VM can drive but the proxy's own: Limit (moved from vmssh's logLimit, with Allow for the link session's warnings), Capped and Trim for ports.log and links.log while they run, and KeepVM, which the VM's proxy (proxy.IO.KeepLogs, Config.VMLogs from backend.Run.Logs) and a Lima build run on the serial consoles' and the hostagent's logs: redacted as they grow (redact.FileFrom), so a reboot in place can't leave the proxy password there, and rotated past 10 MiB, counting what a log holds past the hole its writer left (platform.DataStart). The proxy's http.Server logs through its own limited log, and its copied log counts what reached it as stderr; the build proxy's log is held as a VM's proxy's is. git-pins.jsonl has a cap. Run logs take at most 256 MiB together, never the newest or a live run's. 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]> |
||
|
|
f37c70a5cd |
fix(bounds): bound what a VM can make the host hold
Five bounds, each with a test that failed first. Long downloads,
WebSockets, slow streams and SSE are never cut: every bound is on what a
connection holds, never on how long it lasts.
- _qemu connect (Linux): each guest connection to the proxy was a host
process with no cap. Connect now takes one of connectMax (256) slots,
lock files in the VM's run/proxy.slots (paths.VM.Proxy(".slots")),
each process about 7.7 MB, so about 2 GB per hostile VM. A connection
past them gets an HTTP 503 (connectsFullReply) and closes before it
dials; QEMU's stderr says qemu_connects_full at most once a minute,
decided under full.lock so refusals at once say it once. A VM started
before keeps the two-argument form, unbounded until its next start.
No idle timeout or byte bound: the proxy bounds what each carries.
TestConnectSlots.
- The VM proxy (limits.go):
- maxConns (2048, twice maxConnects so a CONNECT still gets its 503
first) counts a connection from its first request with the VM's
password (conns.admit, via httpServer's ConnContext); a request past
it gets 503 and the connection closes. Connections without the
password wait in a pool of maxWaiting (128) where a new one closes
the oldest, so holding connections can't take a VM's room (a host-speed flood still slows it
through the accept queue: listed in design.md).
- maxRequests (2048) requests upstream at once, plain HTTP's and
intercepted tunnels' (requests.take), 503 past it: per-tunnel
HTTP/2 streams alone allowed ~100,000 upstream connections.
- each limit logs once a minute at most (everyMinute).
- httpServer adds IdleTimeout (10 min); a 407 closes its connection;
handleHTTP's WithoutCancel is replaced by whileHeard, which ends a
plain HTTP request once its client has stopped sending and goneWait
(1 min) passes with nothing written, so half-closing clients still
get answers that keep coming; quiet WebSockets aren't cut.
- heardWriter.Unwrap: plain ws:// upgrades got 502 (pre-existing) and
get 101.
- No ResponseHeaderTimeout: non-streaming LLM requests wait minutes
for headers, and a waiting client is counted.
Tests: TestProxyLimitsSet, TestProxyConnectionBounds,
TestProxyConnectionLimit, TestProxyWaitingConnections,
TestUpstreamRequestLimit, TestUpstreamRequestLimitIntercepted,
TestPlainWebSocket,
TestPlainHTTPEndsWithClient.
- serveOne (intercepted tunnels, transparent HTTP, the 403 page) takes
maxHeaderBytes (64 KiB) always, not 1 MiB, and HTTP/2
MaxConcurrentStreams streamsMax (100, not 250). TestServeOneHeaderLimit,
TestServeOneStreamsLimit.
- Accept loops (forwarder, link session, login forward) retried nothing
or at a fixed 100 ms: vmssh.acceptRetry backs off from 5 ms to 1 s and
logs the first error of a run, ending only when the listener closes or
ctx ends. TestAcceptRetry, TestForwarderAcceptRetries,
TestLinksAcceptRetries.
- The login callback (LoopbackForward) carries at most
loopbackConnsMax (16) connections, an ssh each.
TestForwardLoopbackLimit.
Docs: processes, network, ports, lima, design (threat rows),
attack-vectors, the proxy README, CHANGELOG Fixed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4d409589bb |
refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.
Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.
Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.
Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.
Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
e4ea123927 |
feat(ports): VMs' ssh on ports browsers refuse
Lima listens on a VM's ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as http://localhost:PORT reached a server the VM controls with the cookies of every app on localhost, even in a VM that forwards no ports. - Every VM's ssh port, and every build VM's, is one of the 17 ports every browser engine refuses (ports.SSHPorts): the Fetch standard's bad ports from 1024 up that Chromium's kRestrictedPorts blocks too, which leaves out 4190 and 6679 (headless Chrome 157 loads both). The one allocator chooses it (Allocator.SSH and Build, through freeSSH). A stopped VM keeps its port while it's on the list, free, not listed to forward and not held by another start or build; else it gets one no state records, or else a stopped VM's, which that VM gives up at its own next start. Another VM's listed ports are avoided only while that VM runs or starts. - The proxy and desktop ports never take one (free); one an older devvm chose moves at the VM's next start (Choose's keep path, proxyPort, the desktop's listener; Allocator.SSHOnly). - A forwarder never takes one unless its VM lists it (ports.Reserved), so a guest forwarding every port can't fill them; devvm ports and each launch warn when a VM's list names one, whatever set it (--ports, a devcontainer.json, config.toml's ports) (ports_ssh_listed, ports.SSHListed). - A start holds its port, kept or new, for a minute in the VM's own run/ports.ssh-hold (paths.VM.Forwarder; hold, held, projectHold), which other starts and builds avoid, so none takes it before Lima binds it; it goes with the VM's folder. - A build takes its clone's own port (was) only when no other is free. - Past 17: ports_ssh_limit names the VMs whose recorded ports are in use ("a or b" for a port two states record) with how many are taken otherwise, ports_ssh_limit_all when they have them all, and ports_ssh_limit_others when none of your VMs has one. - Older devvm's ports move at the VM's next start, in startSets' one limactl edit, and the start pins the new host keys (pinHostKeys); a running VM keeps its port until then, and each launch warns of running VMs still on an off-list port (ports_ssh_old, Allocator.OffList, confirmed with the backend's Running). - A test build's own list (DEVVM_SSH_PORTS, registry.Overrides.SSHPorts, the Allocator's and the Proxy's SSHList field), read only by readOverrides in a test build: each CLI test sandbox gets as many ports of its own from below the ephemeral range (sandboxPorts). Frozen 0.1.0 fixture: each launch now makes exactly one limactl edit, of .ssh.localPort alone, onto the sandbox's list, and vm.json changes only in .ports.host.ssh (and the start it records); the fixture's data is untouched. Messages: ports_ssh_limit, ports_ssh_limit_all, ports_ssh_limit_others, ports_ssh_listed, ports_ssh_old. Tests: TestSSHPorts (Fetch's list less Chromium's gaps, SSHListed, SSHOnly), TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild, TestReserved, TestForwardsHeld's reserved counts, TestStartBuildSSHPort, TestPrepareRestartsTheProxy, TestDesktopListener, TestOverrides (DEVVM_SSH_PORTS), ssh_ports.txtar, fixture_v010.txtar, layout.txtar; e2e project: the ssh port, first and after a move, is one browsers refuse. Docs: internals/lima (the ssh bullet, the hold's limit), processes (listener table), design (threat check), ports, overview, contributing/structure and testing (DEVVM_SSH_PORTS), using/ports-size, troubleshooting (Too many VMs at once), safety/attack-vectors (allowed ports, port squatting), CHANGELOG Breaking (17 VMs; forwarding every port leaves the 17 out) and After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cc94465400 |
test(leaktest): goroutine leak checks, and the leaks they found
A new internal/leaktest, standard library only, so the proxy's and the daemon's tests use it too (depguard's proxy rule allows it, and the structure test holds it to tests and to importing nothing of devvm's): - leaktest.Main(m), in TestMain: once the tests pass, every goroutine's stack (runtime.Stack), a settle of 5 s, then a failure naming those still running, but the standard library's own that outlive every test (allowed: signal.Notify's loop, an HTTP client's idle connections); then Go 1.27's goroutineleak profile, which fails on any goroutine blocked for good. - leaktest.Check(t), first in a test: its own goroutines, followed by parent through those still running, and by which ran before it, never by ID (each thread takes a batch of IDs). Main runs in proxy, vmssh, daemon, desktop, ui, vm, backend/lima, platform, cli and gitprotect (main_test.go, or the TestMain they had). Check runs in TestLinksEndStuckRelays (replacing its NumGoroutine count), TestForwarder, the desktop relay's serve helper, TestRunChild, TestPinWaits, and the proxy's new close tests. The structure test's goroutines rule (internal/structure/goroutines_test.go): goroutineSites lists every function outside tests that starts a goroutine, with a go statement, a wait group's Go, or time's or context's AfterFunc, function literals in package-level vars included, as "file: Func", with its waiter, or "detached: " and why nothing waits. A new one fails until listed, a listed one that starts none fails, and a package that starts one fails until its tests call leaktest.Main. Leaks it found, each fixed with a test: - The proxy's close left its connections running: http.Server's Close neither closes a connection a handler took (a CONNECT's tunnel, a WebSocket upgrade ReverseProxy takes) nor waits for a handler. conns (conns.go) holds every connection the listener accepted (track) and counts every handler (handle); serve calls closeConns once Serve returns, which closes them, closes any accepted after, and waits up to 5 s for the handlers. splice also ends when its client's connection can't be read (closed, reset), rather than half-closing the far end and waiting on it; a failed write to the server (one that answered early and closed) still lets its answer through. Tests: TestCloseConns (a tunnel and an upgrade), TestConnectAfterClose, TestSpliceEndsWhenItsClientCloses, TestSpliceKeepsAnEarlyAnswer; the tests' listen closes as the proxy does, and the fake upstream closes its target once its client's end comes. - platform's runChild left its signal-passing goroutine blocked on a channel signal.Stop never closes; it now closes it and waits (TestRunChild). - platform's WaitExit and WatchFolders blocked in poll(2) and read(2), which closing their fd from the stop doesn't wake on every kernel (Debian's didn't), and a retried call could land on a reused fd. They now wait in Go's poller (pollable), which the stop wakes (TestPinWaits, with a wait stopped before its process ends). Docs: Contributing's tests page (Goroutine leaks), the structure page (the goroutines rule, goroutineSites, the layers, the packages), the Go lint rules' depguard line, the proxy's shutdown in How it works' processes page and the proxy's README, and AGENTS.md. Coverage baselines: internal/leaktest's line on both systems, netpolicy's raise on macOS. 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]> |
||
|
|
02ba74e614 |
build(lint): stricter linters, and the fixes they need
golangci-lint now also runs govet's nilness, unusedwrite, hostport and waitgroup analyzers, nilnesserr, durationcheck, canonicalheader, errchkjson, forcetypeassert, contextcheck and gochecksumtype. - errchkjson checks each JSON encoding's error where the value could fail and drops it where errchkjson proves it can't, and reports structs without exported fields; tests may drop theirs. - forcetypeassert holds the code; tests are exempt. - gochecksumtype: agentlogin's format is a sum type (//sumtype:decl), and a switch on one names every case, default or not. - canonicalheader: WWW-Authenticate, X-Request-ID, X-Api-Key. - contextcheck: ctx threaded through carry, peekClientHello and sniOf, and through inject and value, whose cached lookup takes WithTimeout(WithoutCancel(ctx)), so two forbidigo nolints go; openTransparent takes its dialer's ctx. nolints stay where contextcheck can't follow: ReverseProxy's Rewrite, WithoutCancel alone, cobra's cmd.Context, e2e's runner window. - No-behaviour fixes: scrubList for redact's list, the loopback forward's ports kept with its listeners, upgradetest's Key keeps its public key, a CA's leaves read through leafOf. Contributing's Go lint rules lists each one and the sum-type convention. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
54cce97049 |
fix(ports): a stopped VM no longer keeps its listed ports from other VMs
Only a running VM holds a host port. Each VM's forwarder records the ports it forwards, and those it tried and couldn't take (run/ports.forwarded: its pid, then each list on a line; an empty one when it starts, and devvm removes it under ports.lock before each start). A forwarder reserves another VM's ports only while that VM has a claim: its forwarder runs, or devvm holds its ports.lock to start one again (the restart window). It never takes the ports such a VM forwards now, nor those it lists unless this VM lists them too. A stopped or crashed VM holds nothing. A reserved port the VM listens on waits and is forwarded once free, so a VM gets its port back within about 20 s of the other VM stopping. The host decides when a port is given up: every forwarder closes a forward whose port is now reserved every 10 s on its own clock (Forwarder.Recheck), so a VM that holds its session open and stops reporting can't keep another VM's listed port, and closing a forward closes the connections it accepted, so a browser's keep-alive connection never reaches the old VM afterwards. Two VMs starting at once are settled by the host's bind. The ports devvm chooses (ssh, proxy, desktop) still avoid every VM's listed ports, running or not. - ports: Used(d) for the allocator; Reserved, Holders and Live for the forwarders - vmssh: Forwarder.Recheck, Note and release; a forward tracks and closes its connections; Forwards.Reserved, Held, Taken, live, recorded and record; a start keeps a port another VM holds in -only and warns ports_held for any holder, listed or every-port; Main takes paths.Dirs - devvm ports warns ports_held and, for a running VM's listed port its forwarder recorded as a program's, ports_taken, reading the forwarder's record and binding nothing; --json adds held_by - backend.CountPorts; the stub's ssh master reports again when guest-ports changes - tests: TestReserved, TestForwarderWaits, TestForwarderGivesUpSilently, TestForwarderClosesConnections, TestForwardsHeld (restart window, every-port holder, no record, Taken from the record alone, another process's or no record), TestForwardsRecordFails, TestForwardsStart (old record removed), ports_stopped.txtar (CJ's case end to end, and an every-port VM leaving a running VM's listed port alone), layout.txtar - docs: ports-size's Two VMs and one port (the browser origin) and its JSON, internals' Ports other VMs forward, design.md's ports note and the listed ports' threat check; CHANGELOG Fixed Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d55476d3e2 |
feat(images): the prelude is one line, so build scripts keep their line numbers
Every script a build runs with bash, devvm's own and the user's layers, now gets the prelude as one line, eval $'…', in place of its #! line, so bash's errors and $LINENO give the script's own line numbers. A script without a #! line is one line further down. - shell.QuoteLine: ANSI-C quoting for bash, on one line of printable ASCII; every other byte as \xHH, so a multibyte locale's lead byte (Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a quote, and a NUL panics as a caller's bug. image's layer rule allows internal/shell, a leaf. - image.WithPrelude, the one place the prelude and a script are joined (OwnScript calls it), used by base.sh, apt.sh, the built-in layers and features, the user's layers, shared-tools/build.sh and oci/build.sh. Every devvm script has a #! line. A leading UTF-8 BOM goes before the #! check. - A build's exports for a company proxy (lima's proxyExports) and the user's CAs (trust's exports) end in "; ", not a newline, so they share the first line and move no line either; backend.Trust.Env says so. - The stub logs a bash -s script's second line, which is the script's own second line with or without the prelude. - Keys: every build script's bytes change, so base, every image and every shared tool image are built again once; the CHANGELOG's After you upgrade says so with git-lfs, and what VMs say until devvm update, and Breaking has its own heading. - Tests: TestQuoteLine (every byte but NUL, a break-out word, in /bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK, zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL, TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real prelude's line gives the prelude back; a layer under set -euo pipefail gets the names, keeps its function and its line numbers, with and without exports before it). - e2e nix: the layer copy no longer adds the prelude itself. - Docs: images.md's prelude section, Customizing's layer bullet, structure.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5c8aeafcbc |
test: gosec's G703 off in test files, where it reports a helper's write on some runs only
gosec's taint analysis reported internal/gitprotect's test helper write
(G703) on some runs and not others, which failed macOS CI's lint at
|
||
|
|
ab125b1af6 |
fix(lima): tidy the remount restart's failure paths
A review of the remount restart found its failure paths loose: - A restart whose limactl stop failed returned the plain message, and the caller then stopped the VM's proxy with the VM still running. Now a folder still mounted with the old mode is warned of and the VM goes on with its proxy, and anything else fails as a logged stop_failed, saying the VM didn't stop. - The interrupt's cleanup was dropped before the restart's stop, so a Ctrl+C during that stop could leave an open-tier VM running. It now stays until any stop in remountProject returns. - The start again repeated the first start's warnings (policy lines, pins, a degraded start). The UI now says each warning once a run, by its name and values, which covers every package's warnings without a flag through each of them. - mount_cache_unmounted and mount_cache_unchecked come only after the restart failed, so they no longer say to run devvm restart: they say the VM is stopped and its console log may say why. mount_cache_remount_failed says the old mode can lose writes and what may hold the folder. Their doc links stay on "When the cache mode changes", which now points to the console log. - The mountinfo check's comments and docs say why it's used (portable: any awk, no util-linux tool but mountpoint), not that Alpine lacks findmnt, which devvm's base layer installs there. - design.md: the stop that fails, the warnings said once, the cleanup through the stop, and the older race of another devvm starting the VM in the gap, which fails closed. Tests: TestRemountRestartStop (the cleanup held through the stop; a stop that fails, mounted or not), TestRemountRestartConfined (each start's undoStart, an interrupt between the starts: one start, the proxy stopped, the one undo kept; a start again whose proxy fails), TestWarnOnce, and mount_cache.txtar's allowlist restart warning of a bad policy line once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ |
||
|
|
db26def35b |
fix(lima): restart once when the folder can't be mounted again
After a cache-mode change, a Linux VM's start mounts its 9p project
folder again in the guest. On an Alpine --from VM (OpenRC) the umount
succeeds but both mounts fail ("already mounted or mount point busy"),
and devvm stopped the VM with mount_cache_unmounted, though a plain
restart boots with the new mode, which lima.yaml already has.
Now a folder left unmounted, still on the old mode, or a check that
fails gets one restart: the Lima backend writes why in the run log,
stops the VM under one status step (remount_restarting) and returns a
backend.RemountError. The caller, starter.start, starts the VM again
once through startOnce, the same path every start takes, so the restart
gets a new proxy following the new hostagent (the old one exits with
it), the .git pins applied in QEMU's new namespace, its host keys read
again for the new start, and its start recorded. That start's
Want.CheckCache asks Lima for the mountinfo check without the remount;
its outcome is final: unmounted or unchecked stops the VM and fails
with today's messages, another mode warns (its text now says to run
devvm restart to try again). An interrupt gets no restart, and the
cleanup stops the VM once.
- backend: RemountError, Want.CheckCache; backendtest.Fake.StartErr.
- Tests: TestStartSetsProjectCacheOnce (each failure a RemountError,
the run log's line), TestStartRechecksProjectCache (the restart's
check, no second restart), TestRemountInterrupted (no restart),
TestRemountRestart in vm (two starts, a proxy each, no third).
- Stubs: remount-fails (the remount fails and leaves the folder
unmounted until the next start); TestGuestMountOptions covers it.
- mount_cache.txtar: the restart that mounts the folder, and the one
that doesn't, with no third start.
- e2e: the from section's Alpine check expects the launch to succeed
through the restart.
- Docs: backends/lima.md's "When the cache mode changes", design.md's
remount, restart and running-VM paragraphs, tests.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ
|
||
|
|
2406b498d8 |
fix(lima): check the remounted folder without findmnt
After a start that switches a Linux VM's project folder to cache none, devvm checked the remount with findmnt -no OPTIONS, but the Alpine --from base has no util-linux and busybox has no findmnt, so an Alpine VM got an empty answer and was stopped with mount_cache_unchecked. The guest now prints the folder's line of /proc/self/mountinfo, picked by a POSIX awk (lastMount) that busybox runs: the last line whose mount point is the folder exactly, as mountinfo escapes it (mountinfoPath: \040, \011, \012, \134), which awk reads from the environment, as -v would undo the escapes. devvm reads the mount's and its file system's options from it (optionsOfMountinfo), refuses an answer that isn't a mountinfo line, and keeps the 4 KiB cap, the last line and "unknown" for a mode it doesn't know. - TestOptionsOfMountinfo, TestMountinfoPath, TestLastMount: real lines, 9p with and without cache=0x5, Alpine's without optional fields, stacked mounts, a path with a space; awk run on them. - The stubs' guest answers with a mountinfo line; the start tests and the mount_cache script check the new command. - e2e: the from section's Alpine VM, given Lima's mmap with no mode chosen, gets none from devvm mount-cache none at its next start on a Linux host; the e2e helper reads mountinfo too. - design.md and tests.md say how the check works and what e2e checks. 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]> |
||
|
|
b2b12ee55d |
feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only the folder's own: one walk (hostsafety.Walk, at most 4 folders down and 100 repos, no symlinks, one device) finds them, and each is locked on macOS, pinned on Linux or watched where Linux can't pin, scanned within its own top folder and the mount. A repo counts as covered only when a scan locks its git dir; git dirs follow git's own rule, .git is matched without case on macOS, and a recorded repo stays protected while anything is at its .git. Repos the walk can't protect, that appear, that leave or that look like bare repos are named, with the config keys and hooks a VM-made repo would run. Existing VMs get a one-time notice and opt in with devvm git-protect on. Ownership fails closed under one host lock, so a VM never unlocks what another protects; one scan budget covers every repo, and launches into a running VM check only the top repo. devvm doctor gives a tip to set safe.bareRepository=explicit, reading the user's GIT_CONFIG_GLOBAL when set. Refs #3. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2b68a2347c |
feat(gitprotect): .git protection on Linux without root, through a user namespace around QEMU
On Linux, a start of a VM whose protection is on pins .git, its git dirs and every lock path read-only in a user and mount namespace that devvm _qemu pinned makes around QEMU. It keeps the pins while QEMU runs, records each re-pin, refuses hard links and fails closed on watches and records; doctor says why a host can't lock, and such hosts watch .git instead. The pins' events file is read through safefile, and the command-line check takes "devvm lock" in prose as English. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
26a7aca55c |
fix(lima): a build VM's ssh port is never the one its clone kept
testdata/script/tools.txtar expects five numbered steps for each tool's build, configure among them, and once counted three configure steps for four tools. The cause wasn't load or a race in the stubs' state. A tool's build VM is a clone of base, and the clone keeps the .ssh.localPort that base's own build set. The only edit a tool build VM needs is its new ssh port, chosen at random from 20000 to the host's ephemeral range, so when the random port happened to be the clone's own (about 1 in 29,000 on macOS and 1 in 12,800 on Linux, for each build), nothing differed, Lima's start rightly made no edit, and the build's steps were numbered [2/5] starting to [4/5] deleting. ports.Allocator.Build now takes the port the VM's config already has and never chooses it, so a build VM's start always edits its new port in and its steps are the same every run. The test is unchanged: it checks what it always meant to. TestBuild and TestStartBuildSSHPort check that a build never gets the clone's port; the latter fails without the fix. The tools script passed 20 runs in a row while mise run test ran alongside, though at these odds a run that short can't show the flake either way. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
72f6284eb9 |
fix(lima): VM names leave the NUL byte out of the ssh socket's path (#25)
`NameMax` budgets for `paths.SocketMax - 1`, as `ControlMax` does, and the Lima package's own copy of the limit goes, so `paths.SocketMax` is the one owner. On the edge case above, devvm now picks a one-character-shorter folder part, `devvm-jyrkki-webs-fbe3918054ffd3`, and the VM is made. The Lima limits page says a socket path has fewer than 104 characters. Co-authored-by: Claude Fable 5.1 <[email protected]> |
||
|
|
b24da31e41 |
build: Lima 2.3 in CI, bump.sh e2e-lima, and Lima 2.2 as devvm's minimum
CI's e2e workflow installs Lima 2.3.0, its tarball's checksum taken from the release's SHA256SUMS, checked against the sha256 Lima's release notes publish. scripts/bump.sh e2e-lima moves that pin the same way. devvm's doctor, install.sh, the README and the Lima page ask for Lima 2.2 or newer, compared by major and minor. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f2eac89211 |
fix(lima): on macOS, mount the project folder by its device and inode
A parent folder's VM can move a nested project folder aside and put a link in its place. The checks around a start refuse what they see, but a swap timed for the moment Virtualization.framework opens the share, and put back before devvm's last check, made the nested VM mount the link's target. On vz, the Lima backend now mounts the project folder as location /.vol/<dev>/<ino>, from the folder devvm recorded (the state's folder, passed as the new Want.ProjectID), with mountPoint set to its path. macOS's volfs opens the folder by its inode wherever it is, so the share is the recorded folder, never what's at the path. Checked first on a real vz VM (Lima 2.2.1, macOS 26): vz and Lima accept the /.vol location; with the folder swapped for a link before limactl start the VM read the real folder's files at the project path, and wrote there; limactl list --json keeps the location and mountPoint as set. vz serves the share by the path the folder had at the start, so once the folder is put back the VM gets Operation not permitted (as for any rename while it runs) until its next start, and replacing that path with a link while it runs gives the same: never the decoy. The Lima backend alone decides it: projectMount (vz with a recorded folder: by inode; otherwise, and on QEMU/9p, by path), used by CreateVM (the image's vmType, which its clone has) and Start's wantEdits, which now compares the project mount whole (location, path in the VM, writable) through keptMounts, so a start edits nothing when they match and limactl list's filled-in fields never cause an edit. Instance.Project is the mount's path in the VM, so devvm's comparisons, devvm ls, devvm ports and .git protection keep using the host path. mount_comma checks the path in the VM too. platform.VolPath parses a FolderID. The checks from the nested-replaced fix stay, as defence in depth and for Linux, where 9p has no equivalent. Docs: internals/lima.md (the mount, the compare), internals/overview.md (what's checked and what stays open per OS), safety/attack-vectors.md (the residual gap is Linux's only), using/vms.md. Tests: TestVolPath (parsing; on macOS the path opens a moved folder), TestProjectMountByInode (wantEdits on vz: as it is, another inode, moved, a comma, a path mount before, no folder recorded, --clone; QEMU by path; Instance.Project), TestCreateVMByInode (the clone's mount, no mount edit), TestUp (spec and start carry the state's folder), TestUpClone (none); e2e's project section: the folder swapped as limactl start runs and put back when it returns, through the parent's VM (macOS: the VM never sees the decoy, its mount is /.vol/<dev>/<ino> at the path; Linux: noted), and the next start runs no limactl edit. 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]> |
||
|
|
adbaf2612a |
fix(tools): each tool build's steps name the tool and its version
The steps of each shared tool's build named the build VM every tool shares (devvm-tools-build), so a build of several tools printed the same lines over and over. Each step now names its tool: cloning base for node 24.22.2, starting the build VM for node 24.22.2, building node 24.22.2, deleting the build VM for node 24.22.2. Lima's start, configure, script and delete steps take the name from the context (withShown). Messages: building_tool, cloning_for_tools, tools_build_vm; building_tools_in goes. tools.txtar checks all five steps for each tool, in order. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2545de19f3 |
test(e2e): the Go runner is the entry point, mise run e2e -- FLAGS, and tests/e2e.sh goes
TestE2E already set up the sandbox, slots, locks and flags itself, so the 898-line script only handed over. The run is now `mise run e2e -- FLAGS` (go test -tags e2e from tests/e2e, CGO_ENABLED=0) with the same flags: --only, --from, --clean, --every-feature, --slots, --slot, --newest-base, --golden, plus --reuse. - options: the flags named as the script's options; the hand-over flags (lock-holder, count, total, started, summary) and the ported/unported split are gone. - e2eUbuntuRelease, a const in sandbox_test.go, holds the Ubuntu pin; scripts/bump.sh e2e-ubuntu moves it (get_const), and TestE2EUbuntuPins, bump.txtar and the E2E workflow read it there. - From the script into Go: the OpenSSL-not-LibreSSL host check, and --newest-base's start line and its UPSTREAM DRIFT summary. - The script's leftover bash helpers (perl vm_state, no_leak, ca_*, lima_listens, the retry list, its heartbeat) are gone with it. - mise's e2e:go task merges into e2e; TestCommandLines drops its $D rule. - Docs (contributing, testing, maintaining, internals) and AGENTS.md name mise run e2e; testing.md's "Porting a section" becomes "Adding a section". Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7493ead683 |
fix(lima): wait for a starting hostagent's QEMU before a forced stop, and clear an orphaned QEMU at start
Ctrl+C during a start on a slow host (nested virtualization) could reach
devvm's interrupt cleanup while the hostagent was up but QEMU hadn't yet
written its pid file. Lima reported the VM Broken, devvm stopped it with
--force, which killed only the hostagent, and QEMU then ran on without it
("qemu driver is running but host agent is not"), holding the disk so no
later start could boot it.
- Stop waits up to 30 s (DriverWait) while Lima lists a hostagent without
a driver, then stops the VM as Lima then reports it.
- Start stops a Broken VM whose driver runs without its hostagent with
--force before it starts it.
- instance reads Lima's hostAgentPID and driverPID; the limactl stub lists
them (Stubs.PIDs) and refuses to start over a driver left running.
- Tests: TestStubStopStarting, TestStubStartOrphanedDriver, TestState.
- internals/lima.md says so.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
3a2c290d3d |
refactor(msg): messages and comments say network tier and the VM's proxy, not network policy
Every VM runs a proxy and is on one of four tiers, so the proxy's messages name the VM's proxy, the unenforced ones its network tier, and the redaction ones say devvm keeps secrets on this machine on every tier. Message IDs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c0f4b8fb5c |
feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none, in its state's net section (netpolicy.Tier), in place of on/off. Every VM has its proxy. Confined tiers start on NetProxy; open starts on the backend's own network with its proxy set in the guest (Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off. The proxy: Config.Open (every host and address, no floor, no policies), Config.DenyPolicies (files whose denies alone apply), the rule port :* (any port), and ** matching address literals (the floor still holds). Policies per tier (netpolicy.PolicySet): internet is network/internet.policy (**:*) plus your denies; none is the agents' built-in policies, the secrets' hosts and your denies; open none. Links: a client links only to a target on its tier or a stricter one, and a group's VMs are all on one tier. The self-check per tier: open asks its proxy through the guest's settings and warns (net_proxy_unreachable). devvm ls and devvm network show the tier. A backend without egress-proxy offers open alone (net_tier_backend). devvm network on/off and --network-policy/--no-network-policy map to allowlist/open. Design note, threat check and docs; e2e in the network and link sections. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d17e62961e |
refactor(msg): one message for each kind of setting, flag and requirement
Messages that said the same thing for different settings are one message each, given what differs: - new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command) replace from_ignored, net_flag_ignored, git_protect_flag_ignored, size_flags_ignored, ports_flag_ignored, parts_flags_ignored, ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning for each command that changes the same on the VM, naming only the flags given (ignoredFlags). - setting_already (command, vm) replaces net_already, agent_already, clone_on_already and clone_off_already. - setting_set (vm), for a stopped VM, replaces net_set_stopped, agent_set_stopped and links_next_start. - next_start (count, vm), for a running VM, replaces net_set_running, agent_set_running, size_next_start, agent_next_start, mounts_next_start, folder_next_start and net_off_next_start; a launch warns of each change with its next_start_* line, then next_start once. - program_missing, program_broken and program_old (+ _fix) replace lima_missing, lima_broken, lima_old, qemu_missing, macos_old and their _fix messages; the minimum versions are minLima and minMacOS in the lima backend, passed into program_old. - ports_list_needed replaces link_ports_invalid: devvm link publish and unpublish check their ports with ParsePortList, as devvm ports add does, and ParsePublish is gone. - no_vm replaces no_vm_link. - vm_unfinished says nothing of the user's is in the VM, as remake_unfinished does. Kept apart: git_protect_next_stop (it applies at the next stop, and devvm stop applies it), already_stopped and ports_all_already (not settings), group_already (joining again syncs the group's links), has_tools and has_layers (they name which of those given were there), docker_missing (Docker is optional, so it never says to install it). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ac5aaeef0c |
refactor(vmssh): one checked ssh for a VM, vmssh.Checked
vmssh.Checked(ctx, dirs, review, backend, vm, ReadKeys|PinKeys) is the one way to a running VM's ssh: the review lets the backend's ssh through, its SSH target passes FromTarget, and the VM's host keys for its current start are read (KnownHostsFor) or pinned (PinHostKeys). It returns a Reach (SSH, the backend's other ssh options, the record's start). A failure before the host keys is an *UnusableError, the host keys' own wrap ErrNoHostKeys. It replaces vm's ownSSH body (ReadKeys), Forwards.start (PinKeys; Forwards gets a Review, from NewForwards) and sshconfig.Write (PinKeys, skipping UnusableError and ErrNoHostKeys; the start now comes from the record, not a second Running). Tests: TestChecked (refused, stopped, off loopback, read before a pin, pin, read, another start). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7bdaf8e99e |
refactor: one Reporter for every package's messages and prompts
msg.Reporter is what every package below cli prints and asks through: Info, Say, Note, Warn, Status, Ask, Confirm, Answer, the terminal checks and CanPick, the run log (LogNote, LogWriter, LoggedCmd, WithSteps), Stdout, Stderr, AddCleanup and Interrupted, under the UI's signatures. *ui.UI implements it (a compile-time check in ui), and msg.Fake is the tests': quiet as its zero value, its On funcs and fields record and answer. The six UI interfaces (tools, netpolicy, lima, registry, sshagent, vm) are gone, and the copied output and prompt func fields of tools.Env, tools.Making, gitprotect.Protector, secrets.Store, netpolicy.Proxy, from.Lookup, backend.Review, lima.Lima, sshagent.Agent, vm.Env, vm.SizeChoice, vm.AgentsChoice, vm.LayersChoice, vm.NetworkChoice, vmssh.Forwards, build.Env and sshconfig.Config: each embeds the Reporter. Lima's and the shared tools' Warn, which says where the run log is too, is a method of their own over it; vm's interactive check is a function over it. The pickers (build.Env.Pick, vm.Env's PickFeatures and PickParts, the choices' Pick) and vm.Env.CanAsk stay fields: they carry types of their own or cli's answer. The test UIs of tools, netpolicy, lima, registry, build and vm become msg.Fake. Coverage baselines raised: internal/backend/lima, internal/msg, internal/tools. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ca8a91305b |
fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what) when it may not be a message (replacing fail and the direct Die calls in cli), and a.env returns its failure. checkLayout returns its error from the root's PersistentPreRunE. execute alone prints a failure (showFailure): a backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces DieLogged), a message as it is, else what failed or output_failed, with a corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130. Die is now the UI's own die, for where no command can return: a question without an answer, a run log that can't be opened. Error prints nothing once the run is interrupted. After INT, TERM or HUP, Main waited only for the logged command and then ran the cleanups while the command's own code still ran. It now also waits for the command to return, up to returnGrace (2 s), when there are cleanups to run; a run without cleanups ends at once, so the proxy and the other background processes still stop as soon as they are told to. A start's undoStart stays registered once interrupted (interruptCleanup), as the cleanups now run after the start returned. Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old ordering), TestSignalsWaitForAStuckCommandAWhile, TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure; DieLogged's tests are ErrorLogged's. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6a2e85bf37 |
fix(lima): devvm limactl runs without the user's SSH agent
Lima's ssh shares one connection per VM (ControlMaster auto, ControlPersist yes), and an agent forwarded over it is the agent of the ssh that opened it. devvm limactl drops SSH_AUTH_SOCK (limactlEnv), so a limactl shell can't open that connection with the user's agent and hand it to devvm's later sessions of a VM whose choice is devvm's agent or none. TestLimactlEnv. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9ca7a4859 |
feat(vm): a moved or renamed project folder keeps its VM
A VM's files and machine are keyed by its name's hash, which stays; what moves is the state's dir. The finder finds a folder's VM by the state that records its path (finder.state: the path's hash first, then every state, recorded), so a VM moved there is found from the new path alone, and links by path (project.ForDir) match the recorded dir. When the folder has no VM, the finder looks through the states for one made for this folder at another path (moveHere, move.go; the match is here.movedFrom): the same folder identity (device, inode, birth time), the folder this user's, its identity unique (platform.UniqueFolderID: an ID with a birth time, and on macOS APFS or HFS+), another recorded path that's gone on the folder's device or only a symlink to here, its creation finished, not a --clone VM. One match is offered: in a terminal move_vm, [y/N]; without one vm_moved_here, naming devvm adopt; devvm adopt --force moves it without asking. Several matches warn (vms_moved_here) and move none. Never automatic. The move (finder.move) refuses a folder no new VM may have (checkUnsafe), holds the creation locks of the VM and of the folder's would-be new VM, checks again that no state records the folder and that the folder is still the one asked about (move_folder_changed), stops a running VM as devvm stop does, then records the path and identity under the VM's lock, refusing a state that changed meanwhile (create_running); vm_adopted says so. .git protection's record is kept: .git, its identity and its uchg locks move with the folder. The project folder's mount is now part of backend.Want (Want.Project, Instance.Project, Apply), so the next start mounts the folder where it is: Lima's wantEdits rebuilds .mounts in its one edit when the project mount or the agent folders differ (mount.project). A VM running with another path asks to restart (Y/n) and otherwise warns (next_start_folder, folder_next_start). A new VM at the old path can't use the moved VM's folder, so newName takes the first of the path's names whose VM folder holds no state (project.Nth: the hash of the path, then of the path and n). devvm adopt [VM]: with VM (by name or alias, as devvm rm VM), moves a VM whose folder is gone or not connected to this folder, for a copy on another disk (a new inode, never matched on its own): adopt_move_vm [y/N], --force, adopt_move_refused without either; refuses a --clone VM (adopt_clone), a lost machine (rm_vm_lost), an unfinished VM, a folder still there (adopt_folder_there) and a folder with a VM of its own (adopt_has_vm). It clears .git protection's record, as the copy's .git is another. rm_vm_state_mismatch is gone, as a dir needn't hash to the name any more: devvm rm VM acts as devvm rm only on the folder's own VM (finder.folderVM), and a VM whose state names a folder with another VM of its own is refused as one whose folder is there. macOS's FolderID has the folder's birth time too, as Linux's has. Security review (security-audit skill, focused, with an independent read): inode reuse needs a unique identity (birth time; APFS/HFS+ on macOS), the same device (in the ID) and the old folder gone; another user's folder never matches (its owner checked); a copy has a new inode and never matches; links and groups go by name and stay, and links by path take the recorded dir, a move refused when another VM records it; a symlinked cwd is resolved first, and a symlink at the old path counts only when it resolves here; .git protection's record stays for a move and is cleared for a copy; agents' mounts are unchanged (only the project mount changes); a VM can rename only folders inside its own mount, which it already writes. Fixed from the review: a folder swapped at the path while devvm asked was moved to (now move_folder_changed); macOS device:inode could collide with a later volume given the same device number (birth time added); a running VM kept the old path's share, which a new folder made there would reach (the move stops it first); a move to the home folder or into devvm's own folders (now checkUnsafe). FolderID's format change makes VMs and .git records made before it look like other folders (adopt them, or make them again). Tests: TestMovedFrom (table: gone/present, same/different device and inode, a non-unique ID, another user's, a clone, unfinished), TestMovedAway (gone, a folder, symlinks here/elsewhere/dangling), TestMoveHere (refused, no, yes, found by its dir, stopped, the new mount at start, a restart for a running old mount, a new VM at the old path by its next name), TestMoveFolderChanged, TestAdoptMoved, TestMoveHereSeveral, TestAdoptVM, TestUniqueFolderID, ForDir and Nth in project, wantEdits' moved project, the conformance start's moved project; move.txtar (refused, no, yes, found, Lima's mounts edit, a new VM at the old path, adopt VM of a copy); rm_vm.txtar's hand-edited dir; e2e project: mv, refused, a yes in a terminal (script), the home file kept, the new path mounted alone, moved back with adopt --force. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0d9154bd8a |
refactor(vm): one handle for the VM a command acts on, and Env's parts made once
The finder returns a target (target.go): the VM's folder, state, backend
and the instance its backend gave the finder, which each start
(starter.start, target.started, backend.Apply) and stop (target.stop)
then sets as the backend has it, without asking again. It runs what a
command does with that VM: exec, shell, shellDir, running, stop,
ensureRunning, ownSSH, sshHost and widen. Stop, network, ports, size and
ssh-agent read the finder's instance instead of asking again; git-protect
reads it again after its question (refresh), as before.
Env's parts are made once over it (wire, from NewEnv): the finder,
starter, linkRuns, syncer, remaking, clones, vmFolders, devcontainers,
creation, and the command types one reaches from another (launcher,
lifecycle, vmTools, groups, links, leftovers). The 110 conversions
between the package's struct{ *Env } types (finder(e), Launch(e),
starter{e}, creation{Launch(e)}...) are gone: none is left outside wire.
setUp and Groups.warnUnenforced went, their callers using setUpVM with
the target and Links.warnUnenforced; seedClone, gitSSH, fetchUnfetched
and setUpVM take the target. The fake backend applies a Want with
backend.Apply too.
TestTargetAfterStartAndStop: a target's instance after a start and a
stop is the backend's, a start reading it once and a stop not at all.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|