64 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 f3052e5a8e feat(upgrade): releases checked by two of three release keys, bridged from the old key
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.

The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.

- internal/minisign: the one owner of signature checks (moved from
  internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
  compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
  Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
  distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
  blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
  FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
  code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
  but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
  in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
  packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
  none, or three distinct minisign keys, none the old key),
  TestCheckReleaseKeys (fixture keys from minisigntest),
  TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
  empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
  marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
  none or all three of packaging/keys' release keys. With none,
  install.sh's release_<role>_key lines are empty or missing; with all
  three, each is a minisign key, distinct, not the old release key, not
  marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
  and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
  signature only when the script has its key), check_signature,
  signed_by_two, check_legacy; plainer warning without minisign, with
  the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
  upgrade.txtar (-legacy, -keys, and the keys built in, none),
  install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
  (real minisign), release.txtar (none, nolines, nokeyline, old, marked
  and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
  Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
  releases/0.2.0.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 ecd266c7d3 test(cli): one wait for the scripts; the docs release job installs only what it builds with
The scripts waited with copies of the same loop: desktop.txtar's and
nix_cache.txtar's waitfor files, and sh -c loops in link_life,
fixture_v010_links, fixture_v010_small, ports and ports_stopped, each
with its own interval and limit. They now use one testscript command,
wait_until SCRIPT, which runs sh -c SCRIPT every 100 ms until it
succeeds, for up to 90 s, and fails at once when every background
command has ended, as wait_file does, or when SCRIPT exits 100
(waitGiveUp, a status no tool the scripts run gives), as the links
check does when its session has ended. Contributing's tests page names
it beside wait_file, whose limit it now says is 60 s.

The docs workflow's release job installed every tool in the tag's
mise.toml. It now installs only Go, Hugo by the name the tag gives it
(hugo-extended before Hugo 0.170) and Node when the tag draws its
diagrams, with --locked as mise-action did, picking them with mise's
own reading of the tag's mise.toml (mise ls --current --json, the tag's
file alone), and fails when the tag names no Hugo. MISE_AUTO_INSTALL is
off for the job, so mise run docs:diagrams and the shims install
nothing more, and a tool the pick missed fails the build. This job runs
only at a release, so it hasn't run yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-18 10:12:14 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-15 19:36:31 -07:00
w3cjandClaude Opus 5.5 7af09a596f test(cli): a failed script shows its VMs' proxy logs
A script that fails with proxy_start_failed leaves no trace of why: the
proxy's log and status file are in the sandbox, which goes with the
script. The sandbox's cleanup now logs, for a failed script only, the
last 40 lines of each VM's proxy log and its proxy's status file, before
it removes them, so the next such failure in CI shows its cause.

