49 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 e4b44b5994 fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.

The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.

TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:53 -07:00
w3cjandClaude Opus 5.5 bb0df957a0 fix(doctor): a broken VM state hides no other VM's warnings; Cursor's account services refuse more changing verbs
doctor's policy warnings (netpolicy.NotRules) listed the VMs with
state.VMNames, which fails whole for one state it can't read, so one
broken vm.json made doctor skip every VM's policy warnings. So did
devvm network's warnings about every VM (allowlists for -g, and
OtherBinaries). They now use state.ReadableVMs, the VMs whose state
reads, which leaves the broken one out and the rest in; VMNames stays
strict for what must count every VM, such as ports. A VM folder doctor
can't read got two warnings, vms_unreadable from state.VMFolderProblems
and vm_state_broken from vm.StateProblems; VMFolderProblems now leaves
it to the latter, which names the VM and why.

cursorChanges, the verbs refused in Cursor's DashboardService,
AutomationsService and BackgroundComposerService, gains merge, fork,
write, pin, unpin, rerun, confirm, request, release, acquire, activate,
deactivate, notify, make, open, ensure, park, copy, bulk, advance,
abort, wake, snapshot, seed, reply, opt, hand, fail, use, skip, decide,
unshare, undelete, unpublish, unprepare, unresolve, enroll, unenroll,
upgrade, suspend, switch, duplicate, dismiss, deregister, deliver,
decline, convert, close, append, execute, provision, mutate, inject,
finish, finalize, reassign, reinstall, reject, renew, reorder, reparent,
replace, resend, rmdir, report and record. Each was checked against all
1,463 methods of those services in 2026.11.17-f532c45, read and not
run: every one of the 102 methods they match changes something, none
only reads, and the CLI calls none (Submit, Resolve, Check, Batch and
the like stay off, as their methods read or the CLI calls them).

fixture_v010_logs' capped.sh loop and network.txtar's sleeps around the
squatting proxy now wait with wait_until.

Tests: TestNotRules and TestOtherBinaries (beside a state that can't be
read), TestVMFolderProblems, doctor.txtar (an unreadable VM folder, one
warning), TestCursorChangingVerbs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:45:34 -07:00
w3cjandClaude Opus 5.5 c1db911d1b fix(agentlogin): the Claude login reaches claude.ai's connectors (#61)
Claude Code lists a claude.ai account's connectors at
api.anthropic.com/v1/mcp_servers and reaches each at
mcp-proxy.anthropic.com/v1/mcp/<id>, with the login's access token. The
OAuth login's binding named api.anthropic.com alone, so the connectors'
requests carried the placeholder and were refused.

ClaudeOAuthBindings gives the OAuth login a second binding,
claude-connectors: the same placeholder, into Authorization for
mcp-proxy.anthropic.com below /v1/mcp/ alone. It has a name of its own
because the proxy looks a value up by its binding's name, and
secrets.Store.Get gives claude-oauth a Claude Code token in the login's
place but never gives one to claude-connectors, so a token, saved or in
devvm's environment (whose scope isn't checked), still goes only to
api.anthropic.com. The bindings file stays version 1.

Tests: TestClaudeCapture and the claude-oauth golden check both bindings;
TestClaudeBindings checks the connectors' binding gets the OAuth login and
never a saved or environment token (with the claude-oauth control);
network.txtar checks the VM's secrets.json and secrets.policy. e2e's
network section adds the connectors' host to its fake upstream: with the
claude secret, neither its placeholder nor the OAuth login's gets the
token there (the API, the control, does), and after the host's refresh
the connectors' host gets the refreshed access token.

Docs: the Claude Code login, the attack vectors' new entry for connectors
(deny mcp-proxy.anthropic.com to keep them from a VM), How it works'
bindings and threat lines, the agents' table, and Contributing's e2e
network section, whose refresh sentence was stale (the refresh succeeds).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 13:19:11 -07:00
w3cjandClaude Opus 5.5 1793353dd9 feat(proxy): Linux confines the proxy's child with Landlock and seccomp
Before it reads a byte of the VM's, devvm _proxy-child confines every
thread of itself through proxy.confineSelf on Linux: no_new_privs
(syscall.AllThreadsSyscall), Landlock from ABI 2 (TSYNC from ABI 8) to
its logs folder, the Nix cache and the resolver's files (never /, the
home folder or one that holds it), binding no TCP port (ABI 4), scoping
signals and abstract sockets (ABI 6, or ABI 6/7 with erratum 2),
refusing named unix sockets (ABI 9) and UDP but to port 53 (ABI 10);
then a hand-written classic BPF seccomp filter, installed with TSYNC,
that refuses with EPERM AF_UNIX socket/socketpair, listen, io_uring,
ptrace, process_vm_readv/writev, pidfd_getfd, a file's mode, owner,
xattrs and times by its path (chmod, fchmodat, fchmodat2, chown, lchown,
fchownat, the six xattr calls, utime, utimes, futimesat, utimensat with
a path), truncate, the keyrings (add_key, request_key, keyctl),
prlimit64 on any pid but 0, setpriority, ioprio_set,
sched_setaffinity, sched_setscheduler, sched_setparam, sched_setattr,
inotify_init, inotify_init1, inotify_add_watch, fanotify_init,
fanotify_mark, execve, execveat, fork, vfork, unshare, setns, bpf,
userfaultfd,
perf_event_open, clone for anything but a thread or with a namespace's
flag, and clone3 with ENOSYS; it kills a foreign architecture's call or
an x32 number. fchmod, fchown, ftruncate and utimensat on a descriptor
stay. It checks the confinement holds, then proxy.checkConfined, and
that it still reads the host's addresses, within 2 seconds, or fails
the start. A kernel without Landlock or seccomp leaves that part out;
the child runs and says so. The broker sets itself undumpable
(PR_SET_DUMPABLE 0). The Nix cache marks a file used through its
descriptor. The broker's start, and its life with the child, take a
reset of the socket (ECONNRESET, Linux's end of a socket closed with
frames unread) as the child's end, as EOF is (socketEnded,
TestHandshakeChildGone).

Built on the Seatbelt item's shared owner, proxy.Confinement:
- internal/landlock (new, stdlib only, Linux build tags): Self, Result,
  Floor, ABIPorts/ABISignals/ABIUnix, ErrUnsupported; landlock_linux.go
  (resolverFolders, refusedFolder, homeFolder), filter_linux.go (filter,
  asm, encode, archOf), seccomp_linux.go, self_linux.go (Self, check,
  refused).
- internal/proxy: confineSelf on Linux calls landlock.Self;
  landlockConfinement words it (By landlock, seccomp; Why
  no-landlock-or-seccomp, no-landlock, no-seccomp, landlock-below-abi4,
  landlock-signals; full from ABI 6 with seccomp and scoped signals);
  confineChild takes the child's needs and returns an error, bounded by
  confineWait (within, confineWith); checkConfined only where Landlock
  or Seatbelt confines files; confineStarted; IO.confine required, set
  by ChildMain alone; hostAddrs.check; touch_linux.go and
  touch_other.go (touchFile, undumpable); IO.dumpable for tests.
- devvm doctor: netpolicy.Unconfined's Linux warnings
  (proxy_unconfined_no_kernel, _no_landlock, _no_seccomp, _old_ports,
  _old_signals).
- Tests: TestFilter and TestFilterBytes (an interpreter of the program's
  bytes, amd64 and arm64, and the assembler's refusals), TestSelf (a
  real confined child: outside file, ssh-like unix socket, listen, bind,
  signal, chmod, chown, setxattr, utimes, truncate, a keyring, unshare,
  exec, clone3, and new threads, fchmod, ftruncate and futimens kept),
  TestKernel, TestCheck, TestRights (refusedFolder), TestArchNumbers,
  TestLandlockConfinement, TestConfineWithin, TestCheckConfined,
  TestConfineStarted, TestRunChildOn, TestUnconfined; network.txtar; e2e
  network's Landlock, NoNewPrivs and Seccomp check.
