32 Commits
Author SHA1 Message Date
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 e4b44b5994 fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.

The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.

TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:53 -07:00
w3cjandClaude Opus 5.5 cb7177b32c feat(ui): waits for another devvm's lock show a status line; a project folder devvm can't read says so
Lock waits:
- platform.LockFile and LockFileShared take a platform.Waiting, called
  once they find the lock held, never when it's free, whose end they call
  once the wait ends; LockFileWaiting, LockFileSharedWaiting and their
  delays (ShareNote, OCINote, WaitNote, groupsNote, makingNote) go.
- msg.Waiting makes one from a Reporter's Status and a label;
  msg.WithStatus and msg.StatusOf carry the run's Status in its context
  for the two packages that take no Reporter, internal/state and
  internal/trust, which cli's execute sets; forbidigo keeps StatusOf to
  them, and AGENTS.md says so.
- Every lock that waits shows its own label: vm_state_waiting (a VM's
  state, its deletion), claims_waiting, layout_waiting, git_lock_waiting,
  ca_waiting, packages_waiting, rebuilds_waiting, ubuntu_pin_waiting,
  custom_secrets_waiting, forwarder_waiting, agent_store_waiting, and the
  waits that printed a line after a delay, which now show theirs as a
  status line: share_waiting, oci_waiting, image_build_waiting,
  group_waiting, making_waiting.
- An agent's login file's lock (agentlogin's lockLogin, a folder's flock
  that a VM's proxy holds while it refreshes the login) tries first
  without waiting and shows agentlogin.File's Waiting
  (agent_login_waiting) while it waits; secrets fills it from its
  Reporter, for SaveLogins, Claude Code's logins folder and every File.
- The structure test's status-lines rule counts a LockFile or
  LockFileShared whose waiting is nil as slow work; the build port's
  record, a file just made that never waits, is listed in statusSites.
- Without a terminal, or with -v, a status line draws nothing, so the
  waits that printed an info line after a delay no longer print it there;
  the CHANGELOG and the troubleshooting page say so. from.txtar's check
  that a free conversion lock printed no wait goes, as TestLockOCI checks
  it.

The layout's migration runs under a status line (layout_migrating),
only when there are migrations to run.

Backend calls outside a launch: TestCommandStatusLines runs devvm ls,
ports, size, network, tools, git-protect, history export, stop and rm on
a running and a stopped VM and fails on a backend call with no status
line showing, with a control that each makes one.

A project folder devvm can't open and read (vm_folder_unreadable) was
taken for another folder's VM (vm_other_folder, which offers rm and
adopt, and adopt went on); the finder now keeps why (target.unread), and
every command on the folder's VM, from the folder or a subfolder of it,
names the folder and why; devvm rm VM run elsewhere goes by the VM's
name as before.

platform.UniqueFolderID had no caller but its test: FolderStat.Unique,
from the open folder, replaced it; it goes, and its test checks
StatFolder's Unique instead.

Tests: TestLockFileWaiting (rewritten: called only when held, its end
once got or given up, shared too), TestVMLockWaits, TestCheckLayoutWaits,
TestCheckLayout (migrations under layout_migrating, nothing shown
otherwise), TestLockGroups, TestLockShare, TestMaking, TestLockOCI and
the build lock's test (status lines, not info lines), TestLockLogin,
TestInitCACancelled (ca_waiting), the status-lines rule's lock cases,
TestCommandStatusLines, TestUnreadableFolder (a subfolder of it too),
TestStatFolderUnique.

Docs: Contributing's CLI page (Status lines) and structure page, the cli
and codebase-standards skills (the guards), AGENTS.md's Go conventions,
internals/images.md and design.md (the waits), using/troubleshooting.md,
using/vms.md (a folder devvm can't read); CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 15:10:22 -07:00
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.

Boundary parsers, the only places a string becomes a VM:
- vmname.Parse: a project VM's name (state's vm.json name, export file
  names, devvm _links's argument, the forwarder's -vm, project.Nth)
- vmname.ParseListed: one path element, for what a backend lists
- VM.UnmarshalText: JSON (Lima's list, proxy config and events, links'
  targets in state, link lists); empty stays no VM
- vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs
- msg.M.VM: the VM a message's function took, read back

vmname's functions on names became methods (Hash, Slug, Short, Aside,
AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname;
vmname.Join joins VM lists. Messages' vm and vm_name fields are typed
by the generator. Seven messages whose field took something else became
what= (backend_lacks, backend_unreviewed, backend_unreviewed_used,
starting, deleting, configuring, running_script) and rm_vm_failed's
name=: the text is unchanged, the names-mode scripts follow.
Review.RequireFor names an image or the tools being built.

