49 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 c171e205ec docs: the layout as it is, and the agents' guide on the VM's host folders
The in-VM guide says the project folder is the only host folder the VM
can write to, with the agent store's folders and the shared tools
mounted read-only. design.md names internal/vmssh/links_test.go and
internal/proxy/testdata/nix/, and its devcontainer forwardPorts entry
says the file's ports are added, as its Ports entry does. Contributing
drops the old shared CA folder's paragraph; space.md says secrets/ is
for hosts without a Keychain. Coverage baselines raised (netpolicy,
settings, vm).

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 22:47:23 -07:00
w3cjandClaude Opus 5.5 2df3c6840c feat(agents): devvm agent login, an agent's login in the VM for every VM
devvm agent login codex|opencode logs the agent in from inside this
folder's VM, so this machine never needs Codex or opencode, and devvm's
agent store keeps the login for every VM with the agent. It sits under
devvm agent beside import and save: it fills the store, as they do, and
a bare devvm login would read as a verb on the VM itself.

- Browser login (the default): the agent's own login runs in the VM on
  this terminal (codex -c cli_auth_credentials_store="file" login;
  opencode auth login --provider openai --method "ChatGPT Pro/Plus
  (browser)"), and devvm forwards this machine's localhost:1455, and
  1457 (Codex's fallback) when free, on 127.0.0.1 and ::1, to the same
  ports on the VM's loopback, only while the login runs: closed when it
  ends, fails or is interrupted (AddCleanup), and an interrupt also ends
  the agent's login in the VM (its pid kept in ~/.cache/devvm-login.pid),
  so its server doesn't linger for the VM's port forwarder. Port 1455
  taken on this machine: refused, naming --device-code.
- --device-code: codex login --device-auth, or opencode's headless
  ChatGPT login; nothing forwarded.
- --api-key [--provider anthropic|openai|openrouter] [--stdin]: the key
  is asked for on this machine (msg.Question answered by --stdin) and
  saved in the store, never in the VM: Codex's auth.json becomes
  {auth_mode: apikey, OPENAI_API_KEY}, opencode's gets the provider's
  {type: api, key} beside the others; the running VM gets its copy with
  a placeholder and its proxy the binding at once.
- The proxy's capture (agentlogin's capturers) saves ChatGPT logins;
  devvm then confirms what the store saved, with the account's email,
  and fails when the login saved nothing new.
- opencode 1.19.5 has no Anthropic OAuth in its core (no Anthropic
  plugin among its built-ins), so there's no pasted-code capturer:
  Anthropic is an API key. opencode's OpenAI login listens on 1455 only;
  Codex 0.166 on 1455, falling back to 1457.

- vmssh: SSH.ForwardLoopback (LoopbackForward: listeners in devvm's own
  process, each connection its own ssh -W to the VM's 127.0.0.1, no
  master; ErrPortTaken).
- agentlogin: KeyProviders, File.SetKey, File.ChatGPT.
- secrets: Store.SaveKey, LoginSum, ChatGPT (loginsDir shared with
  Capture).
- vm: AgentLogin (agentlogin.go), LoginAgents.
- cli: agentlogin.go (--device-code, --api-key, --provider, --stdin,
  --here/--parent); usage errors before anything runs.
- assets/guest/sync.sh: cli_auth_credentials_store = "file" first in
  the VM's ~/.codex/config.toml on every launch.
- Messages: agent_login_* and agent_key_*; codex_no_key,
  codex_no_chatgpt, codex_refresh_failed and opencode_refresh_failed
  point at devvm agent login.
- Tests: agent_login.txtar (usage errors, no VM, no agent, device code
  argv, browser forward and its end, the agent failing, a login saved
  while it runs, port taken, interrupt, API keys, the VM's copy failing,
  no terminal, an empty key), unit tests for the forward, SetKey,
  ChatGPT, SaveKey, the confirmation and the argv; coverage baselines
  raised.
- e2e (network): the real Codex's login in the VM against the run's
  fake token endpoint, its callback opened through the forward, the
  store's tokens and key, placeholders in the VM, the forward gone; an
  interrupted login takes its forward away.
- Docs: Logging in with devvm agent login (using/coding-agents.md),
  the Commands page, the questions table, Contributing's e2e, the cli
  skill's tree, AGENTS.md; the CLI reference.

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 12:10:45 -07:00
w3cjandClaude Opus 5.5 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 bc8ed10156 fix(vm): devvm gc --orphans forgets a VM under its folder's creation lock
Leftovers.Forget takes the folder's creation lock (holdCreate) for its
re-check and teardown, so a VM a devvm is making again, its state written
before its backend has it, is refused (create_running) however old its
state; gc --orphans and retention's orphans.age both go through it.
TestForgetHoldsCreateLock failed first. TestMoveUnsafe covers a move's
refusal of an unsafe folder, which no test did (fails without
checkUnsafe in finder.move).

Docs: the creation lock in internals/overview.md and space.md's
leftovers; commands.md's moved folder says the agents' sessions keyed by
the folder's path stay under the old one (claude --continue/--resume,
codex resume --all).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:15:03 -07:00
w3cjandClaude Opus 5.5 e9ca7a4859 feat(vm): a moved or renamed project folder keeps its VM
A VM's files and machine are keyed by its name's hash, which stays; what
moves is the state's dir. The finder finds a folder's VM by the state
that records its path (finder.state: the path's hash first, then every
state, recorded), so a VM moved there is found from the new path alone,
and links by path (project.ForDir) match the recorded dir.

