76 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 20f97b10eb feat(vm): a new VM's tools resolve while its image builds
A first run resolved the tools' versions, downloading devvm's own mise
first, only after base had built: 10 s on the mini, 5 s on fedora, in
series. Neither needs the other, so create now starts Versions.Lock in
the background as an image starts to build (resolveWhile's start, which
build.Env.Building calls once an image is found unbuilt and its features
are chosen) and waits for it after, cancelling it when the build fails.
When every image is built already, nothing starts in the background, and
Files resolves in the foreground with its status lines as before.

While the build runs, the resolve says nothing, as the build has the
terminal: a held Reporter keeps its messages, shows no status line and
refuses every question as without a terminal, and its commands' lines
in the run log are tagged resolve. Once the build ends, done releases
it: what it held is said, what it does from then on shows, and devvm
waits under resolving_tools when it's still running. done returns its
error, so a failure is said once and the launch doesn't resolve again.
A VM whose lock is already there reads it at once.

TestHeld, TestResolveShowsAfterBuild and TestBuildingCalled fail when
held shows a status line, when the wait shows none, and when Building
isn't called. Docs: images.md's Versions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 2de3e31a6c fix(vm): devvm ports shows a status line as it restarts a running VM's forwarder, and every lock's wait is tested for its label
Lock waits:
- Tests record the label of each lock's wait that had none, the lock held
  as by another devvm and the wait ended by a cancel, a deadline failing
  one that shows nothing rather than hanging: git_lock_waiting
  (TestGitLockWaits; .git protection's Serial is gitSerial, so a test can
  reach it), packages_waiting and rebuilds_waiting (TestImageLocksWait),
  ubuntu_pin_waiting (TestPinOriginWaits), custom_secrets_waiting
  (TestYoursLockWaits) and forwarder_waiting (TestForwardsLockWaits).