- CI: a nocgo job (CGO_ENABLED=0) for internal/landlock and
  internal/proxy.
- Structure test, depguard, goroutineSites; docs: the child's sandbox,
  processes (and its why-Go note on unsafe), design (the network row's loopback follow-up on Linux,
  other processes and /proc without Landlock), doctor's checks,
  troubleshooting, attack vectors, Contributing, the proxy's README,
  AGENTS.md, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 941c63c696 feat(proxy): the proxy's child runs under Seatbelt on macOS
On macOS the broker starts devvm _proxy-child through
/usr/bin/sandbox-exec -p PROFILE, by devvm's real path, with a
deny-default profile, so the child is confined from its first
instruction: devvm's binary to run and read, its folder's metadata,
dyld-support.sb, /usr/lib and /System/Library, the time zone and
resolver files, its logs folder and the shared Nix cache (regular
files only, no hard links, no folder removed, no flags, ACL, owner,
set-id or xattr changes), stat alone on the watched files and every
link on the way, trustd and trustd.agent, mDNSResponder's socket, TCP
and UDP out (loopback left to the floor: a rule for a loopback port
applies at once, which a profile fixed at the start can't follow),
sysctl but kern.proc, signals to itself. No home folder, no devvm folder but its
own, no Keychain, no other unix socket, no bind, fork, exec, signal to
or look at another process (process-info, the process list).

- internal/seatbelt: the shared owner of Seatbelt (Exec, String,
  Path, Links, ChildProfile, Sandbox.ProxyChild); sbString, sbPath and
  sandboxExec move here from the Lima backend, which uses them.
  ChildProfile refuses a relative path and the root.
- internal/proxy/confine.go: the confinement report every platform
  shares (Confinement, ParseConfinement, ReadConfined: one line of
  fixed words in run/proxy.confined, refused unless it parses, and
  unless it fits what the broker started the child with), the child's
  self-check (checkConfined: its broker's config must be refused), and
  the in-process hook (confineSelf, confineself_linux.go and
  confineself_other.go) for the Landlock follow-up.
- internal/proxy/childstart.go: startChild, childSandbox, childNeeds;
  IO.Seatbelt, set by devvm _proxy on macOS.
  A missing sandbox-exec, or one that failed before devvm's code ran
  (exit 65 or 71, or SIGABRT or SIGKILL, before the child answered,
  decided before the broker's own stop), starts the child again
  unconfined within the broker's 4 seconds, with a warning in
  proxy.log; any other failure fails the start. The broker makes the
  Nix cache's folders first. start carries how the broker started the
  child (Spawned).
- watched.get: a stat refused for want of permission reads through the
  broker each time (a watched link pointed elsewhere after the start).
- daemon.Handle.ExitCode and ExitSignal.
- devvm doctor warns for each running VM whose proxy's child isn't
  fully confined (netpolicy.Unconfined; proxy_unconfined,
  proxy_unconfined_unsupported, _no_sandbox, _sandbox_failed,
  _check_failed).
- Tests: TestParseConfinement, TestCheckConfined, TestReadConfined,
  TestStartChildSandbox (an over-claiming ready, SIGTERM),
  TestSandboxFailed, TestChildNeeds,
  TestWatchedStatRefused, TestUnconfined, TestString, TestLinks,
  TestChildProfile, TestProxyChild, TestChildProfileConfines (the test
  binary run again under the profile on macOS: flags, rmdir, the
  process list), doctor's report, ExitCode and
  ExitSignal; e2e network checks run/proxy.confined is full seatbelt
  on macOS.
- Docs: How it works' The child's sandbox, Processes, the design
  note's confinement and threat check (loopback as open work, other processes'
  details and kern.procargs2, the shared folders' flags, mDNSResponder's
  records, trustd.agent's trust settings, the fallback's signals, a
  ready that claims more), Troubleshooting's The proxy runs without a
  sandbox, Staying safe's escaping the VM, doctor's
  checks, Contributing's packages, the proxy's README, AGENTS.md,
  CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 aeea3135b2 feat(proxy): the proxy's broker and its child
A VM's proxy runs as two processes, as design.md's "The proxy's broker"
says: devvm _proxy, the broker, which keeps what only the host should
do, and devvm _proxy-child, which reads the VM's network and can be
confined by the follow-ups.

- wire.go: the protocol over one socketpair (close-on-exec from the
  start: SOCK_CLOEXEC on Linux, ForkLock elsewhere), length-prefixed JSON
  frames of at most 2 MiB, unknown fields refused, bytes as base64, one
  descriptor on a frame's first bytes (SCM_RIGHTS, MSG_CTRUNC breaks the
  rules), wire types for every secret (redact.Secret at once).
- broker.go: newBroker, the start (handshake: version 1 and each side's
  executable's SHA-256, within 4 s), the answers (value through lookups,
  kept 30 s or 5 min, a failure 5 s, dropped when the bindings change;
  file by number; link connected by the broker and passed as a
  descriptor; token exchanged by the broker), each by something in its
  own config, with caps 1/8/4/256; live: the lifeline closes the socket
  and kills the child 6 s later, SIGTERM stops it within a second, a
  child that ends ends the broker, a rule broken stops the child.
- child.go: the start (startOf), the child's server (newChildServer),
  the broker as hostSide over the socket (brokerClient), runChildOn;
  ready only after it reads the host's addresses (kept: the last good
  read), roots and time zone loaded first.
- process.go: Main(ctx, ...) and ChildMain; the child spawned with
  /proc/self/exe on Linux, PR_SET_PDEATHSIG from a locked thread
  (daemon.Cmd.DieWithThread), descriptors 3 and 4, and TZ, SSL_CERT_*
  and GODEBUG with updatemaxprocs=0 alone; run/proxy-child.pid and
  run/proxy.confined ("none" until the follow-ups); KeepLogs in the
  broker. ChildMain refuses to start unless descriptors 3 and 4 are a
  unix socket and an IP one (checkInherited): run by hand, without
  them, those numbers can be the Go runtime's own, which closing
  crashed it (signal_recv: inconsistent state).
- capture.go: a captured token request goes to the broker
  (captureToken, exchanger), so a login's real tokens never enter the
  child; an error reply passes up to 1 MiB, longer gets 502.
- watched.go: the child stats each changing file and asks the broker
  for it once it changed, keeping the stamp of what the broker read.
- rotate.go: proxy.log rotated by both through its descriptor, under a
  lock of a description of its own; OpenLog opens a log never through a
  link, one link, yours, replacing what a child left in its place.
- nixcache.go: the trim and its count through a safefile.Root, nar/
  only as a folder, links deleted as themselves; reads never through a
  link; the lock tried for 5 s (ErrNixLocked, nix_cache_locked).
- daemon: Cmd.Err, Files, Env, DieWithThread; Handle.Kill, Exit;
  WritePID.
- netpolicy: Proxy.Stop also stops a child that outlived its broker
  (run/proxy-child.pid, _proxy-child -for); proxy.log opened with
  OpenLog; a refused launch keeps a running VM only while both run.
  devvm network log and lock read the event log through safefile.
- vm, vmssh, vmlog: links.log and ports.log opened with OpenLog, read
  through safefile, trimmed only as a regular file with one link.
- backend: the build proxy's logs in a logs/ folder of their own.
- cli: _proxy-child; _proxy waits for its child on a signal
  (StopsItsOwn); the child reads none of devvm's folders (no
  makePrivate); ui.Files.
