Commit Graph
131 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 06bed70fc7 test: record the Linux coverage baseline, and fix two tests that failed on Linux
testdata/coverage/linux.txt is each package's coverage from mise run
coverage on a Linux host (Ubuntu 24.04 arm64), so mise run test checks
Linux runs too.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:06:29 -07:00
w3cjandClaude Opus 5.5 b5742dca2c build: a package's coverage may sit up to a point below its baseline
The same tests can cover a little less from run to run, with timing or the
tools a machine has, so mise run test fails a package only when it is more
than a point below its baseline (COVERAGE_TOLERANCE, 1 by default). A package
within that point passes and keeps its line, so a baseline still never goes
down. coverage.txtar covers within, beyond and a tolerance of 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 15:06:25 -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 9c34ad5c69 fix: host git reaches ssh alone, a queued git-protect mode is set after the check, and retention's lock is an OS file lock
A review of the recent fixes found three gaps, and an e2e cascade.

- hostgit: protocol.allow=never is only the default for protocols with no
  key of their own, so a repo's protocol.ext.allow=always and a url
  insteadOf for the VM's URL made a --clone VM's seed push and rm's fetch
  run a command the repo named on the host. Host git now runs with
  GIT_ALLOW_PROTOCOL=ssh, which git takes over every protocol setting.
  TestCommandSSHOnly (failed on the old code).
- git-protect: checkGit set a mode saved while the VM ran before it
  checked .git, so a .git the VM replaced meanwhile became the baseline
  without git_replaced. It checks under the mode the VM ran with first,
  then sets the new one. git_protect.txtar's replaced-.git step (failed
  on the old code).
- retention: its lock was a folder taken over after 10 minutes, so a
  long retention run could be joined by a second devvm and a crash left
  it held. It's platform.TryLockFile on retention.lock now, and
  retainLockAge is gone. TestRetainDueAndLock checks an hour-old held
  lock isn't taken over.
- e2e: when the group join's helper server didn't start, gp_refused ran
  devvm network on for a VM outside the group, which turned its policy
  on, so six later group and link checks failed too. gp_refused now
  checks the VM is a member first, and lk_start says which server didn't
  start.

