The history export keeps at most 2 GiB: past it, devvm stops the VM's
command, removes the partial file and keeps no export. devvm history
export fails with history_too_large; devvm rm, devvm rm VM and a remake
warn with it and go on. opencode's import of devvm's logins (devvm agent
login) is read up to 1 MiB, then stopped and refused
(opencode_import_too_much). Each VM command adds at most 4 MiB to the
run log (Env.vmLog), then a "devvm: truncated" line.
agentsave's bounded writer is the one owner, in bounded.go: it takes in
vm's capped, and with a cancel it fails every write past its max, so a
command that keeps writing ends. Its buffer is a field: embedded, it gave
the writer bytes.Buffer's ReadFrom, which io.Copy (os/exec's copy of a
command's output) used in place of Write, so no cap held, agent save's
128 MiB included. vmssh's capped had the same flaw, fixed the same way.
Env.HistoryMax, and DEVVM_HISTORY_MAX in a test build, stand in for the
export's cap in tests. The stub guest's opencode-floods and
history-floods switches write without end.
Tests: TestBounded (io.Copy too), TestVMLog, TestExportTooLarge,
TestRemakeHistoryTooLarge, TestImportLoginsTooMuch, TestShellFloods,
vmssh's capped through io.Copy; history_import.txtar (an export that never
ends: export fails, rm deletes and warns, the run log truncated) and
agent_login.txtar (opencode's import floods).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
msg.Fake's writers use cmp.Or in place of orDiscard, which only Fake
called, and LoopbackForward.Ports, which only its test called, is the
test's own listening helper.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chrome, Chromium and Firefox ignore the password in HTTP(S)_PROXY, so in
devvm desktop they asked for the proxy's username and password on every
site. The guest setup now writes devvm-local-proxy, which socat (now in
the desktop layer) serves on 127.0.77.1:3128, the VM's loopback alone.
For each connection it reads the request's head, drops the client's
Proxy-Authorization and Proxy-Connection, adds the VM's password and
sends it to devvm's proxy, then socat carries the rest both ways. It
takes only CONNECT HOST:PORT and absolute http(s):// requests, the
latter with Connection: close, so each connection's one request carries
the password. devvm-desktop starts it and points the Xfce session's
http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY at it; on Xfce,
Chrome and Chromium read those, and Firefox reads them first with its
default system proxy setting. A blocked host still gets the proxy's 403.
- proxy.LocalProxyAddr, LocalProxyPort, IsLocalProxyAddr: the one owner
of the address, sent to the guest as DEVVM_LOCAL_PROXY (vm.localProxy).
- vmssh: the port forwarder never forwards a server on 127.0.77.1.
- Tests: netpolicy's TestLocalProxy runs sync.sh's script (bash 3.2 on
macOS) against a fake proxy: the password replaced, Connection: close,
a tunnel, the 403 passed on, origin-form and junk refused with 400
before any connection; TestListeners, TestIsLocalProxyAddr,
TestLocalProxy (vm), sync.txtar. e2e desktop (tests/e2e.sh, still the
bash section): the session's variables, the listener on 127.0.77.1
alone, curl without a password to github.com, example.com's 403 over
CONNECT and plain HTTP, 400 for origin form, nothing on this
machine's 3128.
- Docs: using/desktop.md (Browsers), internals/desktop.md (The local
proxy), design.md's desktop note, ports.md, network.md's setup.
Security review (security-audit skill, guidance mode, local IPC and
proxy request handling):
- Fixed by design: devvm forwards every VM port by default, so a local
proxy on 127.0.0.1 would have put a password-less route to the VM's
proxy, and its secrets, on the host's localhost for every local user.
The forwarder now skips the local proxy's address on every port.
- The password goes only to the VM's proxy, whose address is fixed in
the script, never to an address a request names, in the one header
the local proxy adds; devvm's proxy strips Proxy-Authorization before
forwarding. It's never in a process's arguments (bash builtins only).
- Web pages: requests from a page to the loopback are origin form,
refused with 400 before any connection; a page can't send CONNECT or
an absolute-form line, and DNS rebinding changes only Host.
- No new power in the VM: the same password is in /etc/environment;
the script is mode 700, the VM user's.
- Residual: a program in the VM can hold up to 256 connections slowly
(30 s a line, 100 headers), only against the VM's own browsing; an
ssh -L the user types to 127.0.77.1:3128 would expose it, as any
forward they choose.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
vmssh.Checked(ctx, dirs, review, backend, vm, ReadKeys|PinKeys) is the one
way to a running VM's ssh: the review lets the backend's ssh through, its
SSH target passes FromTarget, and the VM's host keys for its current start
are read (KnownHostsFor) or pinned (PinHostKeys). It returns a Reach (SSH,
the backend's other ssh options, the record's start). A failure before the
host keys is an *UnusableError, the host keys' own wrap ErrNoHostKeys.
It replaces vm's ownSSH body (ReadKeys), Forwards.start (PinKeys; Forwards
gets a Review, from NewForwards) and sshconfig.Write (PinKeys, skipping
UnusableError and ErrNoHostKeys; the start now comes from the record, not a
second Running). Tests: TestChecked (refused, stopped, off loopback, read
before a pin, pin, read, another start).
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]>
apply closed a forward only once the VM stopped listening, so a port
another VM's start had since chosen (its ssh, proxy or desktop port, or a
listed port) stayed forwarded to this VM. Each report now closes a held
forward on a reserved port; while the reserved ports can't be read, the
forwards it has stay. Test: TestForwarderReservedLater (failed before).
Docs: internals/design.md's How many.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
devvm's ssh for a --clone VM's seed push and rm's fetch read devvm's ssh
config, so a url.*.insteadOf, pushInsteadOf or remote URL in the repo's
config could send them to another host; only the pinned host key
(HostKeyAlias, BatchMode) stood in the way.
Their GIT_SSH_COMMAND (gitSSHCommand) is now a shell function that
ignores the host, port and options git passes, and runs ssh with
vmssh.SSH's new CommandArgs: no ssh config (-F none), the VM's loopback
port, user and key from vmssh.FromTarget, and the host keys pinned for
its current start (vmssh.KnownHostsFor) under HostKeyAlias, with
BatchMode and nothing forwarded. In the VM it runs only git-receive-pack
or git-upload-pack, whichever git's last argument asks for, on the
clone's own path; anything else fails without ssh. Links' linkSSH is now
Env's ownSSH, which both use.
Tests: TestUpCloneInsteadOf (failed on the previous code),
TestGitSSHCommand, TestForwarderSSH's command args, clone.txtar's push
past an insteadOf, and e2e's clone section (an insteadOf on the first
push, and a git worktree's clone with only its branch and upstream).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tests ask the forwarder's process (proc) directly; mise run deadcode now
lists only the test helpers AGENTS.md allows.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
backend.Machines drops ForwardTarget and backend.ForwardTarget goes:
vmssh.Forwards builds the forwarder's target from the backend's SSH and
vmssh.FromTarget, the one check of a target that links and the ssh
config use, so 127.0.0.1 as an ssh target is checked in vmssh alone.
Lima's own copy of the check and its fixed _config/user key path go;
Lima's SSH gives the same user, port and key (its ssh config's first
IdentityFile, Lima's _config/user). The forwarder's spec embeds
vmssh.SSH, KnownHosts included.
The fake loses Forward and its method; the conformance suite's stopped
and reach checks keep SSH's. The registry's guard embeds the roles, so
it needed no change.
Tests: TestForwardsStart sets the fake's SSH target and gains the
targets FromTarget refuses (another address, a name, 0.0.0.0, no user,
no key, a relative key, no port), each warned as ports_forward_failed
with no forwarder; TestForwardTarget (lima) goes, and TestSSH checks it
runs only limactl list. The up tests' fake has a loopback target, so
their calls include the ssh config's entry and its host keys; staged
finds the setup's Exec by its command.
Docs: internals/backends.md, internals/design.md and contributing say
the forwarder takes the backend's SSH, checked by vmssh.FromTarget.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
vmssh owns a VM's host keys: PinHostKeys reads them from the running VM through its backend (at most 64 KiB within 30 s) once for each start, into one record in the VM's folder, vms/<hash>/run/known_hosts (paths.VM.KnownHosts), whose first line names the start it was read for (backend.Run.ID). A record of another start is read again, keys read while the VM started again aren't recorded, and ErrNoHostKeys says none can be pinned. KnownHostsFor returns the record for the current start without reading, for links' sessions; ForgetHostKeys removes it before each start. ParseHostKeys is the one parser, for every key type: a line is kept only when its key decodes, names its own type and has more after it, and certificates, markers, patterns and anything else are dropped.
The ssh config's entries, the port forwarder (-known-hosts), links' sessions and a --clone VM's git all check the VM against that record. sshconfig's own parser, recordHostKeys, changeKnownHosts, HostKey and ForgetHostKeys go, with the shared known_hosts and its lock (Dirs.KnownHosts, Dirs.KnownHostsLock): a record per VM, each written whole, loses no other VM's keys. The forwarder's ports.known_hosts copy and Forwards.HostKey go, and teardown leaves the record to the VM's folder. paths.Dirs's method limit drops to 47.
Tests: TestParseHostKeys, TestPinHostKeys, TestPinHostKeysNone, TestPinHostKeysTogether (vmssh); TestForwardsStart and TestForwardsRun use the record; TestWrite reads keys again after a start, TestWriteUnreadableRecord (sshconfig); TestLinkConn refuses a target without a record and never reads one; up_test's call lists. The limactl stub shows a wire-format ed25519 key per VM. testscripts ssh (a launch keeps the record, a restart reads it again), up, existing, host_code, clone and layout updated; e2e's project and link checks read the VM's record. Docs: internals/security.md, design.md, overview.md, ports.md, lima.md, backends.md, git-protection.md, using/ssh.md and space.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
backend.Backend is Name, Caps and four roles, each required:
- Host: Problems, NameMax, Location, DiskDirs, Floors
- Images: BuildImage, Images, ImageSize, DeleteImage, BuildTools,
ToolFormat, KeyFiles
- Machines: CreateVM, Start, Running, ProxyURL, Stop, Delete, Rename,
List, Inspect, Exec, Shell, SSH, ForwardTarget
- Housekeeping: Usage, Strays, DevvmCache, DeleteCache
The optional interfaces Lima implemented (KeyFiles, Storage, Locator,
UsageReporter, StrayFinder, CacheCleaner) are gone into the roles, and
their callers call the methods directly; Forgetter stays the one
optional role, found with backend.As. Running(ctx, vm) returns a
backend.Run (ID, Confined, Lifeline) in place of StartID, Confined and
Lifeline. Space.Check, Space.Warning and LocationOf take a Host.
lima.Lima keeps its fields, Name, Caps and its shared helpers (14
methods), and embeds host, images, machines and housekeeping, each over
the Lima it's part of (withRoles); backendtest.Fake is split the same
way. The guard has every role's methods, its own for the ones it guards.
Structure test: max-methods counts an interface's declared methods too;
Lima and the fake leave largeTypes. Tests: TestRunning, TestGuardRoles,
TestAs (Forgetter), TestFakeRunningAndNone, two TestRulesFail cases.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>