- Tests: FuzzBrokerFrames, the frames' rules, the handshake and the
  pair's end in synctest bubbles, the caps, the broker naming its own
  alone, the client over a real socketpair with a passed descriptor,
  ChildMain, TestInheritedSocket and proxy.txtar's child run by hand,
  the frozen 0.1.0 configs starting a broker and child,
  two writers rotating once, planted links, FIFOs and hard links; the
  testscript runner stops _proxy-child too; e2e: broker and child, their
  arguments, descriptors and environment, stop, SIGKILL either, planted
  files in the logs folder and the Nix cache, build proxies gone.
- Review fixes: the lifeline closes the socket and starts the kill's
  timer before logging; every log lock (proxy.log's, the event log's
  rotation) is tried without blocking for 200 ms (flockWithin, which the
  Nix lock shares), then written without or the rotation skipped; a
  copied log's rotation streams at most twice its limit from a line's
  start (copyFrom, copyAtomic); a reply too long to send goes as
  too_long; kept token headers capped at 1 KiB; the child gives up on a
  request whose context ended, dropping its late reply and holding its
  slot until then; a write deadline on the start frame; errors reach the
  child as codes (not_found, refused, busy, too_long, failed), their
  text in the broker's log; FuzzFrameStreams, and FuzzBrokerFrames
  writes from a goroutine; nix_cache_locked links to How it works.
- Docs: processes, network, overview, design (with threat rows for the
  logs' locks and a log made huge), troubleshooting, the proxy's
  README, structure, testing; CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.

Boundary parsers, the only places a string becomes a VM:
- vmname.Parse: a project VM's name (state's vm.json name, export file
  names, devvm _links's argument, the forwarder's -vm, project.Nth)
- vmname.ParseListed: one path element, for what a backend lists
- VM.UnmarshalText: JSON (Lima's list, proxy config and events, links'
  targets in state, link lists); empty stays no VM
- vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs
- msg.M.VM: the VM a message's function took, read back

vmname's functions on names became methods (Hash, Slug, Short, Aside,
AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname;
vmname.Join joins VM lists. Messages' vm and vm_name fields are typed
by the generator. Seven messages whose field took something else became
what= (backend_lacks, backend_unreviewed, backend_unreviewed_used,
starting, deleting, configuring, running_script) and rm_vm_failed's
name=: the text is unchanged, the names-mode scripts follow.
Review.RequireFor names an image or the tools being built.

Typed sites per package (added lines with vmname.VM, non-test): msg 347
(generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22,
backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8,
ports 6, paths 3, sshagent 2, sshconfig 2, tools 2.

The structure test's owners rule now fails on a field, parameter or
result named for a VM (vm, vms, otherVM, vmName) typed string, []string
or map[string]…, and on converting anything but a literal to vmname.VM
outside the files it lists; internal/stubtest is free. depguard holds
internal/vmname to the standard library, and the proxy may import it.

ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 647ad4bf2a feat(network): transparent mode for tools that ignore the proxy settings
On every confined tier, a tool that ignores the proxy settings (workerd
under wrangler dev, a static Go binary, a container made through Docker's
API) reaches the VM's proxy by the names it looks up. In the VM, dnsmasq
answers every name with the stand-in address 198.18.0.1 and has no
upstream; nftables sends that address's ports 80, 443 and those the allow
rules name to socat listeners on it, which make each an authenticated
CONNECT transparent.devvm.proxy:PORT to the VM's proxy. The proxy reads the
host from the connection's first bytes (TLS SNI, or each HTTP request's
Host) and judges it as CONNECT host:PORT, with the same order of checks,
log, secrets and floor. A blocked HTTPS host gets the 403 over a
certificate from the VM's CA. Nothing new runs on the host, and the
backends don't change.

Proxy (internal/proxy):
- transparent.go: TransparentHost, ProxyDomain, SentinelAddr,
  IsSentinelAddr, ViaDNS, transparent (serve, take, tls, handler,
  refusePage, ports), sniHost, replay, reservedRefusal, withVia, viaOf.
- routeFor and route: the one order of checks for CONNECT and the
  transparent path; carry, the one tunnel with its SNI check; block split
  into the record and blockPage; links.refuse split (isLinkDomain);
  caEndedRefusal's test moved to routeFor; handshake and serveOne shared
  by intercept and the 403 page.
- devvm.proxy reserved whole, CONNECT devvm.proxy:P included; the stand-in
  address refused with its own reason.
- Hosts and SNI in ASCII alone, never folded (the Kelvin sign), in
  splitHostPort, sniMatches and sniHost.
- A ClientHello record past 16 KiB + 256 is never read; once it starts,
  a ClientHello must arrive whole within 10 s, on every tunnel; a stream
  whose first byte is 0x16 is TLS from then on, so a record header that
  doesn't come whole, or isn't TLS's version, is refused, never passed on
  unchecked; and only a ClientHello that parsed (sniOf) counts, so one
  split across records is refused, an address's tunnel's included, which
  may have no name (a gap older than this change).
- routeFor carries the method and path rules: a host they narrow is
  refused where it can't be decrypted and intercepted where it can, on
  the transparent path too.
- On the transparent HTTP path, devvm.proxy answers /blocked alone.
- policy.transparentPorts and /transparent/ports: 80, 443, then the ports
  allow rules name for hosts by name, at most 32, never 22 or 53.
- Event.Via ("dns"), shown in devvm network log, /blocked and the prompt's
  note as "without proxy settings".

Guest (assets/): base.sh installs dnsmasq(-base), socat and nftables;
guest/transparent.sh is devvm-transparent: setup and teardown from
sync.sh (the proxy URL on stdin), the supervisor service (systemd or
OpenRC), the ruleset (render: two filter chains at -150 keep every
interface but lo and Docker's bridges, and every protocol but TCP, UDP
and ICMP, off the stand-in address; both NAT chains at -110 map every port of
the stand-in address, so Docker's published ports never take one; DNS to
public servers and 127.0.0.1:53 go to dnsmasq, which listens on the
stand-in address alone; private, link-local, CGNAT and loopback servers
are left alone, but the VM's own name servers, which Lima's DHCP adds
beside 127.0.0.1 and Docker gives containers, go to dnsmasq too), slots,
the port list's check, and status for devvm-why. Names without a dot and
names under the search domains (this machine's network's, through Lima)
don't resolve.

Setting: config.toml's transparent-proxy, and devvm network transparent
[on|off], the VM's own value in net.transparent (Settings.Transparent,
SetTransparent; netpolicy.TransparentOf, TransparentAddr); the setup gets
DEVVM_TRANSPARENT_ADDR while the VM runs confined and its mode is on.
devvm network --json has transparent; devvm network lock lists apart the
hosts only tools without proxy settings reached (Learned.NoProxy, via in
--json). vmssh.dialAddr refuses the stand-in address.

Tests: the transparent path's unit tests and FuzzTransparent; the
setting, TransparentOf, FormatEvent's via and learned hosts; the ruleset,
slots and port list under bash 3.2; network_transparent.txtar and
sync.txtar; e2e: transparentRuns, the network section's checks, a docker
step, the from section's Debian 12 and Alpine on the allowlist tier, and
the guarantee checks run with transparent mode stopped and running.