Docs: internals/git-protection (GIT_ALLOW_PROTOCOL, the check's order),
using/space (retention.lock).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 07:31:24 -07:00
w3cjandClaude Opus 5.5 487366d186 fix(netpolicy): one strict parser for policy files, lines that aren't rules named, broken denies fail closed
The proxy read policy files with a laxer parser than devvm network allow's
check: a line that wasn't a rule was dropped without a word, or kept as a
rule that matched nothing (example.com:x became a host of that name, a
rule's trailing dot never matched), so a hand-edited deny could lapse
unseen. proxy.ParsePolicy is now the one parser: it returns each line
that holds more than a comment, with its number and whether it's a rule,
and a line is a rule only when ValidRule takes it, which is what devvm
network allow and deny take. parseRule is strict: ports 1 to 65535 in
digits, printable ASCII names with no empty label, brackets for IPv6
alone, no address under *., IPv4-mapped prefixes as their IPv4 ones, and
one trailing dot dropped, as requests' are.

A line that isn't a rule but starts with ! (proxy.BrokenDeny) fails
closed: while any of a VM's policy files has one, its proxy denies every
name and address, each request getting 403 and a refused block that names
the file and line, with no allow advice (block honours Refused;
policy.verdict and checkRefused carry it). Other lines that aren't rules
are skipped. The proxy logs each one, devvm network marks it (its control
characters dropped, msg.OneLine) and --json lists it in not_rules.
netpolicy.PolicyWarnings warns of each (policy_broken_deny or
policy_not_rule): at each launch with network policy (Proxy.Prepare),
after devvm network allow, deny and rm for the file they change, and in
devvm doctor for the files you edit (NotRules). AddRule and RemoveRule
find rules through ParsePolicy, so ruleOf is gone. A policy file that
comes back after it was missing is read again whatever its mtime, an
error other than a missing file keeps its last rules and broken deny, and
a leading byte-order mark isn't part of the first line.

Docs: rules, broken denies and devvm network's output (safety network),
the parser and the fail-closed policy (internals network), doctor's
warnings (install, internals install), the e2e network section
(contributing), the proxy's README.

Tests: TestParsePolicy, TestPolicySkipsBadLines, TestPolicyBrokenDeny,
TestPolicyFileBack,
TestValidRule's new cases and FuzzParseRule's agreement and host
properties (proxy); TestBuiltinPolicies, every policy file devvm ships,
TestNotRules, TestPrepareWarnsPolicy, TestWriteRules and
TestAddRemoveRule's new cases (netpolicy); TestDoctorReport and the
network JSON shape (cli); network_rules.txtar's mark, not_rules and the
warnings on a change, a launch and in doctor; e2e network: a broken deny
makes the running proxy refuse an allowed host until it's gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:23:22 -07:00
w3cjandClaude Opus 5.5 9454d3b2c5 fix(group): refuse a join whose member's name is the joiner's own hostname, and take turns on a lock so all or none holds
A VM whose folder part is another member's name (its folder part or the
name it joined with) would reach itself at that name, so devvm group join
now refuses it whatever --as it gives (group_name_hostname), naming the
fix: the member leaves and joins again with another --as NAME, or the
project uses a folder with another name. It replaces the
group_link_name_host warning, which is gone; groupLinks still makes no
link by the client's own hostname or localhost.

Joins, leaves, publish and unpublish's group sync and devvm rm's group
part hold a host-side flock, ~/.local/share/devvm/groups.lock
(platform.LockFileWaiting, saying group_waiting after 200 ms), from
reading the members' states to writing them. A join checks before it asks
to widen a parent folder's VM and again under the lock with its state read
again, so two VMs joining at once, one with network policy and one
without, can't both get in.

- vm: checkJoinName (pure: localhost, the joiner's hostname, taken names),
  checkJoin returns the members, Join split into rejoin and join,
  lockGroups, Groups.lock, syncOthers, Groups.forget; groupClash lost Own.
- Messages: group_name_hostname, group_waiting; group_link_name_host gone.
- Docs: links.md Names in a group and Groups and network policy; the
  design note's names rule, a Joins take turns rule, the Not covered
  bullet now only link add/rm racing a group change (those don't take the
  lock), the threat check rows; groups.lock in the state tables; the
  --as example; the CLI reference.

Tests: TestCheckJoinName, TestLockGroups (waits, says so, gets it once
let go; a context that ends first doesn't), TestGroupJoinsAtOnce (ten
rounds of two joins at once, one with policy and one without: exactly one
gets in; it fails without the lock), TestGroupLinks updated; group.txtar:
the refused join with and without --as, the fix, a folder named as a
member's --as, and two joins at once with one getting in; e2e
gp_hostname.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 23:28:21 -07:00
w3cjandClaude Opus 5.5 9c2511117b fix(hostgit): host git runs no program a repo names, nothing of devvm's environment, and ssh only to the VM
devvm ran git on the host bare: --clone's git status could run a repo's
core.fsmonitor or filters, its push, fetch, update-ref and remote remove
the repo's hooks, and git could ask on devvm's terminal or follow
GIT_DIR from devvm's environment. internal/hostgit is now the one runner
(Command, Output, Status), with its settings as GIT_CONFIG_COUNT pairs:
core.fsmonitor=false, core.hooksPath=/dev/null,
core.alternateRefsCommand=true, hook.EVENT.enabled=false for every
githooks(5) event, protocol.allow=never with protocol.ssh.allow=always;
and, for a command with -C DIR, hook.NAME.enabled=false and
filter.NAME's clean/smudge/process emptied with required=false for
each hook and filter driver DIR's config names. It drops every GIT_*
variable and relative PATH folders, and sets GIT_TERMINAL_PROMPT=0,
GIT_NO_LAZY_FETCH=1 (a repo that says it's a partial clone fetches
nothing, with its core.sshCommand or ssh), GIT_SSH_COMMAND=false (no ssh
but gitSSH's) and GIT_SSH_VARIANT=ssh; maintenance.auto=false and
gc.auto=0. Status adds --no-optional-locks and --ignore-submodules=all.

Callers: gitprotect (git, ignoreSubmodules), project.SSHRemote, vm/sync's
gitConfig, vm/clone (hostGit, gitSSH, saveFetched, the uncommitted-changes
status). gitSSH takes the VM: ssh with BatchMode, StrictHostKeyChecking,
devvm's known hosts only, HostKeyAlias=VM, ForwardAgent=no and
ClearAllForwardings=yes, so a url.*.insteadOf reaches only the VM with
its pinned key. The seed push adds --no-verify, --no-recurse-submodules
and --no-signed; rm's fetch --no-recurse-submodules.

Not neutralized: an include.path can make gitConfig read
user.name/email from another git-config file (sent to the VM as its
identity), and a FIFO as a config file hangs git until Ctrl+C; neither
runs code. A VM swapping the repo's config between repoOff's listing and the command
could hide a filter from it, and a --clone VM's root (its host key)
working with another VM that writes the repo could send the push to a
server of theirs; both documented in internals/git-protection.

Tests, each with plain git first running what the hardened one doesn't:
hostgit's TestCommandNoFsmonitor, TestCommandNoHooks (reference-
transaction, pre-push, from .git/hooks and a core.hooksPath; path,
file:// and ext:: pushes refused), TestCommandNoConfigHooks (hook.NAME.*),
TestCommandIgnoresGitEnv (GIT_DIR, GIT_WORK_TREE; environ),
TestCommandNoLazyFetch (a partial clone's core.sshCommand),
TestStatusNoFilters (clean, process, required, names with dots, = and
capitals), TestStatusNoSubmodules; vm's TestHostGitNoFsmonitor and
TestCloneRunsNoHooks (seed push and rm's fetch, update-ref and remote
remove); clone.txtar's push ssh options.

Docs: safety/attack-vectors (devvm's own git commands),
internals/git-protection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:13:43 -07:00
w3cjandClaude Opus 5.5 512793cd69 fix(tools): the share's lock and the --from conversion lock are OS file locks, so a crash never leaves them held
The share's lock was a folder in the share (tools/.lock) removed only by
devvm's cleanup, so a devvm that crashed or was killed left the next one
waiting ten minutes and then failing with share_lock_held. The --from
conversion lock on Lima was a folder holding its devvm's pid, taken over
from one that had ended.

Both are now platform.LockFileWaiting on a file in devvm's data folder
(tools.lock, outside the share VMs mount; oci-build.lock), which the system
lets go of when devvm ends, however it ends. Another devvm waits until the
holder lets go or the run is interrupted, saying so after 3 s
(share_waiting, oci_waiting).

- share_lock_held is gone, with the try count, the cleanup and the pid
  takeover; tools.Env's ShareWait and Lima's OCIWait are ShareNote and
  OCINote, how long before devvm says it's waiting.
- Docs: Building tools and How it's converted describe the locks; the
  state tables list tools.lock, oci-build.lock and images/locks/<key>.

Tests: tools TestLockShareKilled (a killed holder's lock is taken at
once; it failed with share_lock_held before), TestLockShare rewritten
(waits, says so, gets it once let go, the lock outside the share);
lima TestLockOCI rewritten (a lock file nothing holds is taken at once,
a held one is waited for, saying so); from.txtar converts with a lock
file left as a crashed devvm leaves it, and no wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:51:26 -07:00
w3cjandClaude Opus 5.5 20c9fdbadd fix(build): a build holds its image's lock, so concurrent builds, gc and rebuild leave it alone
On Lima a build in progress is a recordless image with its final name, so
a second build, devvm rebuild or devvm gc took it for a leftover and
deleted it. Each build now holds an OS lock per image key
(images/locks/KEY) from before it looks for the image until its record is
written; the system lets go of it when devvm ends, however it ends.

- A second build of the same image waits for the lock, saying so after 3 s
  (image_build_waiting), then finds it built.
- An image without a record is unfinished only while its lock is free;
  while held it's listed as building (devvm images, --json state).
- gc (and gc --backend) and rebuild skip building images; images rm and
  DeleteKey refuse them (image_building). Deleting an image removes its
  lock file while holding it.
- platform: LockFileWaiting and LockFileSharedWaiting (call a func once
  after waiting a while), LockHeld; a lock whose file was removed while
  held is taken again on the new file. tools.Making.Hold uses the shared
  helper instead of its own two-step wait.
- state.ImageLock: a key's lock path, the key checked.

Tests: build TestBuildInProgress, TestBuildTakesTurns; platform
TestLockFileWaiting, TestLockFileRemoved, TestLockHeld; state
TestImageLock; build.txtar checks a hanging build is listed as building,
kept by gc and refused by images rm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:39:11 -07:00
w3cjandClaude Opus 5.5 7929eafaf5 fix(msg): every message value renders without control characters
A value a VM made reached the terminal unfiltered wherever a caller
forgot msg.Shown, such as the errors passed as err.Error() and a link's
name. Four cleaners did the job in different ways: msg.Shown (quoting),
ui's printable and oneLine, netpolicy's oneLine and the port
forwarder's log (which let C1 through, in UTF-8).

msg.Printable and msg.OneLine are now the one cleaner: they drop C0 but
newline and tab (OneLine drops those too), DEL and C1, in UTF-8 or as a
lone byte. Every message value goes through OneLine as the message
renders, in Text, Segments and names mode, so no caller can forget it,
and msg.Shown is gone with its 68 calls. The status line, the run log's
end and verbose output, Pick, devvm network log, the forwarder's log and
a clone's status lines use them too.

Tests: TestPrintable and TestValuesArePrintable (internal/msg), the
hostile-value segments test, TestLogLimit (internal/backend/vmssh) with
C1 in UTF-8 and as a lone byte; TestCheckLinks and
TestNewVMOtherRepoAndCommondir expect the cleaned values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:19:23 -07:00
w3cjandClaude Opus 5.5 5f9e2e2408 fix(rm, git-protect): messages whose advice looped now name what works
- rm_export_failed names devvm rm --no-export, the flag that skips the
  export, in place of devvm rm -f.
- devvm rm --no-clone-check deletes a --clone VM without checking its
  clone, after warning that its unfetched commits and uncommitted changes
  go with it (clone_check_skipped). clone_check_failed names it.
- devvm git-protect on, strict or off on a running VM (macOS) is saved
  in the VM's state (git_protect_next) and applied the next time devvm
  finds the VM stopped: devvm stop, devvm restart, or the next launch of
  a VM stopped some other way, before it starts (git_protect_next_stop).
  So git_protect_flag_ignored's advice, devvm git-protect off, works on a
  running VM, and git_protect_running is gone. gitprotect owns the key
  (Next, SetNext; Set drops it); vm's checkGit applies it, then the
  .git check and set-id files, for devvm stop and every launch.

Tests: TestSetNext (internal/gitprotect); git_protect.txtar (a running
VM's choice saved, replaced, applied by devvm stop and by the next
launch); clone.txtar (clone_check_failed, then --no-clone-check);
e2e project's git-protect check and clone's rm check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:16:47 -07:00
w3cjandClaude Opus 5.5 665b9f3b22 feat(group): devvm group, group join NAME and group leave: VMs that reach each other's published ports by name, through links
A group's links are links in each member's state, marked as the group's
(a sixth field, ,group), so the link session, the proxy's list and every
connection check treat them as any link. Membership is each member's own
state (group, group_as), so a VM made again is in none.

- internal/vm/groups.go: Groups (Show, Join, Leave), groupLinks (pure:
  the user's links kept and taking precedence, a link per published port
  of each other member, one address per member kept across changes),
  sync/syncVM/change (records, names what each member gains and loses,
  applies to running members), clashes warned.
- All or none: join refused by network policy (group_policy_on/off);
  devvm network on/off refused for a member (group_policy_mixed).
- One group at a time (group_other); names unique in a group
  (group_name_taken, group_name_host); a member whose hostname is
  another's name gets no links to it (group_link_name_host).
- CheckLink refuses a group's link once the two aren't in one group
  (ungrouped); leave removes the leaver's own group links first; join
  again works every member's links out again; link rm refuses a group's
  link that still applies (link_from_group).
- Publish/unpublish, link add/rm and devvm rm reach the group's links.
- Docs: using/links.md Groups, the Commands page, safety/network.md,
  internals/ports.md, the design note's Groups section and threat check;
  the CLI reference.
- Tests: groups_test.go, testdata/script/group.txtar, JSON shape; e2e:
  three VMs in a group and the all-or-none refusals in the link section
  on every backend.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 16:01:54 -08:00
w3cjandClaude Opus 5.5 99c6faeda4 feat(link): devvm link add, link publish and the client's launch warn of a target whose network policy isn't in force
A client with network policy has each connection to a running target
whose network policy isn't in force refused (unenforced). devvm now warns
of such a target before that, refusing nothing, with the connection's own
check: link_target_unenforced names the target and the client and says to
run devvm restart in the target's folder. A stopped target isn't warned
of, as its policy applies when it next starts.

- internal/vm/linksession.go: policyUnenforced (policyEnforced's verdict
  for a warning), Links.warnUnenforced (the target's backend, running,
  then policyUnenforced)
- internal/vm/links.go: Add warns for a new link and for one that exists;
  Publish warns, through publishUnenforced, for each client with network
  policy that links to a port published now and not before
- internal/vm/linkrun.go: warnTargets, at the client's launch, warns of a
  running target whose policy isn't in force
- locales/en.toml, internal/msg/docs.go: link_target_unenforced, linked to
  using/links#links-and-network-policy
- TestWarnUnenforced (enforced, unconfined, self-check failed, stopped,
  a client without policy; agrees with the connection's check),
  TestLinksAtLaunch's unenforced target; link.txtar: add, link_exists and
  publish warn, a client without policy isn't warned
- tests/e2e.sh: lk_policy_unenforced also checks link add's and the
  client's launch's warning
- docs: using/links.md, safety/network.md, the design note, contributing's
  link section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 14:31:02 -08:00
w3cjandClaude Opus 5.5 9b7652d347 feat(link): links in VMs' lifecycle, and the link backend feature
backend.FeatureLink ("link"), native on Lima, smolvm and Docker, with its
row on internals/backends.md; linkFeatures() returns it, so link add, each
launch, the session and each connection check it with Require.

- Env.Links is guestLinks: an address and a name per target, by address,
  none for a target whose policy rule no longer holds.
- Launch (setUpVM, after the ssh config pins host keys): linkRuns.atLaunch
  starts devvm _links detached (pid in run/<vm>.links.pid, its log in
  logs/<vm>.links.log), warns once per stopped target (link_target_stopped)
  and per target whose policy rule broke (link_policy_mismatch) or whose
  backend lacks links (link_target_unusable), never starting one, and
  reads the new session's log for refused forwards (link_port_taken).
- link add and link rm on a running client send the setup again and make
  sure _links runs (linkRuns.apply), reporting a new link the VM refused;
  on a stopped one, links_next_start.
- Stopping: Lifecycle.Stop and every Env.start stop the session; a session
  killed has its sockets removed; its masters' control sockets go with
  their ssh.
- devvm rm (Lifecycle.forget, so gc --orphans and retention too) stops the
  session and removes every link to the VM from other clients
  (links_target_gone), giving running clients their links at once.
- devvm network off on a target linked by clients with policy
  (network_off_linked) and on for a client linked to a target without
  (network_on_linked) are refused.
- link unpublish names the clients that link to the withdrawn ports
  (unpublished_linked).
- devvm ls has a LINKS column and "links" in --json; devvm doctor lists
  link; gc --orphans removes links to VMs without state and link sockets
  nothing listens on, which devvm space counts as leftover state.
- net_off_log says devvm logs only a VM's links' connections without
  network policy.
- Lima: Start already compares the guest environment, so it edits only
  when the links' names change (TestStartSetsLinkNames); lima.md and the
  design note say the edit's new host keys are pinned again at the start.

Fixes to the earlier link code: vmssh's masters left their control
sockets when killed; the session's log names a forward the VM refused on
a line of its own (ReadLinksLog).

Tests: vm TestGuestLinks, TestPolicyLinked, TestUnlinkTarget,
TestLinkLeftovers, TestLinkRuns, TestLinksAtLaunch; vmssh TestReadLinksLog;
lima TestStartSetsLinkNames; link.txtar updated, link_life.txtar new, the
stub ssh carries link masters; e2e's project section has a link smoke check
on Lima.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:38:24 -08:00
w3cjandClaude Opus 5.5 133a4d3cdb feat(guest): what a client VM needs for links: sshd's rule, low ports, /etc/hosts and NO_PROXY
Every VM's sshd (base.sh's 00-devvm.conf, services.sh) allows remote
forwards of TCP ports only on 127.77.0.0/16: AllowTcpForwarding all,
GatewayPorts clientspecified, PermitListen 127.77.*:*. Remote socket
forwards, tunnels and X11 stay refused. The setup sets
ip_unprivileged_port_start to 0 where it's 1024, writes the VM's links in
a marked /etc/hosts block in place (Docker's is a bind mount), and puts
DEVVM_NO_PROXY in every NO_PROXY it writes.

The links come from Env.Links (nil: none), a list of GuestLink {Addr,
Names}, checked on the host by checkLinks (link_setup_invalid) before the
start's NO_PROXY (netpolicy.LinkEnv) and the setup's hosts file. design.md,
security.md, smolvm.md and docker.md describe the sshd rule; e2e checks
it with rfwd_links on every backend, and low ports on Alpine and smolvm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 07:03:24 -08:00
w3cjandClaude Opus 5.5 6805d194bd feat(link): devvm _links, the host side that carries a client's links, and the forwarder skipping links' addresses
vmssh.Links runs a running client VM's link session: one ssh master of
its own to the client (never the forwarder's), started with
ClearAllForwardings=yes and -N, to which each link is added with
-O forward -R 127.77.x.y:PORT:<socket> and from which it's removed with
-O cancel, read again every second (Want). Each forward is its own, so
one the client refuses fails that link alone (Failed, which warns with
link_port_taken through Link.PortTaken). Each link's end on the host is
a unix socket, mode 600, in the run folder (made 700), named
link-<hash of client, address, port>.sock; masters' control sockets are
link-<hash>.ctl (the session's; a target's by target and start). A
stale socket is replaced, anything else refused, and sockets go with
their link or the session.

Each connection is checked again (Check), then carried by
ssh -S <target master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT
through a master kept per target and start: a channel goes through the
master or nowhere. At most 256 at once, then refused (link_limit).
Events (link, link_refused, link_target_stopped, link_limit) go to the
client's event log. The session ends once the client no longer runs its
start, or has no links.

vm.Links.Session builds it from the state and the backends: the
client's and targets' ssh from Backend.SSH, the key its first
IdentityFile, host keys devvm's pinned known_hosts (HostKeyAlias), only
on a host loopback port or through the backend's ProxyCommand, FeatureSSH
allowed. linkConn re-reads the states per connection: the link still in
the client's state (removed), CheckLink (gone, replaced, unpublished,
policy), the link features on the target's backend, the target running
(Inspect, StartID: link_target_stopped otherwise; it never starts one),
its ssh (ssh). devvm _links VM (hidden, one argument) runs it, failing
with link_session_failed or vm_not_running.

The port forwarder never forwards a listener in 127.77.0.0/16 (dialAddr,
vmssh.IsLinkAddr), on any VM; a test keeps vmssh.IsLinkAddr equal to
vm.IsLinkAddr on every link address and around them.

netpolicy.AppendEvent writes devvm _links's events beside the proxy's,
mode 600, rotating past 10 MiB; events carry target, which FormatEvent
and devvm network log --json show.

Tests: TestLinkArgs, TestLinkFiles, TestListenSocket, TestLinks,
TestLinksSessionLost, TestLinksCap, TestIsLinkAddr, TestListeners
(range exclusion) in vmssh; TestLinkAddrsAgree, TestLinkConn,
TestSessionLinks, TestLinkEvents in vm; TestAppendEvent and link cases
in TestFormatEvent; link_session.txtar for _links's argument and
refusals; e2e's project section checks a server on 127.77.0.1 isn't
forwarded while the VM's own on 127.0.0.1 with its port is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 06:48:11 -08:00
w3cjandClaude Opus 5.5 4ea141b918 feat(link): devvm link, link add, rm, publish and unpublish, with their state and checks
Links between VMs' commands and state, without anything carrying a
connection yet.

- state: every VM gets a random ID (KeyID, "id") when CreateVM makes it.
- vm: Links (links.go) lists, adds and removes the folder's VM's links
  (KeyLinks, "links": NAME,PORT,TARGET,TARGET_ID,ADDR entries) and
  publishes and withdraws its ports (KeyPublish, "publish"). Each target
  gets one address in 127.77.0.0/16 per client, the lowest free. CheckLink
  says why a link doesn't apply (gone, replaced, unpublished, policy).
- project: Matching (which sshconfig.Alias now uses), IsPath, ForDir and
  Targets resolve a link's TARGET: a path, a VM's name or a folder name.
- cli: link.go, in the Links between VMs group; --json on devvm link and
  devvm link publish; --as checked with the other flag values.
- Messages: no_vm_link, link_failed, link_port_invalid, link_ports_invalid,
  link_unknown_target, link_ambiguous_target, link_self,
  link_not_published, link_policy_mismatch, link_name_invalid,
  link_name_host, link_name_taken, link_target_named, link_exists,
  link_added, link_trust, link_removed, link_not_found, link_port_taken,
  published, unpublished, port_not_published.
- Docs: the Links between VMs table on the Commands page, the CLI
  reference, AGENTS.md and the cli skill's tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 06:13:15 -08:00
w3cjandClaude Opus 5.5 608d287d00 test(cli): devvm space's backend timeout is a test-build setting, so the space script doesn't depend on load
A test build's Host reads DEVVM_TEST_LIST_TIMEOUT (platform.TestListWait):
comma-separated durations, each for every backend ("10m") or one
("smolvm:1s"), one backend's winning. spaceTimeout(backend) reads it
through registry.Host(), so a release always waits 30 s. devvm space's
listings and strays and gc --caches' cache listing use it.

The CLI tests' fakeHost sets 10m for every script. space.txtar adds a
case where smolvm's listing hangs (the stub's smolvm-ls-hangs) past a
1 s smolvm timeout: smolvm is named (space_backend_unknown) and its VM's
state isn't a leftover. TestListTimeout covers the parsing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 08:13:27 -08:00
w3cjandClaude Opus 5.5 16b4ad8771 feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no
question is asked or read. The ui's prompts (Ask, Confirm, Answer,
Secret, Pick/PickOne in a terminal) show the question, then fail with
no_input naming what answers it (msg.AnswerFor, by the question's ID),
or no_input_terminal for a question only a terminal answers. ui.Flags
and SetFlags carry -v and --no-input.

Answers: --network-policy/--no-network-policy, --here, devvm size -g,
devvm setup --features/--backend, devvm network -g, devvm ssh-agent add,
devvm restart, --ssh-config (new, on devvm, host and code: the Include
line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude),
--stdin, and --force.

--force (-f) only skips a confirmation, and destructive commands need it
without a terminal (force_needed, a failure, not a usage error): rm (new
rm_confirm), gc (it went ahead without a terminal), gc --caches (now
allowed without a terminal with --force), images rm (images_rm_confirm),
secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images
are built on the one rebuilt (build.Env.Force). rm --no-export skips the
export; rm's parent-folder, earlier-folder and --clone confirmations are
terminal-only and --force never answers them (vm.RmOptions). gc --tools
--force splits: --recent (only with --tools, gc_recent_needs_tools)
drops the hour's hold and keeps the refusal while a VM is being made
(gc_recent_making); gc_tools_recent names devvm gc --tools --recent.
gc_caches_need_terminal goes.

Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt
(--force), TestRebuild (force_needed, then Force); secret, rebuild,
images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images
rm/secret rm/rebuild with --force (and --no-export where rm -f skipped
the export), and the clone section's rm with its checks. Docs:
commands.md (Questions devvm asks, rm, flags), first-vm, clone, images
(cleaning up, --recent), space, coding-agents, internals overview and
images; CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 03:51:27 -08:00
w3cjandClaude Opus 5.5 a7b605f0c0 feat(cli): -v/--verbose streams the run log
A global -v/--verbose (persistent on the root, the only one with
--help): each line the run log gets, numbered steps, the redacted
command lines and the commands' output, also goes to stderr as it's
written, without control characters (a C1 control split across writes
too) and dim where stderr is colored, with no status line. The run log
is still written. A logged failure while verbose names the log
(log_details) instead of printing its end again. DEVVM_VERBOSE is gone.

ui: SetVerbose; stream (printable, dim) and logTo tee LoggedCmd's and
LogWriter's output; a streamed command's pipe gets WaitDelay
(streamWait, 2s) so a process it leaves running can't hold devvm, and
ErrWaitDelay alone isn't a failure. --version stays root-only, and
version.txtar checks -v isn't it.

Tests: TestStreamIsPrintable, TestDieLoggedVerbose, the logged-command
and status tests; build.txtar streams a build with -v. Docs:
troubleshooting (A command fails), settings (colors, environment),
commands (Flags and values), contributing (styles); CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:55:59 -08:00
w3cjandClaude Opus 5.5 e782de9ae8 feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory,
--disk, --ports, --network-policy, --no-network-policy) are the root's
own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown
flags. build, rebuild and images rm take --backend and --from;
images, gc and space take --backend as a filter of their own (images
and space now filter: only that backend's rows); doctor takes
--backend; restart and tools take none. ports -g is local on ports,
ports add and ports rm. No command has a persistent flag.

One name, one meaning: network log --follow loses -f (-f is --force's,
and gc --force gains it); the hidden secret get's --force becomes
--to-terminal. Flag defaults name the setting command (devvm size -g,
devvm ports -g, devvm setup --backend); descriptions lose then/also
openings.

Special values are words: an empty flag value (flag_blank) or an empty
argument (arg_blank) is refused everywhere, replacing features_empty.
Durations: state.ParseDuration (a whole number and m, h, d or w) for gc
--older-than, retention's ages and ssh-agent add --lifetime (which also
takes forever, via sshagent.CheckLifetime), with one message,
bad_duration, replacing gc_bad_age and agent_lifetime_invalid.
Blanks are checked with the other usage errors (checkCommand, before
checkFlags), and an unknown --backend NAME is a usage error checked
first too (checkFlagValue, against registry.Names, which a test keeps
equal to the registry's own).

Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning,
TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root,
setup, images, space, gc_history, retention, ssh_agent and network_log
scripts. Docs: commands.md (Flags and values), from.md, install.md,
images.md, space.md, settings.md, ssh.md, network pages; CLI reference.

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 02:27:57 -08:00
w3cjandClaude Opus 5.5 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 07ca65c098 feat(cli): devvm host, the tools noun and devvm history
devvm ssh is devvm host. devvm tools shows this folder's VM's shared
tools (TOOL VERSION NEWER BUILT, from the lock as it is, never online);
devvm tools add/rm TOOL... add and take out shared tools, each a word of
its own (joined with + refused: tools_joined; add takes only shared
tools: unknown_tool), and devvm tools update moves the VM to the newest.
devvm IMAGE on a VM that exists adds nothing and asks nothing: it fails
with vm_lacks_tools, naming the devvm tools add command, or
vm_lacks_layer, as only a new VM gets a layer. devvm export is devvm
history export [FILE]; devvm history lists the exports in the exports
folder (FILE VM FOLDER DATE SIZE), the folder from a <export>.folder
file written beside devvm's own exports and deleted with them. gc
--exports is gc --history, retention's exports.age/count are
history.age/count, and devvm space's row is history.

The in-place layer machinery goes: Launch.addLayers and runLayers,
dockerLayers' inPlace/set/unset, backend.DockerLayerVM.SetDockerLayer
and the Docker backend's SetDockerLayer, with the add_in_place,
restart_for_mounts, no_terminal_confirm, keeping, adding and
add_layer_failed messages. vm.Tools (tools.go) holds Add, Remove,
Update and List; tools.VMs.Show lists a VM's tools; tools.Remove takes
names as a list; VMs.Update compares a VM's files as a set.

New messages: vm_lacks_tools, vm_lacks_layer, has_tools, tools_joined,
history_failed, tools_failed; renamed: unknown_tool, gc_history,
gc_history_export, deleted_history, gc_older_than_needs_history.
Command files: host.go, tools.go, history.go, refreshtools.go
(_refresh-tools); ssh.go, remove.go, update.go, export.go and
gc_exports.go gone. Tests: TestImageLacks, TestToolsAdd, TestShow,
TestCompleteToolNames; history.txtar, gc_history.txtar, host_code.txtar
and the e2e tools, docker layer and host checks updated. Docs, the CLI
reference, AGENTS.md and the e2e header follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:27:24 -08:00
w3cjandClaude Opus 5.5 18eefddc16 feat(cli): devvm retention, bare secret and ssh-agent, ssh-agent rm, and setup's network question
- devvm retention [KEY=VALUE...] shows every retention setting (off when
  unset) and changes them; KEY=off turns one off, KEY= is refused and
  nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
  Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
  agent's keys once one is added (it starts no agent without one).
  devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
  its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
  key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
  refused). In a terminal it also asks for new VMs' network policy (ask,
  on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
  VMs read unless --network-policy or --no-network-policy is given.

Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 01:38:54 -07:00
w3cjandClaude Opus 5.5 9b2650e089 fix(gc): gc --tools and retention keep current tools while a VM is being made
A new VM can pick a tool built long before that no VM has, so the hour
alone didn't keep it from plain gc --tools or retention's
tools.unused-age between picking it and its state listing it. Both now
try the making lock without waiting, after the share's lock, and hold it
until they're done.

While any VM holds it, plain gc --tools keeps every current tool no VM
has, after the same filters, and names them (gc_tools_making), deleting
the rest of its list; retention deletes no tool images that run and
leaves their idle records, then applies its other settings. A devvm
that starts to make a VM while either holds the lock waits, saying so
after 200 ms (making_waiting). gc_force_making gives one action.

Tests: TestMaking (the wait message), gc_tools.txtar (a hanging up keeps
an old tool through plain gc --tools, the kill releases it),
retention.txtar (a hanging up keeps the tools, the rest runs). Docs:
using/images.md, using/settings.md, internals/images.md, the CLI
reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 00:39:23 -07:00
w3cjandClaude Opus 5.5 c0b9916ff2 feat(gc): gc --tools names the tools it keeps for the hour, and --force deletes them
gc --tools prints gc_tools_recent (count, tools) for the current shared
tool images no VM has that it keeps because they were built in the last
hour, after the same filters as the ones it deletes (TOOL names,
--backend, skipped backends): with gc's list, or in place of
nothing_to_clean. Plain gc never prints it.

--force, only with --tools (gc_force_needs_tools otherwise), also
deletes those and skips gc's prompt; gc still lists what it deletes.
Tools a VM's state lists stay, the share's lock is held from before the
List, and no other category widens. Retention's Idle keeps the hour.

The being-made signal: tools.Making, an flock on making.lock in devvm's
data folder (platform.LockFileShared, platform.TryLockFile). up's create
(every backend, --clone, devcontainers), devvm update and adding a layer
in place hold it shared from before they pick tools until the VM's state
lists them; gc --tools --force takes it exclusively without waiting,
after the share's lock, and holds it through its deletions, else fails
with gc_force_making and deletes nothing. The OS releases it when the
process ends, and its descriptor is close-on-exec.

Tests: TestLockFileShared, TestLockFileKilled (a killed child releases
it), TestMaking, TestNoVM's recent ones, TestGCAsks, gc_tools.txtar.
Docs: using/images.md, using/space.md, internals/images.md, the CLI
reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 00:19:42 -07:00
w3cjandClaude Opus 5.5 6f680a6f8b feat(proxy): a shared, read-only Nix cache that only the host fills
VMs with network policy and the nix layer share their downloads from
cache.nixos.org: the proxy answers http://devvm.proxy/nix/ itself (a
reserved endpoint, never forwarded), and the guest setup puts it before
https://cache.nixos.org in Nix's substituters, trusted-public-keys left
as Nix's own (cache.nixos.org-1). Each VM keeps its own store and daemon;
only downloads are shared, and no VM can change what another gets.

The proxy (internal/proxy/nixcache.go, -nix-cache DIR and
-nix-cache-max BYTES):
- takes only GET and HEAD, no query, nothing escaped, of
  nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no
  suffix or .xz, .zst or .bz2 (nixPath, FuzzNixPath); 400 otherwise;
- makes up nix-cache-info (priority 30, before cache.nixos.org's 40);
- fetches from https://cache.nixos.org alone, when the VM's policy
  allows cache.nixos.org:443, through the floor or the company proxy,
  with the system's roots and the user's CAs, following no redirect,
  sending nothing of the VM's request;
- keeps a narinfo when its StorePath is the path asked for, its URL is
  of the pattern and named by its own NarHash or FileHash, and a Sig by
  the pinned cache.nixos.org-1 Ed25519 key verifies over
  1;StorePath;NarHash;NarSize;References (parseNarinfo, against a real
  narinfo and NAR of cache.nixos.org's in testdata/nix/);
- fetches a NAR only after a narinfo it checked names it, never for a
  HEAD, once however many ask and at most four at once (fetchOnce), and
  keeps it when its SHA-256 and size are the narinfo's FileHash and
  FileSize; a cached copy of another size is dropped;
- answers 404 to anything that fails, keeping nothing, so Nix goes to
  cache.nixos.org itself; logs each request as a nix-cache event
  (hit, fetched, or why not), which devvm log shows as cache;
- writes files whole and renames them in, 600 in folders of 700.

The cap: the nix-cache.size retention setting, 10 GiB when off
(state.NixCacheDefault, proxy.NixCacheDefault), with state.ParseSize
(500M, 20G, 1T). Under a flock on .lock every proxy takes a file's room
before writing it (reserve, in whole blocks), deleting the least
recently used files (by mtime, which a hit sets) down to nine tenths of
the cap; a NAR being fetched is made its full size at once and counts,
so a fetch the in-flight files leave no room for is refused. devvm gc
trims to the cap, devvm gc --nix-cache empties it, and the daily
retention run trims it (proxy.TrimNixCache, NixCacheUsage). devvm space
has a Nix cache row (GC: what's over the cap, FREED BY gc --nix-cache,
RETAIN nix-cache.size), devvm images says what it takes of its cap.

netpolicy passes -nix-cache and -nix-cache-max only for images with the
nix layer (nixCacheArgs; a retention file it can't read warns and uses
the default). The guest setup writes /etc/nix/devvm-cache.conf through
!include in nix.conf only with the nix layer and policy on, removes it
otherwise, and restarts nix-daemon when it changes. VMs without network
policy get no shared cache: they fetch from cache.nixos.org directly,
and nothing new runs or listens on the host for them.

Review (security-audit skill, on nixcache.go, its callers and the
setup): a NAR could be kept under another NAR's name, as the URL isn't
signed (fixed: the URL must be named by the narinfo's own hashes, and a
hit of another size is dropped); files being fetched didn't count
against the cap and blocks weren't counted, so one VM's parallel
requests could pass it (fixed: reserve, full-size temp files, block
counts, fetchOnce); a HEAD downloaded a NAR (fixed). Ruled out: stored
VM input, paths out of the folder, another upstream, parser
differences, cross-VM visibility beyond timing, a VM's own nix.conf.
Open, documented: timing tells a VM whether some VM fetched a public
path, and a VM can fill the cache to its cap.

Messages: gc_nix_cache_over, gc_nix_cache, deleted_nix_cache,
images_nix_cache; retention_deleted gains nix_files. Paths:
Dirs.NixCache (structure limit for Dirs to 40). Flags: devvm gc
--nix-cache; the CLI reference regenerated.

Tests: TestNixPath, TestNix32, TestParseNarinfo, TestNixCacheServes,
TestNixCacheRefuses, TestNixCachePolicy, TestNixCacheFetches,
TestTrimNixCache, TestNixCacheCap, FuzzNixPath, TestParseSize,
TestRetention, TestNixCacheArgs, TestFormatEvent; nix_cache.txtar (the
proxy's endpoint and refusals, space, images, gc, gc --nix-cache,
retention); e2e nix: the VM's substituters and keys, hello through the
cache, fetched by the host (600/700), a VM's writes and other requests
refused and nothing kept, a second VM's hits fetching nothing, no cache
after devvm network off.

Docs: the design note (internals/design.md), internals/network.md's The
shared Nix cache, the VM's setup, logs and flags, internals/security.md,
internals/images.md, safety/network.md's Nix and Logs,
using/toolchains.md's Nix projects, using/images.md, using/space.md,
using/settings.md's Retention, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:56:53 -07:00
w3cjandClaude Opus 5.5 415e77c773 test: docker's and smolvm's forwarding scripts use free ports and look for their own forwarders
docker.txtar and smolvm.txtar gave the VM's servers fixed host ports
(47327-47329), so another run of the same script on this machine (a gate in
another worktree) could hold them, and the forwarder refused them as taken.
Each script now takes its ports from free_port, writes them into the stub's
guest-ports in hex, and expects them throughout. The ps checks of a running
forwarder match only this run's, by its key in the run's data folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:46:07 -07:00
w3cjandClaude Opus 5.5 3c4a77349c fix(clone): rm checks every worktree inside a --clone VM's clone
devvm rm on a --clone VM ran git status only in the clone's main
checkout, so uncommitted changes in other worktrees in the VM went with
it unasked. It lists the clone's worktrees (git worktree list
--porcelain -z, at most 1 MiB read) and checks each one's status,
showing the changes under each worktree's path, 20 in all.

The list comes from the VM, so only clean absolute paths inside the
clone are used, each once, and bare or prunable ones are skipped; a
worktree whose folder is gone has nothing to lose. Paths go to the VM
only as an argument and are shown through msg.Shown. At most 100
worktrees are checked; past that devvm says so and asks anyway.

- internal/vm/clone.go: cloneChanges, cloneWorktrees, insideClone,
  showChanges, cloneExec, worktreeStatus, cloneWorktreesMax
- messages: clone_worktree_dirty, clone_worktrees_unchecked (linked
  to using/clone#deleting-the-vm)
- tests: TestCloneWorktrees, TestCloneRmWorktrees,
  TestCloneRmTooManyWorktrees; clone.txtar's dirty worktree; the
  limactl stub's git worktree list and worktree status; e2e clone's
  dirty-worktree check
- docs: using/clone.md's Deleting the VM and a new section, Several
  agents in one VM; internals/overview.md

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 22:28:06 -07:00
w3cjandClaude Opus 5.5 36f4d0ab21 feat(gc): a backend that can't list its images is skipped with a warning
When a backend that a VM's state names can't list its images, gc warns
(gc_backend_skipped, linked to Cleaning up) with its Check's error, else
its listing's, and leaves everything of that backend's alone: its
images (not listed), its unused and current shared tool images and
those whose backend devvm can't tell, its orphans (moved to the backends
that couldn't be asked, so gc_orphans_unknown names it) and, with
--caches, its cache. gc goes on with the other backends and succeeds.
devvm images still fails, as it lists every backend's or none.

listImages returns an imageListing (images, tools, unlisted backends);
images uses its failUnlisted, gc's planGC its skip, withoutSkipped and
the skipped set gcRun hands to gcCaches.

Tests: TestWithoutSkipped; gc_skipped.txtar (Lima's stale image and
tool deleted, smolvm's and an unknown backend's tool kept, the smolvm
VM's state kept, gc succeeds, devvm images fails); gc_orphans.txtar's
end. Docs: using/images.md's Cleaning up, using/space.md's leftovers,
gc's help and the CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 16:50:19 -07:00
w3cjandClaude Opus 5.5 c3173b1544 feat(gc): gc --orphans names each Docker volume, network and image it deletes
A gone Docker VM's home volume holds its home folder, and gc --orphans
deletes it without an export, so the listing before gc asks names it.
backend.LeftoverLister is a Forgetter that names the resources of its own
Forget deletes (backend.Leftover, by LeftoverKind); Docker's Leftovers
lists the VM's relay container, its networks (<vm>-net, <vm>-docker-net),
its volumes (home, clone, docker, containerd), each only if the engine
has it as devvm's, and the image its record says its last change was
committed to. Someone else's by one of those names fails it, as it does
Forget, so gc stops before it deletes anything. vm.Leftovers.Find fills
each Orphan's Leaves, and gc prints one line per resource under its VM:
gc_orphan_container, gc_orphan_network, gc_orphan_volume and
gc_orphan_image. Docker's largeTypes maximum is 87 for the new method.

Tests: docker's TestLeftovers; gc_orphans.txtar's Docker orphan has a
network and a commit too, listed by name and deleted. Docs: using/space.md's
leftovers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 16:38:38 -07:00
w3cjandClaude Opus 5.5 452e7bf80a fix(state): devvm's data and settings folders are the user's alone on every run
Before every command, the root command's PersistentPreRun runs
state.MakePrivate: it makes the data folder ($XDG_DATA_HOME/devvm) and
the settings folder ($XDG_CONFIG_HOME/devvm) when they're missing and
sets both to mode 700, whatever mode they had, so a wider mode on
anything beneath them opens nothing to others. When it can't, devvm
warns (folders_not_private, linked to what devvm keeps) and goes on;
without an absolute HOME there are no folders, and the command says so
itself. The per-folder 700s (exports, logs, run logs, run, CA, secrets)
stay as they are.

Tests: state's TestMakePrivate (made, made private from 777, a folder
inside keeps its mode, one that can't be made fails) and
folders_private.txtar (modes after a run, the warning's fields).
Docs: using/space.md's data folder, using/settings.md's state and
internals/overview.md's state section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 16:26:58 -07:00
w3cjandClaude Opus 5.5 7cd15a0862 feat(retention): retention settings for what devvm keeps, all off by default
~/.config/devvm/retention holds key=value lines, written by devvm space
set KEY=VALUE... (KEY= turns one off; a bad key or value is refused
before the file is written; all off removes the file). Every setting
is off unless set:

- logs.runs: run logs kept (20 when off; ui.KeepRunLogs).
- exports.age, exports.count: exports that old deleted, then all but
  the newest count.
- tools.unused-age: current shared tool images no VM's state lists,
  counted from when retention first found them so (an <image>.idle
  record in the share, dropped when a VM lists it again).
- orphans.age: what devvm keeps for VMs their backend no longer has
  (vm.Leftovers, as gc --orphans), once their state hasn't changed for
  that long.

Ages as state.ParseAge (30d, 2w, 12h). Not the backends' caches (gc
--caches only), and never a VM, an image, or a tool any VM's state
lists. devvm's commands apply the settings at their start at most once
a day (data/retention.run; again at once after a clock that went
back), under a lock so two devvms never apply them at once (a dead
one's lock is taken over after 10 minutes), skipping the tools while a
build holds the share's lock; it says what it deleted in one line on
stderr (retention_deleted). orphans.age needs the backends asked, so
only devvm gc --retention applies it; gc --retention applies all of
them at once. space, gc, completion and devvm's internal commands
don't apply them on their own. A bad line names the file and the line,
and then none applies (retention_unreadable). devvm space shows each
setting beside its row (RETAIN), with what it would free now.

Not done here: logs.network.size and logs.network.files, which
override the proxy's log rotation defaults: rotation is another task's
(the proxy rotates its logs), not on this branch; space set refuses
them until it is.

Messages: retention_deleted, retention_off, retention_busy,
retention_unreadable, retention_failed, retention_bad,
retention_saved. Docs: using/settings.md (the file, each setting, all
off), the What devvm keeps page (what each setting does, RETAIN),
using/images.md's Cleaning up, the CLI reference.

Review (deletes only what it's told to): no file or an empty one
deletes nothing (txtar, unit); a VM, an image and a tool any VM's state
lists are never retention's (Idle builds on NoVM: a stopped VM's and a
leftover state's tools stay until orphans.age deletes that state); two
runs at once (lockRetention); a clock that jumps (retainDue, Idle and
the age checks skip a negative age); the one-line report on every
deletion. Tests: TestRetention (parser, set, off, bad lines),
TestIdle, TestExportsToRetire, TestRetainDueAndLock; retention.txtar
(refusals, space set and RETAIN, the automatic run once a day and
again after a day, gc --retention with tools, a VM's tool kept).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 13:29:49 -07:00
w3cjandClaude Opus 5.5 5bfb89c371 feat(gc): gc --caches frees devvm's share of the backends' own caches
Lima's download cache (9.1G on the user's machine) and smolvm's caches
(22G) are filled by devvm's builds but are the backends' own and hold
the user's own downloads too. devvm never prunes them on its own and
never runs limactl prune, smolvm pack prune or smolvm machine prune
(each reaches the user's own entries). gc --caches, only in a terminal
(gc_caches_need_terminal otherwise, before anything is deleted), then
lists devvm's share of each backend's cache with sizes and asks for
each backend apart (backend.CacheCleaner):

- Lima: entries of download/by-url-sha256 whose url hashes to the
  folder's name and is Ubuntu's cloud image at the address devvm
  downloads base from, for its release, a dated release, that no image
  record names, unchanged for an hour (a build may be downloading).
  Lima copies a VM's disk out of the cache, so no VM needs an entry.
- smolvm (macOS): the disks smolvm unpacks of each pack
  (vms/_pack-storage-seeds/v2-<sha256 of the .smolmachine>-auto, found
  on the user's machine: 20G of the 22G), tied to devvm's packs by their
  SHA-256 - packs devvm has, and every pack it makes from now on, which
  smolvm/packs records - that no machine of devvm's was made from,
  unchanged for an hour, with their lock files. Disks of packs that
  are gone and unrecorded can't be tied to devvm and stay; so do the
  machines' folders and smolvm's other caches. On Linux smolvm's state
  is devvm's own folder: nothing listed.
- Docker: volumes with devvm's label that no VM has, not the tools'
  volume, not one of a VM devvm has state for (a VM being made makes
  its volumes before its container). Never an unlabelled one, never a
  prune.

Each delete checks the entry again first. With --backend, only that
backend's cache.

Messages: gc_caches_need_terminal, gc_cache, gc_cache_entry,
gc_cache_confirm, deleted_cache. Docs: the What devvm keeps page (the
backends' caches, Lima, smolvm, Docker), backends/smolvm.md's Cleaning
smolvm's caches, backends/lima.md, the uninstall steps,
using/images.md's Cleaning up, the CLI reference.

Review (touches nothing of the user's): limactl prune empties the
whole cache and isn't used; --keep-referred would see only devvm's
Lima home. smolvm pack prune removes any unused cached extraction,
the user's own packs' included, and machine prune works on a named
machine's images; neither is used. Lima entries are tied by address
and hash, smolvm disks by the SHA-256 of devvm's own packs, Docker
volumes by devvm's label. Tests: lima TestDevvmCache (your download, a
recorded release, one being written, a wrong layout, another file
kept); smolvm TestDevvmCache (a VM's pack, someone else's, a recent
disk, a machine's folder kept; a recorded deleted pack's disk freed;
Linux lists none), TestPackRecorded; docker TestDevvmCacheVolumes (a
VM's, the tools', one being made, someone else's kept); gc_caches.txtar
(refused without a terminal before anything is deleted; the default run
leaves the caches).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 13:08:52 -07:00
w3cjandClaude Opus 5.5 e433e61719 feat(gc): gc --orphans forgets VMs their backend no longer has
A VM deleted outside devvm (limactl delete, smolvm machine delete,
docker rm) left its state, logs, run files, backend files, ssh config
entry and host keys, and gc kept its tools. --orphans finds each VM
whose state names a backend that answers (Check and List, 30 s each)
and that, asked by Inspect, doesn't have it (vm.Leftovers.Find), lists
them with their project folders, asks in a terminal, and deletes what
devvm keeps for each as devvm rm does after its delete (Lifecycle's
tail, now forget), after asking the backend once more. Backends delete
their own leftovers through backend.Forgetter: Lima its port records,
sandbox profile and start record; smolvm its record, proxy file, ssh key
and forwarder files; Docker its relay, networks, ssh keys, labelled
volumes and commit image. Each refuses a VM it has.

Never an orphan, each said with a note: a VM whose backend can't be
asked or isn't this devvm's (gc_orphans_unknown); one made where this
run's backend doesn't look (gc_orphan_elsewhere) - new VMs record
backend_at, a hash of backend.LocationOf: Lima's home (DEVVM_LIMA_HOME),
smolvm's HOME on macOS, Docker's engine ID and name - and a VM without
the record counts only when its backend looks in its default place; one
whose state changed in the last hour, as a VM being made has its state
before its backend has it (gc_orphan_recent). When a backend a VM uses
can't list its images, gc stops before deleting anything, as before.

devvm space: the leftover row says gc --orphans; VMs with devvm's label
that this devvm has no state for (another devvm's, a sandbox's) are
named with their label's data folder (space_stray,
backend.StrayFinder), and never deleted.

Messages: gc_orphans, gc_orphan, forgot_orphan, gc_orphans_unknown,
gc_orphan_elsewhere, gc_orphan_recent, space_stray. Docs: the What
devvm keeps page (leftovers, VMs devvm has no state for, how to delete
one), using/images.md's Cleaning up, the CLI reference.

Review (a backend down, slow or answering garbage; a VM moved between
Lima homes; smolvm under another HOME; Docker Desktop vs a Linux
engine; a VM being made): down, slow (timeout) or unreadable answers
make a backend unknown, never its VMs orphans; moved homes and engines
are caught by backend_at; a VM being made is recent; Forget re-asks the
backend and each Forgetter refuses a VM it has. Tests: gc_orphans.txtar
(a live Lima VM and its files kept, a deleted one forgotten with its
logs, run and port files, a Docker one's volume deleted, a smolvm one,
another Lima home, no record under a non-default home, a recent state,
an unknown backend; no backend delete runs; gc stops when smolvm can't
list); tools.txtar (backend_at recorded).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:57:47 -07:00
w3cjandClaude Opus 5.5 bf03f26221 feat(gc): gc --exports [--older-than AGE] deletes saved exports
Exports (exports/<vm>-<date>-<time>.tar.gz, from devvm export and devvm
rm) were never deleted, and each can be the only copy of a deleted
VM's agent history. --exports deletes them, never as part of gc's
default run; --older-than AGE (state.ParseAge: a whole number of days,
weeks or hours, 30d, 2w, 12h, which retention will read too) keeps those
newer, by the date in their name. Only plain files named as devvm
names them: an export being written (.devvm-export-…), a folder or a
file of the user's in the folder stays. The list names each export's
VM and date (gc_exports, gc_export); it asks in a terminal, goes ahead
without one, never deletes a VM. --older-than without --exports, or an
age devvm doesn't take, is refused.

devvm space's exports row says gc --exports frees them, and counts the
exports as gc does.

Messages: gc_exports, gc_export, deleted_exports,
gc_older_than_needs_exports, gc_bad_age. Docs: coding-agents' History,
using/images.md's Cleaning up, the What devvm keeps page, the CLI
reference.

Tests: TestParseAge; TestExports (names, order, the age boundary);
gc_exports.txtar (the default run keeps them, the flags refused, 30d
deletes the old one only, then every one, nothing else in the folder).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:41:57 -07:00
w3cjandClaude Opus 5.5 e9aba7360d feat(gc): gc --tools [TOOL...] deletes current tool builds no VM has
gc keeps every current tool build, so a toolchain tried once stayed
until a newer version came out. --tools also deletes the current builds
that no VM's state lists (Share.NoVM), on every backend format and C
library; with tool names (the names images use, so node takes pnpm and
bun too) only those. A build whose hash was written in the last hour
stays: a launch builds its tools before it records them in the VM's
state. A tool any state lists stays, a stopped VM's and a leftover
state's included. With --backend, only that backend's builds. Names
without --tools, or a name that isn't a shared tool's, are refused.
Like gc: it lists them first (gc_tools_no_vm, naming each), asks in a
terminal, goes ahead without one, never deletes a VM. A VM that names a
deleted tool builds it again.

devvm space's tool rows say gc --tools frees the rest.

Messages: gc_tools_no_vm, deleted_tools_no_vm, gc_names_need_tools,
gc_unknown_tool. Docs: using/images.md's Cleaning up,
internals/images.md's listing and cleaning up, the What devvm keeps
page, the CLI reference.

Tests: TestNoVM (a VM's, not current, missing hash, built just now,
names); gc_tools.txtar (a leftover state's claude kept, a just-built
codex kept, node's three deleted, names refused without --tools, an
unknown name refused, node built again after).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:36:50 -07:00
w3cjandClaude Opus 5.5 0900ba5372 feat(gc): gc --backend NAME acts on one backend alone
gc reuses the root --backend flag: with it, gc deletes that backend's
images, the current ones too, and its unused tool images (the backend
from the build's .target record; one devvm can't tell is never one),
and leaves every other backend and devvm's own files (old copies of its
files, old mise) alone. Without it gc acts on every backend as before:
g.backend stays empty unless passed, so the default backend file never
narrows a plain gc. An image a smolvm or Docker VM was made from, or on
Linux hosts a Lima image whose disk VMs use, is refused by its backend
and stays (image_in_use, a warning). An unknown name is refused.

devvm space's images rows say gc --backend NAME frees the rest.

Docs: using/images.md's Cleaning up; Cleaning up sections on the Lima
and Docker pages, and smolvm's Cleaning smolvm's caches; the What devvm
keeps page; gc's help and CLI reference.

Tests: gc_backend.txtar: images on Lima, smolvm and Docker; a plain gc
with the default backend file set to smolvm still deletes Lima's stale
image and every unused tool; --backend smolvm deletes only its base and
its plain- tool image; --backend docker only Docker's base; Lima's base
stays; an unknown backend is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:30:17 -07:00
w3cjandClaude Opus 5.5 25930d2252 feat(gc): gc deletes older versions of devvm's own mise
devvm's mise (mise/<version>) is pinned per devvm release, and an
upgrade left the older folder (121M on the user's machine). gc's default
run deletes every folder but this devvm's version
(Versions.StaleMise), except one that changed in the last hour, which
another devvm may be downloading into. mise's data, cache, state and
config are temporary folders per run (miseCmd), so there's no cache to
keep or free. devvm space's mise row shows what gc frees.

Checked first what's kept: mise/<version> holds only the binary; bin/
(devvm-proxy, its key and hash) is written by nothing in this devvm
(the proxy is devvm _proxy, devvm's own binary, which install.sh
prunes in ~/.local/lib/devvm), so gc leaves bin/ alone; Docker's Linux
build is one file, replaced in place.

gc is now a plan (gather, show, ask, run) that the gc options extend.
Messages: gc_mise, deleted_mise. Docs: using/images.md's Cleaning up
(four things), the What devvm keeps page, internals/images.md, the CLI
reference. Tests: TestStaleMise (this version, a recent folder and a
file kept); gc.txtar (an old and a recent mise folder).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:23:35 -07:00
w3cjandClaude Opus 5.5 60d59c46f3 feat(images): the tool table shows each build's backend and C library
devvm images's tool table has BACKEND and LIBC columns, so a Lima and a
smolvm build of one version no longer look alike: from the target
record each build leaves beside it (its format matched to the backend
that has it, or one of the same kind), else the target it's current
for, else a VM's state that lists it, else -. The output ends with the
disk the images and tools take in all, pointing at devvm space
(images_total).

Docs: using/images.md's tool table and the line after the tables;
internals/images.md's listing section (the .target record and how
BACKEND is found); the CLI reference.

Tests: TestWriteImagesTools (rows, - for what a row lacks); images.txtar
(the columns from a record and from a VM's state, the total); gc.txtar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:21:17 -07:00
w3cjandClaude Opus 5.5 bfc925e043 feat(space): devvm space shows what devvm keeps and the space it takes
devvm space [--json] lists each kind of thing devvm keeps, on every
backend, with its count, size (allocated blocks, as du), whether devvm
makes it again (remade, only copy, log, state, leftover), what devvm gc
frees of it now and what frees the rest, then a total: VMs and images
per backend, shared tool builds per backend and C library, exports,
network and run logs, devvm's own mise, the copies of devvm's files,
the leftover state of VMs their backend no longer has, and the rest of
devvm's state. The backends' own caches come apart and outside the
total: Lima's download cache, smolvm's caches on macOS (pack disks,
image disks, archives, registry; never its machines' folders) and
Docker's labelled volumes that aren't one VM's own.

backend.UsageReporter (optional): Lima, smolvm and Docker say what their
VMs and caches take. Each backend gets 30 s; one that doesn't answer is
named when a VM's state uses it (space_backend_unknown), and its VMs are
never counted as leftovers.

Each tool build now leaves <image>.target beside it (libc, format), so
listings tell a Lima, smolvm and Docker build of a version apart;
tools.Listed has Target, from the record or the target it's current for;
Share.Delete deletes the record too.

Messages: reading_space, space_failed, space_backend_unknown,
space_caches_note. Stubs: docker volume ls; smolvm machine ls fails with
smolvm-ls-fails. Docs: the What devvm keeps page leads with devvm
space; commands table; images' Cleaning up; CLI reference.

Review: space runs only listings (limactl list, smolvm machine ls and
data-dir, docker info, container ls/inspect --size, system df, volume
ls), each bounded by ctx with a timeout; the txtar checks no call
creates, deletes, starts, stops or edits. Backend caches aren't in the
total. Sizes checked against du on the e2e sandbox data and the user's
caches (Lima 9.1G, smolvm pack disks 20G, both match du -sh). APFS
clones count for both, as the page says.

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:49:23 -07:00
w3cjandClaude Opus 5.5 37d843c285 fix(test): the CLI tests fake the host's CPUs, memory and free space
The CLI tests read the real host's CPUs, memory and free disk, so they
failed on GitHub's small ubuntu-latest runner (2 vCPUs, 7 GiB, ~10.8 GiB
free) and passed on larger machines.

internal/platform: Host (CPUs, Memory, FreeSpace) is the only way to read
them; the raw reads are unexported (memory, freeSpace). NewHost(test,
getenv) gives a test build's Host, which reads DEVVM_TEST_CPUS,
DEVVM_TEST_MEMORY_GIB and DEVVM_TEST_FREE_GIB (platform.TestCPUs,
TestMemoryGiB, TestFreeGiB) in place of the host's; an unset one leaves
the host's, a bad GiB value is an error. The zero Host reads the host.

The gate is registry.unreviewed, the same -ldflags -X variable as
DEVVM_UNREVIEWED: registry.Host() and newFor pass build == "allowed" into
NewHost, so platform has no package var. backend.Registry gets a Host
field; lima.New, smolvm.New and tools.New take a platform.Host;
vm.ThisHost takes one; vm.NewEnv, doctor, setup, build and
_refresh-tools read the registry's (or registry.Host()). Docker reads
only its engine's NCPU and MemTotal and checks no host free space, so it
has no host reads to route.

forbidigo bans runtime.NumCPU, unix/syscall Statfs, Fstatfs, Sysinfo and
unix.SysctlUint64 outside internal/platform.

script_test.go sets a large host in every script (8 CPUs, 16 GiB, 500
GiB free). small_host.txtar sets 2 CPUs, 7 GiB and 1 GiB free and checks
doctor's disk_low_warning, host_memory_low and host_cpus_few, disk_low on
a build, base_fitted with Lima's --cpus=2 --memory=3.5 and smolvm's --cpus
2 --mem 3584, too_many_cpus have=2 and too_much_memory have=7 max=5. The
host-relative regexes in build, from, setup, size, up_size and smolvm
are now the fake host's exact values.

Docs: contributing/testing.md's "A host of any size" (the overrides, that
only test builds read them, the large host script_test.go sets, how a
script asks for a small one, what stays the Linux CI job's), and the
sandbox table in contributing/_index.md.

Review: GoReleaser's ldflags (both builds) and the Homebrew formula set
only cli.version, linuxURL and linuxSHA256, never registry.unreviewed, so
release binaries ignore the overrides (TestReleaseHostIgnoresOverrides;
a release build checked by hand ignored DEVVM_TEST_CPUS=1,
DEVVM_TEST_MEMORY_GIB=1 and DEVVM_TEST_FREE_GIB=0.5 in doctor and size
while the test build honoured them). No caller outside internal/platform
reads runtime.NumCPU, memory or statfs (grep, and the forbidigo rule
checked against a probe file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:22:01 -07:00
w3cjandClaude Opus 5.5 f196357f43 feat(netpolicy): the proxy rotates a VM's network logs past 10 MiB, one old file each
A VM's <vm>.jsonl and <vm>.proxy.log grew without limit. The proxy, their
only writer, now rotates each before a line would take it past 10 MiB
(logLimit), keeping one old file:

- the event log (-log) is the proxy's alone: renamed to <log>.1 (the
  previous .1 dropped) and a new one opened, 600;
- the proxy's own log is also the process's stdout/stderr, which netpolicy
  opens, where Main's last error and a crash go. A new -proxy-log flag
  names that file: the proxy's logger writes through a rotating writer
  that copies it to <log>.1 (written whole, 600) and truncates it, so the
  O_APPEND writes that bypass the rotation still reach the current file.
  The HTTP servers' and the reverse proxy's ErrorLog is the proxy's
  logger, so their lines go through the rotation instead of straight to
  stderr. Stdlib only.

Writes are serialized and each is a whole line, rotated before the write,
so no line is lost, split or duplicated. A log deleted while the proxy
runs starts again at the limit. The start check (logged) finds the
listening line across a rotation (the rest of <log>.1 and the new log).
devvm log reads <vm>.jsonl.1 before <vm>.jsonl (opened after the log, and
skipped when it's the same file, so a rotation while opening reads
nothing twice); --blocked counts both; -f reads a renamed log to its end,
checked before the drain so no late line is missed, then follows the new
one from its start; a just-rotated empty log with a .1 isn't log_empty.

Review (log rotation): lost or duplicated lines across a rotation (none:
mutex, rotation before the whole-line write; TestRotateConcurrent: 16
writers, every line once across both files); a VM writing faster than
rotation (rotation is inline in Write, so it can't fall behind; a
follower misses a file only if two rotations, 20 MiB, happen within one
250 ms tick); devvm log -f across a rotation (TestWriteLogFollowRotated);
modes 600 after a rotation, a log left 644 tightened at open
(TestRotateRenames, TestRotateCopies); rm deleting every rotated file
(existing.txtar: .jsonl.1 and .proxy.log.1 gone). Copy rotation can lose
only a write that bypasses the logger between the copy and the truncate:
a runtime crash's output.

Tests: proxy unit tests (rotation at the limit, one old file, a long line,
a deleted log, concurrent writes, the copying rotation), netpolicy reader
across a rotation and following one, logged across a rotation, log.txtar
(rotated history and blocks, a just-rotated log), existing.txtar (rm).
Docs: internals/network.md's Log files and -log/-proxy-log flags,
safety/network.md's Logs, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 12:16:48 -07:00
w3cjandClaude Opus 5.5 080d57dd28 fix(netpolicy): builds reach a company proxy through a proxy of their own; ** refuses names the host can't resolve
From an independent review of the company-proxy change.

1. Builds never get the company proxy's credentials. Each build behind
   a company proxy goes through a devvm _proxy of its own on the host
   (backend.ProxyStarter / BuildProxy, shared by Lima and Docker; Docker
   Desktop's build proxy moved into it): policy **, a new random password,
   the company proxy in its -upstream file, -lifeline on the build VM's
   hostagent or the container's docker container wait. Builds get only
   http://devvm:<one-time>@<host>:<port> (each variable the host sets) and
   the host's NO_PROXY.
   - Lima: image builds, the tools build and --from's conversion VM reach
     it at 192.168.5.2; on macOS the build's Seatbelt profile allows that
     one loopback port (NetInternet + ProxyPort), so a loopback company
     proxy works for macOS builds too. guestProxyURL is gone. limactl runs
     without the host's proxy variables (Lima logged them, password and
     all, into devvm's run log; found by the new e2e check); only a
     NetDirect start gets them back for propagateProxyEnv.
   - assets/oci/build.sh: the /etc/os-release probe runs under env -i;
     chroot_run passes only the build proxy's variables (bootify.sh's
     downloads behind a company proxy).
   - Docker: buildNet takes Desktop's path (own network, relay, build
     proxy) on any engine behind a company proxy; hostProxyEnv is gone.
     A Linux engine's build behind one needs devvm's Linux build.
   - Settings the proxy can't go through are refused before anything is
     made (upstream_proxy_scheme, reworded for builds too).
2. noClientProxy on the tools' unpack container and the relay.
3. floorUpstream: a name the host can't resolve goes upstream only when
   an allow rule names it (itself or *.domain: policy.byName); with only
   ** it's refused (errUnresolved, logged as the reason).
4. CONNECT replies are read through a 64 KiB io.LimitReader
   (maxConnectReply); bytes after the answer stay the tunnel's.

Tests: backend (TestProxyStarter, TestProxyStarterFails,
TestListeningPort, TestBuildProxyStop), lima (TestBuildImageHostProxy on
linux and darwin with the Seatbelt port, TestBuildImageHostProxyRefused,
TestConfineProxyEnv), docker (TestBuildHostProxy for a Linux engine with
and without a company proxy, unpack's empty proxy pairs), proxy
(TestUpstreamUnresolved, TestUpstreamConnectReplyLimit). CLI: docker.txtar
(a Linux engine's build behind a company proxy; every container create
and run, kept by the stub in containers-made, sets the empty -e pairs),
from.txtar (builds' proxy folders gone). e2e: images (a build sees only
its own proxy), from (a --from alpine:3.21 base with every feature and a
layer behind a company proxy with a password: the registry, Alpine's
mirror and the layer reach it through the builds' proxies; the password
is in no converted disk, image, log, build file or process's arguments);
corp_start/corp_stop shared with network.

Docs: internals/design (A company proxy: the ** case, builds, checks;
build confinement), safety/network, internals/network, images, lima,
docker, using/troubleshooting, internal/proxy/README.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 09:53:45 -07:00
w3cjandClaude Opus 5.5 2f559eaaa5 feat(netpolicy): network policy behind a company proxy; host proxy credentials kept out of images
Behind a company proxy, network policy's proxy connected to servers itself
and reached nothing. It now reaches allowed hosts through the host's
HTTPS_PROXY / HTTP_PROXY, still deciding each request by the name the VM
asked for.

Step 1, credentials (traced in the code and the backends' published docs;
not yet proven on a real build, which the new e2e checks do):
- Lima: build VMs (images, the tools build, --from's conversion VM) started
  with propagateProxyEnv on, its default. Lima's 07-etc-environment.sh
  writes the propagated settings into the guest's /etc/environment between
  #LIMA-START/#LIMA-END on each boot, and a stopped build VM's disk keeps
  it, so an image built with HTTPS_PROXY=http://user:pass@... kept the
  password. Fixed: propagateProxyEnv is on only for NetDirect; build scripts
  get the variables exported on their input (a loopback proxy as
  host.lima.internal), and /etc/sudoers.d/devvm-build-proxy keeps them for
  sudo until the scripts end.
- Docker: the CLI puts ~/.docker/config.json's proxies into every container
  it creates, and a commit keeps them (Docker's docs). Fixed: every
  container devvm makes sets each proxy variable empty (noClientProxy); a
  Linux engine's build gets the host's settings from an env file
  (hostProxyEnv); Desktop's build proxy goes through the company proxy.
- smolvm: passes the host's proxy only with --use-host-proxy, which devvm
  doesn't use: nothing to fix.

The upstream:
- backend.HostProxy (new): ReadHostProxy (capitals, then lowercase), None,
  Upstream (the proxy's -upstream file; only http:// proxies:
  upstream_proxy_scheme, upstream_proxy_invalid), Env.
- internal/proxy/upstream.go (new): -upstream FILE; ParseUpstream,
  ErrUpstreamScheme; NO_PROXY as Go reads it; localhost, *.localhost and
  loopback/unspecified addresses always direct; CONNECT by name with
  Proxy-Authorization: Basic for tunnels and for the TLS connections that
  put secrets in (checked against the system roots and -upstream-cas);
  plain HTTP in absolute form, canonical host, credentials only in the
  header to the upstream; floorUpstream: addresses judged as before, a name
  refused when the host's resolver answers with any internal or denied
  address, unjudged when it can't resolve; Event.Upstream (host:port), and
  devvm log's "through host:port".
- hostOK refuses shorthand addresses (127.1, 2130706433, 0x7f000001),
  which a company proxy may read as inet_aton does (found in review).
- netpolicy: Proxy.Getenv, run/<vm>.proxy.upstream (mode 600), stale()
  (a changed upstream starts the proxy again), writeUpstream for both files.

Also, from a review of the company-CA change: a proxy that needed starting
again and didn't end within 2 s of SIGTERM was kept, with its old roots,
silently. Stop now sends SIGKILL after 2 s and reports whether it ended;
Prepare fails with proxy_stop_failed instead of keeping it (Proxy.Signal
seam).

Messages: proxy_stop_failed, upstream_proxy_scheme, upstream_proxy_invalid,
with doc links.

Tests: proxy (TestParseUpstream, TestNoProxy, TestUpstreamTunnel,
TestUpstreamNoProxyDirect, TestUpstreamPlainHTTP, TestUpstreamIntercept,
shorthand hosts in TestOddHostsRefused), backend (TestHostProxy), lima
(TestBuildImageHostProxy, TestGuestProxyURL, propagateProxyEnv
expectations), docker (TestBuildHostProxy, create's empty proxy variables),
netpolicy (TestPrepareUpstream, TestPrepareStopsTheOldProxy, FormatEvent's
upstream). e2e: images (a layer built with a fake proxy password: its
script and sudo see it; the image's disk, Lima's files and devvm's logs
don't), network (a devvm _proxy as the company proxy: allowed hosts through
it by name, blocked ones never reach it, its password nowhere, and back to
direct).

Docs: safety/network (Behind a company proxy, Without network policy),
using/troubleshooting (Behind a company proxy), internals/network (Through
a company proxy, restarts, -upstream), internals/design (A company proxy:
what an upstream changes, credentials, builds, checks), internals/images,
internal/proxy/README.md.

Review (security-audit skill, independent pass over the proxy change):
the shorthand-address bypass, fixed; a VM-controlled name can force the
unjudged branch, documented; refusals name the company proxy's address
(no credentials), accepted as on the direct path; a loopback company proxy
isn't reachable from macOS builds, documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 00:20:33 -07:00