25 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 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
w3cj cdac5e5012 refactor(image): typed image names, read once at the CLI boundary 2026-11-04 17:03:07 -07:00
w3cjandClaude Opus 5.5 9cde4abf2e fix(build): refuse a recorded base package older than a newer pocket lists
The host checked that each package a first build of base recorded is
the archive's, but root in the recording build VM chose which signed
lists to hand back: it could return only the release pocket's and
record an older version than -updates or -security have. Now:

- a recording must hand back resolute-updates' and resolute-security's
  signed InRelease files with lists for the architectures whose lists
  have the recorded packages (another archive's InRelease, such as
  archive.ubuntu.com's on arm64, doesn't count), and every non-empty
  list each InRelease it hands back gives for those architectures, in
  every component (packages_lists_missing);
- a recorded package that the release pocket, -updates or -security
  lists a newer version of, for its architecture, is refused, naming
  the package, both versions and the suite (packages_not_newest);
  -backports doesn't count, as apt installs from it only when asked;
- a list's SHA-256 is checked against the verified InRelease files
  before it's read, so only signed lists are parsed;
- apt.sh's recording takes phased updates
  (APT::Get::Always-Include-Phased-Updates), so apt installs the newest
  version the lists have.

- internal/ubuntu: CompareVersions, dpkg --compare-versions in Go
  (epoch, upstream, revision, ~ and letters' order; ErrVersion for one
  that isn't a version); Release.Lists gives the matching lists with
  their paths, ListsFor, List.Arch, Backports, RequiredSuites.
- internal/build: signedEntries returns a signed (entries, each
  package's architectures, the newest version by architecture and name
  and its suite); verified, complete, checkNewest, newer; readArchiveList
  returns an archiveList.
- Messages: packages_lists_missing, packages_not_newest.
- Tests: CompareVersions' table (Debian policy's ordering and dpkg's
  cases, invalid versions); ListsFor and Backports on Ubuntu's real
  InRelease; a recording refused for an older version than -updates
  has, for a missing -updates or -security InRelease, a missing list,
  another archive's -security, a missing backports list; kept for the
  newer version, a newer one in backports, an older one in -security;
  checkNewest's table. The gpg-made fixtures are signed again by a new
  test key, with Packages-newer, Packages-security and InRelease-newer,
  -security, -security-amd64 and -backports added.
- Docs: images.md's Base's packages, design.md's trust note (the
  pocket choice closed; what root in the recording VM still chooses).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 16:50:31 -07:00
w3cjandClaude Opus 5.5 cacbd90498 test(tools): the pins test, and tool image keys hash base's mise
base.sh's mise installs every shared tool mise installs, in a build VM
made from base, yet a tool image's key didn't hash its version. Now it
does: image.MiseVersion reads layers/base.sh's mise_version, and
image.ToolFile hashes it for each tool mise installs (not rust, which
rustup installs), so a mise bump builds those tool images again.

- TestMisePins: base.sh's mise version and Linux checksums equal
  internal/tools/mise.go's (with the host pins' shape, which it held).
- TestE2ELockPins: tests/e2e-mise.lock's first line is
  shared-tools/mise.toml's SHA-256, and it locks each of its tools
  with a download for every platform but rust's.
- TestE2EUbuntuPins: e2e_ubuntu_release is one release-YYYYMMDD,
  exported as DEVVM_UBUNTU_RELEASE; bump.sh's e2e-ubuntu lists
  ubuntu.DefaultURL and moves it; every Ubuntu release tests/e2e.sh
  and bump.sh name is ubuntu.Series and ubuntu.Version.
- TestToolFile: base.sh's mise pin changes a mise tool's key, not
  rust's, nor the rest of base.sh; TestMiseVersion its refusals.
- Docs: internals/images.md and contributing/maintaining.md; AGENTS.md's
  key line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:51:41 -07:00