- A test build's locks panic on a nil platform.Waiting
  (platform.CheckWaiting, which the root's run calls in every test build
  beside state.CheckLockOrder), so the CLI tests and e2e catch a nil wait
  the structure test can't see, such as a zero agentlogin.File's; a
  msg.Waiting given a nil status shows nothing and stays review only.
  msg.Waiting with no status gives a wait that shows nothing, never nil;
  platform.NoWait is the Waiting of a lock that never waits (the build
  port's record, which passed nil), and the status-lines rule holds it to
  statusSites as it does nil (TestCheckWaiting, TestWaiting, the rule's
  NoWait case).
- forbidigo refuses syscall.Flock and unix.Flock outside internal/platform,
  internal/proxy/rotate.go, the stubs and tests (testdata/lint, both).
- TestLockFileWaiting runs in a synctest bubble and checks the wait shows
  while held, not before (its counters under a mutex, which the race
  detector needs, as only the file's lock orders them).

Status lines:
- TestCommandStatusLines runs the setters too: devvm ports LIST and ports
  add, size --cpus, network open, allowlist, transparent off and on, learn
  and allow, git-protect off and on, ssh-agent off. It found devvm ports on
  a running VM starting its forwarder again (ssh and a command in the VM)
  with no status line; that step now shows ports_restarting.

The folder named twice:
- vm_folder_unreadable's why was the open's error, the folder's path in
  it; folderUnreadable gives the system's reason alone when the error is
  about the folder itself (TestUnreadableFolder checks the whole message).
- platform.OpenNoLinks and StatFolder return a link on the path as an
  fs.PathError about the folder too (ErrLinkOnPath still matches), so that
  case names it once as well (TestStatFolderUnique).

Docs: Contributing's CLI page (status lines) and structure page, the
codebase-standards guards; CHANGELOG (devvm ports' status line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 17:04:29 -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 2b176c92b3 feat(ui): every slow step shows a status line, and messages and questions never land on it
Any work that can take noticeable time now runs under the UI's status
line: a Reporter's Status with a label message, or a LoggedCmd step.

The UI:
- status lines are a stack: a Status or LoggedCmd inside another shows
  its own line, then the outer one is drawn again, where before it
  ended the outer one for good
- a message (Info, Warn, Note, Say, data on Stdout/Stderr) clears the
  line, prints and draws it again below; an unended line holds it
- a question (Ask, Confirm, Answer, Secret), the picker and
  ui.Terminal hold it until they're done
- no status line starts once the run is interrupted, as nothing would
  clear it
- the run log's path is read without the log's lock, as the status line
  reads it under outMu

Covered, by site and label:
- finder.target: finding_vm; Lima's limactl --version: checking_backend
- bringUp's checks (seeds, instance, recordFolder, hostChecks, ssh,
  requirements) and a running VM's go-on (proxy, pins, mount check):
  checking_vm; startOnce after the agent: starting; the self-check's
  probes: checking_network; pinHostKeys: reading_host_keys
- setUpVM (sync, ssh config, links, clone seed): setting_up_vm; each
  devcontainer command: running_script; makeMachine: creating;
  buildOnce: checking_image; paste's count and rm: reading_pasted
- volumeOf's lookup (diskutil), for launch, adopt, move, ls and rm:
  looking_up_volume
- vm.ListAll (devvm ls): reading_vms; devvm doctor's checks:
  doctor_checking
- devvm agent import: agent_import_reading (walk, links, opencode),
  agent_store_saving (copy, marketplace git checks, tmutil); devvm agent
  save: agent_save_reading, agent_save_comparing, agent_store_saving
- devvm stop (from its pins check on): checking_vm; a delete, an
  orphan's teardown and Lima's DeleteImage: deleting; devvm git-protect
  and clone on/off's .git work (leftBehind, mountFolder, unmountFolder):
  git_protecting; git-protect's re-read: finding_vm
- devvm clone add: clone_reading, clone_adding; clone fetch:
  clone_fetching; planClone: clone_planning; the clone check before rm
  or a remake: clone_checking; history export and import:
  history_exporting, history_importing; a remake's home: saving_home,
  restoring_home
- devvm upgrade's install: upgrade_installing; the shared tools' step
  back and .NET's downloads: resolving_tools; gc's caches: reading_space;
  the retention settings (daily and in gc): retaining

Work that takes the terminal stays off: the shell, ssh-add's
passphrase (checkAgent, Agent.Ensure, reloadAgent) and an agent's login.

Tests and guard:
- msg.Fake: OnStatus and Showing; its LoggedCmd shows its step
- backendtest.Fake: OnCall
- TestLaunchStatusLines: every backend call of a new, running and
  stopped VM's launch runs under a status line but the shell's and
  Running's (pid files)
- TestSSHAddOffStatusLine: ssh-add, on the user's agent or devvm's, never
  runs under one; chflagsCalls fails a .git lock or unlock with none
- the structure test's status-lines rule (statusSites, statusFree)
- TestStatusLinesNest, TestMessagesClearTheStatusLine,
  TestQuestionsHoldTheStatusLine, TestSecretAndPickerHoldTheStatusLine,
  TestTerminalHoldsTheStatusLine, TestNoStatusLineOnceInterrupted,
  TestFakeStatus, TestAgentImportStatus, TestAgentSaveStatus,
  TestDoctorReport, TestProblems, TestList, TestListLooksUpVolumesOnce,
  TestVolumeOfCache, TestWithSDKDownloads, TestRetainStatus,
  TestSetCloneOn, TestTeardownLeavesNothing

The rule is written in the cli skill (rule 14, checklist, review), the
codebase-standards skill (Show what devvm waits for, its checklist line
and rules.md's row), Contributing's CLI page (Status lines), its tests
and structure pages, and the troubleshooting page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 11:13:13 -07:00
w3cjandClaude Opus 5.5 4d409589bb refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.

Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.

Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.

Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.

Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:31 -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 d55476d3e2 feat(images): the prelude is one line, so build scripts keep their line numbers
Every script a build runs with bash, devvm's own and the user's layers,
now gets the prelude as one line, eval $'…', in place of its #! line, so
bash's errors and $LINENO give the script's own line numbers. A script
without a #! line is one line further down.

- shell.QuoteLine: ANSI-C quoting for bash, on one line of printable
  ASCII; every other byte as \xHH, so a multibyte locale's lead byte
  (Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a
  quote, and a NUL panics as a caller's bug. image's layer rule allows
  internal/shell, a leaf.
- image.WithPrelude, the one place the prelude and a script are joined
  (OwnScript calls it), used by base.sh, apt.sh, the built-in layers and
  features, the user's layers, shared-tools/build.sh and oci/build.sh.
  Every devvm script has a #! line. A leading UTF-8 BOM goes before the
  #! check.
- A build's exports for a company proxy (lima's proxyExports) and the
  user's CAs (trust's exports) end in "; ", not a newline, so they share
  the first line and move no line either; backend.Trust.Env says so.
- The stub logs a bash -s script's second line, which is the script's
  own second line with or without the prelude.
- Keys: every build script's bytes change, so base, every image and
  every shared tool image are built again once; the CHANGELOG's After
  you upgrade says so with git-lfs, and what VMs say until devvm update,
  and Breaking has its own heading.
- Tests: TestQuoteLine (every byte but NUL, a break-out word, in
  /bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK,
  zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL,
  TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real
  prelude's line gives the prelude back; a layer under set -euo pipefail
  gets the names, keeps its function and its line numbers, with and
  without exports before it).
- e2e nix: the layer copy no longer adds the prelude itself.
- Docs: images.md's prelude section, Customizing's layer bullet,
  structure.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:46:30 -07:00
w3cjandClaude Opus 5.5 6ad4f6cb63 feat(images): your own layers get the scripts' prelude
devvm now puts assets/prelude.sh before a user's layer script, as it does
for its own scripts, so a layer gets $devvm_arch, $devvm_libc and
devvm_sha and can pin a download per architecture (and per C library on
Alpine) the way devvm's scripts do.

- image.WithPrelude puts the prelude before any script; OwnScript calls it.
- build.(*Env).LayerData reads the user's layer and puts the prelude
  before it; a deleted layer is still fs.ErrNotExist (Missing).
- The layer's step holds the prelude, so its key changes on its own:
  every image with a user's layer, and every image above one, is built
  again once. base and built-in-only images, and tool images, keep
  their keys; keyFormat is unchanged. The v0.1.0 fixtures have no user
  layers, so their keys don't move.
- The prelude runs first, so a layer that sets its own devvm_ name keeps
  it.
- layer new's starter mentions devvm_sha and $devvm_arch.
- Tests: TestWithPrelude, TestUserLayerGetsThePrelude (LayerData, the key
  differing from a prelude-less build's, a deleted layer still missing);
  prelude.txtar runs a layer as a build does on gnu and musl, and one
  that overrides devvm_arch and devvm_sha.
- e2e (images): the fixture layer prints $devvm_arch, $devvm_libc and
  devvm_sha of two fake pins, which the check compares with the VM's.
- Docs: Customizing's Mailpit example uses $devvm_arch and devvm_sha;
  images.md's key table, recipe and prelude sections; structure.md;
  CHANGELOG (Breaking).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:46:30 -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 297c8f9d23 fix(vm): devvm's first run asks its defaults and base's features first, then this folder's VM
The first run starts with a line saying its questions set devvm's
defaults for every new VM and its base image (first_run_defaults), then
asks new VMs' size and agents and base's features (build's
Choice.Choose, before the summary rather than at the build), then shows
the summary, now headed as this folder's new VM, and asks to customize
it. A base whose features are chosen asks nothing, as before.

new_vm_customize no longer carries its own [y/N], which Ask prints:
TestEveryMessageRenders fails on any message with [y/N] or [Y/n], as
the prompts own them.

Docs: first-vm.md's walkthrough and flowchart, commands.md's questions
table in the first run's order, customizing.md's features question,
images.md's summary and the README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 22:54:01 -07:00
w3cjandClaude Opus 5.5 3a2c290d3d refactor(msg): messages and comments say network tier and the VM's proxy, not network policy
Every VM runs a proxy and is on one of four tiers, so the proxy's messages
name the VM's proxy, the unenforced ones its network tier, and the
redaction ones say devvm keeps secrets on this machine on every tier.
Message IDs are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 17:16:40 -07:00
w3cjandClaude Opus 5.5 d58b24affe refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.

The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.

Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.

A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.

The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.

Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 11:49:57 -07:00
w3cjandClaude Opus 5.5 7bdaf8e99e refactor: one Reporter for every package's messages and prompts
msg.Reporter is what every package below cli prints and asks through:
Info, Say, Note, Warn, Status, Ask, Confirm, Answer, the terminal checks
and CanPick, the run log (LogNote, LogWriter, LoggedCmd, WithSteps),
Stdout, Stderr, AddCleanup and Interrupted, under the UI's signatures.
*ui.UI implements it (a compile-time check in ui), and msg.Fake is the
tests': quiet as its zero value, its On funcs and fields record and
answer.

The six UI interfaces (tools, netpolicy, lima, registry, sshagent, vm)
are gone, and the copied output and prompt func fields of tools.Env,
tools.Making, gitprotect.Protector, secrets.Store, netpolicy.Proxy,
from.Lookup, backend.Review, lima.Lima, sshagent.Agent, vm.Env,
vm.SizeChoice, vm.AgentsChoice, vm.LayersChoice, vm.NetworkChoice,
vmssh.Forwards, build.Env and sshconfig.Config: each embeds the
Reporter. Lima's and the shared tools' Warn, which says where the run
log is too, is a method of their own over it; vm's interactive check is
a function over it. The pickers (build.Env.Pick, vm.Env's PickFeatures
and PickParts, the choices' Pick) and vm.Env.CanAsk stay fields: they
carry types of their own or cli's answer. The test UIs of tools,
netpolicy, lima, registry, build and vm become msg.Fake.

Coverage baselines raised: internal/backend/lima, internal/msg,
internal/tools.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:57:23 -07:00
w3cjandClaude Opus 5.5 aadd3fd416 test(build): keep write's gosec directive, which G703 needs on some runs only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:37:07 -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 450f345b74 fix(build): re-hash a cached package file before keeping it
A recording keeps a packages/<sha>.deb already in the cache only when
its SHA-256 and size still match; a changed one is replaced with the
build's copy, and the run log notes it (build.Env's LogWriter, set from
the UI's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 22:01:37 -07:00
w3cjandClaude Opus 5.5 3649978bdb feat(build): base's features are devvm's own; your extras are layers
devvm reads base's features only from its own files (assets/features):
~/.config/devvm/features is no longer a folder devvm knows. An extra of
your own for every new VM is a layer of yours (devvm layer new), chosen
with devvm setup --layers, which each VM's list can uncheck.

- build: Features returns devvm's features alone; featureStep gives each
  its prelude; FeatureScript, the shadowing check and its
  feature_shadowed warning are gone. A chosen name devvm has no script
  for is skipped with unknown_feature, as before.
- paths: Dirs.Features is gone.
- Tests: TestFeatures, TestOwnFeatures, TestPickFeatures,
  TestSetFeatures, TestBuildRunsFeatures and the key tests use devvm's
  features only and check that a script in ~/.config/devvm/features is
  neither a feature nor in any key; features.txtar likewise.
- Docs: customizing's Extras of your own (a layer chosen in devvm
  setup), settings, install, space, overview, internals/images and the
  landing page drop the user features folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 17:16:41 -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 9348a1e518 refactor(assets): one prelude for the build scripts' architecture, libc and pins
assets/prelude.sh gives each of devvm's scripts that a build runs with
bash $devvm_arch (arm64 or amd64), $devvm_libc (musl where apk is, else
gnu) and devvm_sha TOOL (the script's TOOL_sha256_<arch>_musl on musl
where it pins one, else TOOL_sha256_<arch>). It replaces the arch and sha
helpers in layers/base.sh, layers/nix.sh, features/cli-tools.sh,
shared-tools/build.sh and oci/build.sh, and the Alpine checks in
docker.sh, desktop.sh and fzf.sh. Each script that reads it checks it
came first (: "${devvm_arch:?}").

image.OwnScript reads devvm's own scripts with the prelude before them:
base.sh, apt.sh, built-in layers (LayerData) and features (featureStep),
shared-tools/build.sh (the tools build and ToolFile's key) and the
conversion's oci/build.sh (Lima's convertSteps, written into the
conversion's own temp folder). Users' layers and features get none.
keyHash.own goes, its one caller now hashing OwnScript's bytes.

Image keys change: every image and every shared tool image rebuilds.

Tests: testdata/script/prelude.txtar pins which pin devvm_sha picks from
each script on arm64 (aarch64 and arm64) and amd64, gnu and musl, and
refuses another architecture and a missing pin; oci.txtar sources the
prelude first and checks build.sh stops without it; TestOwnScript,
TestPreludeUsers (only scripts that get the prelude use it, each checks
its variables), key rows for the prelude in build and tool keys, and
recipe expectations with the prelude before devvm's scripts only.
e2e's nix copy as a user layer starts with the prelude.

Docs: internals/images.md (the scripts' prelude, keys), contributing
(owner, agreement test), maintaining, assets/oci/README.md, AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:57:21 -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 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 e5150c6ba7 feat(build): base falls back to the release before when the newest doesn't boot
Users build base from Ubuntu releases e2e hasn't run, so a release whose
image Lima can't start would stop every new machine's first build. When
base's build VM doesn't start from an image the backend pinned in this
run, devvm says so (origin_no_boot), has the backend pin the newest
release older than it (PinOrigin's PinOlder, checked as the newest is)
and builds base on that, which stays pinned. It does so once a run, and
never for an image pinned before the run, which booted then.

Ubuntu's listing isn't signed, so devvm rebuild base never pins a release
older than the one pinned: a listing that ends before it keeps the pin,
with a warning (ubuntu_newest_older).

- backend.BootError (errors.Is ErrBoot, errors.As the logged failure),
  which Lima returns for base from Ubuntu's image whose start fails.
- build's fallback runs after the failed build lets go of its lock;
  what was pinned in the run is under a lock of its own, as builds on
  one Env may run at once.
- Tests: falling back once and recording the older release; no fallback
  for a pin from before the run or for another failure; Lima's
  BootError for base and not for a layer; a listing older than the pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:07:07 -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 285386693a refactor(lima): base's origin is recipe steps, which Lima is given and runs
backend.Images's KeyFiles becomes Origin(from): the backend's own steps
that base starts with, first in base's recipe (image.Recipe.Origin),
which base's key hashes like any step. On Lima they are the pinned
Ubuntu image for the host, with --from the conversion's oci/build.sh
(as root, its arguments the digest, the reference, the image's user and
the converted disk's size), bootify.sh and kernel.sh, then base.yaml.

BuildImage runs the origin it's given rather than reading devvm's files
again: limactl create gets the recipe's base.yaml, base's size comes
from it, and the conversion writes and runs the recipe's scripts with
build.sh's arguments. originOf refuses an origin Lima wouldn't make
(another Ubuntu pin, no base.yaml, a conversion that isn't --from's or
names other files). image.Input's Own and image.ConversionScripts are
gone; the conformance suite checks Origin, and the fake answers
OriginSteps.

Base's key changes again, as its origin is hashed as steps: every image
is built again on next use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 06:18:31 -07:00
w3cjandClaude Opus 5.5 21db9467f2 refactor(build): one image recipe, which the key hashes and the backend runs
An image's recipe is the ordered list of steps its build runs, each a
script with its name, arguments and whether it runs as root
(image.Recipe, image.Step). internal/build puts it together once
(recipe.go: inputs, plan, basePlan), image.Input.Key hashes it, and
backend.ImageSpec carries the same recipe to the backend, which runs it
as it is. image.Inputs, which read the files a second time for the key,
is gone, with its fixtures; its tests move to internal/build.

The user's CAs' variables are no longer written into the scripts sent:
backend.Trust.Env holds them and Lima puts them before each step, so what
the backend is given is exactly what the key hashed.

Two new tests check that every byte and argument sent into a build
changes the key: TestKeyHashesWhatABuildSends (build, on the fake) and
TestKeyHashesWhatLimaSends (Lima driven by build, its commands, inputs
and the conversion's files). Written first against the code as it was,
the Lima test found two gaps, fixed here:
- a --from conversion's user (name, uid, home folder) and the converted
  disk's size went into the image but not its key: Lima's KeyFiles holds
  them (madeArgs, with a User seam);
- the conversion was given all of oci/, try.sh and README.md included,
  which base's key doesn't hash: it gets image.ConversionScripts only.

Every image's key changes, as keys hash the recipe's fields: images are
built again on next use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 06:02:19 -07:00
w3cjandClaude Opus 5.5 ed70aeae3b feat(netpolicy): config.toml's company proxy reaches devvm's own downloads and builds' checks, and VMs without policy warn
config.toml's [proxy] covers the places it missed:

- devvm's own requests on this machine (the download of its mise, Ubuntu's
  cloud image listing, --from's registries) go through it when the
  environment sets no proxy. settings.CompanyProxy.Route is their
  transport's proxy: at the first request it looks up the proxy secret,
  puts it in each URL that names a user, and routes each request as a VM's
  proxy does (proxy.Upstream.WithPassword, proxy.Upstream.Route, reusing
  the proxy's NO_PROXY matching). A missing password fails the request
  with fetch.ErrProxy, which isn't retried; HostMise shows its message.
- The mise devvm runs on this machine gets HTTPS_PROXY, HTTP_PROXY and
  NO_PROXY in its environment (settings.CompanyProxy.Env), with the
  password in the URL, as mise takes it nowhere else; never in its
  arguments or a file. With the environment's proxy it adds nothing.
- devvm build, rebuild, the remakes' builds and tool builds check the
  company proxy and its saved password before anything starts
  (build.Builds' checkProxy, tools.Share.Build), through the one check a
  new VM and a VM's proxy use: settings.CompanyProxy.Upstream, which
  netpolicy.Proxy.Upstream now calls. secrets.Store.ProxyPassword owns
  the proxy_password_missing mapping.
- A VM without network policy never gets config.toml's proxy, as the
  guest would need the password, which never leaves this machine; each
  start of one while config.toml is the only proxy warns
  (proxy_needs_policy), naming devvm network on or the shell's
  HTTPS_PROXY, with a doc link.

Wiring: tools.Env.Proxy (its Password set by cli and vm from devvm's
secrets), from.NewLookup/NewRegistry/NewPublicRegistry take the proxy,
lima.New and registry.New take a *settings.CompanyProxy for Ubuntu's
listing. internal/fetch stays standard library only.

- Tests: TestUpstreamWithPassword, TestUpstreamRoute,
  TestUpstreamRouteAuthorizes, TestCompanyProxy,
  TestCompanyProxyPasswordMissing, TestProxyPassword,
  TestHostMiseThroughCompanyProxy, TestMiseCmdCompanyProxy,
  TestBuildChecksCompanyProxy (tools and build), TestRegistryThroughProxy,
  TestUbuntuThroughCompanyProxy, TestTransient's ErrProxy, and
  company_proxy.txtar's build, rebuild and no-policy cases.
- Docs: network policy's Behind a company proxy and Without network
  policy, config.toml's [proxy], How it works' Through a company proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 01:42:37 -07:00
w3cjandClaude Opus 5.5 6128f400e4 refactor(backend): Backend is four role interfaces, and Running replaces StartID, Confined and Lifeline
backend.Backend is Name, Caps and four roles, each required:
- Host: Problems, NameMax, Location, DiskDirs, Floors
- Images: BuildImage, Images, ImageSize, DeleteImage, BuildTools,
  ToolFormat, KeyFiles
- Machines: CreateVM, Start, Running, ProxyURL, Stop, Delete, Rename,
  List, Inspect, Exec, Shell, SSH, ForwardTarget
- Housekeeping: Usage, Strays, DevvmCache, DeleteCache

The optional interfaces Lima implemented (KeyFiles, Storage, Locator,
UsageReporter, StrayFinder, CacheCleaner) are gone into the roles, and
their callers call the methods directly; Forgetter stays the one
optional role, found with backend.As. Running(ctx, vm) returns a
backend.Run (ID, Confined, Lifeline) in place of StartID, Confined and
Lifeline. Space.Check, Space.Warning and LocationOf take a Host.

lima.Lima keeps its fields, Name, Caps and its shared helpers (14
methods), and embeds host, images, machines and housekeeping, each over
the Lima it's part of (withRoles); backendtest.Fake is split the same
way. The guard has every role's methods, its own for the ones it guards.

Structure test: max-methods counts an interface's declared methods too;
Lima and the fake leave largeTypes. Tests: TestRunning, TestGuardRoles,
TestAs (Forgetter), TestFakeRunningAndNone, two TestRulesFail cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:58:19 -07:00
w3cjandClaude Opus 5.5 f4ad9c2c3d feat(vm): devvm update makes an outdated VM again from its image's new build, keeping its home and settings
devvm update [--force|--no-export|--clean-home] (internal/cli/update.go)
is the shared remake with the VM's own image name: Lifecycle.Update calls
toRemake, decides with build.Builds.Outdated (WarnIfOutdated's check, now
its owner) whether the chain's keys changed, says vm_current and does
nothing when they didn't, else names what changed (vm_changed) and calls
remakeTo. --from VMs are judged on the recorded digest and built with
build's lookup. The remake's flags are one adder (addRemakeFlags) for
devvm layer add and devvm update. vm_outdated names devvm update.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:47:49 -07:00
w3cjandClaude Opus 5.5 619570e445 refactor(backend): backend.Check, the specs' Validate and the registry's guard
backend.Check(ctx, b) returns the first of a backend's Problems, in place
of Check in the Backend interface (Lima's and the fake's go).

ImageSpec.Validate and ToolsSpec.Validate hold the build specs' checks
Lima made itself: a layer from a container image, a network that isn't a
build's, a key that isn't one, a tools format other than the backend's,
folders that aren't absolute. ToolsSpec gets Name, what it builds, for
the refusal's vm.

The registry hands out each backend behind a guard: CreateVM, Start,
BuildImage and BuildTools run the spec's Validate and the review's
refusal for spec.Features() (VMSpec's, Want's and Confinement's,
ImageSpec's, ToolsSpec's) before the backend sees them, without a second
warning for an unreviewed emulation let through. Callers' own Require
calls stay as the clear error path; the guard is the backstop.
Want.Features is new; VMSpec.Features uses it and adds agent-toggle when
the VM is made ready for it. backend.As finds a backend's other
interfaces behind the guard (KeyFiles, Storage, Locator, Forgetter,
UsageReporter, StrayFinder, CacheCleaner).

Structure test: execSites lists the 17 files whose 24 exec.Command*
calls stay, each with why (they make a command a runner runs, or one
that streams, asks on the terminal, outlives the run or carries a
secret); a host command made anywhere else fails, as does a listed file
making none. guardOwner: a type assertion or type switch to a backend
package's type outside guard.go fails (use backend.As). TestRulesFail
cases for both.

Tests: TestCheck, TestImageSpecValidate, TestToolsSpecValidate,
TestGuardRefuses, TestGuardLetsThrough, TestAs; TestFeaturesNeeded
gains Want's and agent-toggle; Lima's refuse cases for what Validate
owns move to the backend package.

Docs: internals/backends.md (the guard behind the first check);
contributing's How a backend plugs in (Check, the guard, Validate, As),
the structure test's execSites and guardOwner, and the owners table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:13:57 -07:00
w3cjandClaude Opus 5.5 ae0fd533fc refactor(msg): names mode is the UI's, read once with each stream's style
A msg.M always renders as its text: String, Error, Parts and Segments no
longer read DEVVM_MESSAGES, and Line is gone. internal/ui reads names mode
in newStyle, with each stream's color, and shows messages as names through
the style (message, segments, line, valueParts). ui.New takes the function
it reads the environment with, so tests make a names-mode UI without
t.Setenv. Messages shown as data go through UI.Text or Table.Text (doctor
--json, ls's image cell, setup's network choices); vm.PickRow.Desc is a
msg.M that cli renders. A config.toml value's refusal keeps its message
(state.CorruptError.Msg, Shown), so fail shows its names in names mode.

Tests: ui TestNamesMode; state TestFiles covers Msg and Shown; Go tests
compare NamesOf or Names, and drop t.Setenv("DEVVM_MESSAGES") outside ui,
msg's TestNames and the testscript runner. The structure test lists
DEVVM_MESSAGES in internal/ui/style.go only; ui.UI's method limit is 47
(Text).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 17:01:47 -07:00
w3cjandClaude Opus 5.5 628dc11c94 feat(state): a layout version for devvm's folders, made_by in its records, the golden listing and doctor's leftovers in vms/
The data and config folders each hold a version file (state.Layout, 1).
state.CheckLayout runs before every command but help, completion,
version and devvm's hidden commands, under version.lock: the same
version goes on, a missing file gets this devvm's, an older one runs
the migrations in order (migrations(), empty now), and a newer one in
either folder refuses with layout_newer; a file that isn't a version
fails with layout_unchecked.

made_by, devvm's version, is in vm.json's core fields (set when the VM
is made, kept by later changes), image records and tool image records.
It's passed from cli's devvmVersion through vm.NewEnv, tools.New and
build.Env.Version.

testdata/script/layout.txtar makes two network-policy VMs with a
forwarded port, a link and a secret, and compares every path under the
data and config folders with checked-in listings (macOS and Linux).

devvm doctor warns about entries in vms/ that aren't VM folders
(vms_stray) and VM folders without vm.json (vm_folder_stateless),
changing nothing.

Tests: TestMigrations, TestCheckLayout, TestCheckLayoutMigrationFails,
TestVMFolderProblems, TestSkipsLayout; made_by checks in TestVMRoundTrip,
TestImage, TestToolImage, TestUp, the build and tools tests and scripts;
doctor's unit test and script. Docs: internals/overview (the layout
version, made_by), using/space, using/settings, using/troubleshooting,
internals/images, Contributing (changing the state layout).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 15:50:49 -07:00
w3cjandClaude Opus 5.5 d2dc8c74b6 feat(layers): desktop is a built-in layer, not one of base's features
devvm --layers desktop (or desktop under the picker's Layers heading)
gives a VM the Xfce desktop devvm desktop opens; base no longer has it.

- assets/features/desktop.sh moves to assets/layers/desktop.sh, with a
  built-in layer's header, and assets/layers/desktop.policy (no rules: its
  packages come from the distribution's archive, which base's policy has).
- image.DesktopLayer joins image.Builtins (desktop, docker, nix, sorted):
  reserved, listed under Layers, taken by --layers and completion, its
  policy read by netpolicy.Policies.
- build: desktopFeature and chosenFeatures' special case are gone; until
  a choice is made, base gets every feature. devvm setup --features
  desktop is no_feature.
- devvm desktop: desktop_no_feature becomes desktop_no_layer (devvm rm,
  then devvm --layers desktop), linked to the desktop page. The picker's
  row: pick_layer_desktop.
- apt snapshot: base.sh's /etc/apt/apt.conf.d/50devvm-snapshot stays in
  base's image, and only guest/sync.sh (project VMs) removes it, so a
  layer built on base installs from the same snapshot and package lists;
  said in base.sh, desktop.sh and internals/images.md.
- No backend feature: desktop builds and runs like any layer on Lima.

base's image key changes (desktop leaves the features, base.sh's comment
changes), so base rebuilds, now about 400 MB smaller without the desktop
on the --from tier's every-feature base, and for anyone who chose it.

Tests: TestBuiltins; TestOwnFeatures (devvm's features without desktop,
every one until chosen, desktop refused); TestLayersAndCheckLayers,
TestCompleteParts, TestPartFlags and TestUpPicker list desktop under
Layers; TestBuiltinPolicies allows desktop.policy alone without rules;
testscript: desktop.txtar (a base VM refused with desktop_no_layer, its
build without the layer's script; --layers desktop builds the desktop
image), setup.txtar (--features desktop is no_feature), the layer lists
in build, layer, up and up_checks. e2e: the desktop section checks a base
VM has none of the desktop's programs and is refused, then makes its VM
with --layers desktop; from's Alpine VM gets the desktop layer too.

Docs: using/desktop.md, using/images.md (built-in layers, desktop),
using/customizing.md, using/from.md, using/_index.md,
getting-started/commands.md, internals/desktop.md, internals/images.md
(the desktop layer, the snapshot in layers), internals/design.md,
contributing; the CLI reference for devvm desktop.

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:37:36 -07:00
w3cjandClaude Opus 5.5 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 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 82566e9010 refactor: shell quoting, the VM-name grammar and value patterns each in one place
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.

internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.

Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.

netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.

The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 16:07:18 -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 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 cd6fc60576 feat(cli): --json on every command that shows or lists
ls, images, tools, size, ports, network (and -g), network log (and
--blocked), ssh-agent, git-protect, secret, history, space, retention and
doctor take --json: one JSON object on stdout with "version": 1 first,
messages on stderr (ui.DataOnly), lists [] when empty. Settings commands
only show with --json and refuse a value (json_shows_only). doctor --json
replaces --fixes: problems with key, fix (null without one) and message,
warnings, docker and every backend's features; it prints nothing else and
succeeds whatever is missing, and install.sh reads its problems with awk.
TestJSONShapes holds each command's field names and types. Each shape is
documented on its command's page, with the contract under Everyday
commands' Output for scripts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:06:56 -08:00
w3cjandClaude Opus 5.5 fe32d2a01c feat(cli): reserved command names, and did-you-mean for devvm WORD
A word after devvm that's neither a command nor an image (no +, and not
base, a shared tool or a layer) is a usage error, exit 2, suggesting the
closest command (Cobra's SuggestionsFor, distance 2) and the closest image
name. devvm help WORD and devvm WORD --help fail the same way instead of
printing the root's help. Layers can't take a word devvm keeps for its
commands.

- internal/image/reserved.go: Reserved (every command and subcommand
  name, hidden ones and help, and link, group, join, leave, publish,
  unpublish kept for later), IsReserved; LayerName refuses them, so
  Layers() and completion leave such files out.
- build.CheckLayerName refuses one (layer_name_command); CheckLayers
  refuses a layer file named with one wherever an image names it
  (layer_is_command, naming the file).
- internal/cli/word.go: checkWord (the root's Args), closest and
  levenshtein, addHelp (devvm's own help command, and a help func that
  panics with wordPanic for execute to recover), helpTarget, printUsage.
- Messages: layer_name_command, layer_is_command, no_command_or_image,
  no_command_or_image_command, no_command_or_image_image,
  no_command_or_image_both, with doc links.
- Tests: TestEveryCommandReserved, TestImagesNotReserved,
  TestLevenshtein, TestUnknownWord; layer.txtar and up_checks.txtar; e2e
  checks a mistyped command exits 2 with its suggestion.
- Docs: customizing (layer names), commands (devvm WORD), contributing,
  AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:54:41 -08:00
w3cjandClaude Opus 5.5 f9e14e9b37 feat(cli): usage errors as devvm messages, checked before anything runs, exit code 2
Every argument and flag error is a devvm message naming what the command
expected, followed by usage_help naming that command's own --help, and
exits with 2. Arguments and flag values are checked in Args, before the
root's PersistentPreRun and any VM lookup.

- internal/cli/args.go: noArgs, exactArgs, maxArgs, minArgs (argsN, with
  ValidArgs), argsOf (the arguments in Use), checkCommands (wraps every
  command's Args with checkFlags and marks RunE's errors as ranError),
  checkFlagValue (--cpus, --memory, --disk, --ports, --lifetime,
  --older-than), exclusive (flag groups checked first, then Cobra's own
  required flags and groups), flagError (SetFlagErrorFunc: pflag's
  NotExist, ValueRequired, InvalidValue, InvalidSyntax errors).
- Execute: 0, 1 for a failure (RunE's error: a message, or
  output_failed), 2 for a usage error; usage_error is only the fallback.
- Checked early: ports LIST and add/rm LIST (vm.ParsePortList), network
  allow/deny RULEs, network on/off(/ask with -g), layer new NAME
  (build.CheckLayerName), retention KEY=VALUE (state.CheckRetention),
  setup --features '', secret NAME, completion SHELL, git-protect and
  ssh-agent values.
- ui.UI.Error prints an error without ending the run (UI's method limit
  44).
- Messages: usage_help, arg_missing, args_too_many, args_none,
  arg_not_choice, no_subcommand, flag_unknown, flag_needs_value,
  flag_bad_value, flag_bad_switch, flags_exclusive, output_failed;
  usage_error reworded; doc links to troubleshooting.
- Tests: TestUsageErrorsEveryCommand, TestRanErrorIsAFailure, TestArgsOf,
  TestFlagErrors; txtars check message names; e2e checks a bad port list
  exits 2.
- Docs: troubleshooting (a command refused before it runs, exit codes),
  contributing (command arguments), AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 91a429108f feat(images): a built-in nix layer with Nix, direnv and nix-direnv, pinned
nix is a layer devvm ships, as docker is: devvm nix, devvm node+nix, devvm
build nix, or added to an existing VM in place. A folder with flake.nix,
shell.nix or devenv.nix at its top level, or a default.nix that makes a
shell (mkShell), gets it after its toolchains, so package.json and flake.nix
give node+nix.

- assets/layers/nix.sh: Nix 2.35.4's release tarball (releases.nixos.org),
  its version and SHA-256 per arch at the top, checked against the
  tarball's .sha256 files and nixos.org/nix/install, fetched with
  devvm-fetch; 2.35.3 fixes GHSA-hf6w-2rg9-v84g (store ownership in the
  scripted installer) and CVE-2026-110450 (store corruption through the
  daemon's repair flag). The tarball's own install --daemon --yes
  --no-channel-add, with experimental-features = nix-command flakes,
  trusted-users = root, sandbox = true and sandbox-fallback = false. The
  installer runs without proxy variables (it writes any it finds into a
  systemd override for nix-daemon, which would put a build's proxy into
  the image) and with NIX_SSL_CERT_FILE at the system's bundle. The layer
  checks the store is root's, adds Nix's default profile to the end of
  sudo's secure_path (/etc/sudoers.d/devvm-nix, checked with visudo), and
  appends Nix's profiles to BASH_ENV's PATH. direnv 2.38.2 (per arch) and
  nix-direnv 3.2.0's direnvrc, pinned the same way; direnv's hook in
  ~/.bashrc.d/direnv.sh, which loads before mise.sh so direnv's prompt hook
  runs after mise's and a dev shell's PATH comes first; a direnv lib file
  puts each project's layout under ~/.cache/direnv/layouts, so nix-direnv
  writes no .direnv into the project folder. Without systemd the script
  refuses in one line.
- assets/layers/nix.policy: cache.nixos.org, channels.nixos.org,
  releases.nixos.org (GitHub is in base.policy).
- assets/guest/sync.sh: nix-daemon gets a systemd drop-in with the VM's
  proxy (http_proxy, https_proxy, no_proxy) under network policy, removed
  when it's off, the daemon restarted when it changed.
- image.NixLayer in Builtins; project.Detect's nix marker (a default.nix is
  read only as a regular file, at most 64 KiB); backend.FeatureNixLayer
  (nix-layer), needed by a VM of an image with the layer and by building
  one: Lima native, smolvm and Docker none, so both refuse in one line
  (backend_lacks); dockerLayers.choice returns every layer feature of the
  image, so docker+nix on Docker needs nix-layer too.
- scripts/bump.sh: nix (the version nixos.org's installer names, the
  sums Nix publishes; it fails when the installer names no tarball, as
  Nix's Rust installer will), direnv, nix-direnv.
- Docs: using/images (built-in layers, detection), using/toolchains (Nix
  projects), safety/network (the layer's hosts; source builds' hosts
  blocked), internals/images (the nix layer), internals/network (the
  daemons' drop-ins), internals/backends (nix-layer), internals/design
  (the nix layer beside Instead of Nix), backends, customizing,
  coding-agents, contributing (the e2e section); the CLI reference;
  AGENTS.md's assets/ and e2e lines.
- Tests: Detect (markers, default.nix with and without a shell, a linked
  one), layer and environment lists, layer new nix reserved, nix-layer in
  ImageSpec and ImageFeatures, caps tests, up_checks.txtar (node+nix
  detected under an agent), docker.txtar (nix refused for a VM and a
  build). e2e nix section: the layer built behind a company proxy leaves
  no proxy settings and no password on its image's disk; a node+nix flake
  VM with network policy: pins, a root-owned store, sandbox without
  fallback, trusted-users root and an untrusted substituter ignored, the
  daemon's drop-in, nix run nixpkgs#hello, sudo nix and nix over ssh, the
  flake's node ahead of the shared node prompt after prompt through
  direnv, no .direnv in the folder, a blocked fixed-output fetch named by
  devvm-why, and the drop-in gone after network off.

Review (security-audit skill, guidance mode, against the review task's
list): the tarball and direnv's files are pinned in devvm's source and
checked before tar or install runs; nothing from the host goes into the
image (no proxy override, e2e greps the disk); the drop-in holds only the
VM's own proxy URL, devvm's value, and goes when policy is off;
trusted-users stays root and an untrusted user's substituters are
ignored (the VM's user has sudo, so that guards an honest VM and the
allowlist is what holds); secure_path gains only the root-owned default
profile, last; /nix is on the VM's own disk and nothing mounts a host's
or another VM's store. Found and fixed in review: Nix's default
sandbox-fallback would build unsandboxed without a word where the kernel
can't sandbox, so it's off. No confirmed findings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:22:02 -07:00
w3cjandClaude Opus 5.5 e2e3c70d81 feat(desktop): a desktop feature and devvm desktop, over VNC, on every backend
The desktop feature (assets/features/desktop.sh, not chosen until you
choose it, about 370 MB) installs Xfce and TigerVNC's Xvnc from base's
package snapshot, and devvm-desktop, which starts Xvnc on display :1 on a
socket of the VM user's own (/run/devvm-desktop/vnc.sock, 0600 in a 0700
folder), with no TCP port (-rfbport -1, -nolisten tcp) and no password of
its own, the clipboard on or off as asked (vncconfig on a running one),
then an Xfce session in a D-Bus session of its own. Nothing starts it at
boot: devvm desktop does, on every backend.

devvm desktop gets the VM ready as devvm ssh does, refuses a VM without
the feature (desktop_no_feature), starts its desktop (desktop_start_failed),
and serves it on 127.0.0.1 alone until Ctrl+C or the VM stops
(desktop_vm_stopped), on the VM's own port (desktop_port, among
netpolicy.UsedPorts, so no forwarder or new VM takes it), showing the
address and password (desktop_ready) and opening vnc://127.0.0.1:PORT in
Screen Sharing on macOS (--no-open; desktop_open_failed). --clipboard
shares the clipboard both ways for that run.

internal/desktop's Relay is the guarantee, not the VM's server: it speaks
RFB 3.3/3.7/3.8 as a server, offers VNC authentication alone, checks the
answer against the VM's password (8 characters of 31, about 40 bits,
crypto/rand, kept in the VM's state as desktop_password, never sent to the
VM) one check at a time with a second's wait after a wrong one, and only
then opens an ssh -W channel to the VM's socket through devvm's ssh config
(pinned host key, no session, agent or forwarding), closed by its input
first so the VM's sshd ends its side. Without --clipboard it drops every
ClientCutText (extended ones too) and ends a connection on a message type
it can't size. At most 8 connections.

Also: vm.Desktop (Open, serve, listener, dial), vm.ready (devvm ssh's
launch without the Include prompt), Env.OpenURL; build's chosen features
leave desktop out until it's chosen; messages desktop_failed,
desktop_no_feature, desktop_start_failed, desktop_ready,
desktop_open_failed, desktop_vm_stopped, with doc links.

Tests: internal/desktop (passwords, Response, wrong passwords refused with
no dial, 3.3/3.7/3.8, not a viewer, the clipboard dropped or carried, an
unknown message ending the connection, a VM server asking for a password),
internal/vm (the password kept and remade, the listener's port kept and
replaced, ssh's arguments), internal/build (desktop off until chosen),
testdata/script/desktop.txtar (no VM, no feature, a stopped VM started,
the forward asked for with the clipboard off and on, the same port and
password, Screen Sharing opened or failing, the VM stopping, the start
failing), setup.txtar, docgen; tests/e2e.sh's desktop section (Lima, with
network policy) and checks in the smolvm and Docker sections;
TestE2EDesktop.

Docs: using/desktop.md (new), customizing.md's features, commands.md,
internals/desktop.md (new), design.md's note on the desktop,
contributing/testing.md's manual Screen Sharing check, the CLI reference.

Review (security-audit skill, guidance mode, local IPC and loopback
listener classes), against the review's list:
- another local user or process reaching the port: 127.0.0.1 alone,
  without address reuse; VNC authentication checked on the host before any
  ssh, constant-time, about 1 guess a second globally (thousands of
  years); the password in the VM's state (0600 file, 0700 folder), shown
  only on stdout with the address, never in open's arguments or the run
  log (e2e: no run log, no host process's arguments);
- never in an image or the VM: the VM's server has no password; e2e greps
  the VM's files for it (found the first time only in the VM's journal,
  from the check's own sudo command line, now fed on its input);
- the server on no address but loopback on each backend, even if root
  changes it: Xvnc has no TCP listener (e2e on each backend), the relay
  is the only way in and lives on the host; root's own server without a
  password (e2e, Lima) still gets no viewer without devvm's password;
- clipboard off really off: the relay drops the viewer's clipboard
  whatever the server accepts (e2e: root's server records a key event but
  never the clipboard); the VM's clipboard to the viewer can't be filtered
  without decoding screen updates, documented, Screen Sharing's setting;
- nothing from the VM toward the host: a local ssh -W channel, which ssh's
  client asks for; the VM reaches neither the relay's port nor anything
  new (e2e: with network policy, no direct connection out, nor to the
  port); a VM that reaches host loopback (no policy, Docker Desktop) meets
  the password like anyone;
- network policy unchanged: no policy file or allowlist changes; the
  self-check passes with the desktop running (e2e).
Left as documented residuals: the VM's clipboard sent by a changed
server; a local process or VM keeping the relay's 8 slots busy or failing
checks (availability only).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:49:23 -07:00