When the folder has no VM, the finder looks through the states for one
made for this folder at another path (moveHere, move.go; the match is
here.movedFrom): the same folder identity (device, inode, birth time),
the folder this user's, its identity unique (platform.UniqueFolderID:
an ID with a birth time, and on macOS APFS or HFS+), another recorded
path that's gone on the folder's device or only a symlink to here, its
creation finished, not a --clone VM. One match is offered: in a terminal
move_vm, [y/N]; without one vm_moved_here, naming devvm adopt; devvm
adopt --force moves it without asking. Several matches warn
(vms_moved_here) and move none. Never automatic.

The move (finder.move) refuses a folder no new VM may have
(checkUnsafe), holds the creation locks of the VM and of the folder's
would-be new VM, checks again that no state records the folder and
that the folder is still the one asked about (move_folder_changed),
stops a running VM as devvm stop does, then records the path and
identity under the VM's lock, refusing a state that changed meanwhile
(create_running); vm_adopted says so. .git protection's record is kept:
.git, its identity and its uchg locks move with the folder.

The project folder's mount is now part of backend.Want (Want.Project,
Instance.Project, Apply), so the next start mounts the folder where it
is: Lima's wantEdits rebuilds .mounts in its one edit when the project
mount or the agent folders differ (mount.project). A VM running with
another path asks to restart (Y/n) and otherwise warns
(next_start_folder, folder_next_start).

A new VM at the old path can't use the moved VM's folder, so newName
takes the first of the path's names whose VM folder holds no state
(project.Nth: the hash of the path, then of the path and n).

devvm adopt [VM]: with VM (by name or alias, as devvm rm VM), moves a
VM whose folder is gone or not connected to this folder, for a copy on
another disk (a new inode, never matched on its own): adopt_move_vm
[y/N], --force, adopt_move_refused without either; refuses a --clone VM
(adopt_clone), a lost machine (rm_vm_lost), an unfinished VM, a folder
still there (adopt_folder_there) and a folder with a VM of its own
(adopt_has_vm). It clears .git protection's record, as the copy's .git
is another.

rm_vm_state_mismatch is gone, as a dir needn't hash to the name any
more: devvm rm VM acts as devvm rm only on the folder's own VM
(finder.folderVM), and a VM whose state names a folder with another VM
of its own is refused as one whose folder is there.

macOS's FolderID has the folder's birth time too, as Linux's has.

Security review (security-audit skill, focused, with an independent
read): inode reuse needs a unique identity (birth time; APFS/HFS+ on
macOS), the same device (in the ID) and the old folder gone; another
user's folder never matches (its owner checked); a copy has a new inode
and never matches; links and groups go by name and stay, and links by
path take the recorded dir, a move refused when another VM records it;
a symlinked cwd is resolved first, and a symlink at the old path counts
only when it resolves here; .git protection's record stays for a move
and is cleared for a copy; agents' mounts are unchanged (only the
project mount changes); a VM can rename only folders inside its own
mount, which it already writes. Fixed from the review: a folder swapped
at the path while devvm asked was moved to (now move_folder_changed);
macOS device:inode could collide with a later volume given the same
device number (birth time added); a running VM kept the old path's
share, which a new folder made there would reach (the move stops it
first); a move to the home folder or into devvm's own folders (now
checkUnsafe). FolderID's format change makes VMs and .git records made
before it look like other folders (adopt them, or make them again).

Tests: TestMovedFrom (table: gone/present, same/different device and
inode, a non-unique ID, another user's, a clone, unfinished),
TestMovedAway (gone, a folder, symlinks here/elsewhere/dangling),
TestMoveHere (refused, no, yes, found by its dir, stopped, the new
mount at start, a restart for a running old mount, a new VM at the old
path by its next name), TestMoveFolderChanged, TestAdoptMoved,
TestMoveHereSeveral, TestAdoptVM, TestUniqueFolderID, ForDir and Nth in
project, wantEdits' moved project, the conformance start's moved
project; move.txtar (refused, no, yes, found, Lima's mounts edit, a new
VM at the old path, adopt VM of a copy); rm_vm.txtar's hand-edited
dir; e2e project: mv, refused, a yes in a terminal (script), the home
file kept, the new path mounted alone, moved back with adopt --force.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 09:30:05 -07:00
w3cjandClaude Opus 5.5 0d9154bd8a refactor(vm): one handle for the VM a command acts on, and Env's parts made once
The finder returns a target (target.go): the VM's folder, state, backend
and the instance its backend gave the finder, which each start
(starter.start, target.started, backend.Apply) and stop (target.stop)
then sets as the backend has it, without asking again. It runs what a
command does with that VM: exec, shell, shellDir, running, stop,
ensureRunning, ownSSH, sshHost and widen. Stop, network, ports, size and
ssh-agent read the finder's instance instead of asking again; git-protect
reads it again after its question (refresh), as before.

Env's parts are made once over it (wire, from NewEnv): the finder,
starter, linkRuns, syncer, remaking, clones, vmFolders, devcontainers,
creation, and the command types one reaches from another (launcher,
lifecycle, vmTools, groups, links, leftovers). The 110 conversions
between the package's struct{ *Env } types (finder(e), Launch(e),
starter{e}, creation{Launch(e)}...) are gone: none is left outside wire.
setUp and Groups.warnUnenforced went, their callers using setUpVM with
the target and Links.warnUnenforced; seedClone, gitSSH, fetchUnfetched
and setUpVM take the target. The fake backend applies a Want with
backend.Apply too.