w3cjandClaude Opus 5.5 29740acb21 fix(build): refuse a stale mirror's old signed archive state for base's packages
Ubuntu's InRelease files carry no Valid-Until, so a mirror that stopped
updating, a hostile one, or anyone on an http path to one, could serve
an older, validly signed state of the archive, and a first build of
base would record its old packages for every later build of the key.
Now the host refuses a verified InRelease older than the archive state
the pinned cloud image was built from: every pocket but the release's
must be dated no more than a day before the pin's release-YYYYMMDD, and
the release pocket, which Ubuntu froze at release, no earlier than that
day (ubuntu.Released, 2026-04-23). The refusal names the mirror
(packages_stale_mirror) or Ubuntu's archive when none is set
(packages_stale), and nothing is kept.

From the security audit of both checks:
- only resolute, -updates, -security and -backports are accepted, never
  -proposed;
- verify tries at most 4 signature packets, as each hashes the whole
  signed text (a CPU bound on what the build VM or a mirror sends).

- internal/ubuntu: Release.Stale, Released, the suites accepted,
  maxSignatures.
- internal/build: signedEntries reads the pin (state.ReadUbuntuPin) and
  refuses a stale InRelease; taken keeps the mirror to name it.
- Messages: packages_stale, packages_stale_mirror.
- Tests: Stale's table (each pocket a day either side, the release
  pocket at Released, a release that isn't a date); -proposed and
  backports; more signatures than tried; a recording with an old
  InRelease refused, naming the mirror or the archive; a good set kept
  with the release pocket's InRelease (gpg-made fixtures InRelease-old,
  InRelease-release). Coverage baselines raised: build, ubuntu.
- Docs: design.md's trust note (the stale-mirror gap closed, what root
  in the recording VM still chooses), images.md's Base's packages,
  settings.md's mirror section, troubleshooting.md's Base gets old
  package lists, maintaining.md (moving Released with the series).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:14:48 -07:00
w3cjandClaude Opus 5.5 de28721978 fix(build): check base's recorded packages on the host against Ubuntu's signed archive lists
A first build of base gave back each package it downloaded with apt's
entry for it, and the host took the build VM's word that each entry was
apt's: anything with root in that VM before apt.sh end could record a
package with a made-up entry, which every later build of the key
replayed. Now the build also hands back the InRelease files and package
lists apt used, and the host checks them itself before it keeps
anything:

- each InRelease is clearsigned by Ubuntu's archive key, pinned in
  assets/layers/ubuntu-archive.gpg ("Ubuntu Archive Automatic Signing
  Key (2018)", F6ECB3762474EDA9D21B7022871920D1991BC93C, from
  keyserver.ubuntu.com by fingerprint, checked against the Ubuntu
  security team's list), and one of 26.04's suites;
- each package list has the SHA-256 and size a verified InRelease gives
  one of its Packages lists;
- each recorded .deb's SHA-256 is in one of those lists, as the package,
  version, architecture and size apt's entry says, and the set keeps
  the archive's own entry.

- internal/ubuntu/pgp.go verifies clearsigned messages (RFC 4880's
  cleartext signatures: text signatures, dash-escaping, trailing
  whitespace, nothing before or after); archive.go's VerifyRelease and
  Release.Lists read a verified InRelease (ArchiveKeyring).
- assets/layers/apt.sh: record copies apt's *_InRelease and *_Packages
  lists to out/<n>.InRelease and out/<n>.Packages; base's build keeps
  lists uncompressed (Acquire::GzipIndexes "false").
- internal/build: take accepts the lists (an InRelease at most 4 MiB and
  all of them 32 MiB, a list 512 MiB with lines of 1 MiB and entries of
  4 MiB, all lists 2 GiB, no name twice), signedEntries and
  archiveEntry check them; cache carries devvm's own files for the key.
- Tests: Ubuntu's real resolute-updates InRelease verified, and refused
  when changed, framed differently or signed by another key; clearsigned
  parsing (dashes, CR LF, trailing whitespace, a binary signature
  refused); InRelease fields; a recording refused for a forged
  InRelease, a list no InRelease gives, a .deb no signed list has,
  another package's entry, missing lists, a list or an InRelease twice,
  a line over 1 MiB; a good set kept
  with the archive's entry (gpg-made fixtures in
  internal/build/testdata/archive); apt.sh's record giving back the
  lists.
