project.Unsafe's Holds and Inside compared a project folder with the home
folder and devvm's config, data and Lima folders by name alone
(paths.Within, paths.Below), so on a volume that ignores case, as a
Mac's does by default, a project at ~/.Config/devvm/layers passed both
and its VM got devvm's settings and layer scripts read-write. They now
compare by identity too: paths.In, the vm package's isIn moved to its
owner, finds the path or a folder above it to be the same folder as the
other, by device and inode, and paths.Under is In for the path's
folder. An empty folder holds nothing, so an unset one can't match the
working folder. sshagent's mountedBy, which refuses a key in a folder a
VM mounts, compared by name in the same way and uses paths.In now.
Each launch (Launch.Up, beside warnMounted) warns once, in one line,
when the project folder it mounts is inside an agent's folder in the
home folder or holds one (project_agent_folder), naming every such
folder from the agents' registry, with agent_import_project_inside's
detection (overlapsAgent). A --clone VM mounts nothing and gets no
warning.
Tests: TestUnsafeIgnoresCase, TestInAndUnder, TestMountedKeyIgnoresCase,
TestWarnAgentFolders; the case checks skip on a volume that tells
names apart by case.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenSSH's ssh-agent answers every request a forwarded connection sends,
so a VM that forwarded your agent or devvm's own (shared by every VM
that uses it) could remove all its keys (ssh-add -D), lock it with a
password of its own (ssh-add -x) or add keys without bound, denying the
agent to you and to the other VMs. Checked with a throwaway sshd and
ssh-agent: all three succeed over ssh -A.
Each VM's proxy now relays the agent its start chose on a socket of the
VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and
the VM's backend, devvm's own connections and the ssh entries for
editors name that socket. The relay passes on only
SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the
[email protected] extension (so destination-constrained keys keep
their constraints), answers everything else with SSH_AGENT_FAILURE,
reads messages whole up to OpenSSH's 256 KiB, carries at most 16
connections and closes one idle for 2 minutes. A filtering relay rather
than an agent per VM: it covers your own agent too, needs no copy of a
key or a passphrase per VM, and fronts hardware and app-held keys.
- proxy: Config.Agent/AgentSocket (checked together, absolute), the
relay in agent.go, listened before the proxy says it's ready; its
accept loop backs off after an error that leaves the listener open
(EMFILE), 5 ms doubling to 1 s, logging the first.
- daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only
package the proxy already imports, so the relay, the port forwarder,
the link session and a login's forward share one owner.
- netpolicy: Prepare takes a start's agent; a running VM's proxy keeps
its start's agent from proxy.json (relayedAgent); Stop deletes the
relay's socket.
- structure: paths.Dirs may have 62 methods (AgentRelay); the relay's
goroutines in goroutineSites.
- sshagent: Made.Relayed, which RecordStart sets on every start of this
devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK
included, and ReachOf(st,
start): a relayed start gets the relay (or none while it's down), a
start devvm didn't record (one outside devvm) gets none, or its
proxy's relay, and only an older devvm's recorded start keeps the raw
agent until its next start (runningConfinement, finder.inspect,
sshconfig).
- vm: LeftoverSockets also finds a killed proxy's relay socket for
devvm gc --orphans and devvm space.
- Tests: relay filter, wiring through Main, bounds and idle close, real
ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay,
RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar,
an outside start in ssh_agent.txtar, and e2e checks that the VM can't
remove, lock or add to your agent, nor the VM or an editor's
connection remove devvm's agent's keys.
- Docs: processes (the SSH agents, listeners), ssh, attack-vectors,
security, design, lima, overview, space, structure, proxy README,
AGENTS.md, CHANGELOG Fixed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
~/.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]>
internal/stubtest puts testdata/stubs first on PATH with a folder of its
own (New, New with only some stubs), reads and writes the stubs' files
(Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It
replaces the stub setups of the Lima, Docker and smolvm backends' tests,
vm's --clone tests and platform's Keychain tests, and the backends' own
execRunner, reset and touch copies. The structure test holds it to tests
and to importing only internal/msg.
msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers
and the errors.AsType checks that only read a message's ID or names;
msg.Recorder replaces the inline recorders tests set as Info, Warn or Say.
backendtest.Stored replaces the four stored fakes with disks.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory,
--disk, --ports, --network-policy, --no-network-policy) are the root's
own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown
flags. build, rebuild and images rm take --backend and --from;
images, gc and space take --backend as a filter of their own (images
and space now filter: only that backend's rows); doctor takes
--backend; restart and tools take none. ports -g is local on ports,
ports add and ports rm. No command has a persistent flag.
One name, one meaning: network log --follow loses -f (-f is --force's,
and gc --force gains it); the hidden secret get's --force becomes
--to-terminal. Flag defaults name the setting command (devvm size -g,
devvm ports -g, devvm setup --backend); descriptions lose then/also
openings.
Special values are words: an empty flag value (flag_blank) or an empty
argument (arg_blank) is refused everywhere, replacing features_empty.
Durations: state.ParseDuration (a whole number and m, h, d or w) for gc
--older-than, retention's ages and ssh-agent add --lifetime (which also
takes forever, via sshagent.CheckLifetime), with one message,
bad_duration, replacing gc_bad_age and agent_lifetime_invalid.
Blanks are checked with the other usage errors (checkCommand, before
checkFlags), and an unknown --backend NAME is a usage error checked
first too (checkFlagValue, against registry.Names, which a test keeps
equal to the registry's own).
Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning,
TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root,
setup, images, space, gc_history, retention, ssh_agent and network_log
scripts. Docs: commands.md (Flags and values), from.md, install.md,
images.md, space.md, settings.md, ssh.md, network pages; CLI reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ls, images, tools, size, ports, network (and -g), network log (and
--blocked), ssh-agent, git-protect, secret, history, space, retention and
doctor take --json: one JSON object on stdout with "version": 1 first,
messages on stderr (ui.DataOnly), lists [] when empty. Settings commands
only show with --json and refuse a value (json_shows_only). doctor --json
replaces --fixes: problems with key, fix (null without one) and message,
warnings, docker and every backend's features; it prints nothing else and
succeeds whatever is missing, and install.sh reads its problems with awk.
TestJSONShapes holds each command's field names and types. Each shape is
documented on its command's page, with the contract under Everyday
commands' Output for scripts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- devvm retention [KEY=VALUE...] shows every retention setting (off when
unset) and changes them; KEY=off turns one off, KEY= is refused and
nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
agent's keys once one is added (it starts no agent without one).
devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
refused). In a terminal it also asks for new VMs' network policy (ask,
on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
VMs read unless --network-policy or --no-network-policy is given.
Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
.golangci.yml:
- forbidigo bans context.Background and context.TODO outside internal/ui
and cmd/devvm.
- nolintlint requires each //nolint to name its linters and say why, and
reports unused ones.
- reassign (patterns .*) forbids setting another package's variables,
tests included.
- revive keeps its default rules and adds function-length (100
statements, 160 lines) and cognitive-complexity (75).
Fixes:
- Backend.Lifeline takes a ctx: smolvm's machine data-dir lookup runs
with the caller's.
- The proxy's TLS handshake with a VM uses the request's context, limited
to 30 seconds.
- OAuth token refreshes run within refreshTimeout (30 seconds).
- Tests use t.Context().
- Launch.create is split into plan, newVM.record and undoCreate.
- lima's TestStartConfined is split into helpers.
- smolvm's Terminal comes from its UI's StdinIsTerminal.
- Unused //nolint directives are removed.
- Fresh contexts that remain (an in-memory TLS parse, lookups shared by
every request, a test cleanup) each carry a nolint saying why.
Docs: contributing.md lists which lint rule enforces which convention;
AGENTS.md names the linters behind its Go conventions.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
internal/ui has no package state: ui.UI holds the streams, terminal
flags, run log, status line, cleanup stack and interrupt flag, and its
functions are methods. ui.Main makes the run's UI on devvm's own
streams, owns signals, recovers Die and runs the cleanups; ui.New makes
one on other streams. cmd/devvm passes it to cli.Execute, and every cli
command gets it through its constructor.
Only cmd/devvm and internal/cli import internal/ui (a depguard rule).
Each other package defines the small UI interface it needs, which its
constructor takes, filling fields tests set:
- gitprotect.New, secrets.NewStore, from.NewLookup: a warn func
- ubuntu.New: LoggedCmd, Note
- netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its
log lines drop control characters themselves (oneLine)
- sshagent.New: Info, Note, Warn, LogWriter
- tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup
- lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run),
WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too
- backends.Registry: lima's and smolvm's
- vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout,
LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields
- build.Builder: Terminal and LogNote fields
- sshconfig.New: its caller sets what it prints and asks
ui's tests build their own UI over buffers and run in parallel; other
packages' tests use small fakes; cli's unit tests a UI over buffers.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
SSH agent forwarding per VM: off by default, on (your agent, --ssh-agent
for a new VM) or devvm (devvm's own agent, holding only keys added to it).
devvm ssh-agent [on|devvm|off] shows or changes it from the VM's next
start; devvm ssh-agent add KEY_FILE [--confirm] [--lifetime D] loads a key
into devvm's agent and records it with its pinned fingerprint
(agent-keys); devvm ssh-agent keys lists them. Keys are loaded again on
launch (after a reboot or their lifetime), only while the file holds the
pinned key and isn't in a folder a VM mounts.
- internal/sshagent: Mode/Key, Agent (Ensure, Add, Keys), its messages.
- vm: --ssh-agent on create, applyAgent and checkAgent on relaunch,
ssh_agent_flag_ignored, devvm's agent socket at start, SSH_AUTH_SOCK
per mode for devvm's own connections, SetSSHAgent/SSHAgent.
- sshconfig: ForwardAgent from the VM's state; devvm mode forwards and
names devvm's socket (IdentityAgent).
- ssh_remote_hint names devvm ssh-agent on; skipped with --ssh-agent.
- Tests: sshagent table tests (the five bats cases) plus one with real
OpenSSH tools and a throwaway agent; vm tests; ssh_agent.txtar with
ssh-agent/ssh-add/ssh-keygen stubs; e2e project section "SSH agents".
The test task and e2e unset SSH_AUTH_SOCK.
- Docs: ssh.md agent forwarding and devvm's own agent, commands,
security, contributing; CLI reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>