Docs: safety/network.md (tools that ignore the proxy, what isn't
covered, the setting, logs, lock), internals/network.md (tools that skip
the proxy), internals/design.md (the design note and threat check),
using/settings.md, using/troubleshooting.md, using/limits.md,
using/images.md, safety/attack-vectors.md, internals/lima.md,
contributing/tests.md and testing.md, the proxy's README, the CLI
reference and the Commands page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 07:18:53 -07:00
w3cjandClaude Opus 5.5 2865158e02 feat(network): learn the hosts a new VM needs, then lock it to them (#22)
--network learn runs a VM on the internet tier while it records the hosts
it reaches beyond its allowlist, shown as internet (learning). devvm
network lock picks which of them go into the VM's own rules, ticking only
reviewed registries on 443 and listing risky hosts apart, then gives the
VM the allowlist tier at once. learn is per VM only. The lock command
names its docs page in its about.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:59 -07:00
w3cjandClaude Opus 5.5 d209071ec3 feat(network): devvm-why and the agents' note point at a tool that skipped the proxy
With nothing blocked, the proxy's /blocked answer (devvm-why) adds that a
DNS or connection error for an allowed host means the tool skipped the
proxy, to turn on its own proxy setting or give it $HTTPS_PROXY, and links
troubleshooting's A host on the allowlist doesn't resolve. The agents' note
in ~/.claude/CLAUDE.md and ~/.codex/AGENTS.md says the same in one sentence.

Tests: proxy_test's empty answer, network.txtar asks a running proxy's
/blocked, and the e2e network section checks that curl --noproxy fails for
github.com, devvm-why's hint and the note in CLAUDE.md. Docs: internals and
safety network pages.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 04:40:50 -07:00
w3cjandClaude Opus 5.5 b80550bc5a feat(vm): customizing a new VM asks which ports it forwards
After the network tier, a picker (PickOne) offers every port, none, or
a list typed at new_vm_ports_prompt and checked by settings.ParsePorts,
asked again on port_invalid. The summary's ports are preselected and
Enter at the list keeps them; the choice is this VM's alone. --ports
skips it and counts in leftToChoose; where devvm can't ask, the
summary's ports stand. Ports are now read for the requirements after
the choice. new_vm_choose, the customize question and devvm's help name
--ports. Tests: TestPortsRows, TestChoosePorts, TestUpCustomize,
TestLeftToChoose, up_customize.txtar, network.txtar. Docs: commands.md,
first-vm.md, images.md, ports-size.md, devvm.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 02:15:28 -07:00
w3cjandClaude Opus 5.5 086ee543c3 feat(vm): customizing a new VM asks its disk after its memory
The disk's question (new_vm_disk_prompt) starts from the summary's disk,
after one line saying it grows with devvm size --disk but never shrinks
and takes only what the VM writes (new_vm_disk_question). It's this VM's
alone, skipped with --disk, and a disk below the image's or not a size is
refused with Size.Check's and ParseGiB's messages, then asked again.
leftToChoose counts the disk; new_vm_choose and the customize question
name --disk. Tests: TestSizeChoiceAskVM, TestUpCustomize, TestLeftToChoose,
up_customize.txtar. Docs: commands.md, first-vm.md, images.md, devvm.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 00:52:27 -07:00
w3cjandClaude Opus 5.5 b5c7a7fb1c feat(vm): a new VM's network tier is chosen from a list
Customizing a new VM shows the four tiers in order, each with what it
reaches (Tier.Desc, which devvm setup's network picker shares), the
summary's tier chosen, through the UI's PickOne (vm.Env.PickOne). Where
the picker can't show, the VM keeps the summary's tier. net_ask,
net_about and net_tier_unknown go; network_default_open, _internet,
_allowlist and _none become net_tier_*; net_tier_help is the picker's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 00:40:48 -07:00
w3cjandClaude Opus 5.5 62cdd16dd4 feat(agents): devvm agent login claude, Claude Code's login captured in the VM for every VM
Claude Code logs in from inside a VM, so this machine never needs it, and
devvm keeps one Claude Code login on the host for every VM with Claude
Code: the subscription's OAuth login, or a Claude Code token from claude
setup-token. The newest replaces the other. The VM holds placeholders
alone, so claude /login in a VM no longer leaves real tokens there.

- Capture: every VM's proxy captures at platform.claude.com and
  console.anthropic.com /v1/oauth/token (agentlogin.Endpoints), only for
  a VM whose image has Claude Code (netpolicy.Capturer). setup-token's
  code grant (expires_in, agentlogin.SetupToken) gives the claude secret
  (agentlogin.ClaudeToken, secrets.Token's checks) and the VM the
  secret's placeholder. Any other code grant goes in the store's
  .claude/.credentials.json (a File of kind agentlogin.ClaudeOAuth:
  claudeAiOauth accessToken, refreshToken, expiresAt ms, scopes); the
  VM's reply holds sk-ant-oat01-devvm-proxy-managed-oauth-<salt> and a
  managed refresh token, and the VM's own refresh is answered from the
  store. Refused: a new login without user:inference (Console), any
  login or refresh with org:create_api_key, an access token that isn't
  sk-ant-oat01- shaped.
- One login: saving the claude secret (captured or devvm secret set
  claude) removes the OAuth login, and an OAuth capture deletes the saved
  token, both under the claude logins folder's lock
  (agentlogin.LockFolder); a token that can't be deleted is a warning.
  CLAUDE_CODE_OAUTH_TOKEN in devvm's environment wins, as in Claude Code
  (secrets.ClaudeOf(store).Login). A launch gives the VM either
  CLAUDE_CODE_OAUTH_TOKEN or ~/.claude/.credentials.json (placeholder,
  managed refresh token, expiry 2099), never both. Both bindings
  (claude, claude-oauth) go into Authorization for api.anthropic.com
  while either login exists, and Store.Get gives each the login devvm
  keeps now, so a running VM survives the switch.
- Refresh: the host refreshes the OAuth login when due, JSON to
  platform.claude.com with Claude Code's client ID and the login's
  scopes, through the company proxy (proxy.RouteOf), under the file's
  lock; claude_refresh_failed says to log in again.
- devvm agent login claude [--setup-token]: claude auth login --claudeai
  or claude setup-token in the VM without CLAUDE_CODE_OAUTH_TOKEN, the
  code pasted back on this terminal (no forward); the VM is set up again
  once the store has a new login of the kind asked for
  (secrets.ClaudeOf(store).Sums); claude_env_token_wins when the
  environment's token wins. --device-code, --api-key and --stdin are
  usage errors with claude, --setup-token without it.
- Confirmed in Claude Code 2.1.317's linux-arm64 bundle (sha256 checked):
  TOKEN_URL platform.claude.com/v1/oauth/token, client ID
  9d1c250a-e61b-44d9-88ed-5944d1962f5e, the JSON code and refresh
  bodies, setup-token's expires_in 31536000 and user:inference scope,
  the claudeAiOauth fields, the anthropic-beta oauth-2025-04-20 header
  Claude Code sends itself, claude auth login's pasted code#state on
  stdin. The real claude auth login logged in in e2e against the fake.
- Messages: agent_login_claude_paste, claude_login_saved,
  claude_setup_token_saved, claude_env_token_wins,
  agent_login_claude_flag, agent_login_setup_token_alone,
  claude_refresh_failed, claude_no_login; no_claude_token,
  claude_token_invalid, claude_token_howto and not_setup_token point at
  devvm agent login claude.
- Tests: TestClaudeCapture, TestClaudeSetupToken, TestClaudeOAuthGet,
  TestCaptureRefuses' Claude cases (agentlogin); TestOneClaudeLogin,
  TestClaudeBindings, TestClaudeOAuthVMCopy (secrets); TestCapturer's
  Claude cases (netpolicy); agent_login.txtar's Claude section;
  network.txtar's bindings.
- e2e (network): the fake company proxy fakes Claude's token endpoint
  and Anthropic's API too; setup-token's request makes the claude secret;
  devvm agent login claude runs the real claude auth login, the store
  keeps the login, the claude secret goes, the VM holds placeholders and
  no token, the API gets the store's token for the VM's placeholder; a
  due login makes the host refresh through the company proxy (which
  fails there, as the host doesn't trust the run's CA).
- Docs: Claude Code login (using/coding-agents.md), first VM, the home
  page, README, commands, settings, safety/network.md, internals
  network.md, the design note's risk that this path is unofficial,
  Contributing's e2e, the proxy README; the CLI reference.

Security review (security-audit skill, an independent read):
- Fixed: a login granting org:create_api_key would let a VM make an API
  key through the binding and get it unread: refused, on refresh too.
- Fixed: a refresh could install a Console login when the store had
  none: the scope check applies to every new login.
- Fixed: any VM, without Claude Code, could replace the login or delete
  the token with a refresh grant: only a VM with Claude Code captures.
- Fixed: two captures at once could leave neither login: one lock.
- Fixed: a saved token that couldn't be deleted gave the VM a 502 for a
  saved login: a warning instead.
- Fixed: captured and refreshed access tokens are shape-checked.
- Accepted, documented: the bound login reaches every api.anthropic.com
  path its scopes allow (profile, sessions); any VM with Claude Code can
  replace the login; a token Claude Code mints in a VM for another use
  (install-github-app) becomes devvm's login.
- Unconfirmed: whether another Anthropic host also answers
  /v1/oauth/token (it would pass unguarded).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 20:18:20 -07:00
w3cjandClaude Opus 5.5 7a26d80a17 feat(settings): the network setting for new VMs is a tier, allowlist by default
The ask setting is gone: a new VM's summary shows its tier (--network,
else the saved tier, else allowlist) and customizing it asks for the
tier, with Enter keeping the one shown, so ask added nothing.

- settings.NetworkChoices is the tiers alone; settings.NetworkDefault
  (allowlist) replaces NetworkAsk, checked against netpolicy.TierDefault.
- chooseNet takes --network, then the saved tier; customize asks for the
  tier whenever --network didn't give it (netpolicy.Proxy.Choose takes
  the tier shown, and net_tier_unknown names it).
- devvm network -g ask and devvm setup's ask choice are gone; ask is a
  usage error (arg_not_choice). net_ask_global and network_default_ask
  removed.
- A saved "ask" in config.toml or settings.json is refused like any
  value that isn't a tier.
- Docs: safety/network, using/settings, using/images, getting-started
  commands and first-vm, the cli skill, devvm network's and up's help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:01:03 -07:00
w3cjandClaude Opus 5.5 d94929523d feat(vm): a new VM shows a summary, then asks whether to customize it
Before devvm makes a new VM it shows a summary of what the VM gets:
each toolchain, coding agent and layer with why (the file that calls for
it, devvm setup, config.toml or the flag that gave it), its size, network
tier and ports, and the devcontainer.json it's made as. Where the picker
shows (CanPick) and something is left to choose, it asks
"Customize it? [y/N]": Enter makes the VM as shown; y opens the picker
(a part a flag gave greyed out), then the network tier question when no
tier is given or saved, then the VM's CPUs and memory (for this VM
alone). Without a terminal or with --no-input the summary ends with the
flags that choose others. The summary replaces new_vm_gets and
devcontainer_using. devvm's first run asks its size and agents first,
as before, then shows the summary.