- Docs: images.md's Base's packages, design.md's trust note (the
  recording VM's made-up packages closed), settings.md's mirror
  section, maintaining.md's archive key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:57:10 -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 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 da93384f60 fix(lint): fetch.Client is its own type, and forbidigo bans http.Transport, os.Create and O_TRUNC
fetch.Client was an alias of http.Client, so &fetch.Client{} got past
NewClient's timeout and HTTPSOnly. It is now a struct only NewClient fills:
Do sends with the client's policy, Transport returns its own transport for
callers to change (ubuntu's file://, the public registry's dialer), and any
other Client fails every request with ErrNoClient, which isn't transient.
forbidigo's HTTP rule also bans http.Transport, and http.Client's Transport
field, outside fetch, the proxy and tests.

The os.WriteFile rule also bans os.Create and os.O_TRUNC, so a
truncate-in-place write outside state needs a nolint saying why. The four
left are not files written whole from memory, or are the standard library
only: tools' check log and a link session's log (a process writes them as
it runs), fetch.Download's file (streamed, removed on failure) and
daemon's pid and status files (one write, which readLine and readStatus
take as missing until its line ends). state's doc says so.

Tests: TestClientMadeByNewClient (nil and zero Clients send nothing and
aren't retried; NewClient's transport is its own); from's and build's
tests use the registry's own client trusting the TLS test server.
Fixture lines: http.Transport, os.Create, os.O_TRUNC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 06:43:13 -07:00
w3cjandClaude Opus 5.5 f2a8ddd404 refactor: write every file whole through state, and make private folders with state.PrivateDir
internal/state is the one writer of whole files outside the proxy:
state.WriteFileMode joins state.WriteFile for another mode (0700 for
the QEMU wrapper and Docker's copies of devvm's Linux build), and
state.PrivateDir makes a folder the user's alone (700), refusing a file
or a symbolic link there, as vmssh's runDir did.

- Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's
  writeFile (the Seatbelt profile, the QEMU wrapper, the start record),
  vmssh's writeWhole and runDir, Docker's copyFile, the Linux build
  fetch's temporary file (fetch.Open's body is read whole, its SHA-256
  checked, then written with state.WriteFileMode), and Resolve's
  .tmp-and-rename loop. The host's mise stays fetch.Download's.
- os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions'
  mise.toml, the checked file, the tools build's files), sshagent (two),
  ubuntu's checksum files, docgen's pages and backendtest's fake tool
  images.
- state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders):
  the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and
  socket folder, lima's run folder and the exports folder. MakePrivate
  and ~/.ssh keep following a link: where they live is the user's choice.
- The proxy's writers are one, writeAtomic: the login files' writeJSON
  and the Nix cache's size file use it, its temporary files named
  .<name>.tmp-* as state's are.
- forbidigo bans os.WriteFile outside internal/state, internal/proxy,
  internal/msg/gen, internal/stubtest and tests, with its line in
  testdata/lint/forbidigo.go.

Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder
refused, its folder's mode unchanged), TestWriteAtomic; mode checks on
the Seatbelt profile and Docker's Linux build copy. Coverage baselines
raised: lima, netpolicy, proxy, secrets, ui.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:50:40 -07:00
w3cjandClaude Opus 5.5 b4402a74e8 refactor: every HTTP client through internal/fetch
internal/fetch (standard library only) owns how devvm reaches the web:
NewClient(timeout, HTTPSOnly|SameScheme) on a clone of net/http's
default transport, the Client alias other packages name, Retry and
Transient/TransientStatus (no answer, 408, 429, 5xx; never a refused
redirect, a bad request, a body over its cap or a SHA-256 mismatch),
ReadCapped, Open, Get, and Download, which keeps a file only when its
SHA-256 matches and leaves nothing on any failure.

- from: NewRegistry uses fetch.NewClient(HTTPSOnly); its own NewClient,
  httpsOnly, errRedirect and transient go; the token GET is fetch.Get;
  retry wraps fetch.Retry, keeping ErrNotFound and ErrUnreachable.