- logProxies, proxyLogLines

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 b30229ca19 test(fixture): a fixture's host ports are ones free here
fixture_v010.txtar launched app, scratch and web on the host ports
0.1.0 recorded on the machine that made the fixture. When any of them
was taken here, by a program or by another run of the same tests (two
checkouts' gates on one machine), the launch rightly chose another port
and edited the VM's Lima config, failing the script's check that a
launch makes no limactl edit.

fixture VERSION now maps each VM's ports.host to a port free here,
wherever the number stands on its own (vm.json, the stub's state,
lima.yaml's proxy URL, the proxy's config and status, the sandbox
profile), never inside a hash. The other fixture_v010 scripts' own
free_port and json_set of ports are no longer needed and go.

- freePorts: free_port's helper, shared with fixture
- fixtureRewrite: the paths' replacer plus the ports
- TestFixtureRewritePorts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 4f99e40731 test(clone): don't depend on the machine's git-lfs or system git config
CI (run 43285988512, at 9535110f) failed two tests that pass on a Mac
with Apple's git and no git-lfs:

- TestSeedConfig found "filter" in the VM's config. With git-lfs on
  PATH, as on GitHub's runners, the seed's own per-clone
  git lfs install --local --skip-repo writes filter.lfs.*, which is
  what the copy is meant to do. The check now looks for this machine's
  filter (filter.crypt) and allows only filter.lfs.* besides. Reproduced
  with git-lfs 3.8.1 on PATH; passes with and without it.
- clone_uncommitted_retry wanted clone_kept_branches. That has nothing
  to do with LFS: after the failed first copy, the VM's repo is empty,
  and the script's git commit landed on the VM git's default branch.
  Apple's system gitconfig sets init.defaultBranch=main, so locally it
  was main, which the retry keeps (clone_kept_branches); on the runners
  it's master, so main was set as copied and only HEAD stayed
  (clone_kept_head). Reproduced with GIT_CONFIG_NOSYSTEM=1, which now
  fails the old script locally exactly as CI did. The script now puts
  the VM's HEAD on main before it commits, and every testscript runs
  with GIT_CONFIG_NOSYSTEM=1, so a machine's system config can't change
  what a script's git does.

The gate passes twice, with git-lfs 3.8.1 first on PATH and without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 12:30:46 -07:00
d349868c31 feat(agents): one definition per coding agent, and Cursor's CLI
Every list of the coding agents now derives from internal/agents'
registry, one Def each, and Cursor's CLI (cursor-agent) is a fifth
agent.

The registry:
- each agent's login command, login formats and capture on its Def;
  one message for every agent where each had its own
- the agents' table, the README's list and the docs' history lists are
  generated from the registry (cli.DocBlocks, TestDocBlocks); scripts
  and Go tests take their lists from it too
- each agent's own code lives in a file named for it; the structure
  test lets only an agent's own files choose by its name, following
  constants named after an agent
- a VM remade by clone on/off keeps no agent's login files
  (agents.LoginFiles from every Def.Logins; Claude Code's .claude.json
  stays, as it is also history)

Cursor's CLI:
- `devvm --agents cursor`, `devvm agent login cursor`, history import
  and export of ~/.cursor/chats
- the proxy captures its login at a GET endpoint, guards a shared host
  by path, and puts the login in only where the CLI sends it, bound to
  the CLI's 57 methods
- account changes and the agent store are refused in a VM; Cursor's
  headers and trailers are scanned for tokens
- e2e: Cursor's CLI in the network section, its poll behind the fake
  company proxy

Docs: the agents' pages lead with commands, with a How it works page
for the agents.

Co-authored-by: JB <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:49:48 -07:00
CJandClaude Opus 5.5 2b49967b4e chore: CI time zones, test isolation from the repo, a flaky test and the agents page (#45)
Upkeep: CI, flaky tests, dead code and the coding agents page.

- test: tests never run git on the repo they're run from. A git that
  runs the tests (a hook, git rebase --exec) sets GIT_DIR and friends,
  and the tests' plain git followed them into the real repo's config.
  Every test's git now runs through internal/stubtest (Git, GitEnv,
  NoGitRepo), the structure test enforces it, and the whole suite
  passes with GIT_DIR pointing at a decoy repo that stays untouched.
- ci: two test jobs instead of three: Linux in America/Los_Angeles
  (DST) and macOS in UTC, with lint on both, since golangci-lint checks
  only the runner's OS's files.
- test(e2e): accept Codex 0.167's wording for an API-key login.
- test: internal/safefile's swap-after-look branch is tested on purpose
  through a seam, so its coverage no longer depends on a race (97.7%
  every run).
- test(fetch): TestRetryUnanswered's "no answer" comes from a listener
  that keeps its port, so a parallel test's server can no longer take
  the freed port and answer in its place (Linux reuses ports at once).
- refactor(proxy): the test-only policy.decide and policy.byRequest
  move to the tests; the proxy already judges a host from one read of
  the rules (rulesFor).
- docs(agents): "Pasting images" moves down the coding agents page,
  before History, and its run of paragraphs becomes commands and
  lists, every fact and anchor kept.

Gate and coverage pass on each commit; e2e `network` and `project` pass
on Linux (251 passed, 4 macOS-only skips).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-12 07:20:42 -07:00
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]>
2026-11-11 22:29:46 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-08 16:34:40 -07:00
w3cjandClaude Opus 5.5 017cc90a4a test(state): devvm 0.1.0's state, frozen, read and upgraded by today's devvm
testdata/v0.1.0/{darwin,linux} hold what devvm 0.1.0 itself left: four
VMs, its defaults, its agent store and logins, its image and tool records
and each --json it printed. The TestV010 tests in internal/vm read and
write back every field, and fixture_v010.txtar runs today's devvm on it:
each --json keeps all of 0.1.0's, read-only commands change no file, and
launches start each VM without a Lima edit, naming Codex's unknown login
field as withheld. Contributing's Released state says the fixture is
frozen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 11:28:27 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-08 10:06:17 -07:00
w3cjandClaude Opus 5.5 33ec9eb0dc refactor(tools): one definition per toolchain
Each toolchain is one image.ToolDef in image.SharedTools, which also
holds its guest environment, its PATH folders and its version files. They
leave base's devvm-tools.sh for /etc/devvm/toolchains.sh, which every
launch writes, so base.sh changes and every image rebuilds once. The
structure test's names rule fails on a toolchain's name as a literal
outside internal/image, TestToolchainsComplete checks the toolchains
page, and Contributing gains Adding a toolchain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:29 -07:00
w3cjandClaude Opus 5.5 edce817b4f test(cli): cp_exe copies devvm for scripts under the fork lock, no text file busy
On Linux, a child another script forked while testscript's cp held the copy's write descriptor kept it open until that child exec'd, so running the copy failed with ETXTBSY. cp_exe writes it under syscall.ForkLock; upgrade.txtar and release_notice.txtar use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 07:03:35 -07:00
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-06 01:56:50 -07:00
w3cjandClaude Opus 5.5 b045eff522 feat(cli): say at a launch in a terminal when a newer devvm release is out
A launch in a terminal checks at most once a day for devvm's newest
release, with upgrade's Source.Check in the background (5 s at most, the
launch waiting at most 1 s more once it's done), and records what it
found in the data folder's cache/release.json (latest, checked, tried;
an offline try keeps what was known, silently). The next launch says
upgrade_available in one line when that release is newer. Nothing
without a terminal, with --no-input, for a source build or for a copy
neither install.sh nor Homebrew installed. Off with config.toml's
release-check = false or DEVVM_NO_RELEASE_CHECK=1. devvm doctor shows
the newest release known (doctor_latest_release, --json's release).

- upgrade: Known, ReadKnown, Due, Newer, Source.Refresh
- settings: ReleaseCheck, KeyReleaseCheck (strict bool)
- paths: Dirs.ReleaseCheck (Dirs' limit 58)
- cli: releaseNotice in up; doctor's Release
- tests: release_notice.txtar, TestKnown, TestRefresh, TestReleaseCheck;
  the CLI tests set DEVVM_NO_RELEASE_CHECK=1 by default
- docs: settings (the release check), install, troubleshooting

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 23:22:34 -07:00
w3cjandClaude Opus 5.5 5f7289e6f7 feat(cli): devvm upgrade, the newest release the way devvm was installed
devvm upgrade [--check] [--to VERSION] [-f/--force] [--json] installs
devvm's newest release the way this devvm was installed, asking first
(upgrade_confirm, answered by --force). upgrade is a top-level exception
in the cli skill: it acts on devvm itself, not this folder's VM, and it's
the name other tools give the verb. It skips the layout check, as a
layout a newer devvm wrote is a reason to run it.

- install.sh's (<prefix>/lib/devvm/<version>/devvm, which
  <prefix>/bin/devvm links to): SHA256SUMS and its .minisig over HTTPS,
  the signature checked against the key built in from
  packaging/minisign.pub (packaging/key.go embeds the folder; no file,
  no key, and upgrade_no_key), the archive's SHA-256, unpacked into
  lib/.<v>.new.<pid>, run (--version), renamed to lib/<v>, the link
  switched atomically (symlink beside, rename over), run again through
  the link, rolled back on any failure; then older versions pruned as
  install.sh does (kept: the one that ran, any a running process names,
  another upgrade's staging folder).
- Homebrew's (a Cellar/devvm/ keg): brew upgrade devvm, asked first,
  through the run log; --to refused.
- Anything else: says how it was installed (a checkout build, go
  install, a copy elsewhere) and fails.
- Already latest says so; a newest release older than this devvm is
  refused even with --force (rollback); --to installs a named one, older
  asked about (upgrade_confirm_older). --check and --json install
  nothing.

minisign verification is Go's: ed25519 over blake2b.Sum512 for the
default prehashed ED signature (legacy Ed refused), the key ID, the
global signature over signature||trusted comment, and the trusted
comment "devvm <version>" as scripts/release.sh writes it. Verified
against a signature minisign 0.12 made. golang.org/x/crypto v0.58.0
added for blake2b only (approved; depguard allows only
golang.org/x/crypto/blake2b); MVS raised x/text to v0.43.0 and x/tools
to v0.51.0. mise run vuln: no vulnerability reached; the module-level
GO-2026-5932 is x/crypto/openpgp, which devvm doesn't import.

New: internal/upgrade (Detect, Source: Latest, Check for the release
notice to call, Fetch; ParsePublicKey/Verify; Valid/Compare; Upgrader),
internal/upgrade/upgradetest (TLS release server, minisign signer;
tests only, a structure layer), fetch.Resolve (where a HEAD's redirects
end), fetch.Download's size cap (mise's 256 MiB too). Test-build
overrides: DEVVM_REPO_URL, DEVVM_RELEASE_KEY, DEVVM_RELEASE_CA,
DEVVM_TEST_VERSION; script command release_server [-badsig].

Security review (security-audit skill, guidance mode, a fresh reviewer):
- Prerelease order compared suffixes as text (rc.10 < rc.9), which let
  an older signed prerelease past the rollback refusal: fixed, semver
  precedence, with table cases.
- No cap on the archive download (a host could fill TMPDIR before the
  checksum failed): fixed, fetch.Download takes a limit.
- Two upgrades at once: prune removed another's staging folder: fixed,
  .<v>.new/old.<pid> folders are kept while that pid runs.
- A failed rollback of the link was silent: fixed,
  upgrade_rollback_failed names the link and the old devvm, and the new
  folder stays so the link isn't left dangling.
- QEMU's guestfwd names devvm with commas doubled, which the in-use check
  missed: fixed.
- Freeze (a host serving the current version as newest forever): no
  boundary crossed, inherent without signed expiring metadata;
  documented in internals/install.md.
Checked sound: nothing untrusted runs or unpacks before the signature
and SHA-256; versions from the redirect and --to pass Valid before any
URL or path; tar takes only regular files in its one folder (no links,
subfolders, ..), 512 MiB cap, fixed modes; test overrides are read only
by test builds.

Tests: minisign (real minisign fixture, tampering, legacy, other key),
each install kind against the fake TLS server, bad signature, wrong
trusted comment, replaced archive (wrong SHA), bad archives, a new
devvm that fails before and after the switch, a failed switch (old
kept), a failed rollback, downgrade refused and --to, pruning, Homebrew
via a brew script, Check, Latest's failures, Compare; CLI test
upgrade.txtar.

Docs: getting-started/install.md (Upgrading: how, what it checks, an
older release, --json), getting-started/commands.md (This machine row,
Upgrading devvm, questions, output for scripts), internals/install.md
(devvm upgrade), contributing (release_server), the CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 22:47:23 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-05 00:00:12 -07:00
w3cjandClaude Opus 5.5 e93f29333a feat(ubuntu): pin the newest signed cloud image at base's first build
devvm's files keep only Ubuntu's release (26.04) and its cloud image key.
The first build of base on a machine pins the newest dated release whose
SHA256SUMS carry a valid signature from that key and list an image for the
host (state.UbuntuPin, images/ubuntu.json), and every later build uses the
pin without looking anything up. devvm rebuild base pins the newest again.
The pin is in base's recipe, so base's key hashes it.

The signature is checked in Go (internal/ubuntu/pgp.go: OpenPGP v4 RSA
signatures with SHA-256/384/512, the standard library's crypto), so no
gpgv is needed and a host without one is no longer unchecked.

- backend.Images gains PinOrigin (backend.Pin: PinFirst, PinNewest,
  PinOlder); internal/build pins before it keys a build, and says what it
  pinned (origin_pinned).
- Lima: Origin and createFromUbuntu read the pin; PinOrigin finds the
  newest with ubuntu.Finder (Newest, Release) under images/locks/ubuntu; a
  --from conversion pins only when nothing is.
- Messages: ubuntu_unreachable and no_ubuntu_release; ubuntu_unsigned and
  ubuntu_checksum_unpinned are gone.
- e2e pins its own release (DEVVM_UBUNTU_RELEASE, a test override;
  scripts/bump.sh e2e-ubuntu moves it); bump.sh's apt moves the package
  snapshot alone. The gpgv stub is gone.
- Tests: the verifier against Ubuntu's real signature and a test key
  (damaged keys and signatures, packet and subpacket lengths, armor),
  Newest/Release, PinOrigin, the pin record, and the key covering the pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:27:25 -07:00
w3cjandClaude Opus 5.5 bdc95ef6ee refactor(ports): port forwarding out of the backends, one owner in vmssh
The port forwarder is devvm's on every backend. vmssh (moved out of
internal/backend) holds it, the link sessions, and its one owner,
vmssh.Forwards: the lock, stop and start of a VM's forwarder, which
ports it forwards read from vm.json (ports.Forwarding) each time, the
listed ports a host program has left out (ports_taken), the host key
devvm pins, and the backend's new ForwardTarget (user, key, host
loopback port) and Lifeline. One hidden command, devvm _ports
(cli/forwarder.go, vmssh.Main), replaces _lima-ports.