A test build's DEVVM_PICK_ON_PIPE shows the picker with a terminal on
stdin alone, so testscript's ttyin reaches it (up_customize.txtar).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 16:48:53 -07:00
w3cjandClaude Opus 5.5 fcbab78670 refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its
tier, so even an open VM never holds a real secret: a request that goes
around its proxy carries only the placeholder.

- vm/sync.go: the open branches of stage go (the agents' logins copied
  as they are, the ClaudeCopy for unconfined VMs and its MCP warning,
  real values in ~/.config/devvm/env); stageNet is stageSecrets, run
  for every VM, and the salt is every VM's.
- netpolicy: Prepare readies the CAs, salt and secret files on every
  tier, and the proxy config carries the CAs and bindings on every tier;
  dropCA and its caller are gone, so a VM keeps its CAs as its tier
  changes.
- Removed without a caller left: the messages secret_unuse_copied,
  net_on_old_tokens and claude_mcp_secrets_copied;
  secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets,
  claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly.
- Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across
  tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for
  another host), TestStageSecretsEveryTier (every tier's setup sends
  the VM's CAs, the guard against a tier's own path); sync, ca, network
  and secret scripts for open VMs.
- e2e: network checks that an open VM holds no real secret (its proxy
  puts the token in over TLS the VM verifies, a direct request carries
  only the placeholder and gets a 401); project checks an open VM's
  placeholder, and its company-CA checks allow for the VM's own CAs in
  /etc/ssl/devvm.pem.
- Docs: safety/network (tiers, secrets), internals/network, the design
  note's tiers threat check, attack vectors, coding agents, first VM,
  staying safe, contributing; devvm secret's help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:55:21 -07:00
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00
w3cjandClaude Opus 5.5 c0f4b8fb5c feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none,
in its state's net section (netpolicy.Tier), in place of on/off. Every
VM has its proxy. Confined tiers start on NetProxy; open starts on the
backend's own network with its proxy set in the guest
(Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU
wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off.

The proxy: Config.Open (every host and address, no floor, no
policies), Config.DenyPolicies (files whose denies alone apply), the
rule port :* (any port), and ** matching address literals (the floor
still holds). Policies per tier (netpolicy.PolicySet): internet is
network/internet.policy (**:*) plus your denies; none is the agents'
built-in policies, the secrets' hosts and your denies; open none.

Links: a client links only to a target on its tier or a stricter one,
and a group's VMs are all on one tier. The self-check per tier: open
asks its proxy through the guest's settings and warns
(net_proxy_unreachable). devvm ls and devvm network show the tier. A
backend without egress-proxy offers open alone (net_tier_backend).
devvm network on/off and --network-policy/--no-network-policy map to
allowlist/open. Design note, threat check and docs; e2e in the network
and link sections.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 14:32:06 -07:00
w3cjandClaude Opus 5.5 317bd8f978 feat(agents): devvm's agent store, filled by devvm agent import
Every VM gets its agents' settings and logins from devvm's own store,
never from the agents' files in the home folder: settings in
~/.config/devvm/agents/<agent>/, logins in
~/.local/share/devvm/logins/<agent>/ (folders 700, files 600, each
agent's logins folder kept out of Time Machine), each laid out as in a
home folder. The store's settings folders are mounted read-only and
linked into the VM's home; its files and logins are copied in, with
network policy as placeholders the proxy fills from the store.

devvm agent import [AGENT...] [--force] copies the home folder's agent
settings and logins into the store once: only agentDirs, agentFiles and
secrets.LoginRel's paths, never history; .claude.json reduced to its
settings, account state and MCP servers; read through each agent's
folder as an os.Root, so no link out of it is followed (a link to a file
inside becomes a copy, any other is left out with a warning, and so is
a login file that's a link); Claude Code's plugin records renamed to the
store's folders. It asks before replacing what the store has (refused
without a terminal, naming --force), replaces in place, keeping the
mounted folders, and prunes what the home folder no longer has.

- paths: Dirs.AgentSettings, Dirs.AgentLogins
- secrets: LoginRel, LoginFile(Dirs, kind), SaveLogin, HasLogin,
  Store.ExcludeFromBackup; Logins, VMLogin, ClaudeCopy, MCPSecrets and
  the proxy's Get read the store
- vm: agentStore, agentMounts/homeSkips/Inventory.Mounts take Dirs,
  syncer.stageAgents, AgentImport; the guest's links file holds each
  folder's home path and its mount's (host_home is gone)
- structure: callers takes methods (pkg.Type.Name);
  Dirs.AgentSettings only in vm/agents.go, Dirs.AgentLogins only in
  secrets/secrets.go
- messages: agent_import_none, agent_import_nothing,
  agent_import_replace, nothing_imported, agent_settings_imported,
  agent_login_imported, agent_import_link_left_out,
  agent_login_read_failed, agent_import_failed; the login refresh
  messages point at devvm agent import
- tests: agentimport_test.go, testdata/script/agent.txtar, sync and
  network scripts through the store, e2e project and network sections
- docs: coding agents (devvm's agent store, importing from this
  machine), README, getting started, safety, internals, contributing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 14:08:41 -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 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 c12fadd036 fix(ui): the run log keeps URL passwords out of commands' output
Lima's hostagent logs a proxy variable's value, password and all, when it
replaces a loopback proxy's address with the guest's gateway, overrides
the system's or lima.yaml's value, or can't parse it (Lima's
pkg/cidata setupEnv), and limactl start passes those lines on to its
stderr. For a VM without network policy, Start gives limactl the shell's
proxy variables, so a password in the shell's HTTPS_PROXY could land in
devvm's run log.

LoggedCmd's output now goes to the run log through a redacting writer:
whole lines (ended by \n or \r, or 64 KiB), each redacted, so a password
split across writes is still found, the rest written once the command
ends. redact, which the command's + line already took, also replaces the
password of any URL's user info with <password>, besides the proxy keys'
<key>. limactl.go's comment says when Lima logs the values.

- ui: urlPassword, redacting, redactLineMax.
- Tests: TestURLPasswordsStayOutOfTheLog (a Lima-like line, the URL in
  the command's environment, never its arguments), TestRedactingWriter;
  network.txtar and e2e's network check expect Lima's password stand-in
  as devvm:<password>@ in the run log.
- Docs: troubleshooting's run log, network policy's Without network
  policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 02:09:59 -07:00
w3cjandClaude Opus 5.5 cb9ee36f0a test: drop usage-error and e2e checks that other tests already cover
Generic usage errors (an argument too many or missing, an unknown flag)
left 14 CLI scripts: TestUsageErrorsEveryCommand checks every command
for them, TestShowCommandsTakeJSON for which commands take no --json,
and root.txtar keeps one through the binary. e2e drops five checks that
exercise no VM: retention's settings (retention.txtar), a second gc
(gc.txtar), ls and size --json (TestJSONShapes, beside e2e's text
checks), devvm code with a stub (host_code.txtar) and a CA file that
isn't a certificate (ca.txtar, trust's TestRead).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 22:00:43 -07:00
w3cjandClaude Opus 5.5 1640feb608 feat(netpolicy): one CA per VM, with a successor the VM trusts ahead of time
Each VM with network policy has CAs of its own in its run folder,
vms/<hash>/run/ca/ (paths.VM.CA, paths.CA: ca.pem/ca.key, next.pem/
next.key; folder 700, keys 600, kept out of Time Machine on macOS), so a
leaked key reaches one VM and no proxy can sign for another VM. The
shared ~/.local/share/devvm/ca (Dirs.CA) is gone.

trust.InitCA(paths.CA) readies the current CA and the next one at each
launch: the current one stays while it has over a week left, then the
next one (started) takes its place, else a new one; the next one starts
a week and an hour before the current one ends and is made again when it
doesn't follow it. Each CA lasts 30 days and an hour, and its common
name holds its serial, so a VM's two CAs never share a subject.

The proxy's config gains ca_next, ca_next_key and ca_next_sha256 (part
of Sum); the proxy signs with the next CA from an hour after its start
(ca.signer), so the switch needs no launch or new proxy, and a VM not
opened again stays verifiable for at least 30 days less an hour after
its last launch. /ca.pem serves both certificates. loadCA reads the CA
files with readPrivate (no links, a key only the user may read, 64 KiB
cap) instead of tls.LoadX509KeyPair. The VM's setup sends both
certificates (devvm-proxy.crt, devvm-proxy-next.crt) and no key.