- ubuntu: NewClient is fetch.NewClient(SameScheme) with file://
  registered; sameScheme and errRedirect go; fetch is fetch.Retry over
  fetch.Get.
- tools: mise's client is fetch.NewClient(HTTPSOnly); its download is
  fetch.Download, which checks the pin before the file is kept.
- docker: devvm's Linux build is fetched with a client of its own
  (HTTPS-only redirects, a Client seam on linuxFinder) instead of
  http.DefaultClient, and retried twice on a failure that may pass or
  an archive cut short; an archive without a devvm (errArchive) isn't.

forbidigo bans http.Client, DefaultClient, DefaultTransport, Get, Head,
Post and PostForm outside internal/fetch, internal/proxy and tests; its
line in testdata/lint/forbidigo.go fires. internal/fetch is a leaf in
the structure test's layers.

Tests: fetch's TestRetry, TestRetryUnanswered, TestRetryCanceled,
TestTransient, TestRedirects, TestReadCapped, TestDownload; first,
characterising the callers, from's TestDigestRetries and tools'
TestHostMiseRedirect; docker's TestFetchLinuxRetries. Coverage
baselines: fetch 95.2 (new), from 87.1 to 91.3, ubuntu 88.7 to 92.5,
tools 87.9 to 88.6, docker 80.8 to 81.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:28:01 -07:00
w3cjandClaude Opus 5.5 1cfc8e24f1 test: share the stubs sandbox, message checks and recorders across Go tests
internal/stubtest puts testdata/stubs first on PATH with a folder of its
own (New, New with only some stubs), reads and writes the stubs' files
(Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It
replaces the stub setups of the Lima, Docker and smolvm backends' tests,
vm's --clone tests and platform's Keychain tests, and the backends' own
execRunner, reset and touch copies. The structure test holds it to tests
and to importing only internal/msg.

msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers
and the errors.AsType checks that only read a message's ID or names;
msg.Recorder replaces the inline recorders tests set as Info, Warn or Say.
backendtest.Stored replaces the four stored fakes with disks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 13:24:43 -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 45ab474d85 fix(msg): a failed Docker build is deleted by the next build too
docker_script_failed says the next build or devvm gc deletes the kept
container, as on Lima and smolvm: Docker's Images lists a failed build's
container, so the next build deletes it as a leftover. ubuntu.go's verify
comment says the pinned SHA-256 still decides without gpgv.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 10:22:24 -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 2b413028e6 fix(images): pin Ubuntu's container image with base's package snapshot
smolvm's and Docker's base start from Ubuntu's container image by a
digest pinned in internal/ubuntu (ContainerDigest), not the tag's digest
looked up at build time. base's key hashes it (each backend's KeyFiles),
and base's record names it. The image is never newer than
assets/layers/base.sh's snapshot: an image with newer packages leaves apt
unable to install what depends on their exact versions (the docker
layer's docker-ce, through systemd's libsystemd0).

- internal/ubuntu: ContainerRepo, ContainerDigest, ContainerRef,
  ContainerOrigin; the backends' Digest fields and UbuntuImage go.
- base.sh: apt_snapshot 20261026T000000Z, with the image's digest
  sha256:19fcd1bf268f (built 2026-10-25).
- scripts/bump.sh: apt moves the snapshot and the image's digest
  together (the index's digest hashed from what the registry sent), and
  refuses an image built after the snapshot; bump.txtar covers both.
- tests/e2e.sh: timings per selection and Docker engines, so an
  --engine linux run isn't compared with one that included Desktop; the
  Linux engine's run pulls the pinned Ubuntu image before recording what
  Docker has without the sandbox's label; base's records are checked
  against the pin; smolvm's TSI check takes any of this machine's
  resolvers; the from section allows devvm's labelled VM listing.
- docs: smolvm, Docker, images, maintaining, contributing; design.md's
  smolvm notes describe the reviewed emulations as they are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 01:16:57 -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 4bbd35a24b refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal
flags, run log, status line, cleanup stack and interrupt flag, and its
functions are methods. ui.Main makes the run's UI on devvm's own
streams, owns signals, recovers Die and runs the cleanups; ui.New makes
one on other streams. cmd/devvm passes it to cli.Execute, and every cli
command gets it through its constructor.

Only cmd/devvm and internal/cli import internal/ui (a depguard rule).
Each other package defines the small UI interface it needs, which its
constructor takes, filling fields tests set:
- gitprotect.New, secrets.NewStore, from.NewLookup: a warn func
- ubuntu.New: LoggedCmd, Note
- netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its
  log lines drop control characters themselves (oneLine)
- sshagent.New: Info, Note, Warn, LogWriter
- tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup
- lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run),
  WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too
