mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
64
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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]> |
||
|
|
f80fd2df60 |
fix(vm): devvm agent save applies all or nothing under the login lock; a lock's wait and a walk end with their context; a link to the home folder counts unless only root can change it
All or nothing: - devvm agent save goes through devvm agent import's undo journal: each plan's files are written into a staging folder of the agent's store (saver.stage, newStage, the import's .devvm-import- name, swept by the next import or save), then put in place (applyPlan: each file renamed in, the one it replaces kept aside as a hard link, folders made, what a folder no longer has moved aside, seeds and kept entries left), and the .claude.json subset saved last with secrets.SaveLogins, which holds the login's lock. A failure after the first change puts every agent's store and the login back; an undo that fails too says so (agent_save_undo_failed) and keeps the staging folder. - applyStages (and stageSet) is what both commands apply through; importStage is now storeStage, pruneIn takes an fs.FS, and pruneFolder moves a folder's leftovers aside. pruneStore and applySettings go. - A file in the VM where the store has a folder, or the other way round, fails the save before anything changes (agent_save_store_folder, agent_save_store_file; sameKind), where the stage would have replaced it without the diff showing; storeFiles reads such a path as empty. Contexts: - platform.LockDir flocks a folder, polling until ctx ends as LockFile does (waitLock is their shared loop); agentlogin's lockLogin is it, so the lock is the one an older devvm's proxy takes. LockLogin, LockFolder, File.CaptureRequest, Capture, SetKey, Remove and secrets.Store.CaptureRequest take a ctx. A capture whose reply the endpoint has given is saved with agentlogin.AfterReply's context, the exchange's without its end and bounded by two minutes of its own, so the exchange's deadline never loses a rotated login while a refresh or a save holds the lock, and a stalled holder never holds it for ever (File.Capture, secrets.Store.Capture, its loginsDir included). - safefile.Walk takes a ctx and stops before each folder and batch once it ends; readSettings, followLinks and follower.copy pass theirs. - LockFolder's comment said its lock was another than a login file's in the same folder; it's the same (.claude.json's), and says so. Links while a state can't be read: - homeHops exempted every link on the way to the home folder, on the claim that no project folder can hold one, which --unsafe-folder breaks. rootOnly exempts a link only when every folder above it, up to /, is root's, has no group or other write bit and the system says you can't write it (platform.Writable, access(2), which counts ACLs and FUSE), and devvm doesn't run as root. The structure test lets internal/agentlogin import internal/platform and counts platform.LockDir in its status-lines rule. Tests that fail without their fix: TestAgentSaveApplyFailsWhole (a rename and the login failing), TestAgentSaveUndoFails, TestAgentSaveLoginLock (waits under agent_login_waiting; Ctrl-C leaves the stores as they were), TestAgentSaveKindChanged, TestAgentImportHomeBelowALink, TestCaptureOutlivesItsDeadline, TestClaudeCaptureOutlivesItsDeadline, TestWalkCancelled, TestLockLogin (synctest: a deadline and a cancel). New: TestLockDir (synctest, and a plain flock's lock), TestRootOnly, TestWritable, the status-lines rule's LockDir case. TestStoreOpsRefuseLinks checks openStoreDir in pruneStore's place. Docs: internals/agents.md (saving, the staging folder, links to the home folder), using/coding-agents.md, Contributing's CLI and structure pages; CHANGELOG. 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]> |
||
|
|
da872a6550 |
fix(vm): a renumbered folder's volume is checked until it's read; folder identity is read once
When a boot numbered a project folder's disk anew and its volume couldn't be read at that launch (diskutil failing or slow), recordFolder recorded the new device with the old volume, and from then on the identity matched byte for byte, so no launch compared the volume again: a copy of the disk with a volume ID of its own, mounted at the folder's path later, would have kept the VM. It now records the folder unchecked (state.VM.SetFolderUnchecked, vm.json's folder_unchecked), so each launch looks the volume up again; Env.keepsVolume compares it while the record is unchecked, as for a renumbered one, refusing another volume (vm_other_folder), and the first lookup that finds the recorded volume clears the mark (folderRecord). A move matches an unchecked record only on its volume (here.same), and a move whose lookup fails keeps the recorded volume, bound to the inode and birth time a move keeps, unchecked (recordMove). On Linux, where the volume is read in the process (volumeFree), every launch compares it, so a Btrfs snapshot or a ZFS clone mounted at the folder's path is another folder even on the original's device; after a volume's UUID changes, devvm adopt gives the folder its VM again. The finder's sameFolder and madeFor share one body (madeForOpen), and the folder is opened once: platform.SameOpenFolder is SameFolder for a folder StatFolder already read, platform.RecordedAs is its exact match, and keepsVolume, recordFolder and here.same take that read rather than open the folder again (here's id and unique are its stat's). madeFor, which the checks that ask which VM mounts a folder use, falls back to the folder's stat when it can't be opened, as when code in a VM that mounts it took away its read permission, so no VM hides from clone_repo_mounted or project_in_vm_folder that way. recordFolder compares again under the state's lock with the same folderRecord. The structure test's folder-ids rule now finds a map literal keyed by a folder's identity whose type is a named map type of the module's, a generic one included, or elided in a map's or a slice's literal whose elements are maps. Docs: a Btrfs rollback at the folder's path, or a volume's new UUID, needs devvm adopt; a Mac volume that ignores ownership makes every folder yours to the offer's check; the unchecked mark and Linux's check at every launch (internals, overview's vm.json fields). Tests: TestUncheckedOnAnotherVolume, TestKeepsVolume, TestRecordFolder (unchecked, then checked), TestRecordFolderUnderLock, TestRecordMoveVolume, TestMovedFrom (unchecked), TestMountedByUnreadableParent, TestSameFolder (SameOpenFolder, RecordedAs), folder-ids' named, generic and elided map cases, and fixture_v010_renumbered's unchecked steps on 0.1.0's state. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4ccdbf8125 |
fix(vm): folder identity's last checks: a renumbered folder keeps its volume
From the volume UUID commit's security review. A folder at its own recorded path on a disk numbered anew (platform.SameFolder's renumbered case) must now also be on the volume its state records, when both are known (platform.KeepsVolume): the finder checks it (finder.sameFolder, Env.keepsVolume, so a launch refuses with vm_other_folder) and so does recordFolder under the state's lock, so a copy of the disk with a volume ID of its own mounted at the folder's path is another folder. A volume that can't be told leaves the device's rule, as for a state that records none. mountedBy and mountsRepo keep the check without volumes (madeFor), which errs towards warning. hereOf reads the folder's identity, uniqueness, owner and volume from one open folder (platform.StatFolder, now with Owner), so the folder checked as the user's is the one matched and recorded. StatFolder is one function for macOS and Linux (folderstat_unix.go) over each system's openFolder, which SameFolder's renumbered case uses too, in place of openFolderID and darwin's copy. devvm ls and devvm space look volumes up through the run's Env (Env.FolderOf, Inventory.List(ctx, e)), each mount once a run, in place of diskutil for each VM; FolderOf, parentVolume and movedAway go. FolderDevice is unexported (folderDevice), so only platform reads a device; OnRecordedDisk takes a record without a device as on any disk. The folder-ids rule tracks names assigned from such names, however many steps on, and maps keyed by an identity, indexed or in a map's literal, without counting a struct literal's field; its loop is sitesWhereIn, shared with sitesWhere. The hdiutil e2e check makes sure macOS gave the disk a new number, attaching up to three images first, and is skipped when it never does. The design notes say who can forge a volume ID and what it gets them. Tests: TestKeepsVolume, OnRecordedDisk without a device, TestRenumberedOnAnotherVolume (a launch and recordFolder), TestListLooksUpVolumesOnce, StatFolder's Owner on both systems, the folder-ids rule's new cases, and fixture_v010_renumbered.txtar (another volume at its own path refused with nothing recorded; ls calls the moved folder gone by its recorded volume, where it said not_connected). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ba510eec1f |
feat(vm): a folder moved across a restart keeps its VM, by its volume
A project folder's identity was its device, inode and birth time, and since #60 a folder at its recorded path matched on another device. A folder that moved while a restart gave its disk another device number matched nothing, so plain devvm made it a second VM, and folderOf took a renumbered disk for an unmounted one ("not connected"), so movedAway was false too. Each VM's state now records the folder's volume, which no renumbering changes, as folder_volume, "<kind>:<value>:<ino>:<btime>", bound to the folder it was read with (platform.VolumeOf, RecordedVolume): macOS's volume UUID from diskutil (platform.VolumeUUID, only for the mount point and device read from the folder opened with no link, its answer checked against both), Linux's f_fsid on ext4, Btrfs and ZFS (StatFolder, read from the open folder); none on a read-only volume or a snapshot, or elsewhere. state.VM's folder is unexported: Folder(), FolderVolume() and SetFolder(id, vol), the one writer, which creation, adopt, a move and recordFolder (renumbered's successor, at each launch) use; a launch records the volume of a VM made before, once it can (1 s at a launch, 5 s at an adopt or a move, one failure a run stops the rest, through Env.Volumes and its run's cache). moveHere matches a moved folder by its volume, inode and birth time (platform.MayHaveMoved, MovedFolder), looking the volume up only once the rest matches, with the identity it matched and records both read from the folder opened with no link (hereOf), and folderOf compares the parent's volume where the state records one (platform.OnRecordedDisk), through Env.folderState for a move or an rm. The folder-ids rule now also reads Folder() and FolderVolume() calls, FolderDevice, locals assigned from any of them, switches and strings/slices comparisons. An older devvm keeps folder_volume as it is (checked with 0.1.0's own reader in a temp copy of its tree). A rename keeps the inode, so the binding stays right; when an older devvm adopts another folder for the VM, or a move across volumes copies it, the binding names another inode, so the record names no volume and is recorded again. DEVVM_VOLUME stands in for diskutil, and for Linux's f_fsid, in test builds (VolumesOnly). Tests: TestFolderOf (not connected after a renumbering), TestMovedFrom (moved and renumbered, and a split between the read that matched and the one recorded), TestRecordFolder (made, a VM made before at its next launch, a failed lookup, a renumbering keeping the bound volume), TestVolumeOfCache, TestVolumeOf, TestMovedFolderAndRecordedDisk, TestStatFolder(AndVolumeUUID), TestPlistStrings, the folder-ids rule's new cases, fixture_v010_renumbered.txtar (0.1.0's VM records its volume, then moved and renumbered it's offered, never a second VM), and e2e's projectRenumbered (hdiutil, macOS) and the project section's volume check. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aed6424c09 |
fix(proxy): a stale proxy.confined no longer hides proxy_old
run/proxy.confined said how the child was confined, but not which broker said it. After a downgrade, an older devvm starts the VM's proxy as one process and never writes the file, so the newer devvm's file stayed and devvm doctor took the older devvm's unconfined proxy for a confined one. The broker now writes a second line naming itself, its pid and its start as the system tells it (proxy.BrokerID, through IO.Started), and ReadConfined takes the file only when it names the running broker, which doctor finds by the pid file and platform.ProcessStart (kern.proc.pid's p_starttime on macOS, /proc's starttime on Linux). A file that names another broker, or none, is one that hasn't said, so another binary's proxy gets proxy_old, and when doctor can't read the running broker's start it says it can't tell (proxy_confinement_unknown). The e2e broker check reads the file's first line and checks the second names run/proxy.pid's broker. Tests: TestUnconfinedStaleMarker, TestReadConfined, TestProcessStart. 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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
6c36850251 |
feat(cursor): devvm cursor opens this folder's VM in the Cursor editor
devvm cursor is devvm code's twin for Cursor, the editor. It gets the folder's VM ready as devvm host does, then runs `cursor --remote ssh-remote+HOST DIR` in devvm's place, with the SSH agent devvm started with. Without `cursor` on PATH it fails with no_cursor_command, naming the host to connect to. Cursor's Agent and your sign-in (from CJ's manual check with a real login): recent Cursor runs Agent in the editor's server in the VM, which holds your Cursor sign-in in memory only (no token on disk, in any environment or command line) and calls Cursor from the VM. Cursor's `cursorAgentHost.remoteInferenceRoute` is application-scoped, so it's read only from the user settings on this machine; with it set to "always", Agent's own requests go through the Cursor app here, while the VM's server still talks to Cursor. - vm: Code and Cursor share openRemote; vm.CursorCommand names the editor's command, apart from the CLI agent's agents.Cursor. After LookPath finds `cursor`, devvm reads Cursor's user settings on this machine (platform.AppSettingsDir: Application Support on macOS, $XDG_CONFIG_HOME or ~/.config on Linux) through safefile.Read, 1 MiB at most, read-only, as JSON with comments, and warns with cursor_agent_in_vm unless the route is "always". It never fails on the file. - sync.sh: Cursor's ~/.cursor-server/data/Machine/settings.json gets VS Code's remote.autoForwardPorts, git.terminalAuthentication and github.gitAuthentication off, in one loop over both editors' files. devvm doesn't write the route there, since Cursor ignores it. - structure: nameFree lets a literal that is an agent's name stand in one file, with its reason, and fails when it frees nothing. - cli: cursor.go (--ssh-config, --here, --parent), registered beside code; cursor_failed, no_cursor_command, cursor_agent_in_vm and their doc links; ssh_host_info names Cursor too; the cli skill's judgment note: an editor's command is a bare verb named after the editor's. - Tests: host_code.txtar (cursor, its full-name host, the missing command, the warning and no warning once the route is set), guest.txtar, TestCursorAgentWarning (always, absent, other values, no file, broken JSON, too long, a FIFO, the XDG path; never written), e2e network: devvm cursor passes the editor only the host and folder, a fake editor sign-in on this machine reaches neither the VM's home, its processes' environments nor the proxy's logs, and a Cursor login in the store reaches the CLI's methods while the agent store's are refused. - Docs: SSH and editors (commands first; "Cursor's Agent": it runs in the VM with your sign-in, the user-settings line, what it doesn't cover, open only VMs you trust; if Tab doesn't work on the allowlist tier, devvm network allow api3.cursor.sh), the agents page's Cursor notes, Commands, attack vectors, design, the home page, CHANGELOG, generated CLI pages. Reviewed adversarially before the push: the settings read (size, FIFOs, links), the warning's wording and when it fires. Researched with PR #44's design as reference only. Co-authored-by: JB <[email protected]> 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
|
||
|
|
2f0cc97392 |
feat(paste): devvm paste and devvm paste rm (#38)
feat(paste): devvm paste, an image, PDF or copied file from the clipboard into the VM (#38) devvm paste reads the host's clipboard and streams what's on it into the running VM's paste folder over the backend's Exec, with no SSH agent and no new channel, then copies the file's path in the VM to the host clipboard for the agent's prompt. devvm paste rm empties the folder after a question, and a launch that starts a stopped VM offers to. What it reads: - an image (PNG, JPEG, GIF, WebP; TIFF is converted to PNG), checked by its bytes; browsers hand over a PNG, so an animated GIF arrives as one frame - PDF data, sent as it is, and preferred over a file reference beside it (Preview's page copies) - one copied file, after a question that shows its path on this machine; --send-file answers it only for a file inside the project folder reached without links, and never for a --clone VM - never text; several files are refused Security: - macOS reads file URLs only through NSPasteboard (FileURLsOnly): AppleScript's «class furl» coercion turned any text, such as a path a web page or the VM's OSC 52 put there, into a file to send - copied files are opened with openat and O_NOFOLLOW|O_NOCTTY|O_NONBLOCK, following a root-owned link only in a folder only root can change, and read through internal/safefile (Checked), capped at 64 MiB - osascript and pbcopy by absolute path, Linux's tools only from system folders, never PATH - time limits on every clipboard tool and on paste.sh in the VM; bounded reads of everything the VM prints - the path copied back is built on the host, keeping only the file's extension: nothing the VM says reaches the clipboard Also: the paste-dir setting (default /tmp/devvm-paste, made at each launch), --json with sent, the agents' guide line, messages with doc links, stubs, CLI tests, an e2e check in the project section, and docs on coding-agents, settings, design, security and attack-vectors. Co-authored-by: dustypolk <[email protected]> Co-authored-by: w3cj <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b2b12ee55d |
feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only the folder's own: one walk (hostsafety.Walk, at most 4 folders down and 100 repos, no symlinks, one device) finds them, and each is locked on macOS, pinned on Linux or watched where Linux can't pin, scanned within its own top folder and the mount. A repo counts as covered only when a scan locks its git dir; git dirs follow git's own rule, .git is matched without case on macOS, and a recorded repo stays protected while anything is at its .git. Repos the walk can't protect, that appear, that leave or that look like bare repos are named, with the config keys and hooks a VM-made repo would run. Existing VMs get a one-time notice and opt in with devvm git-protect on. Ownership fails closed under one host lock, so a VM never unlocks what another protects; one scan budget covers every repo, and launches into a running VM check only the top repo. devvm doctor gives a tip to set safe.bareRepository=explicit, reading the user's GIT_CONFIG_GLOBAL when set. Refs #3. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8f6b30a887 |
feat(secret): your own secrets, bound to the hosts you choose
devvm secret set NAME --host HOST[,HOST…] --env VARIABLE [--header H] [--prefix P] [--stdin] saves a secret of your own: the value from a hidden prompt or stdin (never argv) into the Keychain or devvm's secrets folder, and its definition into custom-secrets.json. A VM that uses it (devvm secret use NAME) gets only a per-VM placeholder in VARIABLE, and its proxy puts the real value in that header only for those exact hosts, over TLS on 443; the hosts join that VM's allowlist. Names, hosts, headers, variables and prefixes are checked; wildcards, addresses, internal names and other ports are refused. One placeholder builder serves every secret and login, and the proxy caches values by kind, agent and name. After an independent review, a secret goes in only in four exact shapes (alone; Bearer, Token or a saved --scheme in Authorization; the Basic password; the Basic username only with --basic-user), values are printable ASCII under 3,800 bytes, the proxy checks each binding against its definition, definitions carry IDs and VMs record their hosts, and custom values are stored apart from the known secrets. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2b68a2347c |
feat(gitprotect): .git protection on Linux without root, through a user namespace around QEMU
On Linux, a start of a VM whose protection is on pins .git, its git dirs and every lock path read-only in a user and mount namespace that devvm _qemu pinned makes around QEMU. It keeps the pins while QEMU runs, records each re-pin, refuses hard links and fails closed on watches and records; doctor says why a host can't lock, and such hosts watch .git instead. The pins' events file is read through safefile, and the command-line check takes "devvm lock" in prose as English. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f5e6eebc55 |
refactor: one safe reader for files a VM can write
internal/safefile (standard library only) owns every read of a file a VM can write or swap: Read and Open never block on a FIFO, follow a final link only when asked, and check the opened file is regular, within its cap and, with OneLink, singly linked; OpenRoot opens beneath a folder. The proxy, secrets, agentlogin, devcontainer, detect, agent save and gitprotect read through it, fixing three hangs on a FIFO the VM leaves, and forbidigo holds those callers to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cda2d09f42 |
feat(gitprotect): on Linux, warn at each launch and report .git hooks and config that changed (#20)
Linux hosts have no unprivileged immutable flag, so devvm can't lock .git there. It now warns at every launch of a VM that mounts a folder with a .git (git_unprotected), unless it's a --clone VM or the user chose devvm git-protect off (git.chosen), and it names, after the fact, the hooks and config that changed (git_changed). It sums what a lock would cover, .git/commondir, include.path targets and the folder core.hooksPath names, never through a symlink out of the project folder and within bounds (git_watch_blind names what it can't fully watch), at each launch that finds the VM stopped and at devvm stop. A check on such a host runs protect's reports without locking: git_replaced, git_commondir, stray worktrees, git dirs that appeared, core.hooksPath and delegations into the project folder, and a submodule's folder that isn't a git dir (git_gitdir_not_git), in which nothing is created and which the watch doesn't sum as a git dir. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
ae7c8b619f |
refactor(platform): parsePortRangeFirst and its test move to the linux files
Its only caller is ports_linux.go's ephemeralFirst, so on darwin mise run deadcode listed it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2dfb0d2d50 |
fix(platform): Linux UniqueFolderID allows only file systems with stable inodes
UniqueFolderID on Linux reads the folder's statfs type and allows ext4, XFS, Btrfs, tmpfs, OpenZFS, F2FS and bcachefs (uniqueFS), as macOS's allows APFS and HFS+: FUSE, network shares, 9p, overlayfs and FAT may make inode numbers up, so a moved folder on one is never offered its VM. TestUniqueFS covers each type. 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]> |
||
|
|
a575fd55db |
test(platform): TestCloseInheritedOnExec checks descriptor 3 is its own file, after exec
A dynamically linked sleep's loader opens its libraries on the lowest free descriptor just after exec, so fd 3 being open could be ld.so.cache or libc rather than the inherited file. The test now hands the child a temp file of its own and checks fd 3 is that file (os.SameFile through /proc on Linux, lsof's name on macOS). On Linux it first waits until /proc/<pid>/exe is sleep, as the fork before exec still holds the file. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cf30bdfd99 |
test: golden fixtures from the real tools, captured by e2e
testdata/golden/<os>/ holds what the real tools printed, and the tests check devvm's parsers and the stubs against it on any machine: limactl-version.txt and limactl-list-stopped.json (TestLimactlStubContract's dummy instances, with STUB_GOLDEN set), limactl-list-running.json (a running project VM), qemu-img-info.json (base's disk, Linux), qemu-img-info-overlay.json (a project VM's, Linux, when project runs there), security-missing.txt and tmutil-isexcluded.txt (macOS). - tests/e2e.sh --golden captures them into the checkout: images runs the contract test with STUB_GOLDEN, qemu-img info, security and tmutil; project lists its first VM. Home, user name, full name, timezone and a VM's environment are replaced (golden in e2e, anonymous in Go). A capture isn't a check, so check counts don't change; --slots passes it on. - TestGoldenLimactlVersion, TestGoldenLimactlList and TestGoldenQemuImgInfo read every system's fixtures through limaVersion, Lima.list and diskInfo, and check every field the stub prints is one the real tool prints, of the same kind (the stub's listing after the contract scenario); TestShapes checks the comparison and anonymous. TestGoldenSecurityTmutil checks the stubs' exit status and form on macOS. Captured on this Mac (e2e --only images,project,tools --slots 2 --golden) and on Fedora (--only images --golden). Docs: testing.md's Golden fixtures, contributing (--golden, the stubs), AGENTS.md's testdata row. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
39c2ff4f4e |
test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of them) are one Go binary, internal/stubtest/stub, which acts as the command it's run as (argv[0]): limactl, docker, security, ssh, ssh-add, ssh-agent, ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags, tmutil, sw_vers, uname, open, code and mise, and stub, scripts' commands on the stubs' state. stub-log is gone: each stub logs its call itself, in one write to $STUB_LOG, its arguments on no other process's command line. - internal/stubtest builds the binary once, into $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link per command, which every test process and later run reuses until the sources change; a day-old folder of another build is removed. stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs' VM, Size, VMs, Keychain and SetKeychain on the state. - internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json, typed JSON under a file lock (Lima's instances with their status, size and config, the Keychain, the SSH agent and its keys, Time Machine's exclusions, the tools build VM's folder). The instances file wasn't locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes at once. - guest.go is the VM behind limactl shell and ssh alike: a --clone VM's git on vmfs, a remake's home, a base build's packages, the setup's tar, the direct connection, host keys, a forwarder's ports, link forwards. - A link session's master listens with a backlog of one and never accepts, as the Perl one did, so a killed session's socket reads as stale once probed (link_life). TestScript's cleanup stops the sandbox's masters by their -M -S arguments. - Structure: the stubtest layers cover internal/stubtest/..., the binary and its state import nothing else of devvm's; execSites lists internal/stubtest/build.go and internal/stubtest/stub/process.go. Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state: instances, size-<vm>, config-<vm>, keychain/<account>, agent-up, agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size, keychain, keychain-set, agent and agent-stop instead (build, existing, from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm, secret, size, space, ssh, ssh_agent, up). Tests: stub_test.go (every stub in-process, TestShellWords), stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima, platform, vm, tools and build tests use the state helpers and stubtest.Command. Coverage: internal/stubtest/stub and stubstate added, stubtest, build and tools raised (and lima, netpolicy on Linux). Docs: contributing (Stubs: the binary, logging, the state and the stub command, switches, the guest, adding a stub or a switch; Go test helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
da5bae47f9 |
fix: tighten VM names, validate aliases, make written folders private and choose build VMs' ssh ports under the claims lock
- vmname.IsVM takes a name's folder part only as project.Slug makes it ([a-z0-9-], a letter or digit at each end), so a hand-edited name never carries spaces, slashes, newlines or ssh patterns. TestSlug checks that every name project.New makes is one. - vmname.Short and vmname.IsAlias: a VM's alias is devvm-<folder> of its own name or the name itself. sshconfig.Host, ChooseAlias and project.Named ignore any other alias, so one edited into vm.json never reaches the ssh config's Host line or names a VM. - state's writeFileMode makes a missing folder with PrivateDir (exactly 700, whatever the umask, a link refused); a folder already there keeps its mode. - ports.Allocator.Build chooses a build VM's ssh port on macOS under the claims lock (state.Claims, which VM.Claim now shares), records it in run/build-ports/<name> until limactl start returns, and ports.Used reads those records, so no VM or forwarder takes the port before Lima binds it. Lima's own freePort and platform.PortFree, its only user, go; Lima gets a Ports field (the allocator). paths.Dirs.BuildPorts is new, and Dirs' method limit goes to 54. Tests: TestIsVM, TestIsAlias, TestSlug, TestChooseAlias, TestWrite, TestTargets, TestWriteFileMakesPrivateDir, TestBuild, TestStartBuildSSHPort; layout.txtar lists run/build-ports on macOS. Docs: internals (backends, overview, design), contributing, using/space. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d49163a85c |
refactor(gitprotect): gate locks on the host's immutable flag, not its OS name
platform.HasImmutableFlag says whether the host has a user-immutable flag (true on macOS alone), and the Protector's CanLock field, set from it by New, replaces its OS field: NewMode, NewVM, Set, Check, Unlock and devvm git-protect's running-VM check (vm's settings) read it instead of comparing an OS name with "darwin". Tests set CanLock; TestNewCanLock checks New takes it from platform, and TestRealLocks skips on the same constant. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
866b9e0930 |
fix: the processes devvm starts don't inherit the files it was given
A terminal, an editor or a test harness can give devvm files past the standard three without close-on-exec (testscript's ttyin puts a pty on descriptor 3), and devvm's background processes then held them, keeping that terminal or pipe open as long as they ran: on Linux a script hung until its timeout. devvm now marks every file it was given from descriptor 3 up close-on-exec as it starts (platform.CloseInheritedOnExec, called first in main), which covers every process it starts, Lima's included, and keeps them open itself. TestCloseInheritedOnExec re-runs the test binary with an extra file on descriptor 3, starts a detached process and checks it doesn't hold it (/proc/<pid>/fd on Linux, lsof on macOS); layer_add.txtar now answers yes in a terminal. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
120ca70279 |
fix(vm): a VM whose folder is on a disk that isn't connected isn't gone
A folder with nothing at its path is now one of three folder states (vm.FolderOf): there, gone, or not connected. With nothing at the path, devvm compares the device of the nearest folder above it that exists (platform.DeviceOf) with the device in the recorded folder identity (platform.FolderDevice): the same device is gone, another is not connected (a folder moved to another disk and then deleted counts too), and no recorded identity or an unreadable device is gone. devvm ls writes (not connected) and --json gives folder_state (there, gone, not_connected) in place of folder_gone; devvm space names such VMs (space_folder_not_connected) and lists them as folder_not_connected. devvm rm VM refuses one without a terminal, even with --force (rm_vm_not_connected), and in one asks (delete_not_connected_folder_vm), which --force never answers. Tests: TestFolderOf (a fake device: same, other, none, unreadable, and a real deleted folder), TestDeviceOf, the JSON shapes, rm_vm.txtar's not-connected case, ls.txtar. Docs: commands (rm, ls, a folder on a disk that isn't connected), space, troubleshooting, overview. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cd7f202b64 |
fix(ports): choose new ports below the host's ephemeral range
The proxy's, desktop's and Lima's ssh ports came from 20000-59999 (or the kernel's port 0, inside the ephemeral range), which overlaps Linux's ephemeral range: a live outgoing connection could take the port between the check and the bind. One owner now picks them: platform.FreePort over platform.ChoosablePorts, 20000 up to just below the ephemeral range (Linux: ip_local_port_range; macOS: net.inet.ip.portrange.first, 49152 if unreadable), or 20000-32767 when unknown or too small. Proxy.Ports is the seam. Tests: TestPortsBelow, TestParsePortRangeFirst, platform's TestFreePort; netpolicy's TestFreePort checks the chosen range. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f4fd373439 |
refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend, Caps, Features, Review/Require, the registry, backendtest.Fake), so another backend is an addition. State from a smolvm VM reads as an unknown backend (backend_unknown_vm, gc_orphans_unknown); nothing migrates it. The image keys of layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images rebuild once. Lima's port forwarder moves off smolvm's files first: newForwarderCmd and forwarderMain from internal/cli/smolvmports.go to limaports.go, and assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder at run time, so no image key changes). Removed: - internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its registry entry, registry.Experimental and backend_experimental. - The decider: backend.Decider/UsesDecider, Confinement.Decider and DeciderToken, internal/proxy/decider.go and its test, the proxy's -decider, -decider-to and -decider-token-file, netpolicy's KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in vm's forwarding and UsedPorts. - backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and agent_unchosen_stop. - vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped). - paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing called (a test helper now). - ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and bump.sh's ubuntu_image, with its part of bump.txtar. - assets/smolvm/ and assets/container/; the no-init-system branches of layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in features/desktop.sh and guest/ca.sh. - Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh, creating_from_image, packing_image, pack_failed, backend_experimental, agent_unchosen_stop; descriptions naming smolvm reworded. - Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a failing or hanging Lima listing instead (the limactl stub's list-fails and list-hangs); the --backend smolvm examples; e2e's --backend smolvm and its section (about 1,130 lines), the smol_* helpers and the link section's backend switch. - Coverage: internal/backend/smolvm's lines in both baselines. - Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm notes (Ports on Lima now holds the forwarder's description), the backends table's smolvm column, every page naming smolvm, the README, the home page's backends art, and AGENTS.md's smolvm rows and gotchas (and the Docker bind-mount gotcha, which nothing refers to). Kept: the docker layer, on Lima; --from's local Docker; --backend, the BACKEND column and setup's backend choice, which the next commit removes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2b25a0c7dd |
fix: the shared foundations' review: one Lima host address, a kill only for its own process, and the Linux baselines
The consolidation pass over the shared foundations: - Lima's host address on its user-mode network, 192.168.5.2, is one constant, limaHost, which the VM's proxy URL and the build proxy's both use (proxyHostDarwin and buildProxyHost went). - platform.LockFileShared had no caller: LockFileSharedWaiting with no waiting does its job, and its tests use that. image.ToolName had none either, and goes until the tools picker needs it. mise run deadcode lists only what AGENTS.md names. - tools' writeNew, a third whole-file writer, goes: the share's .sha256, .target and idle files are written through state.WriteFile. From the security audit of the phase: - daemon.Proc.Stop sends SIGKILL only to a process whose arguments still say it's this one. A process still ending, whose arguments can't be read, is waited for; so is another process given the pid since whose arguments can't be read either (a setuid one, on macOS), which would have been killed. TestProcStopKillsOnlyItsOwn fails without it. - forbidigo's signalling rule also bans os.Process's Kill and Signal outside daemon and platform; tests signal their own children, and devvm desktop's ssh child, not yet waited for, says why with a nolint. testdata/lint has a line for each. Contributing's checks table says so, and internals/network.md says which process SIGKILL goes to. testdata/coverage/linux.txt is measured again with mise run coverage on the x86_64 Linux host: it had no lines for fetch, shell and vmname, so mise run test failed on Linux, and daemon was set by hand. arm64 (the Linux host VM) agrees within a point. darwin.txt: daemon 97.8, tools 89.2. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c601958355 |
fix(links): link sessions' and port forwarders' ssh get devvm's limit on open files
A link session carries up to 256 connections at once through an ssh
master to each target, which takes in two descriptors (stdin, stdout)
for each connection's ssh -W. Go raises devvm's own soft limit on open
files but gives the processes it starts the one it started with, 256 by
default on macOS (and for launchd jobs, as the remote e2e runs are), so
the master ran out of descriptors well before 256 connections
("mm_receive_fd: recvmsg: Message too long") and closed those it
couldn't take: e2e's 256-connection check failed,
and as it returned early it left its link to db:47241 in place, so the
group checks after it found other links than they expected. A shell
with a higher limit (this Mac's) never showed it.
- platform.ShareFileLimit sets the limit to what it is now, so the
processes devvm starts from then on get it; vmssh.Links.Run and
vmssh.Forwarder.Run call it first. TestShareFileLimit starts a child
test at a soft limit of 256 and checks its own child gets more (fails
without it: 256).
- e2e: the link section runs devvm at a soft limit of 256, so it fails
without the fix on any Mac (it did, deterministically, on this one).
lk_cap ends its hold server and removes its link whatever came of its
checks, and shows the reasons of its refusals. lk_start waits until the helper listens or has ended (its
wrapper writes "exited N"), and on a failure says so with "failed: ",
lists its files, shows its output and the VM's TCP listeners. gp_join
publishes and starts its server, then the three join whatever came of
the server (gp_joined), so a server that doesn't start fails that
check alone.
- docs: internals/ports.md (the ssh processes' limit), contributing
(the link section's limit).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
ae77c7bc45 |
fix(daemon): a stopped process counts as stopped once it's gone, not once its arguments go
A proxy restarted on a running VM (its company proxy settings changed, say) was stopped with SIGTERM, and Proc.Stop took it as stopped as soon as its arguments could no longer be read. An ending process loses its memory before its files: on macOS kern.procargs2 fails some milliseconds before its listening socket closes (every time, in a test of 30 stops), and on Linux /proc/PID/cmdline reads empty. When Stop looked in that window, Prepare found the VM's proxy port still taken, failed the launch with proxy_port_taken and stopped the VM (Unproxied): e2e's company proxy checks 15 and 17 failed in turn, and the checks after them found the VM stopped. - daemon.Proc.Stop waits until no process has the pid, or another process does (Proc.ended); one whose arguments can't be read is still ending. - platform.ProcessArgs on Linux returns an error for an empty cmdline (an ending or unreaped process), as macOS does, never [""]. - Tests: TestProcStopWaitsForTheEnd (fails before the fix: Stop returned while the process still ran) and TestProcessArgsEnded. - e2e: check prints a failed check's "failed: " lines first, then its last lines (5, or check_lines); checks 15 and 17 are functions (corp_through, corp_direct) whose steps each name themselves, then corp_why shows the VM's status, its proxy, the launch's output, the proxy's log and events, and the company proxy's log and events. - docs: internals/network.md says when the old proxy counts as stopped. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2687eec488 |
refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns devvm's background processes: Detach and Spawn (own session, no input, reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status file), Handle (signals through the process started), Proc (a pid file checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL, the pid file removed once stopped), readiness by status file (Ready, WriteStatus, WaitReady: the pid and data, written in one line-ended write, never another start's), Alive and Signal (no pid below 1), and one lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content equality, a bounded wait past what the file held first). It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards' pid, stop and start wait, the build proxy's process and log-read port, links' link-session pid, stop and start, the proxy's watchLifeline and vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess, and the alive copies (netpolicy alive/signal, lima alive, vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go: the proxy and the forwarder say they're ready in a status file, and the build proxy's port comes from its own. forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside internal/daemon and internal/platform, with its line in testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS and puts internal/daemon among the leaves; depguard holds it to the standard library. Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file, groups refused, readiness, lifeline), characterisation tests first for the proxy's, the forwarders', the link sessions' and the build proxy's pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1cfc8e24f1 |
test: share the stubs sandbox, message checks and recorders across Go tests
internal/stubtest puts testdata/stubs first on PATH with a folder of its own (New, New with only some stubs), reads and writes the stubs' files (Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It replaces the stub setups of the Lima, Docker and smolvm backends' tests, vm's --clone tests and platform's Keychain tests, and the backends' own execRunner, reset and touch copies. The structure test holds it to tests and to importing only internal/msg. msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers and the errors.AsType checks that only read a message's ID or names; msg.Recorder replaces the inline recorders tests set as Info, Warn or Say. backendtest.Stored replaces the four stored fakes with disks. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bdd26779b4 |
fix(cli): only a test build reads the test overrides
DEVVM_HOST_MISE (which replaced the pinned, checksummed mise), DEVVM_KVM and DEVVM_UBUNTU_URL were read in every build, a release's included. One ldflag in a leaf package, internal/testbuild (testBuild=yes, set by tests/e2e.sh and the CLI tests), now marks a test build, and cli's readOverrides is the one place devvm reads every test override, into Overrides (registry.Overrides, with platform.Overrides for the host's size, and HostMise): empty unless testbuild.On(). registry.New takes them; lima.New takes Ubuntu's URL; ubuntu.New takes a URL, not getenv; Lima's and smolvm's KVM default to /dev/kvm; tools.Env has Mise in place of reading DEVVM_HOST_MISE; platform.NewHost takes Overrides. Gone: registry.unreviewed, registry.Host, newFor, hostFor, ubuntu.URLEnv. The documented settings (DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE, DEVVM_NO_TOOL_CHECK, DEVVM_FROM) stay as they are. Tests: TestReleaseReadsNoOverrides (cli: a release reads none, its mise, KVM, unreviewed and host its own), TestOverrides (registry: every override reaches its backend, none leaves the defaults), TestHostOverrides and TestListTimeout (platform) and ubuntu's TestNew moved to the new shapes. Docs: contributing/testing.md's Test builds, contributing's sandbox table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
20c9fdbadd |
fix(build): a build holds its image's lock, so concurrent builds, gc and rebuild leave it alone
On Lima a build in progress is a recordless image with its final name, so a second build, devvm rebuild or devvm gc took it for a leftover and deleted it. Each build now holds an OS lock per image key (images/locks/KEY) from before it looks for the image until its record is written; the system lets go of it when devvm ends, however it ends. - A second build of the same image waits for the lock, saying so after 3 s (image_build_waiting), then finds it built. - An image without a record is unfinished only while its lock is free; while held it's listed as building (devvm images, --json state). - gc (and gc --backend) and rebuild skip building images; images rm and DeleteKey refuse them (image_building). Deleting an image removes its lock file while holding it. - platform: LockFileWaiting and LockFileSharedWaiting (call a func once after waiting a while), LockHeld; a lock whose file was removed while held is taken again on the new file. tools.Making.Hold uses the shared helper instead of its own two-step wait. - state.ImageLock: a key's lock path, the key checked. Tests: build TestBuildInProgress, TestBuildTakesTurns; platform TestLockFileWaiting, TestLockFileRemoved, TestLockHeld; state TestImageLock; build.txtar checks a hanging build is listed as building, kept by gc and refused by images rm. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
608d287d00 |
test(cli): devvm space's backend timeout is a test-build setting, so the space script doesn't depend on load
A test build's Host reads DEVVM_TEST_LIST_TIMEOUT (platform.TestListWait):
comma-separated durations, each for every backend ("10m") or one
("smolvm:1s"), one backend's winning. spaceTimeout(backend) reads it
through registry.Host(), so a release always waits 30 s. devvm space's
listings and strays and gc --caches' cache listing use it.
The CLI tests' fakeHost sets 10m for every script. space.txtar adds a
case where smolvm's listing hangs (the stub's smolvm-ls-hangs) past a
1 s smolvm timeout: smolvm is named (space_backend_unknown) and its VM's
state isn't a leftover. TestListTimeout covers the parsing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c0b9916ff2 |
feat(gc): gc --tools names the tools it keeps for the hour, and --force deletes them
gc --tools prints gc_tools_recent (count, tools) for the current shared tool images no VM has that it keeps because they were built in the last hour, after the same filters as the ones it deletes (TOOL names, --backend, skipped backends): with gc's list, or in place of nothing_to_clean. Plain gc never prints it. --force, only with --tools (gc_force_needs_tools otherwise), also deletes those and skips gc's prompt; gc still lists what it deletes. Tools a VM's state lists stay, the share's lock is held from before the List, and no other category widens. Retention's Idle keeps the hour. The being-made signal: tools.Making, an flock on making.lock in devvm's data folder (platform.LockFileShared, platform.TryLockFile). up's create (every backend, --clone, devcontainers), devvm update and adding a layer in place hold it shared from before they pick tools until the VM's state lists them; gc --tools --force takes it exclusively without waiting, after the share's lock, and holds it through its deletions, else fails with gc_force_making and deletes nothing. The OS releases it when the process ends, and its descriptor is close-on-exec. Tests: TestLockFileShared, TestLockFileKilled (a killed child releases it), TestMaking, TestNoVM's recent ones, TestGCAsks, gc_tools.txtar. Docs: using/images.md, using/space.md, internals/images.md, the CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
37d843c285 |
fix(test): the CLI tests fake the host's CPUs, memory and free space
The CLI tests read the real host's CPUs, memory and free disk, so they failed on GitHub's small ubuntu-latest runner (2 vCPUs, 7 GiB, ~10.8 GiB free) and passed on larger machines. internal/platform: Host (CPUs, Memory, FreeSpace) is the only way to read them; the raw reads are unexported (memory, freeSpace). NewHost(test, getenv) gives a test build's Host, which reads DEVVM_TEST_CPUS, DEVVM_TEST_MEMORY_GIB and DEVVM_TEST_FREE_GIB (platform.TestCPUs, TestMemoryGiB, TestFreeGiB) in place of the host's; an unset one leaves the host's, a bad GiB value is an error. The zero Host reads the host. The gate is registry.unreviewed, the same -ldflags -X variable as DEVVM_UNREVIEWED: registry.Host() and newFor pass build == "allowed" into NewHost, so platform has no package var. backend.Registry gets a Host field; lima.New, smolvm.New and tools.New take a platform.Host; vm.ThisHost takes one; vm.NewEnv, doctor, setup, build and _refresh-tools read the registry's (or registry.Host()). Docker reads only its engine's NCPU and MemTotal and checks no host free space, so it has no host reads to route. forbidigo bans runtime.NumCPU, unix/syscall Statfs, Fstatfs, Sysinfo and unix.SysctlUint64 outside internal/platform. script_test.go sets a large host in every script (8 CPUs, 16 GiB, 500 GiB free). small_host.txtar sets 2 CPUs, 7 GiB and 1 GiB free and checks doctor's disk_low_warning, host_memory_low and host_cpus_few, disk_low on a build, base_fitted with Lima's --cpus=2 --memory=3.5 and smolvm's --cpus 2 --mem 3584, too_many_cpus have=2 and too_much_memory have=7 max=5. The host-relative regexes in build, from, setup, size, up_size and smolvm are now the fake host's exact values. Docs: contributing/testing.md's "A host of any size" (the overrides, that only test builds read them, the large host script_test.go sets, how a script asks for a small one, what stays the Linux CI job's), and the sandbox table in contributing/_index.md. Review: GoReleaser's ldflags (both builds) and the Homebrew formula set only cli.version, linuxURL and linuxSHA256, never registry.unreviewed, so release binaries ignore the overrides (TestReleaseHostIgnoresOverrides; a release build checked by hand ignored DEVVM_TEST_CPUS=1, DEVVM_TEST_MEMORY_GIB=1 and DEVVM_TEST_FREE_GIB=0.5 in doctor and size while the test build honoured them). No caller outside internal/platform reads runtime.NumCPU, memory or statfs (grep, and the forbidigo rule checked against a probe file). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e6929a3530 |
feat(disk): check free disk space before builds and new VMs
- platform.FreeSpace: statfs (Bavail * Bsize) on darwin and linux, the nearest existing folder for one not made yet; ErrUnsupported elsewhere - backend.Storage (DiskDirs: Lima's home; smolvm's folder, and HOME on macOS; Docker none), backend.Space Check and Warning, floors FreeBase 12 GiB, FreeImage 8, FreeTools 8, FreeVM 4, each commented with its measurement - builds (base, other images), shared tool builds (also the data folder) and new VMs refuse below their floor before anything is made (disk_low); statfs errors carry their cause (disk_free_unknown); doctor warns below base's floor without failing (disk_low_warning) - FreeSpace fields on build.Env, tools.Env and vm.Env; structure limits Lima 67, smolvm 72 for DiskDirs - docs: ports-size Free space, troubleshooting Not enough free space, install requirements, docker, smolvm, design's open work; doctor's help - tests: backend Space, build, tools, up, smolvm DiskDirs, platform Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8439cbdb8c |
ci: the tests pass on Linux runners; workflows linted with actionlint and zizmor
The tests assumed a macOS host with 4 or more CPUs: - size: the stub VM has 2 CPUs, which any host running the tests has - ls, images: smolvm's --state-dir on Linux - docker: .git protection is off on Linux - the limactl stub's delete forgets the VM's port forwards and ssh port, as Lima does, so from's second conversion VM is configured again - TestStartForwarder confines Lima's start as the host does (no sandbox-exec on Linux) - TestProcessArgs runs sh, which ignores the extra arguments GNU sleep exits on lint:code runs actionlint and zizmor (offline) on the workflows; ci.yml's paths are written out, without a YAML anchor, and the deploy job's permissions say why. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
70f472eacd |
feat(ports): port changes apply to running VMs
devvm ports on a running VM records the ports and starts only its forwarder again, on every backend: the VM runs on, and connections open through the old forwarder close (ports_forwarding). SetPorts takes the VM's Confinement (host key, proxy and decider ports, Free, which leaves out and warns ports a host program has); Env.forwarding builds it for starts and changes alike. State is written first, so other VMs' forwarders reserve the new ports, and put back if the backend fails. A per-VM lock (platform.LockFile, Forwards.Lock) keeps two runs from leaving a forwarder nothing stops; Stop kills a forwarder that outlives SIGTERM by 2 s. A smolvm or Docker VM started outside devvm gets ports_no_ssh. Removed: ports_set, applyPorts, startPorts, ports_pending, ports_next_start. ports.txtar takes free ports (free_port) instead of fixed ones a host program can hold. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3da0d6b0a6 |
feat(devcontainer): a project's devcontainer.json as input for new VMs
A new VM gets what the folder's .devcontainer/devcontainer.json (or .devcontainer.json) says, on every backend: image as --from (only an image its registry gives anyone, asked anonymously, pinned to that digest, never a registry on this machine or its network), features devvm has layers for (docker-in-docker as the docker layer, node, python, rust, go), forwardPorts as far as the user's ports allow, containerEnv and remoteEnv in the VM's environment, onCreate/updateContent/postCreate commands once and postStartCommand at each start, in the VM as its user. --no-devcontainer skips it; the command line wins. Later launches only warn when the file changed.
Nothing from it runs on or reaches the host: initializeCommand never runs, ${localEnv} and the host-folder variables are refused, builds, Compose and docker-outside-of-docker are refused, mounts, runArgs and privileged ignored. The file is read through os.Root, without blocking, at most 1 MiB. A docker layer only the file asks for still asks about network policy on Docker.
Reviewed with the security-audit skill (FuzzParse, design note); e2e: project 69/0, docker linux 135/0, smolvm 131/0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
7259ad13a1 |
feat(docker): the docker layer on Docker VMs with Sysbox
Docker's engine runs inside a Docker VM only under Sysbox, on a Linux engine of this machine's: its own user namespace, its own network with nothing else on it, volumes of its own for Docker's and containerd's files, dockerd started after each start. Made with the layer or given it in place (its container made again from a commit); a failed add in place makes the VM as it was. Elsewhere refused in one line (docker_layer_no_sysbox, docker_layer_needs_vm); devvm never runs a container --privileged. No network policy for it at any step (net_docker_layer): root in it controls its own network. A bridge routing to this machine's loopback (Docker's userland proxy off), or one whose setting can't be read, is refused at creation and each start (docker_route_localnet, docker_bridge_unreadable). Set-id files of root's, or root's group's, in the project folder are named apart as running as root (setid_root_files); setid_files says the rest run as their owner. Root in any Docker VM writes the folder as the host's root. Reviewed with the security-audit skill; e2e on the Linux engine with Sysbox 0.7.1 (135/0) and Docker Desktop (115/0, the refusal). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fcbea2c744 |
feat(docker): network policy, and build confinement on Docker Desktop
A Docker VM with network policy sits alone with a relay container on an internal network of its own (inhibit_ipv4). The relay, devvm's own Linux build in an empty imported image (read-only, every capability dropped), copies the VM's connections to a unix socket of devvm's proxy on the host, so tokens, the Keychain, the CA key and agents' logins never enter Docker. On and off is docker network connect/disconnect at the next start. Desktop builds run on a network and relay of their own, through a host proxy allowing any host on ports 80 and 443. - every Docker VM drops NET_RAW; it's in the config hash, so containers are made again from their commit - confined: the start's ID, the VM alone on its network with the relay by its recorded container ID, the network still internal; a foreign member is docker_network_shared, at start and on removal - proxy: -listen-unix, -relay/-relay-to; a lifeline pid file written after the proxy started whose process has gone ends it - macOS fetches the release's Linux build on first use, checked against a SHA-256 the two-pass release.sh bakes in; builds without the pin use devvm-linux-<arch> beside devvm or refuse - the build proxy is stopped through the process devvm started - reviewed: design notes and threat check in design.md; e2e on the Linux engine and Desktop: dropped capabilities, network members and options, no IPv6 beyond the bridge's link-local, no DNS query leaving (captured, with an unconfined control), direct connections refused Co-Authored-By: Claude Opus 5.5 <[email protected]> |