TestTargetAfterStartAndStop: a target's instance after a start and a
stop is the backend's, a start reading it once and a stop not at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 08:18:35 -07:00
w3cjandClaude Opus 5.5 c1ca05bd94 refactor(vm): housekeeping and exports move out of cli
vm.Housekeeping owns what devvm keeps besides its VMs, and cli only
renders what it returns: ListImages and ShareListing (the tool targets,
worked out once in ToolTargets, for devvm images, gc, space and
retention), LockGC, PlanGC (one inventory per run: the states, with
--orphans the backends' lists too), GCPlan.Apply (returns GCDone, what
it deleted in order, an image the backend refused among it) and Retain.
gc runs on the run's one registry throughout, --caches included.

vm.Exports owns an export's name (parsed without a regex), the list,
the .folder file written and read, deletion and a folder's newest
export; it replaces lifecycle.go's name, history.go's parse and
retention's handling.

One orphan definition: devvm space's leftover state is now what
devvm gc --orphans would forget (Leftovers.FindIn, on space's own
inventory), so a VM whose state changed in the last hour, one made in
another Lima home and one being made again count as state, not
leftover, and the row's retention uses the orphan's Changed time.
space.txtar pins it against gc --orphans' list.

gc's Short names old files and the Nix cache over its cap; the CLI
reference is regenerated. using/space.md says what leftover state is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 03:29:38 -07:00
w3cjandClaude Opus 5.5 e6f64dae31 refactor(vm): one VM inventory per run
vm.Inventory (internal/vm/inventory.go) holds each project VM's state,
backend and Instance, read in one place: ReadStates for the states
alone, ReadInventory (UsedBackends or AllBackends) for the backends'
lists too, each within the host's list wait (30 s), with the backend's
Check saying why a list failed. It replaces Env.mounts, recordedVMs,
vm.List and vm.ToolsInUse, linkstate's clientStates listing, the
secret list's, Leftovers.Find's (and backendVMs), cli/space.go's two
(backendRows' list, vmFolders), images' state.Backends and sshconfig's
running list: sshconfig.Write takes the inventory's Running VMs.
state.ReadAll reads each VM folder on its own (only the inventory calls
it, a structure-test callers rule); state.Backends and Registry.Used go.

One failure policy:
- a backend that can't list fails a listing (Inventory.Err) only when
  some VM's state names it: devvm ls and the ssh config fail, and the
  ssh config stays as it was rather than lose that backend's entries;
  space and gc --orphans name it and leave its VMs alone;
- an unreadable vm.json is its own row: ls lists the VM with its name
  and status alone and warns (vm_state_unreadable); links, the secret
  list, rm VM and link targets leave it out; gc --orphans never takes it
  for an orphan; ToolsInUse and Mounts (images, gc, space, the SSH
  agent's mounted-key check) fail on it, naming the file;
- FolderOf is bounded (5 s): a folder on a hung share is there.

Mounts come from the states alone, stopped VMs and agents' folders
included, so the mounted-key check asks no backend. ui.Table shows every
cell through msg.OneLine, so ls's cells can't move the cursor or break
a row.

Docs: internals/overview's listing, troubleshooting's file devvm can't
read, ssh's mounted keys, contributing's owners table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 02:30:53 -07:00
w3cjandClaude Opus 5.5 1b9755a7df refactor(vm): one finder for the VM every command acts on
finder.target(ctx, need) finds the VM a command acts on: the folder's
own, the nearest parent folder's (resolveFolder), or one named for
devvm rm VM. Its need says what the command needs (has: any, the VM,
its machine, made; own; folder; noVM), and need.check is the one place
that refuses a missing VM, one made for an earlier folder at its path
(found.other, from sameFolder), a pending remake and an unfinished one.

It replaces Env's find, own, findExisting, existing (10 callers),
folderVM (7 callers) and the linkVM, groupVM, portsVM and agentVM
wrappers, Net's policyVM, up's and toRemake's checkFolder, and rm VM's
inspect by name. devvm rm VM refuses a state whose folder doesn't hash
to the VM's name (rm_vm_state_mismatch), so a changed vm.json never
sends it to this folder's VM.

The environment reads the folder devvm runs in lazily (finder.dir), so
devvm build, rebuild, images, space and gc run from a deleted folder;
NewEnv no longer fails.

Guard: the structure test's callers rule, state.ReadHash and
project.Parents called only in internal/vm/finder.go outside their
package and tests. Tests: TestFinder (need x none, own, parent, nested
repo, other folder, unfinished, remake pending with and without its
machine), TestRmVMFolderOfAnother, callerCases, no_folder.txtar and
rm_vm.txtar's mismatch case (its fixtures' hashes now match their dirs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 01:52:45 -07:00
w3cjandClaude Opus 5.5 e132a29b5a refactor(cli): one per-run app holds the run's services
NewRoot makes one app for the run's UI and hands it to every command.
The app makes each service the first time a command asks for it and
keeps it, or its error, for the rest of the run: devvm's folders
(dirs), a test build's overrides, the secrets store, the backends'
registry, the shared tools, the VM environment (vmEnv) and the image
builder of the backend new VMs get (builder). The retention that runs
before a command and the command itself share them.

- paths.FromEnv: 23 of 24 calls go through a.dirs; partNames, which the
  parser's flag and word checks call before any command, keeps its own.
- The registry is made once (8 newRegistry calls and newEnv's).
- builder(u) (6 calls) and cli's newBuilder are gone: a.builder and the
  per-backend builders in images, space and gc are vm.Env.Builder,
  exported, the only builder. setup's feature choice takes a build.Env
  of its folders and prompts alone.
- The shared tools are made once (newTools and vm.NewEnv's), and the
  secrets store once (companyProxy's, newTools', vm.NewEnv's and
  _proxy's): vm.NewEnv takes the run's tools and store.
- withEnv (46 calls) is a.env; autoRetain, retainOrphans and gc
  --orphans use the run's VM environment.
- thisHost and readOverrides' other callers read the overrides once
  (a.host); space and gc --caches time out on the registry's host.

TestAppMakesEachServiceOnce checks that one run makes each service once
and that the VM environment and builder share the run's registry and
tools; TestAppKeepsAFailure that a failure is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:53:51 -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 40d6f45296 fix: the phase review's findings in --clone, --from's output check and tool builds' CAs
- --clone refuses a symlink anywhere in objects or refs (a pack folder, a
  loose object's folder), not only at their top, which could copy another
  repo's objects into the VM.
- A worktree's seed push sends its upstream only when it is one ref: a
  branch.<name>.merge pattern (refs/heads/*) pushed every branch.
- The rm/clone off fetch passes --refmap=, so a remote the repo names after
  the clone's address can't update branches outside saved/devvm/*.
- Undoing devvm clone off checks .git (gitprotect Check) before its locks
  come off, as leftBehind does: a clone VM's .git is never checked again.
- --from's converted disk must have its first 1024 bytes zero before the
  ext4 superblock, so a qcow2 or VMDK header can't sit in front of one; the
  glibc file is checked a plain file before it is read (a link to a FIFO).
- Tool builds get the CAs' variables from the backend (Trust.Env), as image
  builds' steps do; trust.CAs.Script, the caller-side copy, is gone.
- image.isAgent unexported (used only in image).

Tests: TestOwnRepo (pack folder, loose folder), TestSeedRefs (a pattern
upstream), TestCloneRm (a remote named as the clone URL), TestSetCloneUndo
(git_replaced on undo), TestCheckConverted (qcow2 before a superblock, a
short disk, glibc a link to a FIFO), TestBuildToolsTrust. Docs:
internals/git-protection, using/clone, internals/images, internals/design
(the pin's name). Coverage baselines raised (darwin, linux).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 18:01:00 -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 7dba353351 fix(agentlogin): Redact parses settings files whole and scrubs what ~/.claude.json's servers lose
A VM with network policy got secrets from the agents' settings files that
Redact couldn't read or didn't look for: TOML lines it couldn't parse
(multi-line arrays, quoted dotted keys, spaces around dots) were copied as
they were, and JSON's string lists, URLs and env values under names that
don't look secret were never scrubbed.

Redact now parses each file whole (JSON with UseNumber, TOML with
BurntSushi/toml), refuses one that doesn't parse, and writes the copy from
what it parsed, through one walk for both formats: values under
secret-looking keys, and lists and tables under them (but key bindings);
every value of env and headers tables (env, environment, headers,
http_headers, shell_environment_policy.set), but references, paths, URLs
(scrubbed, or whole under a credential's name: credName) and true, false
and numbers up to five digits; scrubURL for every URL; scrubArgs for every
list; known key shapes anywhere. scrubArgs also scrubs URLs in arguments
and in --flag=URL, for ~/.claude.json too.

Claude Code's own settings env (settings.json's top-level env) keeps its
documented configuration variables (claudeEnv: ANTHROPIC_MODEL and the
model families, CLAUDE_CODE_*, DISABLE_*, MAX_*, *_TIMEOUT_MS), unless the
name says it's a credential (credName: KEY, TOKEN as a word, SECRET, PASS,
AUTH, CREDENTIAL, COOKIE, HEADER), so Claude in the VM keeps its model and
limits. MCP servers' env and headers keep no value.

Tests: TestRedactTOMLLeavesNothingUnread, TestRedactJSONArraysURLsAndEnv,
TestRedactClaudeEnv (failing before), TestRedactTOML and TestRedactRefuses
updated; sync.txtar's unreadable config.toml is now one that doesn't parse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:45:38 -07:00
w3cjandClaude Opus 5.5 4a782085b9 test: raise the linux coverage baselines, and network.txtar's proxy follows a hostagent that lasts
- linux.txt raised from Fedora's mise run coverage (backend, lima,
  build, cli, docgen, gitprotect, image, netpolicy, paths, ports,
  project, proxy, secrets, settings, sshconfig, state, trust, vmssh).
- network.txtar's first network-policy launch makes the test's runner
  its hostagent, so the proxy that follows it is still running when the
  ps check looks under load: the stub's hostagent is devvm itself,
  gone at once, and the proxy ended within a lifeline tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:15:12 -07:00
w3cjandClaude Opus 5.5 8d00c42e14 fix(netpolicy): a VM's CAs are readied under a lock and deleted once its policy is off, and the proxy refuses minting GitHub credentials in absolute form too
- trust.InitCA takes the caller's ctx and holds the CA folder's lock
  (paths.CA.Lock, vms/<hash>/run/ca/lock), so two launches of one VM at
  once never leave a key and a certificate of different runs
  (TestInitCATogether failed first, TestInitCACancelled, TestInitCAMismatched).
- netpolicy.Proxy.Unconfined: a VM's first start without network policy
  stops its proxy and then deletes its CA folder, keys and all, under
  that lock; a proxy that won't stop keeps them (TestUnconfined,
  network.txtar).
- The proxy's forwarder refuses GitHub calls that make a lasting
  credential for every HTTPS request, so absolute-form https:// requests
  get the 403 that intercepted tunnels got (TestForwarderRefusesMinting
  failed first); the minting paths also match /repositories/ID and
  /organizations/ID. Each forwarder's idle upstream connections close
  when its request or tunnel ends.
- e2e: the build proxy check expects the run log's devvm:<key>@ and no
  proxy key in the log.
- Docs: design.md's CA threat check, network.md, overview.md's locks,
  space.md, safety/network.md. Baselines raised (darwin).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 13:57:19 -07:00
w3cjandClaude Opus 5.5 8670db2df9 refactor(project): trim project to the folder, its VM's name and its unsafe folders
What a folder's files call for (detectFiles) moves to internal/vm's
detect.go, beside the parts a new VM gets. The set-id check and
SSHRemote move to internal/hostsafety, beside gitprotect. The set-id
walk skips .git folders and runs only once the VM is stopped (devvm
stop, or a launch that finds it stopped) and when a VM is made, never
at a launch into a running VM: measured on APFS at about 5 us a file,
1.0-1.3 s for 220,000 files, 65 ms for a 20,000-object .git alone.

internal/paths owns resolving and comparing host paths (resolve.go):
Physical (every link, as far as the path exists), PhysicalParent (the
folder's links, the last element as named) and, for a path that must
exist, filepath.EvalSymlinks itself; Within (the folder or inside it)
and Below (inside only). project's Unsafe and Parents, sshagent's
mountedBy and recordedPath, Lima's Seatbelt paths and QEMU's PATH
search, and the home copy's skips use them.

Tests: TestPhysical, TestWithinAndBelow, TestSetIDOnStop (named at
creation and stop, not at a launch into the running VM; not in .git),
SetIDFiles' .git and missing-folder cases; detect's and hostsafety's
tests moved with their code. Docs: when set-id files are named, on the
user, safety and internals pages; the contributing page on the
resolvers; AGENTS.md's layout rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 13:16:36 -07:00
w3cjandClaude Opus 5.5 74f41b0efb refactor(image): one shared-tool table
image.SharedTools, a table of image.ToolDef (name, kind, members, the
files that call for it, its installer), is the one list of shared
tools. image.Toolchains, image.Agents, GroupTools, IsTool, IsAgent and
SortTools derive from it, and so do project.DetectFiles' toolchain
markers (the nix layer's own files stay in project), the lock's rust
case (image.NoDownload, for a tool rustup installs) and the
devcontainer features devvm maps to a toolchain.

Tests: TestSharedTools (the views, NoDownload, each member once),
TestSharedToolsPolicies (shared-tools' policies are one per shared
tool), and TestConfigTools now checks mise.toml's tools against the
table's members. The contributing page names the table and what adding
a shared tool takes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:53:40 -07:00
w3cjandClaude Opus 5.5 12d1a84149 fix(redact): proxy passwords stay out of Lima's hostagent log and guest commands' output
Lima's hostagent logs a proxy variable's value, password and all, as it
starts a VM (Lima's cidata setupEnv: a loopback proxy pointed at the
guest's gateway, an override of the system's value, or a value it can't
parse), into <lima home>/<vm>/ha.stderr.log. For a VM without network
policy that's the shell's HTTPS_PROXY. devvm's run log already redacted
the copy limactl start prints; Lima's own file kept it.

Start now redacts that file once limactl start ends, started or failed:
each password becomes as many "*", in place. Lima creates the file with
os.Create (no O_APPEND) and the hostagent keeps writing at its own
offset, so the file keeps its length and every other byte, and Lima goes
on where it was. Keeping the password out of the hostagent's
environment would keep it out of the guest too (Lima writes the guest's
/etc/environment from it), so apt and curl there couldn't use the
company proxy. A file devvm can't change warns (lima_log_unredacted).

Output written through UI.LogWriter() (guest commands: a VM's setup, the
home folder's copy, devcontainer.json's commands) now goes through the
run's one redacting writer, flushed at a logged command's start, at
DieLogged and at the run's end.

The patterns and both redactions have one owner, internal/redact (stdlib
leaf): String, the run log's (moved from ui's redact), and File.

- redact.String, redact.File; ui: LogWriter's redacting, flushLog;
  lima: redactLog; message lima_log_unredacted.
- Tests: TestLogWriterRedacts (fails without the fix),
  TestStartRedactsTheHostagentLog, TestString, TestFile; e2e's network
  section restarts its VM without network policy behind the run's
  loopback company proxy, its fake password read from a file: the guest
  has and uses the proxy, the run logs hold <password> only and
  ha.stderr.log stars only.
- Docs: troubleshooting's run log, network policy's Without network
  policy, Contributing's layers and e2e network section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:52:42 -07:00
w3cjandClaude Opus 5.5 866b9e0930 fix: the processes devvm starts don't inherit the files it was given
A terminal, an editor or a test harness can give devvm files past the
standard three without close-on-exec (testscript's ttyin puts a pty on
descriptor 3), and devvm's background processes then held them, keeping
that terminal or pipe open as long as they ran: on Linux a script hung
until its timeout. devvm now marks every file it was given from
descriptor 3 up close-on-exec as it starts (platform.CloseInheritedOnExec,
called first in main), which covers every process it starts, Lima's
included, and keeps them open itself.

TestCloseInheritedOnExec re-runs the test binary with an extra file on
descriptor 3, starts a detached process and checks it doesn't hold it
(/proc/<pid>/fd on Linux, lsof on macOS); layer_add.txtar now answers
yes in a terminal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:34:42 -07:00
w3cjandClaude Opus 5.5 9568e6c47f fix(proxy): agents' OAuth refreshes go through the VM's proxy's company proxy
A VM's proxy refreshed Codex's and opencode's OAuth logins with net/http's
environment proxy alone, so with config.toml's [proxy] the refresh went
directly, and failed behind a company proxy. The proxy now makes its
upstream's route for its own requests as it starts (proxy.Upstream's
WithPassword, with the proxy secret it looked up, then Route) and gives it
to each lookup in the lookup's context; agentlogin's refresh sets it as its
transport's proxy. A proxy without an upstream routes the refresh directly,
as it does the VM's requests.

- proxy.WithRoute, proxy.RouteOf; upstreams.host; secrets.route.
- Tests: TestRefreshGoesThroughTheProxysRoute (fails without the fix),
  TestLookupRoute.
- Docs: How it works' Through a company proxy, network policy's Behind a
  company proxy, the proxy's README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 02:03:11 -07:00
w3cjandClaude Opus 5.5 6379e52c54 refactor(vmssh): a backend's ssh target carries its key, and vmssh.FromTarget checks it for links and the ssh config
backend.SSHTarget has Key, the one private key file that logs in (Lima:
its ssh config's first IdentityFile), and Options no longer carry
IdentityFile. vmssh.FromTarget is the one check of a target: a user and
an absolute key that can't break an ssh config line, on a port of the
host's loopback (vmssh.Loopback, 127.0.0.1) and nowhere else.

Links' linkSSH uses it in place of its own IdentityFile parsing and
checks. The ssh config uses it too, which adds the loopback check it
lacked: a VM whose backend names another address, a name, no user or no
key gets no entry, so an editor's ssh (and a forwarded agent) never
goes elsewhere. Entries write Hostname, User and IdentityFile from the
checked target.

Tests: TestFromTarget (vmssh); TestWriteNoAddress gains other
addresses, a name, 0.0.0.0, no user and no key (failed before on the
addresses); TestSSH (lima) checks Key is the first IdentityFile alone;
the conformance reach check needs a user and a key.

Docs: using/ssh.md says entries reach the VM on 127.0.0.1 alone;
internals/design.md says links take a VM's ssh only there, and names
internal/vmssh's path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 00:28:17 -07:00
w3cjandClaude Opus 5.5 2a23197372 test(backend): a conformance suite every backend runs, on the fake, the limactl stub and real Lima
backendtest.Conformance(t, factory) checks backend.Backend's documented
contract, one subtest per check on a new backendtest.Subject (the
backend holding one image, a folder of its own, Boots, Restart). Checks
that need a running VM skip with the reason when Boots is false, and
restart when Restart is nil.

Checks: caps, problems, host (Host); images, delete-image, key-files,
build-image (Images); create, create-refused, inspect-missing, stopped,
start-shrink, proxy-url, rename, delete (Machines); start, confined,
restart, reach, running-refused (running VMs); usage, strays, caches
(Housekeeping); guard (the registry's guard refuses through Images and
Machines alone).

Runs: TestConformance and TestConformanceWithoutBooting on the fake;
lima.TestConformance on the limactl stub (VMs start) and on real
Lima's dummy instances (skips without limactl; running checks skipped,
left to tests/e2e.sh). TestConformanceFinds checks ten broken fakes fail
the check meant for them.

Found and fixed in the fake: a start of a running VM gave it a new
start and confinement; Restart kept a NetProxy start's Confined; a VM
it made was confined while stopped or never started; CreateVM took a
missing image, a name over NameLimit, and left its size unset
(ImageVMSize); Rename took a name over NameLimit; SSH reached a stopped
VM. Preset VMs keep their old Confined answer, which other packages'
tests rely on. In the limactl stub: stop leaves ha.pid, and create and
clone made no instance folder. Real Lima: nothing.

Docs: contributing's How a backend plugs in. Coverage baselines raised:
backendtest 46.5 to 74.4 (both), backend 97.0, lima 89.5 (darwin).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 20:54:10 -07:00
w3cjandClaude Opus 5.5 329e31be1d refactor(secrets): the proxy looks secrets up in-process, from one versioned bindings file
The proxy no longer runs devvm secret get for a value: proxy.IO.Secret,
which devvm _proxy sets to secrets.Store.Get, looks a binding's value up
in the proxy's own process (Keychain, devvm's secrets folder, or the
agent's login file), so internal/proxy stays standard library only.
Config.SecretCmd (secret_cmd) and the hidden devvm secret get command go,
with secret_to_terminal and secret_read_failed; Main refuses a config
with secrets and no IO.Secret.

One binding type, proxy.Binding, with kind secret|login and a login's
agent, in proxy.BindingList ({"version": 1, "bindings": [...]}), written
by secrets.Store (Encode) and read by the proxy and RefreshFiles with
proxy.ReadBindings (private regular file, no link, 1 MiB, version and
kinds checked; an unreadable file has no bindings). It replaces
proxy.binding, secrets.binding and agentlogin.Binding; the kind replaces
the name-prefix classifiers in proxy.ttlOf, secrets.loginOf and
RefreshFiles' Lookup check; proxy.InterceptLines replaces
agentlogin.Hosts and RefreshFiles' host loop.

agentlogin's user-actionable errors are typed (ErrCodexNoKey,
ErrCodexNoChatGPT, RefreshError) and secrets maps them to messages:
codex_no_key, codex_no_chatgpt, codex_refresh_failed,
opencode_refresh_failed, and login_read_failed for the rest.

Tests: proxy TestSecretValueLooksUpInProcess, TestReadBindings,
TestBindingsUnreadableHaveNone, ttlOf by kind, Main refusing secrets
without a lookup and -secret-cmd, config refusing secret_cmd; secrets
TestGet by kind, TestLoginFailed; agentlogin TestCodexBindings (kind and
agent checked on every binding), TestGetErrorsSayWhatToDo; secret.txtar
and network.txtar on the new file and without secret get; e2e's network
section keeps the fake token off argv and checks no command prints it.

Docs: the proxy README (Secrets section), internals/network.md,
safety/network.md, using/coding-agents.md, contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:35:25 -07:00
w3cjandClaude Opus 5.5 361087f95a refactor(proxy): host-only modes out of proxy.Main, into agentlogin and trust
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:

- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
  File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
  keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
  MCPSecrets and Redact. The salt is a parameter, not a global or
  DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
  hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
  through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
  1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
  netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
  redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.

Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 14:47:06 -07:00
w3cjandClaude Opus 5.5 f4fd373439 refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend,
Caps, Features, Review/Require, the registry, backendtest.Fake), so
another backend is an addition.

State from a smolvm VM reads as an unknown backend (backend_unknown_vm,
gc_orphans_unknown); nothing migrates it. The image keys of
layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images
rebuild once.

Lima's port forwarder moves off smolvm's files first: newForwarderCmd and
forwarderMain from internal/cli/smolvmports.go to limaports.go, and
assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder
at run time, so no image key changes).

Removed:
- internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its
  registry entry, registry.Experimental and backend_experimental.
- The decider: backend.Decider/UsesDecider, Confinement.Decider and
  DeciderToken, internal/proxy/decider.go and its test, the proxy's
  -decider, -decider-to and -decider-token-file, netpolicy's
  KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in
  vm's forwarding and UsedPorts.
- backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and
  agent_unchosen_stop.
- vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped).
- paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's
  Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing
  called (a test helper now).
- ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and
  bump.sh's ubuntu_image, with its part of bump.txtar.
- assets/smolvm/ and assets/container/; the no-init-system branches of
  layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in
  features/desktop.sh and guest/ca.sh.
- Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh,
  creating_from_image, packing_image, pack_failed, backend_experimental,
  agent_unchosen_stop; descriptions naming smolvm reworded.
- Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and
  sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a
  failing or hanging Lima listing instead (the limactl stub's list-fails
  and list-hangs); the --backend smolvm examples; e2e's --backend smolvm
  and its section (about 1,130 lines), the smol_* helpers and the
  link section's backend switch.
- Coverage: internal/backend/smolvm's lines in both baselines.
- Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm
  notes (Ports on Lima now holds the forwarder's description), the
  backends table's smolvm column, every page naming smolvm, the README,
  the home page's backends art, and AGENTS.md's smolvm rows and gotchas
  (and the Docker bind-mount gotcha, which nothing refers to).

Kept: the docker layer, on Lima; --from's local Docker; --backend, the
BACKEND column and setup's backend choice, which the next commit removes.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:37:36 -07:00
w3cjandClaude Opus 5.5 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 2b25a0c7dd fix: the shared foundations' review: one Lima host address, a kill only for its own process, and the Linux baselines
The consolidation pass over the shared foundations:

- Lima's host address on its user-mode network, 192.168.5.2, is one
  constant, limaHost, which the VM's proxy URL and the build proxy's
  both use (proxyHostDarwin and buildProxyHost went).
- platform.LockFileShared had no caller: LockFileSharedWaiting with no
  waiting does its job, and its tests use that. image.ToolName had none
  either, and goes until the tools picker needs it. mise run deadcode
  lists only what AGENTS.md names.
- tools' writeNew, a third whole-file writer, goes: the share's .sha256,
  .target and idle files are written through state.WriteFile.

From the security audit of the phase:

- daemon.Proc.Stop sends SIGKILL only to a process whose arguments still
  say it's this one. A process still ending, whose arguments can't be
  read, is waited for; so is another process given the pid since whose
  arguments can't be read either (a setuid one, on macOS), which would
  have been killed. TestProcStopKillsOnlyItsOwn fails without it.
- forbidigo's signalling rule also bans os.Process's Kill and Signal
  outside daemon and platform; tests signal their own children, and
  devvm desktop's ssh child, not yet waited for, says why with a nolint.
  testdata/lint has a line for each. Contributing's checks table says so,
  and internals/network.md says which process SIGKILL goes to.

testdata/coverage/linux.txt is measured again with mise run coverage on
the x86_64 Linux host: it had no lines for fetch, shell and vmname, so
mise run test failed on Linux, and daemon was set by hand. arm64 (the
Linux host VM) agrees within a point. darwin.txt: daemon 97.8, tools
89.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 23:52:51 -07:00
w3cjandClaude Opus 5.5 5003d94cfb refactor: read HOME once, into paths.Dirs.Home
paths.FromEnv reads HOME, which must be absolute, and keeps it, cleaned,
as Dirs.Home; everything else takes the home folder from there. Six other
reads go: vm.NewEnv's and cli's devvm secret's os.Getenv("HOME"),
gitprotect.New's, Docker's and smolvm's os.UserHomeDir (Desktop's
settings file, the machines' location), and smolvm's Getenv("HOME")
(DiskDirs).

- vm.Env.Home and secrets.Store.Home are gone: both read Dirs.Home.
  secrets.NewStore takes the Dirs alone; gitprotect.New takes the home
  folder for ~ in git's paths.
- forbidigo bans os.UserHomeDir, with its line in
  testdata/lint/forbidigo.go; the structure test's owners check gains
  envOwners, HOME read only in internal/paths/dirs.go, with cases for a
  read outside it, through a field, in paths and in a test.

Tests: TestFromEnv checks Home (and a HOME cleaned), TestNewHome (~ is
the home New is given, not the environment's), TestDiskDirs checks
Location too. Coverage unchanged.

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:28:01 -07:00
w3cjandClaude Opus 5.5 2687eec488 refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns
devvm's background processes: Detach and Spawn (own session, no input,
reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status
file), Handle (signals through the process started), Proc (a pid file
checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL,
the pid file removed once stopped), readiness by status file (Ready,
WriteStatus, WaitReady: the pid and data, written in one line-ended
write, never another start's), Alive and Signal (no pid below 1), and one
lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content
equality, a bounded wait past what the file held first).

It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards'
pid, stop and start wait, the build proxy's process and log-read port,
links' link-session pid, stop and start, the proxy's watchLifeline and
vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess,
and the alive copies (netpolicy alive/signal, lima alive,
vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go:
the proxy and the forwarder say they're ready in a status file, and the
build proxy's port comes from its own.

forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside
internal/daemon and internal/platform, with its line in
testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS
and puts internal/daemon among the leaves; depguard holds it to the
standard library.

Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file,
groups refused, readiness, lifeline), characterisation tests first for
the proxy's, the forwarders', the link sessions' and the build proxy's
pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:34:18 -07:00
w3cjandClaude Opus 5.5 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 32aa8fe3e6 refactor: one parser and formatter for port lists, and a bad entry is refused, not port 0
backend owns port lists: ValidPort, ParsePortRanges, FormatPortRanges
and Ports.Has. They replace vmssh.ParseRanges and FormatRanges,
vm.portsValue, vm.ParsePorts's own regex and range checks, smolvm's
lists, netpolicy's forwarded parsing, publishedIn's and the forwarder's
range loops, and the 1-to-65535 checks in ParseLinkPort, desktop's
listener, the build proxy's log reader and Docker's checkProxy. The
proxy and devcontainer keep theirs for their layer rules. vm.ParsePorts
keeps only all, none and port_invalid.

fix(vm): PortsBackend ignored Atoi errors, so a bad entry in a ports
value (a state file edited by hand) became port 0, or a range ending at
0. It now returns port_invalid: a VM whose state holds one doesn't
start, devvm ports rm parses the old value first, and group links and
Published read such a value as none. TestPortsBackend's bad entries and
TestAddRemovePorts's rm case failed on the old code; TestStartBadPorts
covers the start.

Tests: TestValidPort, TestParsePortRanges, TestFormatPortRanges,
TestPortsHas; TestFlags checks a bad -only is refused. internal/backend's
coverage baseline is raised to 95.8.

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -07:00
w3cjandClaude Opus 5.5 088f180842 fix(vm): an interrupted start under network policy stops the VM and its proxy
Ctrl+C while Lima's start waited for a VM with network policy left the
VM running: the hostagent runs on its own from early in the start, and
an interrupt skips everything after the backend's Start, so the proxy
kept running and the VM had no record of its confined start. devvm ls
then showed it unenforced, and the next launch asked to restart it
confined. Env.start now registers a cleanup around the backend's Start
for a NetProxy start (undoStart): interrupted, it stops the VM and its
proxy and says so (interrupted_start). Lima's Stop stops a VM it reports
as Broken (a start cut short before its hostagent answers) with
limactl stop --force, which plain limactl stop refuses.

Tests: net_interrupted.txtar (tools add on a VM with network policy,
its start hanging with the VM running, Ctrl+C: VM and proxy stopped,
state kept, ls --json net on, the next launch confined and unasked);
TestStartInterrupted (vm); TestStubStopBroken (lima). The limactl stub
gains start-hangs-running. e2e network: Ctrl+C during the start stops
it and its proxy, and ls shows its policy on. Coverage baselines raised
for backend/lima, cli and msg.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 16:27:05 -07:00
w3cjandClaude Opus 5.5 06bed70fc7 test: record the Linux coverage baseline, and fix two tests that failed on Linux
testdata/coverage/linux.txt is each package's coverage from mise run
coverage on a Linux host (Ubuntu 24.04 arm64), so mise run test checks
Linux runs too.

Two tests failed there:
- secret.txtar checked that --no-input saved nothing by asking whether
  the secrets file existed, but on Linux an earlier step had saved one.
  It now checks that github keeps the token saved earlier, on both
  systems.
- smolvm's TestStartSSH looked for the proxy password "pw" in the
  arguments, which also held a random ssh public key whose base64 can
  contain "pw". The password now has a "!", which base64 never has.

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:25:09 -07:00