- backends.Registry: lima's and smolvm's
- vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout,
  LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields
- build.Builder: Terminal and LogNote fields
- sshconfig.New: its caller sets what it prints and asks

ui's tests build their own UI over buffers and run in parallel; other
packages' tests use small fakes; cli's unit tests a UI over buffers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 16:23:51 -06:00
w3cjandClaude Opus 5.5 7fcac40758 refactor: test seams on structs, not package vars
Tests set fields; no test outside internal/proxy and internal/ui assigns
a package var.

- backend.Review: Unreviewed and Warn, with Require and Allowed as its
  methods; Registry embeds it, set by backends.Registry (a test build
  reads DEVVM_UNREVIEWED); build.Builder.Review, sshconfig.Config.Review,
  and Tools.Build takes the review with the backend
- netpolicy.Log: Path and Tick (NewLog), with Write and WriteBlocked;
  Proxy.Terminal for Choose and SelfCheck
- vm.Env.Terminal, sshconfig.Config.Terminal
- cli: setup's terminal check and backend picker are fields of setup;
  versionOf takes the release's version
- from.Registry.RetryDelay, ubuntu.Finder.RetryDelay, lima.Lima.OCIWait
- msg's tests use real messages, not entries added to docs and specs

The tests these free run in parallel. AGENTS.md: test seams are fields;
internal/proxy's globals and internal/ui's process-wide state are the
exceptions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:28:37 -06:00
w3cjandClaude Opus 5.5 f5cca0ff02 feat(images): devvm images and images rm
devvm images lists the images on every backend (IMAGE, FROM, DIGEST,
KEY, STATE current/stale/unfinished, SIZE, BACKEND), then the shared tool
images by the name images have them by (NAME, TOOL, VERSION, SIZE, VMS,
STATE current/in use/unused/not built/not installed). Listing never
resolves the tools lock. devvm images rm IMAGE|KEY... deletes images by
name (with --from, on that base) or by key, resolving every one first;
shared tools are refused.

- backend.Backend gets ImageSize (Lima: du of the instance folder);
  platform.DiskUsage counts blocks, hard links once.
- build: Listing, Delete, Image.Digest; ubuntu.ReleaseDate.
- tools: List, ReadLock (uses Lock.Version); vm: ToolsInUse,
  BackendUsed exported.
- Messages: reading_images, images_failed, images_rm_failed,
  deleted_image, no_image_named, no_image_named_from,
  tools_not_images_rm.
- Tests: testdata/script/images.txtar (images.bats' three images cases
  and images rm), Go tests for Listing, Delete, List, compareVersions,
  DiskUsage, ImageSize, ReleaseDate, humanSize; e2e images section lists
  base and a layer, deletes by name and an unfinished build by key.
- Docs: images.md (Listing images, Deleting images), commands.md, the
  CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 20:42:39 -06:00
w3cjandClaude Opus 5.5 09786d1951 feat(image): Ubuntu cloud image and the base image files
Add base.yaml and layers/ (base.sh, base.policy, Ubuntu's cloud image
key) and internal/ubuntu, which finds the newest dated Ubuntu 26.04
release with an image for the host, takes its digest from SHA256SUMS
and checks the signature with gpgv when it's installed. Fetches use
net/http with a timeout, retries and no redirects to another scheme;
DEVVM_UBUNTU_URL moves the listing (file:// folders in tests).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 03:21:27 -06:00