Tests: TestInitCA, TestInitCASwitch, TestInitCAReplaced (trust);
TestNextCASigns, TestLoadCA, config check rows (proxy); TestPrepare and
TestPrepareRestartsTheProxy for the VM's CA files and both sums
(netpolicy); TestVMFiles; network, sync and layout txtar; e2e network: a
second network-policy VM with different CAs, each VM trusting only its
own and holding no key, each proxy serving and presenting only its own
VM's CAs, devvm rm deleting one VM's CAs.

Docs: internals/network.md (The VM's CA), design.md (A CA per VM, its
threat check), safety/network.md, overview.md's per-VM files, space.md,
security.md, attack-vectors.md, limits.md, coding-agents.md,
contributing, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 20:54:41 -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 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 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 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 a134e0d8a6 feat(cli): choose a new VM's toolchains, agents and layers in a picker or with --tools, --agents and --layers
devvm takes no IMAGE word any more than any other: in a terminal a new VM's
toolchains, coding agents and layers are checked in one picker, under three
headings, before the network-policy question; --tools, --agents and
--layers (each an exact list, or none) skip it, and a part left out takes
its default: the detected toolchains, devvm setup's agents, no layers (a
devcontainer.json's features still count). Without a terminal, or with
--no-input, the VM gets the defaults and new_vm_gets says so in one line.
devvm setup --agents (and its first-run question) chooses new VMs' agents.
devvm tools in a terminal opens the same picker for the VM, its layers
fixed, and turns the changes into tools add and rm.

An image is base and layers only: tools are the VM's tool_names state key.
build, rebuild and images rm refuse a shared tool (tool_not_layer), and
devvm build builds no tool images. devvm ls gains a TOOLS column and
--json tools. gc's --tools is --tool-images, so --tools has one meaning.

Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or
no_command_like, did-you-mean over commands, msg.Closest), the lacks path
in internal/vm/existing.go, and the messages vm_lacks_tools,
vm_lacks_layer, layer_is_command, layer_name_command, no_image_for,
no_command_or_image*, tools_not_images, tools_not_images_rm, detected,
vm_is_now (vm_tools_now), secret_with_image (secret_with_claude).
New: ui.Pick takes headed sections with fixed rows, ui.CanPick,
vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go),
state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents,
project.DetectFiles. Image keys are unchanged in form: images never held
tools; docker.sh's and nix.sh's comments changed, so those layers rebuild.

Docs: the home page's quick start steps, diagram (sandbox.svg), cards and
FAQ; README; getting started; using (images' What a new VM gets, coding
agents' Running an agent, settings' agents); internals; contributing;
the cli skill; AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 00:45:09 -07:00
w3cjandClaude Opus 5.5 e9f791bc96 refactor: one owner for the proxy's constants, URLs, variables and tunnels
The proxy owns the links' addresses and domain and the proxy user:
proxy.IsLinkAddr, proxy.LinkAddr, proxy.LinkDomain and proxy.ProxyUser
replace vm.IsLinkAddr, vmssh.IsLinkAddr, vm.LinkNet, vm's linkNetAddr,
vm.LinkDomain, netpolicy.LinkDomain and the proxy's own isLinkAddr and
linkDomain. TestLinkAddrsAgree goes, because there's nothing left to agree.
The proxy's link list now refuses an IPv4-mapped address too, as vm's
parser already did.