The backend no longer forwards: SetPorts, Want.Ports, Confinement.Free,
Confinement.HostKey and Confinement.Forwarded go; Lima keeps its own
forwards off and gives ForwardTarget (Lima's ssh port on 127.0.0.1,
Lima's user, _config/user). Lima's Stop and Delete no longer touch the
forwarder, and Lima's Forget goes with the backend/ folder: the
forwarder's files are in the VM's run/ (ports.pid, .status, .lock,
.known_hosts) and logs/ (ports.log), its control socket run/port-<hash>.ctl.
vm starts the forwarder after each start and on devvm ports of a running
VM; devvm stop, rm, gc --orphans and an interrupted start stop it.
vm/ports.go's hand rollback goes: the state changes first, and a
forwarder that can't start only warns. A structure-test layer keeps
backends from importing vmssh.

Tests: TestForwardsStart, TestForwardsRun, TestForwarderMain,
TestSplitPorts (vmssh); TestForwardTarget (lima); TestForwarding
(ports); TestStartPorts, TestSetPortsRunning (vm); testscripts up,
ports, layout, gc_orphans updated. Docs: internals/ports.md,
backends.md, lima.md, design.md (Ports on Lima), overview.md,
using/space.md, contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 18:19:39 -07:00
w3cjandClaude Opus 5.5 8e914b17c9 refactor(proxy): one typed, versioned config for every proxy, read as a private file
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON
(version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by
netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by
backend.ProxyStarter) both use. It holds what the flags and the run
folder's sidecars held: the address, the VM, the password (proxy.auth),
the built-in policies and the user's files (proxy.policy), the logs, the
lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company
proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix
cache and its cap, the links, and the SHA-256 of devvm's binary and CA
(proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole,
mode 600, before each start, and starts a running VM's proxy again when
the config it would start it with has another Sum. ReadConfig reads it as
the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat,
a regular file owned by the proxy's user that nobody else may read or
write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a
loopback listen address. The VM's proxy is found by _proxy -config with
its own config's path. paths.VM names ProxyConfig, ProxyPID and
ProxyStatus.

Policy files are read only as regular files of at most 1 MiB
(proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so
a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong;
ErrNotPrivate for the config and the links' list); the proxy keeps a
file's last rules and logs why once.

hostOK refuses a name with an empty label (evil.test.., evil..test,
.evil.test), so no form of a name gets past a deny the policy's own trim
would miss.

A build proxy that can't be spawned leaves no config behind.

Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a
folder, group-readable and group-writable files, a long file, other
versions, unknown fields, two configs, no password, non-loopback
addresses, a CA without its key, a negative cap; ReadRegular and the
policy readers on a FIFO, /dev/zero and a big file without hanging; the
running proxy keeping its last rules; hostOK and requests with empty
labels (failing on the code before); Prepare's config, restarts on a
binary change, a missing config and one others may read; concurrent
config writes; the build proxy's config and its removal; proxy.txtar,
network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the
config's mode, password and the proxy's arguments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 17:51:45 -07:00
w3cjandClaude Opus 5.5 9f6f62d28a refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name,
alias, image, chain, from, dir, folder, backend, backend_at, created)
and one section per package, each a json.RawMessage its owner decodes
into its own type (state.Section, state.SetSection), what was asked for
at its top level and what devvm made under "made":
net (netpolicy), git (gitprotect), ports (the new internal/ports),
agent (sshagent), tools (tools), secrets (secrets), and size, clone,
devcontainer, desktop and links (vm, internal/vm/state.go).

- state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the
  file again, applies a change and writes it once; a failed change, or
  write, writes nothing. VM.Set and its calls are gone; read-modify-write
  of lists (links, publish, secrets, tools, size, ports) happens inside
  Update. VM.Claim also holds run/claims.lock, after the VM's own;
  VM.Create writes a new VM's whole record once, its alias chosen
  (sshconfig.ChooseAlias) under the claims lock. Reads take no lock.
- created replaces "net unset" as unfinished (VM.Finished).
- internal/ports: the ports section (forward, host.ssh/proxy/desktop),
  ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy
  and desktop ports under the claims lock (desktop allocated without
  one before; run/ports.lock and netpolicy's own ports key are gone).
- gitprotect: mode recorded before the backend makes the VM (NewMode;
  clone for --clone, which ls and git-protect share as gitprotect.Mode);
  made.git_id (platform.FolderID), one git_dirs list for modules and
  embedded git dirs, delegations, protected; Unlock takes the union of
  recorded and current git dirs.
- links' entries, git dirs, tools and devcontainer commands are JSON
  lists, not strings in values; the key=value parser is gone.
- vm.checkState reads every section of the folder's VM as it's found.
- registry.For drops its unused Dirs.
- Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate,
  TestVMUpdateTogether (two writers on one VM and on crossed VMs),
  TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether,
  TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded,
  TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's
  vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 14:47:06 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-03 11:34:05 -07:00
w3cjandClaude Opus 5.5 1917072228 refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the
default backend and smolvm stays experimental. The backend architecture
(Backend, Caps, Require, the registry, backendtest.Fake) stays, so
another backend is an addition.

Removed:
- internal/backend/docker, its registry entry and Names/Experimental's
  docker half; devvm _docker-connect and _docker-ports
  (internal/cli/dockerssh.go); assets/docker/unpack.sh.
- Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS,
  DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256
  ldflags vars and the CLI tests' Linux-build archive (linux_release).
- Interfaces only Docker implemented, with their callers:
  backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix),
  DiskUser (ls's and size's disk-over warning, size's disk_used and
  --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover
  (gc --orphans' volumes, networks, containers and images),
  DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and
  vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name.
- The docker layer's runtime on a backend that makes VMs for it:
  vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet
  returns a bool now), the refusals at start and devvm network on, ls's
  "(sysbox)" and --json docker_layer, size_disk_default_unused.
- The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix).
- paths.Dirs.Docker and paths.VM.Lifeline.
- assets/guest/tools.sh's linked-folder branch; services.sh's
  DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd.
- Messages: every docker_* the backend used, docker_layer_runtime,
  net_docker_layer, net_off_docker_layer, committing_image,
  pulling_image, unpacking_tools, disk_over, size_disk_default_unused,
  gc_orphan_volume/_network/_container/_image, docker_connect_failed;
  gc_orphan_elsewhere reworded.
- Tests: docker.txtar, the docker stub's engine (its --from half
  stays), the ssh stub's login-shell branch; e2e's --backend docker,
  --engine, the docker host VM and Docker Desktop runs.
- Release: one GoReleaser pass, no Linux-build pin in the macOS builds,
  no Linux devvm in the Homebrew formula's libexec. Linux builds stay.
- Docs: backends/docker.md and internals/docker.md, design.md's Docker
  notes, the Docker column of the feature table, and every page's
  mentions of the Docker backend, Docker Desktop as one, and Sysbox.

Kept: the docker layer in Lima VMs, devcontainer docker-in-docker,
--from with images only a local Docker has, Docker Hub references.

State written by a Docker VM before this reads as an unknown backend
(backend_unknown_vm).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 10:26:07 -07:00
w3cjandClaude Opus 5.5 d8a7d4de7f refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/,
where <hash> is the 14-hex hash of the project folder's path that the VM's
name ends with: its state, its own rules (policy), its backend's files
(backend/: record.json, key, known_hosts, proxy, ports and the port
forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb,
started, lifeline.pid, secrets.*, links.*) and its logs (logs/:
network.jsonl, proxy.log, links.log). Build VMs keep the same layout in
run/builds/<name>/. The top-level run/ holds only what isn't one VM's or
must be short: the hashed control sockets, links' link-<hash>.sock/.ctl,
the QEMU wrapper and the ports lock.

A folder's VM is found by its path's hash (state.ReadHash), with the name
and backend its state records, so devvm --backend docker then devvm in
the same folder opens the one VM, and a backend's name limit applies to
new VMs only. The state records the VM's name and its ssh alias, chosen
once at creation (sshconfig.ChooseAlias) and never recomputed. Links'
targets match recorded names, aliases and folders (project.Targets).

One teardown (vmFolders.teardown) replaces Lifecycle.forget,
undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's
leftoverFiles: it stops the proxy and link session, then the pieces
outside the folder (clone remote or .git locks, other VMs' links and the
group, host keys, the backend's leftovers), removes the folder, and
writes the ssh config. Each backend's Delete and Forget remove the VM's
backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier
one's folder was left clears it first. devvm space counts an orphan's
whole folder as leftover state and the other VMs' logs as network logs.

Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files
(secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog,
LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file,
vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and
lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the
user's cache folder for Lima's and smolvm's caches is Dirs.UserCache,
from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and
DockerVM go. vmname.HashOf and IsHash, project.Hash.

The proxy takes the links' sockets' folder (-link-sockets, devvm's run
folder) apart from the links' list, which is in the VM's run folder.

Tests: a VM made and removed (rm, gc --orphans) leaves nothing under
vms/, and with network policy has no file named for it outside its
folder (TestTeardownLeavesNothing); a new VM over an old folder starts
clean; lookup finds a VM made on another backend with a long folder name
and makes no second one (TestLookupOtherBackend, and in docker.txtar);
the alias stays put when a second VM shares the folder name
(TestChooseAlias, ssh.txtar); every socket fits under a 35-character
home with the longest VM name (TestSocketsFit); space counts an
orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by
hash and name; the proxy refuses a socket in the list's own folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 08:16:39 -07:00
w3cjandClaude Opus 5.5 dd3f0deb3f feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).

internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.

devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.

ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.

Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:56:29 -07:00
w3cjandClaude Opus 5.5 299ddb1476 refactor(state): image records in images/<key>/, rebuild counters per backend and --from, tool image records, cache/
- Image records are images/<key>/record.json (JSON, unknown fields
  ignored; name, chain, from, digest, libc, built). state.Images lists
  the folders; AnyImage needs a record.json; RemoveImage deletes the
  folder. Lima's cache cleaner reads records through state.Images.
- Rebuild counters are images/rebuilds.json, keyed by (backend, from as
  given, name), changed under images/locks/rebuilds. image.Inputs takes
  them through an image.Rebuilds interface. A rebuild on one backend no
  longer outdates the others' images, and two --from references that
  wrote the same counter name (node:24, node-24) stay apart.
  paths.RebuildFile, RebuildName and unsafeName are gone.
- Tool images: <file>.sha256, .target and .idle become one <file>.json
  (sha256, libc, format, backend, built, idle_since; state.ToolImage).
  BACKEND and LIBC read the record; the fallbacks (format matching,
  a VM's target, the current target) go, with toolTargets, vmToolTargets,
  formatBackend and gc's backendTools (toolsOn does it).
  Share.IdleFor owns reading idle_since.
- cache/ (Dirs.Cache) holds mise/, nix-cache/ and from-digests.json.
  With the cache gone, from.Recorded takes the newest base record's
  digest for the reference, so no key changes.
- Key check: the rebuild counter is the one input that moved and changes
  keys (deliberately: per backend and exact from). The --from digest
  moved to cache/ and stays an input, kept stable by the records'
  fallback. Records, mise and the Nix cache are outputs.
- Tests: state's image, rebuild, digest and tool record tests; image key
  cases per backend and exact from; build.TestRebuildIsPerBackend;
  from.TestRecordedWithoutTheCache; cli.TestToolsOn; rebuild.txtar
  (Docker's and smolvm's rebuilds keep Lima's and the other --from's
  bases), gc_caches.txtar and from.txtar (a missing cache/); the
  testscript command json_set; e2e reads the JSON records.
- Docs: space, images, settings (retention), internals images,
  overview, network, security, contributing (json_set).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:37:36 -07:00
w3cjandClaude Opus 5.5 d01a1872ca test(smolvm): the listed range in smolvm.txtar is two free ports
smolvm.txtar listed host ports 8000-8001 and expected no ports_
warning, so it failed where a program has port 8000, as a dev server on
the Linux test machine does (ports_taken ports=8000). free_port gets
-range FIRST LAST, two adjacent ports free here, and the script lists
$FIRST-$LAST as it lists $LISTED and $UNLISTED. The other scripts'
fixed ports are either guest ports (link publish and add) or lists
whose host check nothing asserts (up_size, ports, devcontainer, the
sshd and many sections of smolvm.txtar), so they pass whatever holds
them.

Test: with a listener on 127.0.0.1:8000, the script failed at
smolvm.txtar:73 before (ports_taken count=1 ports=8000) and passes
after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 23:32:39 -07:00
w3cjandClaude Opus 5.5 6f9259b514 test: give each CLI test script its own coverage folder
The CLI tests' devvm is built with -cover, and every script set one
GOCOVERDIR. Go names a run's temporary meta-data file by the time
(time.Now().UnixNano(), microseconds on macOS) with no process ID, so two
devvm runs from parallel scripts that start together write the same
temporary file; the first renames it and the second's rename fails, and
devvm prints "coverage meta-data emit failed" on stderr, failing any
script that checks stderr (seen in ls.txtar and version.txtar).

- script_test.go: scriptCoverDir sets GOCOVERDIR to a folder of the
  script's own (os.MkdirTemp under CLI_GOCOVERDIR).
- scripts/test.sh: covdata merge takes the unit folder and every
  non-empty script folder as one comma-separated -i list, so percent and
  the baselines read the same counters as before.
- Contributing's Coverage section says each script writes to a folder of
  its own, and why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 22:04:17 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-02 18:34:18 -07:00
w3cjandClaude Opus 5.5 ddbc377f8f test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN
and CFG by default, and adds stub_reset, catg (the one file a glob
matches), vm_name VAR NAME (the folder's VM) and project NAME [git];
script_cmds.txtar checks each. Every script is rewritten onto them, its
assertions kept; TestCommandLines leaves the scripts' own commands out.

mise run test runs scripts/test.sh: the tests as before, with the CLI
tests' devvm built with -cover for every package (CLI_GOCOVERDIR),
merged with the Go tests' counters by go tool covdata, then
scripts/coverage.sh holds each package to testdata/coverage/<os>.txt.
mise run coverage raises the baselines; coverage.txtar checks the
comparison. The macOS baseline is recorded from this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:25:09 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-01 19:13:23 -07:00
w3cjandClaude Opus 5.5 9b7652d347 feat(link): links in VMs' lifecycle, and the link backend feature
backend.FeatureLink ("link"), native on Lima, smolvm and Docker, with its
row on internals/backends.md; linkFeatures() returns it, so link add, each
launch, the session and each connection check it with Require.

- Env.Links is guestLinks: an address and a name per target, by address,
  none for a target whose policy rule no longer holds.
- Launch (setUpVM, after the ssh config pins host keys): linkRuns.atLaunch
  starts devvm _links detached (pid in run/<vm>.links.pid, its log in
  logs/<vm>.links.log), warns once per stopped target (link_target_stopped)
  and per target whose policy rule broke (link_policy_mismatch) or whose
  backend lacks links (link_target_unusable), never starting one, and
  reads the new session's log for refused forwards (link_port_taken).
- link add and link rm on a running client send the setup again and make
  sure _links runs (linkRuns.apply), reporting a new link the VM refused;
  on a stopped one, links_next_start.
- Stopping: Lifecycle.Stop and every Env.start stop the session; a session
  killed has its sockets removed; its masters' control sockets go with
  their ssh.
- devvm rm (Lifecycle.forget, so gc --orphans and retention too) stops the
  session and removes every link to the VM from other clients
  (links_target_gone), giving running clients their links at once.
- devvm network off on a target linked by clients with policy
  (network_off_linked) and on for a client linked to a target without
  (network_on_linked) are refused.
- link unpublish names the clients that link to the withdrawn ports
  (unpublished_linked).
- devvm ls has a LINKS column and "links" in --json; devvm doctor lists
  link; gc --orphans removes links to VMs without state and link sockets
  nothing listens on, which devvm space counts as leftover state.
- net_off_log says devvm logs only a VM's links' connections without
  network policy.
- Lima: Start already compares the guest environment, so it edits only
  when the links' names change (TestStartSetsLinkNames); lima.md and the
  design note say the edit's new host keys are pinned again at the start.

Fixes to the earlier link code: vmssh's masters left their control
sockets when killed; the session's log names a forward the VM refused on
a line of its own (ReadLinksLog).

Tests: vm TestGuestLinks, TestPolicyLinked, TestUnlinkTarget,
TestLinkLeftovers, TestLinkRuns, TestLinksAtLaunch; vmssh TestReadLinksLog;
lima TestStartSetsLinkNames; link.txtar updated, link_life.txtar new, the
stub ssh carries link masters; e2e's project section has a link smoke check
on Lima.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:38:24 -08:00
w3cjandClaude Opus 5.5 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]>
2026-11-01 08:13:27 -08:00
w3cjandClaude Opus 5.5 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]>
2026-10-31 12:22:01 -07:00
w3cjandClaude Opus 5.5 422e409e41 test: wait_file waits 60 s, and fails at once when the background command ended
Under the full suite's load the background devvm in build.txtar and
up.txtar takes over 10 s to reach the stub call that writes hanging: a
dozen limactl stub calls, each bash and its own commands, about 80 ms
alone and up to a second under load. wait_file's 10 s ran out while
devvm was still on its way (testscript then ended it: exit status 130).

wait_file now waits up to 60 s, and fails at once, saying so, when
every background command has ended, as nothing is left to write the
file. A devvm that hangs before the stub still fails, after 60 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 11:21:46 -07:00
w3cjandClaude Opus 5.5 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]>
2026-10-30 00:04:38 -07:00
w3cjandClaude Opus 5.5 b27cd9b9b3 feat(lima): forward ports through devvm's own forwarder
Lima VMs forward their ports, every port and listed ones, through
devvm's forwarder (devvm _lima-ports), as Docker's do: loopback only,
exclusive binds, every port from 1024 up, never a port a host program
or another VM's record holds. Lima's own portForwards are ignore rules
for TCP and UDP on every address. The port choice is a record
(lima-vms/<vm>.ports), so changing it edits no Lima config and keeps
the VM's host keys. The forwarder pins the host key devvm pins
(Confinement.HostKey, sshconfig.HostKey) and ends with the hostagent
(the shared lifeline in vmssh). Lima's ports and ports-all are
emulated, reviewed: design note, threat check, e2e.

Docs: the forwarding rules for every backend, UDP not forwarded and
the socat alternative, in the docs voice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 21:43:10 -07:00
w3cjandClaude Opus 5.5 cf5a7db974 fix(images): pin Lima's Ubuntu cloud image with base's snapshot
Lima's base starts from a pinned dated Ubuntu cloud release (release-20261016) with each architecture's SHA-256, checked against Ubuntu's signed SHA256SUMS; another checksum is refused (ubuntu_checksum_unpinned). The pin is in base's image key (Lima's KeyFiles). scripts/bump.sh apt moves it with the snapshot and container digest: the newest release dated before the snapshot, its SHA256SUMS checked with gpgv against Ubuntu's cloud key.

e2e: default tier 146/0, --only from 13/0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 05:13:12 -07:00
w3cjandClaude Opus 5.5 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]>
2026-10-28 05:08:03 -07:00
w3cjandClaude Opus 5.5 6f597d7e1f feat(docker): ssh, ports and agent forwarding over docker exec
Docker VMs get ssh for editors, listed ports, every port, agent
forwarding and agent toggling, all over one transport: devvm's ssh
config reaches a VM through `devvm _docker-connect`, which runs
`sshd -i` in the labelled container by ID with docker exec. The
container publishes nothing and runs no listening sshd.

- internal/backend/vmssh: VM keys, host-key parsing, the port
  forwarder and its processes, shared by smolvm and docker
- `devvm _docker-ports`: every port, or the listed ones; ports a host
  program has are skipped (ports_taken)
- the agent goes only to ssh sessions (ForwardAgent, IdentityAgent);
  no socket is mounted
- --clone on Docker, its clone in a per-VM volume
- platform.ListenExclusive keeps SO_REUSEADDR on Linux; UsedPorts
  leaves out the VM's own listed ports
- messages: vm_no_ssh, vm_no_sshd, ports_no_ssh, ports_forward_failed,
  forwarder_failed, docker_ssh_path, docker_connect_failed
- reviewed: design notes and threat check in design.md; e2e checks for
  a hostile sshd config, host ports kept on every address family, and
  ports not forwarded off loopback or listed by another VM

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 10:33:41 -06:00
w3cjandClaude Opus 5.5 a9459a8c9c fix(ports): never forward a listed port a host program has
A listed port's forward (Lima's hostagent, smolvm's -p) listens on
127.0.0.1/::1 with SO_REUSEADDR, so on macOS it took a port a host
program held on *:PORT, and that program's localhost connections with it
(checked on both backends). Now each start checks the VM's listed ports
first and leaves out those in use, warned; the VM starts all the same,
and the next start that finds a port free forwards it again.

- platform: ListenLoopback (moved from smolvm's forwarder), PortFree and
  PortInUse, which listen on 127.0.0.1 and ::1 without SO_REUSEADDR (a
  port held only by ended connections counts as free; one that can't be
  bound for another reason, such as below 1024 on Linux, isn't in use).
- vm: start checks the backend's listed ports (ports_set) with
  Env.PortInUse, warns ports_taken, and passes the rest in the new
  Confinement.Ports; every port and none pass nil.
- Lima: Start parses portForwards from limactl list and sets them only
  where devvm's rules differ (guestIP compared for ignore rules alone),
  so a start edits, and the VM gets new host keys, only when a port is
  left out or comes back.
- smolvm: Start updates -p where the machine's ports differ
  (listedPorts); the ssh port choice (freePort, PortFree) and Lima's
  confined ssh port use platform.PortFree.
- Lima's forwards of every port aren't checked (Lima makes them as guest
  servers start): documented as a limit.

Message: ports_taken. Docs: images.md (ports), lima.md, smolvm.md,
security.md, design.md, limits.md, contributing.md. Tests: platform
TestListenLoopback, vm TestSplitPorts and TestStartPorts, lima
TestStartSetsPorts, smolvm TestStartListedPorts; ports.txtar and
smolvm.txtar with a host listener (listen_any); the limactl stub keeps
the portForwards clone and edit set. e2e: a host program on *:PORT
keeps its port while the VM lists it, and the port is forwarded again
once freed (project and smolvm sections).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 01:12:58 -06:00
w3cjandClaude Opus 5.5 75652b3097 feat(smolvm): turn ssh-agent forwarding on or off for an existing VM
smolvm forwards an agent only if the machine was made with --ssh-agent,
and reads SSH_AUTH_SOCK at each start. agent-toggle is now an emulation,
reviewed:

- Every new smolvm VM is made with --ssh-agent. Each start points
  SSH_AUTH_SOCK at the user's agent (on), devvm's agent (devvm), or a
  path no socket can exist at, /dev/null/devvm-no-agent (off): nothing
  listens, so off VMs share no agent to add keys to or sign with.
  Every other smolvm command runs without SSH_AUTH_SOCK.
- Off wins whenever the record or Confinement.NoAgent says so, so starts
  for exports and clone checks give no agent either.
- A VM made without forwarding can't be turned on (agent_fixed).
- Each start records the machine's lifeline; a running VM whose lifeline
  differs and whose mode isn't on (started outside devvm, with whatever
  agent that shell had) is stopped at launch, ssh, code, restart and
  export (agent_unchosen_stop), through backend.AgentStarter.

Docs: smolvm.md (SSH agent forwarding), backends.md, ssh.md,
security.md, limits.md, testing.md, design.md (the design note and
threat check). e2e: each mode, toggling on an existing VM, devvm's agent
ending, a start outside devvm stopped; direct starts in the network
checks pass an agent path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 00:39:10 -06:00
w3cjandClaude Opus 5.5 293c3a82ca feat(smolvm): forward every port, loopback-only servers included
smolvm forwards only listed ports, and only to servers on the guest's
0.0.0.0. ports-all is now an emulation, reviewed:

- devvm _smolvm-ports, started with the VM and ended with its lifeline,
  holds one ssh master connection to the VM's sshd (its key alone, the
  host key pinned, no agent, no forwarding asked) and relays each host
  connection as an ssh -W channel, so every connection starts on the host.
- assets/smolvm/ports.sh reports the guest's TCP listeners; the host
  parses the report as untrusted (sizes capped, loopback addresses only,
  applied at most every 500 ms).
- Ports from 1024 up, at most 256, bound on 127.0.0.1 and ::1 with
  platform.ListenExclusive: never a port another host program holds, nor
  any VM's ssh, proxy, decider or listed ports (netpolicy.UsedPorts).
- Its log is rate- and size-limited; reads through smolvm exec (host
  key, the sshd probe) are capped at 64 KiB and 30 s.
- sshd's AddressFamily is any, for channels to the guest's ::1.
- vm checks the VM's port features at every start.

Messages: smolvm_ports_no_ssh, smolvm_ports_failed,
smolvm_forwarder_failed. Docs: smolvm.md (every port), backends.md,
security.md, design.md (the design note and threat check), limits.md,
testing.md. e2e: the smolvm section's every-port checks, and its fake
decider reads smolvm's request before closing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 23:32:00 -06:00