Typed sites per package (added lines with vmname.VM, non-test): msg 347
(generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22,
backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8,
ports 6, paths 3, sshagent 2, sshconfig 2, tools 2.

The structure test's owners rule now fails on a field, parameter or
result named for a VM (vm, vms, otherVM, vmName) typed string, []string
or map[string]…, and on converting anything but a literal to vmname.VM
outside the files it lists; internal/stubtest is free. depguard holds
internal/vmname to the standard library, and the proxy may import it.

ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 6fd1d846d6 fix(lima): cache a Linux VM's project folder with 9p's none
Linux's 9p client loses data with Lima's default cache=mmap for a
writable share: a stat() during an extending write() takes the host's
stale size and writeback drops the data, so files reach the host empty
or cut to 4096 bytes even after fsync (Claude Code's Edit sets it off);
and on devvm's Ubuntu 26.04 guest kernel, a lock after a write makes the
next read return zeros, which breaks SQLite in any journal mode and
Gradle's daemon. macOS's vz VMs use virtiofs and aren't affected.

- New VMs on a Linux host record cache mode none in a new mount section
  of vm.json, and their project folder is made and started with it, as
  is the folder devvm clone off mounts. VMs whose state has no mode
  (0.1.0's, and every VM made before this) keep Lima's mmap untouched,
  with no limactl edit, and each launch warns (mount_cache_unchosen)
  until devvm mount-cache none.
- devvm mount-cache [none], with --json: none is the only mode devvm
  sets, so any other value is a usage error (mount_cache_invalid); a
  stopped VM gets it in its next start's one edit, a running one after
  the restart devvm offers. macOS refuses (backend_lacks), and so does a
  Linux VM whose folder isn't a 9p mount (mount_cache_no_choice). No -g
  or config.toml key: every new VM gets none.
- The start that changes the mode mounts the folder again in the guest,
  as cloud-init rewrites fstab only after systemd has mounted it, through
  the logged runner with a minute's limit (output pipes closed a second
  after), then checks it with mountpoint and findmnt, reading 4 KiB at
  most and only the last line: a folder left unmounted stops the VM and
  fails the start before its shell (mount_cache_unmounted), and so does a
  check that gets no answer (mount_cache_unchecked); one still mounted
  with the old mode is warned of (mount_cache_remount_failed), any mode
  but none or mmap named unknown. An interrupt meanwhile, on any tier,
  leaves a cleanup that stops the VM, the one stop then. A launch into a
  running VM asks the guest, in words, whether its folder is a mount
  point, and refuses one that isn't (project_unmounted) or whose check
  fails or gives no answer (project_unchecked). A stored mmap, from a
  build before none alone, reads as none chosen, and devvm clone off
  records none for its new mount; any other mode is refused naming
  vm.json.
- backend: FeatureMountCache (native on Linux, none on macOS, built on
  project-mount), Want.ProjectCache, Instance.ProjectCache, CacheModes.
- lima: mount rewrites keep only the sshfs and 9p settings devvm knows
  where they differ from Lima's defaults, and drop the rest for Lima to
  fill in, so lima.yaml never freezes a default; same() compares the
  cache where devvm sets one. Build VMs' writable output folders (tools,
  --from) get none.
- tools: an EROFS tool image that ends before its superblock does, or is
  shorter than its superblock says, as a build under mmap could leave
  one, counts as not built, so the next build makes it again; a build's
  short output is refused. The fakes' tool images are a page
  (backendtest.ToolImage).
- The limactl stub lists QEMU's vmType, fills in 9p cache defaults on
  Linux, and answers the remount's check.
- Docs: backends/lima (the project folder's cache, when it changes,
  programs that map files for writing, SQLite), using/limits,
  using/clone, commands, internals/lima, internals/backends, the design
  note (both mmap bugs, why none alone, the remount, tool images, the
  e2e findings), the CLI reference and the cli skill.
- Tests: TestProjectCache, TestMountRoundTrip,
  TestStartSetsProjectCacheOnce (the remount's outcomes), TestCutShort,
  TestBuiltCutShort, TestGuestMountOptions, TestFilledMounts,
  TestUpCacheMode, TestWarnMountCache, TestCacheAtNextStart,
  TestSwitchCache, TestSetMountCache, TestCheckStateCache, the
  mount_cache CLI test, clone_switch and the 0.1.0 fixture on Linux, and
  e2e's projectMountCache (findmnt, a stat-while-write loop, SQLite's
  journals, a shared writable mmap refused, the opt-in switch of an
  unchosen VM, what mmap does reported, macOS unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 07:17:12 -07:00
w3cjandClaude Opus 5.5 84f1190b04 feat(agents): pi, as a fourth coding agent (#23)
Adds pi (earendil-works/pi) as a shared coding agent beside Claude
Code, Codex and opencode: --agents pi, devvm tools add pi, the new-VM
picker and devvm setup offer it. Its network policy allows pi.dev; base
sets PI_SKIP_VERSION_CHECK=1 and PI_TELEMETRY=0 and installs fd-find,
so base and every image on it build again once. The agent store mounts
and copies pi's settings, with keys redacted as JSON.

pi's auth.json is a new login kind: its API keys for Anthropic, OpenAI
and OpenRouter become per-VM placeholders the proxy fills in (devvm
agent login pi --api-key --provider PROVIDER), and everything else is
withheld by default, unless config.toml's [pass-keys] lists the
provider. pi's own account logins aren't supported, and pi has no musl
build, so a musl VM refuses it (image.ToolDef.GlibcOnly). Its sessions
go into devvm history export and import.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-07 19:16:35 -07:00
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00
w3cjandClaude Opus 5.5 d17e62961e refactor(msg): one message for each kind of setting, flag and requirement
Messages that said the same thing for different settings are one message
each, given what differs:

- new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command)
  replace from_ignored, net_flag_ignored, git_protect_flag_ignored,
  size_flags_ignored, ports_flag_ignored, parts_flags_ignored,
  ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning
  for each command that changes the same on the VM, naming only the
  flags given (ignoredFlags).
- setting_already (command, vm) replaces net_already, agent_already,
  clone_on_already and clone_off_already.
- setting_set (vm), for a stopped VM, replaces net_set_stopped,
  agent_set_stopped and links_next_start.
- next_start (count, vm), for a running VM, replaces net_set_running,
  agent_set_running, size_next_start, agent_next_start,
  mounts_next_start, folder_next_start and net_off_next_start; a launch
  warns of each change with its next_start_* line, then next_start once.
- program_missing, program_broken and program_old (+ _fix) replace
  lima_missing, lima_broken, lima_old, qemu_missing, macos_old and
  their _fix messages; the minimum versions are minLima and minMacOS in
  the lima backend, passed into program_old.
- ports_list_needed replaces link_ports_invalid: devvm link publish and
  unpublish check their ports with ParsePortList, as devvm ports add
  does, and ParsePublish is gone.
- no_vm replaces no_vm_link.
- vm_unfinished says nothing of the user's is in the VM, as
  remake_unfinished does.

Kept apart: git_protect_next_stop (it applies at the next stop, and
devvm stop applies it), already_stopped and ports_all_already (not
settings), group_already (joining again syncs the group's links),
has_tools and has_layers (they name which of those given were there),
docker_missing (Docker is optional, so it never says to install it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 12:10:45 -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 d9d169e972 fix(tools): a --from base never builds tool images other VMs mount
gnu tool images, which any VM whose tools need their key mounts, always
build in a clone of devvm's own Ubuntu base on the VM's backend, never in
a --from image, whose code runs as root in its build. --from Debian and
Ubuntu VMs mount those images, and tool_needs_glibc still refuses a base
too old for one. When devvm's own base isn't built yet, devvm says so
(tools_need_own_base) and builds it first, pinning the cloud image on
its first build as usual.

musl tool images build in the VM's own --from base, and their keys hash
that base's digest (image.Tool.Base, tools.Target.Base, from the base's
record), so they're only ever another VM's on the same container image.
Their records keep it (base). devvm tools add, tools update and update
build a musl VM's base first, its digest looked up, so the keys they
work out are those of the base the images build in. Every gnu key hashes
devvm's own base, so no image built in a --from base under an earlier
key is mounted again.

Share.Build reads the record of the base it's about to clone and refuses
any but the one the images are for (buildsFor, tools_wrong_base): base
from Ubuntu's cloud image for gnu, a --from base with the target's
digest for musl.

Tests: TestBuildOnlyInItsBase (hostile --from gnu and musl bases, a
layer, no record), TestUpFromTools, TestToolsAddFrom, TestToolFile's musl
digest, TestToolFileRefuses, TestToolTarget's digest; from.txtar: the
clone of devvm's own base, a base record that says it came from a
container image refused (tools_wrong_base), and tools_need_own_base
before devvm's own base is built; e2e from checks where the Debian and
Alpine VMs' tool images built and the musl records' digest.

Docs: internals/images.md (building tools, keys, the share, listing),
using/from.md, using/images.md, using/space.md, internals/design.md,
internals/security.md, contributing's e2e list, AGENTS.md's tool-key
rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 22:22:16 -07:00
w3cjandClaude Opus 5.5 97672c4267 refactor(backend): base's size as Go constants, base's disk in Lima's origin
Base's size was read from assets/base.yaml four ways: vm.BaseDisk's
line scanner (a new VM's smallest disk), SizeChoice.Fitted's same scanner
for CPUs and memory (devvm size -g and setup's question), Lima's
buildSize regexes (base's build size), and limactl create reading disk:
from the template on its input. Now backend.BaseCPUs, BaseMemoryGiB and
BaseDiskGiB are the one source:

- vm checks new VMs' disks against backend.BaseDiskGiB, and Fitted fits
  BaseCPUs and BaseMemoryGiB; SizeChoice has no Assets any more.
- Lima's buildSize uses the constants; its Origin carries base's disk as
  a step of its own ("disk", its GiB), which originOf requires and
  createArgs passes as --disk=, so base's key still hashes it, and the
  --from conversion's VM gets it too.
- base.yaml sets no cpus, memory or disk, and is hashed only into Lima's
  key as Lima's settings.

Tests: TestBuildImageBaseSize (pinned on the old code: base created with
4 CPUs, 8 GiB and a 100 GiB disk, now all flags and none in base.yaml),
TestBaseSize, TestOriginOfRefuses' no disk and bad disk; the limactl stub
reads create's --disk=. Docs: internals/images.md, internals/lima.md,
contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:55:01 -07:00
w3cjandClaude Opus 5.5 1f2e4a0edc feat(tools): refuse a shared tool that needs a newer glibc than its --from base
Each shared tool is its project's prebuilt release, built against a
glibc it needs at least, so a --from gnu base older than that ran the
tool into a loader error. Now devvm measures both sides and refuses the
tool clearly.

- A tool image's build measures the newest GLIBC_ version its ELF
  programs and libraries need (shared-tools/build.sh's glibc_needs:
  readelf's version needs, testdata folders left out), writes it to
  FILE.glibc, and devvm keeps it in the image's record (glibc), taken
  only as a plain file holding one version (tool_bad_output).
- A --from conversion records the image's glibc version (getconf
  GNU_LIBC_VERSION in a chroot; oci/build.sh's glibc output, checked by
  checkConverted), in base's record and every image's on it
  (backend.Built.Glibc, state.Image.Glibc). Ubuntu's own base has none
  and isn't checked; musl needs none.
- tools.Target carries the base's glibc (not hashed: a gnu tool image is
  the same on every base); a VM's state records it (tools.made.glibc);
  Launch.buildTools checks every tool with tools.Share.Runs after
  building, for new VMs and devvm tools add/update and devvm update:
  tool_needs_glibc names the tool, its version and both glibc versions.
- image.ValidGlibc and image.GlibcOlder own the version's shape and
  order. build.Env.ToolTarget reads base's record once (BaseLibc gone).
- Measured minimums, current releases (arm64 / amd64): node 2.28/2.28,
  pnpm 2.18/2.18, bun 2.17/2.17, python 2.17/2.17, uv 2.28/2.17, rust
  2.17/2.17, go none (its 2.34 came from Go's own testdata), claude
  2.17/2.17, opencode 2.17/2.17, codex 2.28/2.28 (its voice helper).
- Tests: TestGlibc, TestBuildGlibc, TestBuildGlibcRefused, TestRuns,
  TestGlibcNeeds (build.sh's function against debug/elf, where readelf
  is), TestToolTargetGlibc, checkConverted's glibc cases; from.txtar: an
  old base refuses node at launch and at devvm tools add, keeps go, and
  records 2.24; e2e: the Debian base's record and VM state hold the VM's
  real glibc, no tool image needs a newer one, and Ubuntu's tool images
  record a glibc; the stubs write FILE.glibc and glibc.
- Docs: using/from.md (Shared tools and glibc), using/toolchains.md
  (Which bases they run on), internals/images.md, assets/oci/README.md.

Every tool image's key changes once (build.sh), so each is built again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:11:16 -07:00
w3cjandClaude Opus 5.5 0941219a76 feat(build): base's packages recorded per key, replayed from a host cache
base's apt packages are no longer pinned by a snapshot. A key's first
build of base records them: assets/layers/apt.sh (a recipe step, as
root, before base.sh and after the last feature) points the image's
sources at an apt mirror+file: list of config.toml's ubuntu-mirror and
then Ubuntu's own archive, so apt checks everything against the archive
key whichever server answers, and keeps what it downloads. At the end it
gives back each package with apt's entry for it. devvm checks what comes
back (regular files only, each named by its own SHA-256, each entry
matching a file's size and SHA-256, nothing left over, at most 20,000
entries and 16 GiB), keeps the files in
~/.local/share/devvm/packages/<sha256>.deb and the key's set in
packages/sets/<key>.json, before the image's record. Every later build of
that key replays the set from the cache, checked on the host first, with
apt given only those files: no network for base's packages, and a key's
packages never change. A --from base keeps its image's own sources,
unpinned. base keeps no package lists, so each layer's recipe starts
with apt.sh lists, which fetches them when there are none.

- backend.ImageSpec.Packages (Send before the steps, Take after) and
  backend.PackagesDir; Lima runs both over limactl shell as root.
- Fail fast: apt.sh turns apt's retries off and exits 75 when no source
  answers, which Lima reports as build_sources_unreachable.
- packages_missing refuses a replay whose cached file is gone or changed;
  packages_refused what a build gives back that isn't packages.
- config.toml's ubuntu-mirror (settings.UbuntuMirror), checked as an
  http(s) address without a user, query or spaces (ubuntu_mirror_invalid).
- devvm gc deletes the sets of keys neither current nor built, then,
  under the cache's lock, the files no set names at that moment, and
  builds' leftover folders over a day old (gc_packages,
  deleted_packages); devvm space lists the cache.
- The snapshot is gone from base.sh, guest/sync.sh and desktop.sh, and
  scripts/bump.sh's apt step with it.
- Tests: recording then replaying, a missing or changed cached file,
  every refusal of what comes back, gc's view of the cache and its race
  with a new set, the set record, the mirror setting, Lima's exchange and
  exit 75, apt.sh's mirrored and record functions, apt.sh in the keys;
  the limactl stub keeps what's sent and gives back
  $STUB_DIR/packages-out.tar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:58:23 -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 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 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 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 a134e0d8a6 feat(cli): choose a new VM's toolchains, agents and layers in a picker or with --tools, --agents and --layers
devvm takes no IMAGE word any more than any other: in a terminal a new VM's
toolchains, coding agents and layers are checked in one picker, under three
headings, before the network-policy question; --tools, --agents and
--layers (each an exact list, or none) skip it, and a part left out takes
its default: the detected toolchains, devvm setup's agents, no layers (a
devcontainer.json's features still count). Without a terminal, or with
--no-input, the VM gets the defaults and new_vm_gets says so in one line.
devvm setup --agents (and its first-run question) chooses new VMs' agents.
devvm tools in a terminal opens the same picker for the VM, its layers
fixed, and turns the changes into tools add and rm.

An image is base and layers only: tools are the VM's tool_names state key.
build, rebuild and images rm refuse a shared tool (tool_not_layer), and
devvm build builds no tool images. devvm ls gains a TOOLS column and
--json tools. gc's --tools is --tool-images, so --tools has one meaning.

Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or
no_command_like, did-you-mean over commands, msg.Closest), the lacks path
in internal/vm/existing.go, and the messages vm_lacks_tools,
vm_lacks_layer, layer_is_command, layer_name_command, no_image_for,
no_command_or_image*, tools_not_images, tools_not_images_rm, detected,
vm_is_now (vm_tools_now), secret_with_image (secret_with_claude).
New: ui.Pick takes headed sections with fixed rows, ui.CanPick,
vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go),
state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents,
project.DetectFiles. Image keys are unchanged in form: images never held
tools; docker.sh's and nix.sh's comments changed, so those layers rebuild.

Docs: the home page's quick start steps, diagram (sandbox.svg), cards and
FAQ; README; getting started; using (images' What a new VM gets, coding
agents' Running an agent, settings' agents); internals; contributing;
the cli skill; AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 00:45:09 -07:00
w3cjandClaude Opus 5.5 f71adb5a04 refactor: devvm's own files stay in the binary
assets.FS is the only copy of devvm's own files: nothing writes them to
~/.local/share/devvm/assets/<hash> any more, so an edit on disk can't
widen running proxies' allowlists or change a --from base its key
doesn't describe.

- Proxy: -builtin-policy NAME,... names policies in IO.FS (cli's _proxy
  passes assets.FS; proxy stays stdlib-only). Built-ins are parsed once
  at start (readBuiltins), ahead of -policy's files in the union, never
  re-read; a missing one, or one with a line that isn't a rule, refuses
  to start. -policy carries only the user's files.
- netpolicy: PolicyFiles(d, assets, vm, img) becomes Policies(d, vm, img)
  (builtin, files); Proxy.PolicyFiles and AssetsInUse go. .proxy.policy
  records both lists, a line each, for the restart check. ReadRules takes
  built-ins from an fs.FS; RuleFile.Builtin.
- devvm network: built-ins labelled "# devvm: layers/base.policy";
  --json entries carry "builtin": NAME or "file": PATH ("version": 1).
- Lima: createArgs ends in "-" and create() feeds base.yaml on stdin;
  convert writes oci/ and, with company CAs, guest/ca.sh into its own
  temp folder beside vm/ (writeScripts, state.WriteFile), mounted
  read-only and deleted by the existing cleanup. Lima.assets() goes.
- Deleted: internal/state/assets.go and its test (WriteAssets,
  StaleAssets, AssetsHash), paths.Dirs.Assets, gc's stale-assets plan
  and the gc_assets/deleted_assets messages, space's devvm's files row.
- Tests: proxy built-ins (order, not re-read, missing/invalid refuse,
  Main refuses before listening), Policies, the restart check on either
  list, ReadRules/WriteRules labels, JSON shape, createArgs and create's
  stdin, writeScripts' files and modes; CLI scripts check
  $XDG_DATA_HOME/devvm/assets never appears after up, build and --from,
  base.yaml on create's input (the limactl stub keeps it), the
  conversion's mounts and script paths in its temp folder.
- Docs: design (One binary), install, overview, space, images (gc),
  internals network, images and lima, safety/network, proxy README,
  the network command's Long and its CLI page; AGENTS.md rule.
- Coverage baselines (darwin) raised: cli 88.2, netpolicy 87.2,
  proxy 88.2, state 91.8. Dirs' method cap lowered to 41.

Image keys are unchanged: they already hash the embedded files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -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 512793cd69 fix(tools): the share's lock and the --from conversion lock are OS file locks, so a crash never leaves them held
The share's lock was a folder in the share (tools/.lock) removed only by
devvm's cleanup, so a devvm that crashed or was killed left the next one
waiting ten minutes and then failing with share_lock_held. The --from
conversion lock on Lima was a folder holding its devvm's pid, taken over
from one that had ended.

Both are now platform.LockFileWaiting on a file in devvm's data folder
(tools.lock, outside the share VMs mount; oci-build.lock), which the system
lets go of when devvm ends, however it ends. Another devvm waits until the
holder lets go or the run is interrupted, saying so after 3 s
(share_waiting, oci_waiting).

- share_lock_held is gone, with the try count, the cleanup and the pid
  takeover; tools.Env's ShareWait and Lima's OCIWait are ShareNote and
  OCINote, how long before devvm says it's waiting.
- Docs: Building tools and How it's converted describe the locks; the
  state tables list tools.lock, oci-build.lock and images/locks/<key>.

Tests: tools TestLockShareKilled (a killed holder's lock is taken at
once; it failed with share_lock_held before), TestLockShare rewritten
(waits, says so, gets it once let go, the lock outside the share);
lima TestLockOCI rewritten (a lock file nothing holds is taken at once,
a held one is waited for, saying so); from.txtar converts with a lock
file left as a crashed devvm leaves it, and no wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:51:26 -07:00
w3cjandClaude Opus 5.5 20c9fdbadd fix(build): a build holds its image's lock, so concurrent builds, gc and rebuild leave it alone
On Lima a build in progress is a recordless image with its final name, so
a second build, devvm rebuild or devvm gc took it for a leftover and
deleted it. Each build now holds an OS lock per image key
(images/locks/KEY) from before it looks for the image until its record is
written; the system lets go of it when devvm ends, however it ends.

- A second build of the same image waits for the lock, saying so after 3 s
  (image_build_waiting), then finds it built.
- An image without a record is unfinished only while its lock is free;
  while held it's listed as building (devvm images, --json state).
- gc (and gc --backend) and rebuild skip building images; images rm and
  DeleteKey refuse them (image_building). Deleting an image removes its
  lock file while holding it.
- platform: LockFileWaiting and LockFileSharedWaiting (call a func once
  after waiting a while), LockHeld; a lock whose file was removed while
  held is taken again on the new file. tools.Making.Hold uses the shared
  helper instead of its own two-step wait.
- state.ImageLock: a key's lock path, the key checked.

Tests: build TestBuildInProgress, TestBuildTakesTurns; platform
TestLockFileWaiting, TestLockFileRemoved, TestLockHeld; state
TestImageLock; build.txtar checks a hanging build is listed as building,
kept by gc and refused by images rm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:39:11 -07:00
w3cjandClaude Opus 5.5 16b4ad8771 feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no
question is asked or read. The ui's prompts (Ask, Confirm, Answer,
Secret, Pick/PickOne in a terminal) show the question, then fail with
no_input naming what answers it (msg.AnswerFor, by the question's ID),
or no_input_terminal for a question only a terminal answers. ui.Flags
and SetFlags carry -v and --no-input.

Answers: --network-policy/--no-network-policy, --here, devvm size -g,
devvm setup --features/--backend, devvm network -g, devvm ssh-agent add,
devvm restart, --ssh-config (new, on devvm, host and code: the Include
line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude),
--stdin, and --force.

--force (-f) only skips a confirmation, and destructive commands need it
without a terminal (force_needed, a failure, not a usage error): rm (new
rm_confirm), gc (it went ahead without a terminal), gc --caches (now
allowed without a terminal with --force), images rm (images_rm_confirm),
secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images
are built on the one rebuilt (build.Env.Force). rm --no-export skips the
export; rm's parent-folder, earlier-folder and --clone confirmations are
terminal-only and --force never answers them (vm.RmOptions). gc --tools
--force splits: --recent (only with --tools, gc_recent_needs_tools)
drops the hour's hold and keeps the refusal while a VM is being made
(gc_recent_making); gc_tools_recent names devvm gc --tools --recent.
gc_caches_need_terminal goes.

Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt
(--force), TestRebuild (force_needed, then Force); secret, rebuild,
images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images
rm/secret rm/rebuild with --force (and --no-export where rm -f skipped
the export), and the clone section's rm with its checks. Docs:
commands.md (Questions devvm asks, rm, flags), first-vm, clone, images
(cleaning up, --recent), space, coding-agents, internals overview and
images; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:51: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 080d57dd28 fix(netpolicy): builds reach a company proxy through a proxy of their own; ** refuses names the host can't resolve
From an independent review of the company-proxy change.

1. Builds never get the company proxy's credentials. Each build behind
   a company proxy goes through a devvm _proxy of its own on the host
   (backend.ProxyStarter / BuildProxy, shared by Lima and Docker; Docker
   Desktop's build proxy moved into it): policy **, a new random password,
   the company proxy in its -upstream file, -lifeline on the build VM's
   hostagent or the container's docker container wait. Builds get only
   http://devvm:<one-time>@<host>:<port> (each variable the host sets) and
   the host's NO_PROXY.
   - Lima: image builds, the tools build and --from's conversion VM reach
     it at 192.168.5.2; on macOS the build's Seatbelt profile allows that
     one loopback port (NetInternet + ProxyPort), so a loopback company
     proxy works for macOS builds too. guestProxyURL is gone. limactl runs
     without the host's proxy variables (Lima logged them, password and
     all, into devvm's run log; found by the new e2e check); only a
     NetDirect start gets them back for propagateProxyEnv.
   - assets/oci/build.sh: the /etc/os-release probe runs under env -i;
     chroot_run passes only the build proxy's variables (bootify.sh's
     downloads behind a company proxy).
   - Docker: buildNet takes Desktop's path (own network, relay, build
     proxy) on any engine behind a company proxy; hostProxyEnv is gone.
     A Linux engine's build behind one needs devvm's Linux build.
   - Settings the proxy can't go through are refused before anything is
     made (upstream_proxy_scheme, reworded for builds too).
2. noClientProxy on the tools' unpack container and the relay.
3. floorUpstream: a name the host can't resolve goes upstream only when
   an allow rule names it (itself or *.domain: policy.byName); with only
   ** it's refused (errUnresolved, logged as the reason).
4. CONNECT replies are read through a 64 KiB io.LimitReader
   (maxConnectReply); bytes after the answer stay the tunnel's.

Tests: backend (TestProxyStarter, TestProxyStarterFails,
TestListeningPort, TestBuildProxyStop), lima (TestBuildImageHostProxy on
linux and darwin with the Seatbelt port, TestBuildImageHostProxyRefused,
TestConfineProxyEnv), docker (TestBuildHostProxy for a Linux engine with
and without a company proxy, unpack's empty proxy pairs), proxy
(TestUpstreamUnresolved, TestUpstreamConnectReplyLimit). CLI: docker.txtar
(a Linux engine's build behind a company proxy; every container create
and run, kept by the stub in containers-made, sets the empty -e pairs),
from.txtar (builds' proxy folders gone). e2e: images (a build sees only
its own proxy), from (a --from alpine:3.21 base with every feature and a
layer behind a company proxy with a password: the registry, Alpine's
mirror and the layer reach it through the builds' proxies; the password
is in no converted disk, image, log, build file or process's arguments);
corp_start/corp_stop shared with network.

Docs: internals/design (A company proxy: the ** case, builds, checks;
build confinement), safety/network, internals/network, images, lima,
docker, using/troubleshooting, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 09:53:45 -07:00
w3cjandClaude Opus 5.5 2f559eaaa5 feat(netpolicy): network policy behind a company proxy; host proxy credentials kept out of images
Behind a company proxy, network policy's proxy connected to servers itself
and reached nothing. It now reaches allowed hosts through the host's
HTTPS_PROXY / HTTP_PROXY, still deciding each request by the name the VM
asked for.

Step 1, credentials (traced in the code and the backends' published docs;
not yet proven on a real build, which the new e2e checks do):
- Lima: build VMs (images, the tools build, --from's conversion VM) started
  with propagateProxyEnv on, its default. Lima's 07-etc-environment.sh
  writes the propagated settings into the guest's /etc/environment between
  #LIMA-START/#LIMA-END on each boot, and a stopped build VM's disk keeps
  it, so an image built with HTTPS_PROXY=http://user:pass@... kept the
  password. Fixed: propagateProxyEnv is on only for NetDirect; build scripts
  get the variables exported on their input (a loopback proxy as
  host.lima.internal), and /etc/sudoers.d/devvm-build-proxy keeps them for
  sudo until the scripts end.
- Docker: the CLI puts ~/.docker/config.json's proxies into every container
  it creates, and a commit keeps them (Docker's docs). Fixed: every
  container devvm makes sets each proxy variable empty (noClientProxy); a
  Linux engine's build gets the host's settings from an env file
  (hostProxyEnv); Desktop's build proxy goes through the company proxy.
- smolvm: passes the host's proxy only with --use-host-proxy, which devvm
  doesn't use: nothing to fix.

The upstream:
- backend.HostProxy (new): ReadHostProxy (capitals, then lowercase), None,
  Upstream (the proxy's -upstream file; only http:// proxies:
  upstream_proxy_scheme, upstream_proxy_invalid), Env.
- internal/proxy/upstream.go (new): -upstream FILE; ParseUpstream,
  ErrUpstreamScheme; NO_PROXY as Go reads it; localhost, *.localhost and
  loopback/unspecified addresses always direct; CONNECT by name with
  Proxy-Authorization: Basic for tunnels and for the TLS connections that
  put secrets in (checked against the system roots and -upstream-cas);
  plain HTTP in absolute form, canonical host, credentials only in the
  header to the upstream; floorUpstream: addresses judged as before, a name
  refused when the host's resolver answers with any internal or denied
  address, unjudged when it can't resolve; Event.Upstream (host:port), and
  devvm log's "through host:port".
- hostOK refuses shorthand addresses (127.1, 2130706433, 0x7f000001),
  which a company proxy may read as inet_aton does (found in review).
- netpolicy: Proxy.Getenv, run/<vm>.proxy.upstream (mode 600), stale()
  (a changed upstream starts the proxy again), writeUpstream for both files.

Also, from a review of the company-CA change: a proxy that needed starting
again and didn't end within 2 s of SIGTERM was kept, with its old roots,
silently. Stop now sends SIGKILL after 2 s and reports whether it ended;
Prepare fails with proxy_stop_failed instead of keeping it (Proxy.Signal
seam).

Messages: proxy_stop_failed, upstream_proxy_scheme, upstream_proxy_invalid,
with doc links.

Tests: proxy (TestParseUpstream, TestNoProxy, TestUpstreamTunnel,
TestUpstreamNoProxyDirect, TestUpstreamPlainHTTP, TestUpstreamIntercept,
shorthand hosts in TestOddHostsRefused), backend (TestHostProxy), lima
(TestBuildImageHostProxy, TestGuestProxyURL, propagateProxyEnv
expectations), docker (TestBuildHostProxy, create's empty proxy variables),
netpolicy (TestPrepareUpstream, TestPrepareStopsTheOldProxy, FormatEvent's
upstream). e2e: images (a layer built with a fake proxy password: its
script and sudo see it; the image's disk, Lima's files and devvm's logs
don't), network (a devvm _proxy as the company proxy: allowed hosts through
it by name, blocked ones never reach it, its password nowhere, and back to
direct).

Docs: safety/network (Behind a company proxy, Without network policy),
using/troubleshooting (Behind a company proxy), internals/network (Through
a company proxy, restarts, -upstream), internals/design (A company proxy:
what an upstream changes, credentials, builds, checks), internals/images,
internal/proxy/README.md.

Review (security-audit skill, independent pass over the proxy change):
the shorthand-address bypass, fixed; a VM-controlled name can force the
unjudged branch, documented; refusals name the company proxy's address
(no credentials), accepted as on the direct path; a loopback company proxy
isn't reachable from macOS builds, documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 00:20:33 -07:00
w3cjandClaude Opus 5.5 d55dae5386 fix(build): fit base's CPUs to the host, as its memory is
Base asked for base.yaml's 4 CPUs whatever the host had. It now gets
base.yaml's CPUs, or the host's count when the host has fewer, by the
same shared rule as its memory.

What happens above the host's count (from published docs, not checked
on a VM):
- Lima accepts cpus above the host's count: its template's default is
  min(4, host CPU cores), and its proposed check that refused more than
  runtime.NumCPU() (lima-vm/lima#2309) was closed unmerged. On vz, a
  VM given more CPUs than the Mac has can start so slowly that ssh never
  comes up (lima-vm/lima#1621, open).
- Apple's Virtualization framework only requires cpuCount <=
  VZVirtualMachineConfiguration.maximumAllowedCPUCount, whose docs don't
  tie it to the host's count.
- smolvm and libkrun document no limit for --cpus.
- Docker refuses --cpus above its engine's machine's count ("Range of
  CPUs is from 0.01 to N.00, as there are only N CPUs available").

Changes:
- internal/backend/fit.go: FitCPUs(want, hostCPUs int) int and
  FitMemory(wantGiB float64, hostBytes uint64) float64, pure and
  exported; fitMemory's rule moved there from Lima, with table tests.
- Lima: buildSize replaces buildMemory and reads base.yaml's cpus and
  memory; limactl create gets --cpus and --memory for base and the
  --from conversion VM (createArgs). A CPUs field (runtime.NumCPU) is
  the host-CPU seam beside Memory.
- smolvm: baseSize fits CPUs and memory with the shared rules, for
  base's build, tool builds and VMs given no size; a CPUs field is the
  seam. spec.Size.CPUs still wins.
- Docker: the engine's NCPU is read from docker info beside MemTotal
  (engineSize replaces engineMemory), and baseSize fits both.
- Image keys are unchanged: neither the fitted memory nor CPUs are in
  them.
- Tests: TestFitCPUs, TestFitMemory, Lima's TestBuildImageSmallHost and
  "no CPUs" case, smolvm's TestSmallHost, Docker's TestBaseSize; the
  build and from testscripts expect --cpus.
- Docs: using/ports-size.md and using/images.md say what a small
  machine gets; internals/images.md has a Base's size section on the
  mechanism; internals/smolvm.md and internals/docker.md match it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:55:30 -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 9ec1601801 feat(docker): an experimental Docker backend, its containers and native features
Each VM is a container from an image devvm builds by running its scripts
in a container and committing it. A container is not a VM: on Linux it
shares the host's kernel, on macOS Docker Desktop's one VM; docker.md says
so first.

- internal/backend/docker: build-image (docker commit; base from Ubuntu's
  image by digest, prepared by the container scripts smolvm shares, now in
  assets/container), from (any image Docker has or pulls), clone,
  project-mount and agent-folders (bind mounts), tools-share (tool images
  unpacked into a volume by a network-less container, linked by
  guest/tools.sh; ToolFormat dir-<unpack.sh>), cpus and memory (docker
  update). Build confinement native only on a rootful engine of this
  Linux machine; Docker Desktop and other engines build nothing yet.
- Containers run --init and a sleep; services.sh after each start, without
  Docker's daemon. Mounts and network are hashed into a label; a start that
  finds them changed commits the container and makes it again under the
  same name (flattened past 100 layers), its home a per-VM volume.
- The VM's user has the host's uid, and on Linux its gid. A --clone VM's
  clone gets a volume (VMSpec.CloneAt).
- Disk none: DiskUser reports what a VM holds (devvm size's disk_used),
  warned past base's disk by launches and ls; a default disk size is left
  out of a new VM on such a backend, said.
- Everything labelled devvm.data=<data folder>; only labelled resources
  are touched; names Docker shares between users carry its hash.
- Problems: docker on PATH, a reachable engine (or the docker group fix),
  29.1+, Linux containers, this machine's arch; Report names the engine and
  Docker Desktop's file sharing, which CreateVM checks.
- ssh, ports, ports-all, agent forwarding and toggling, egress-proxy, disk
  and the new docker-layer feature are none: refused in one line. Builds
  ask for build features only when they build, so a built image works
  where it couldn't be built.
- testdata/stubs/docker: a stateful engine; docker.txtar; unit tests;
  tests/e2e.sh --backend docker on a Linux engine in a Lima VM e2e keeps
  (~/.lt-e2e-go-docker) and on Docker Desktop, with images copied from the
  Linux run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 08:54:04 -06:00
w3cjandClaude Opus 5.5 851e39ef86 build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/,
shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which
cli passes to every constructor; backends, the builder, the shared
tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts
reach VMs on stdin (backend.Script carries their contents). What needs
a path (limactl create's base.yaml, oci/ mounted into the conversion
VM, the proxies' policy files) is written out to
~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders
700; devvm gc deletes older copies no VM's proxy was started with
(gc_assets, deleted_assets). Release archives hold the binary with
README.md, CHANGELOG.md and LICENSE, and the formula installs the
binary alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 18:12:37 -06:00
w3cjandClaude Opus 5.5 9f24d2639e refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/,
shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and
oci/. devvm reads them from assets/ beside its binary (paths.Root,
paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e
put them there. Image keys hash them by their names in assets/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:08:33 -06:00
w3cjandClaude Opus 5.5 0aec2ece89 feat(from): base images from Docker and OCI images
--from IMAGE (default $DEVVM_FROM) starts base from a Debian-, Ubuntu-
or Alpine-based container image instead of Ubuntu's cloud image, for new
VMs, build and rebuild. base is keyed by the image's digest, looked up
once per build and recorded per reference; existing VMs keep their own
(from_ignored).

- internal/from: ParseRef (registry_ref, with a fuzz target), Valid/
  Check (bad_from), Pinned, Name, Recorded (from_digest), Registry.Digest
  (manifest HEAD, anonymous Bearer token from an https realm only,
  timeouts, size caps, retries; ErrUnreachable/ErrNotFound), Lookup.Refresh
  (refresh_from_digest: registry, else Docker's ID, else the recorded
  digest with a warning), DockerID, DockerRunning.
- build.Builder: From and Lookup; Inputs/Key/Chain with the recorded
  digest; spec.From for base; records keep from and digest on every image
  above a --from base; rebuild counters per from; building_image_from.
- lima: convert (oci_base): devvm-oci-build from Ubuntu's image with only
  <tmp>/vm (rw) and oci/ (ro) mounted, confined to the internet, runs
  oci/build.sh; docker save plus exportIs for images only Docker has;
  checkConverted (regular files, gnu/musl, cmdline charset, raw ext4);
  base created with --set .images (disk, kernel, cmdline, initrd); the
  temp folder, build VM and the OCI build lock (lockOCI, pid, stale
  takeover, oci_waiting) go however the run ends.
- cli/vm: global --from flag, state from=, builders with the VM's from in
  open, update, remove.
- Messages: building_image_from, bad_from, from_ignored, from_unreachable,
  from_not_found, from_cached_unreachable, from_cached_not_found,
  no_digest, docker_only, exporting_docker, docker_export_failed,
  docker_image_changed, oci_waiting, converting_in_vm, converting,
  convert_failed, convert_bad_output; doc links to from.md.
- Copied: oci/ (build.sh and README edited: comment, docs link),
  testdata/stubs/docker; limactl stub gains oci/build.sh outputs and
  interrupt-on.
- Converted: from.bats (registry_ref, registry_digest token, 1/2,
  https realm, refresh per tag, Docker-only, offline, no Docker, pinned,
  moved tag, cached keys, build flow, docker save, Ctrl+C, steps, failures,
  bad outputs, record, export check, lock) as Go tests and from.txtar;
  oci.bats (libc_for, missing architecture, crane pins) as oci.txtar;
  cli.bats --from parse_args and project.bats --from input checks.
- e2e: from section (--from tier, or --only from): node:24 Debian 12
  node+python+claude, alpine:3 musl tools and Docker on OpenRC, base from
  ubuntu:26.04, no Docker needed. Left out: features, an image only Docker
  has.
- Docs: from.md; images, commands, lima, contributing, index; CLI
  reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 13:23:29 -06:00