backend owns the guest's view of a proxy: ProxyUser (proxy.ProxyUser),
ProxyURL, GuestProxyVars, ClientProxyVars and NewProxyPassword replace
four URL builders (BuildProxy.URL, Lima's, Docker's and smolvm's), the
user written out in three places (netpolicy.ProxyUser, buildProxyUser,
Docker's proxyUser), the guest's variable list in three (Lima's inline
loop, smolvm.proxyVars, Docker's proxyVars) and the client's in two
(limaProxyVars, Docker's noClientProxy list), and the two password
generators. Confinement.ProxyUser goes: Docker ignored it, and every
backend now uses ProxyUser. A new VM's proxy key is NewProxyPassword's
64 hex digits, as a build proxy's was; a VM keeps the key it has.
doctor reads HTTPS_PROXY through backend.ReadHostProxy.

In the proxy, hijack and splice replace the three CONNECT copies
(tunnels to allowed hosts, tunnels to links, interception's hijack) and
the relay's pipe. A tunnel passes the bytes as they are, passes on the
end of what the client sent, and ends, closing both connections, when
the server's bytes end or the client has gone. A relayed connection now
ends with the proxy's side too, where before it waited for both.

Tests: splice_test.go characterises the allowed-host tunnel, the link
tunnel and the relay (a megabyte of every byte value, a half-close
answered, a client that goes away ending the tunnel), written against
the code before this change; TestSpliceEnds, TestHijack and
TestIsLinkAddr (every LinkAddr) are new, and so are TestProxyURL,
TestNewProxyPassword and TestProxyVars. TestLinkListRefused gains a
mapped address.

e2e: the relaunch without a company proxy says which step failed, with
the launch's output, the VM's status and the proxy's log, and a link
helper that doesn't start shows its output.

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 3b1959efd2 feat(network): network policy rules and log under devvm network, and network -g for new VMs
devvm network allow|deny|rm RULE... [-g] and devvm network log [-f] [-n N]
[--blocked] replace devvm policy and devvm log. Bare devvm network shows the
VM's network policy, then its allowlist file by file. devvm network -g shows
or saves whether new VMs get network policy (ask, on or off), through the
network file devvm setup also writes; --network-policy and
--no-network-policy beat it and skip reading it, a saved off makes a VM
without the docker-layer and backend warnings, and with ask and no terminal
a new VM gets it.

The proxy's block messages, devvm-why's, network log --blocked's ALLOW WITH
and the VM's setup note name devvm network allow. New messages:
net_default_failed, net_ask_global; -g reports with network_default. Docs,
the CLI reference, txtars (network_rules, network_log, network), e2e
(bare devvm network's first line) and AGENTS.md follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:40:20 -07:00
w3cjandClaude Opus 5.5 906d598954 feat(trust): VMs, builds and the proxy trust a company's CAs from ~/.config/devvm/ca
Behind a proxy that inspects TLS, VMs and build VMs couldn't make TLS
connections. The CA certificates in ~/.config/devvm/ca (*.pem, *.crt) are
now read at each launch, build and proxy start, checked, and trusted;
images never keep them.

- internal/trust (new): Read parses every PEM block with crypto/x509 and
  refuses anything but CA certificates (ca_not_certificate, ca_not_ca,
  ca_invalid, naming the file); only the re-encoded certificates leave the
  host. Env/GuestEnv (NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem,
  SSL_CERT_FILE, REQUESTS_CA_BUNDLE, PIP_CERT, UV_SYSTEM_CERTS), Build
  (a build's Add/Remove root scripts from guest/ca.sh), Script (Env
  exported at a build script's start), Name, Bundle.
- assets/guest/ca.sh (new): installs exactly DIR's devvm-*.crt into
  /usr/local/share/ca-certificates (update-ca-certificates --fresh), or
  into the bundle file itself when there's no update-ca-certificates (the
  old bundle kept and put back), writes /etc/ssl/devvm.pem; without DIR,
  removes all of devvm's. sync.sh runs it with the proxy's CA
  (ca/devvm-proxy.crt) and the user's (ca/devvm-extra-N.crt).
- backend: ImageSpec.Trust and ToolsSpec.Trust (backend.Trust{Add,
  Remove}); VMSpec.Env. Lima runs Add after the start and Remove after the
  scripts (runScript's root mode, sudo sh), the --from conversion VM runs
  Add and oci/build.sh runs ca.sh in the image's chroot around bootify.sh
  (guest/ mounted read-only, CA_SH argument); smolvm and Docker run Add
  before prepare.sh and Remove after sshd.sh; tools builds run Add only.
  Lima's clone sets the guest environment, so starts edit nothing.
- vm: every project VM starts with trust.Env (netpolicy.Env keeps only the
  proxy's variables); the setup sends ca.sh and ca/; Dirs.TrustedCAs.
- proxy: -upstream-cas FILE adds CAs to the system roots for its own TLS
  connections; netpolicy writes run/<vm>.proxy.cas and restarts a proxy
  whose bundle changed.
- doctor: doctor_proxy_ca when HTTPS_PROXY is set and the folder has no
  CAs (Say), a refused folder warned about.
- Tests: internal/trust unit tests (folder reading, scripts, ca.sh run in a
  stand-in root with and without update-ca-certificates); ca.txtar; sync,
  up, network, smolvm txtars and the limactl stub (clone's .env, list
  shows lima.yaml's env); e2e: images (a layer built with a test CA, its
  key unchanged, its image's copy without CA files), project ("a company's
  CA" section), tools (node fetch), smolvm and docker build checks.
- Docs: using/settings (a company's CA), using/troubleshooting (TLS errors
  behind a company proxy), internals/network and internals/images,
  safety/network, design (assets written out), oci README, doctor's help.
- Structure: Dirs at 38 methods, trust.Env a table, trust above backends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 17:54:01 -07:00
w3cjandClaude Opus 5.5 9cf45cc5e0 feat(net): network policy on by default; a warning where a VM can't have it
A new VM gets network policy unless it's turned off. In a terminal devvm
shows the tradeoff and asks yes by default ([Y/n]); without a terminal
it's on. A VM that can't have network policy gets no question, only a
warning, and is made without it: on a backend without egress-proxy (or
with it unreviewed), and a Docker VM made for the docker layer, whether
named or from a devcontainer.json's docker-in-docker. An explicit
--network-policy on such a VM is still refused (net_docker_layer, or
backend_lacks from Require). Existing VMs keep their state's choice.

- netpolicy.Proxy.Choose: no terminal gives on; in a terminal net_about,
  then Confirm (yes by default). Proxy's Ask field and netpolicy.UI's Ask
  removed (unused); vm.UI asks Ask itself.
- vm.creation.chooseNet: --no-network-policy first; the docker layer
  warns (net_off_docker_layer) or refuses --network-policy; a backend
  Registry.Allowed doesn't let egress-proxy through warns
  (net_off_backend); otherwise Choose.
- Messages: new net_off_docker_layer, net_off_backend (with doc links);
  net_about rewritten as the two-line tradeoff with a doc link
  (safety/network#turning-it-on-or-off); net_ask is "Turn it on?" (no
  fields); devcontainer_docker_net removed (no caller).
- --network-policy's help: secrets, default on, asked in a terminal; CLI
  reference regenerated.
- Tests: TestChoose (flags, terminal yes/no, no terminal on, what's said);
  TestChooseNet replaces TestChooseNetDockerLayer (docker layer named and
  from the file, no egress-proxy, unreviewed egress-proxy, flags, with and
  without a terminal); TestUpWithoutEgressProxy (backend_lacks for
  --network-policy, the warning and net=off by default).
  network.txtar: --no-network-policy for the off VM, and a VM made without
  a flag or terminal gets net=on. docker.txtar: another machine's engine
  (backend_lacks, then the warning and net=off), and the sysbox VM's
  warning. e2e's docker sysbox check expects the warning.
- Docs: first-vm, commands, safety/network (the prompt, the VMs that
  can't have it), security, attack-vectors, devcontainer, backends index
  and docker, design notes, README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 08:45:55 -07:00
w3cjandClaude Opus 5.5 fd6170c7f7 fix(lima): the sandbox refuses the hostagent's port binds; ssh ports recorded
On macOS, a network-policy VM's hostagent Seatbelt profile denies every
network bind but TCP on its ssh port and unix sockets in its Lima
folder, so Lima forwards none of the guest's ports even if its ignore
rules were bypassed. Lima's host resolver is off for these VMs, as on
Linux: it binds a random port the profile can't allow.

Every VM's ssh port is chosen and recorded before create (VMSpec.SSHPort,
Lima's .ssh.localPort), under a lock so two VMs can't choose the same
one, and checked free by a bind as well as a connect. Other VMs'
forwarders reserve it, so none can take it while Lima boots, when
Lima's unpinned ssh would reach whatever has it.

Design note: the sandbox's binds, how they were found, the threat check.
e2e: the profile's rules, binds refused around Lima's rules, a taken
ssh port, a direct VM's recorded port.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-30 01:14:22 -07:00
w3cjandClaude Opus 5.5 b27cd9b9b3 feat(lima): forward ports through devvm's own forwarder
Lima VMs forward their ports, every port and listed ones, through
devvm's forwarder (devvm _lima-ports), as Docker's do: loopback only,
exclusive binds, every port from 1024 up, never a port a host program
or another VM's record holds. Lima's own portForwards are ignore rules
for TCP and UDP on every address. The port choice is a record
(lima-vms/<vm>.ports), so changing it edits no Lima config and keeps
the VM's host keys. The forwarder pins the host key devvm pins
(Confinement.HostKey, sshconfig.HostKey) and ends with the hostagent
(the shared lifeline in vmssh). Lima's ports and ports-all are
emulated, reviewed: design note, threat check, e2e.

Docs: the forwarding rules for every backend, UDP not forwarded and
the socat alternative, in the docs voice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 21:43:10 -07:00
w3cjandClaude Opus 5.5 851e39ef86 build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/,
shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which
cli passes to every constructor; backends, the builder, the shared
tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts
reach VMs on stdin (backend.Script carries their contents). What needs
a path (limactl create's base.yaml, oci/ mounted into the conversion
VM, the proxies' policy files) is written out to
~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders
700; devvm gc deletes older copies no VM's proxy was started with
(gc_assets, deleted_assets). Release archives hold the binary with
README.md, CHANGELOG.md and LICENSE, and the formula installs the
binary alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 18:12:37 -06:00
w3cjandClaude Opus 5.5 9f24d2639e refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/,
shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and
oci/. devvm reads them from assets/ beside its binary (paths.Root,
paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e
put them there. Image keys hash them by their names in assets/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:08:33 -06:00
w3cjandClaude Opus 5.5 782f67e4ad fix(netpolicy): keep the proxy's password out of every process's arguments
The VM's proxy URL, password included, reached the guest through
limactl edit --set .env and smolvm machine update -e, both visible to
other local users with ps.

- lima: startSets puts a stand-in (devvm-proxy-password) in the .env
  edit; fillPassword then replaces the stand-in URL with the real one in
  the VM's lima.yaml, rewritten atomically mode 600, refusing a URL with
  characters YAML treats specially or a lima.yaml without the stand-in.
- smolvm: the proxy variables are no longer machine env. Start writes
  smolvm/vms/<vm>.proxy (mode 600) with the URL under network policy and
  removes it without; every devvm exec (userArgs, asRoot) names it with
  machine exec --secret-file, so smolvm reads it. create's --secret-file
  is ignored by smolvm for machines made from a pack. Proxy variables
  left in an older machine's env are removed; rm deletes the file;
  updateQuiet is gone (update prints no secrets now).
- stubs: limactl's edit writes --set .env into lima.yaml; smolvm's exec
  fails on an unreadable --secret-file.
- tests: TestStartConfined (both backends), TestFillPassword, network
  and smolvm testscripts check the password is in no stub call and is in
  the file, mode 600.
- e2e: network and smolvm sample ps every 0.1 s during the launch
  (ps_watch) and check the password is in none, nor after, with the
  guest's environment (and on smolvm Docker's daemon) as the control.
- docs: lima.md, smolvm.md, network.md, design.md, contributing.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 11:31:40 -06:00
w3cjandClaude Opus 5.5 d53bfdb5d1 feat(smolvm): network policy through devvm's proxy
egress-proxy is emulated on smolvm, and reviewed: a VM with network policy reaches nothing but its proxy.

- smolvm Start (NetProxy): allow list of the gateway alone (--reset-allow-list --allow-cidr 100.96.0.1/32), DNS closed (--allow-host-pattern devvm.invalid), and the start through devvm's decider (--mediated-egress --egress-interceptor, token in SMOLVM_INTERCEPTOR_TOKEN, never in arguments); a start without policy removes them (--net --reset-allow-list --no-egress-interceptor). The proxy's environment goes in by a quiet update, as smolvm prints the values it sets. Confined compares agent.pid with the confined start's and re-checks the allow lists on every call.
- The proxy is smolvm's mediated-egress decider (protocol v2, internal/proxy/decider.go, stdlib only): -decider, -decider-to, -decider-token-file; it takes over only connections to its own address in the VM, served with password and policy, and refuses and logs the rest; the token is checked before anything past it is read, first bytes capped at 8 KiB; FuzzPrelude.
- Interface: Confinement.Decider/DeciderToken, backend.Decider (UsesDecider); netpolicy.Proxy.Prepare takes the backend, allocates decider_port and a decider_token new at each start.
- A running network-policy VM whose proxy can't start again (port taken, start failed) is stopped, on Lima and smolvm (net_proxy_down_stopped; proxy_port_taken reworded); the stop isn't cancelled by an interrupt.
- DEVVM_UNREVIEWED=backend:feature lets unreviewed emulations through, warned (backend_unreviewed_used), only in test builds (-X internal/backend/backends.unreviewed=allowed: tests/e2e.sh and the CLI tests).
- Tests: decider, prelude and token unit tests; Prepare with a decider; Unproxied; smolvm Start/Confined on the stub (allow lists, decider requirement, env echo); testscript smolvm.txtar (policy VM, no password in run logs, proxy down stops it), network.txtar (Lima: proxy down stops it), doctor.txtar; e2e smolvm network section: proxy and decider, allow list, allowed/blocked hosts, direct connections as root (controls off policy), DNS refused per smolvm's decision log with devvm.invalid as control, UDP and ICMP (UDP allow control), token nowhere, log, policy, a widened allow list unenforced, fail closed with the proxy gone or a fake decider (garbage, silent, allow-direct; take-over as control), no start without a decider, someone else's decider stopped, network off/on.
- Docs: design note (how it works, what it relies on, what could break it, not covered: UDP allows the host's user adds, the devvm.invalid DNS channel), smolvm.md, backends.md, security.md, network.md, testing.md (DEVVM_UNREVIEWED, a canary DNS zone check), contributing, limits; AGENTS.md gotchas and a deliberate change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 10:47:43 -06:00
w3cjandClaude Opus 5.5 eae6614cab feat(network): devvm network, a folder's VM's network policy on or off
devvm network prints the VM's network policy as ls shows it (on, off,
unenforced); devvm network on|off changes its state, applied when it next
starts (net_set_running/net_set_stopped, net_already when unchanged,
net_on_old_tokens on turning on). on needs the backend's egress proxy.

A running VM turned off stays on its proxy until it next starts
(net_off_next_start). Confined now means started with the proxy (Lima
reads the recorded network; the fake tracks Start's), so a VM turned on
while it ran direct is unenforced and its launch offers the confined
restart; net_unenforced* say it wasn't started confined.

net_flag_ignored, net_off_log and net_off_policy name devvm network.
Docs: network.md "Turning it on or off", commands.md, security.md,
contributing.md, CLI reference. Tests: TestNetwork,
TestNetworkRequiresEgressProxy, Lima's Confined after a direct start,
network.txtar (what it prints), e2e network (off, on while running,
off while confined).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 17:09:40 -06:00
w3cjandClaude Opus 5.5 ff57370ffb feat(network): network policy for VMs
A new VM can get network policy: --network-policy, else a question in a
terminal (no by default), else off. devvm makes its CA, writes the VM's
secret bindings, starts the VM's proxy (devvm _proxy, its password in a
file) and starts the VM confined to it, then runs the self-check before
the setup and the shell: a VM that isn't held to its proxy is stopped.
Tokens stay on the host; the hidden devvm secret get reads them for the
proxy, from the Keychain or a file. e2e gets a network section.

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