29 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 5d7f941678 feat(network): quiet hosts: documented telemetry stays blocked without a notice in the VM
A built-in policy's `quiet HOST[:PORT]` line, for one exact host name,
marks a host devvm leaves out on purpose. A quiet host is blocked as any
host no rule allows, and an allow of the user's still lifts it. A block is
quiet only when its reason is "not on the allowlist" (notAllowed), it isn't
refused, and no rule covers the host (an allow, a deny or one that
narrows): then it's logged with "quiet": true but never counted in
/blocked or /blocked/new, so neither the VM's prompt nor devvm-why shows
it, its 403 page suggests no command, devvm network log --blocked shows it
as a row of its own with "- (quiet)", and devvm network lock never offers
it.

- proxy: rule.quiet, parseQuiet (exact hosts only), PolicyLine.Quiet,
  policy.quiet, Allowlist.Quiet, Event.Quiet, server.blocked (proxy and
  transparent paths), notAllowed; loadPolicy skips and logs quiet lines in
  the user's files.
- netpolicy: Judge.Quiet, Block.Quiet (its own row key), FormatEvent's
  ", quiet", RuleFile.Quiet, quietMark, policy_quiet_not_own in
  PolicyWarnings.
- cli: quiet in network log --json, log --blocked --json and network
  --json; the agents' table leaves quiet lines out.
- Quiet hosts, each with its source: api3.cursor.sh (the host Cursor
  documents for Tab requests; Cursor's CLI uses it for its metrics) and
  telemetry.go.dev (Go). Not marked: Claude Code's Datadog intakes (shared
  multi-tenant hosts projects may need), .NET's telemetry (no host in
  Microsoft's docs).
- Tests: TestParseQuiet, TestQuietHosts, TestQuietOnlyWhenNoRuleAllows,
  learn/log/rules tests, network_rules.txtar, e2e network check for
  api3.cursor.sh.

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-09 07:18:53 -07:00
w3cjandClaude Opus 5.5 01e5d2488a feat(network): rules by HTTP method and path, and secrets by method
A policy rule for a host name can narrow it to some of its requests:
`api.github.com GET,HEAD /repos/` in a policy file, written by devvm
network allow, deny and rm from --method and --path. Allows add up and a
deny beats any allow, as for every rule, so narrowing a host that a rule
allows whole, such as devvm's built-in GitHub, takes a deny:
`devvm network deny api.github.com --method POST,PUT,PATCH,DELETE`, or
`devvm network deny github.com --path '/*/*/git-receive-pack'`. An allow
by method and path for a host already allowed whole warns that it
narrows nothing and names the deny.

The proxy decrypts such a host's HTTPS on :443 with the VM's CA, refuses
its tunnels on other ports and without a CA, and judges every request on
the connection, kept-alive HTTP/1.1 and HTTP/2 alike, every absolute-form
one, and the shared Nix cache's own fetches. A connection's verdict and
whether its requests are judged come from one read of the policy files.
A blocked request gets 403 and a blocked event with its method and path;
devvm network log shows it, and an allowed one's forward event names the
rule that let it through.

One matcher, internal/proxy/request.go, judges rules and secrets'
bindings: methods from a closed list (RFC 9110's, PATCH, QUERY; never
CONNECT); the methods a request names besides its own (every
override-like header in any spelling, `_` for `-`, and the query's
_method), each word judged, and while a rule narrows by method, a value
that isn't exactly one method refused; path patterns with *, ** and a
last / for everything below; and only a path in plain form. Allows and
bindings match strictly, denies broadly: any case, every path that isn't
plain, the prefix above a trailing /, and a last segment cut at its first
dot (/admin.json, /admin.). A method devvm doesn't know isn't a rule, so
a typo in a deny is a broken deny. Upgrades other than WebSocket and
CONNECT inside a decrypted tunnel are refused for narrowed hosts.

devvm secret set takes an optional --method (none for every method), and
a secret's --path takes the same patterns, marked path_pattern in
custom-secrets.json; a saved path with a * from before is refused rather
than read as a wildcard. The bindings file stays version 1 while every
binding reads alike to an older proxy, so devvm secret set and rm after
an upgrade don't take a running older proxy's bindings away; a binding
with methods or a pattern makes it version 2, which such a proxy refuses
instead of putting a value in for every method, and writing one warns
for each such VM. devvm network allow, deny and rm warn, naming the VM,
when a rule by method and path changes while the VM's proxy runs from
another devvm binary, or one devvm can't tell. A query with a ; or one
Go can't read whole is refused while a rule narrows the host by method,
and denies also match each segment with its trailing dots dropped. An
allow that narrows nothing names the VMs, with -g by each VM's own
allowlist, and says when it narrows only port 80's plain HTTP.

- proxy: match, Methods, ParseMethods, PathOK, plainPath, matchPath,
  overrides, overrideLike, server.judgeRequest; parseRule/parseHostRule,
  CanonicalRule, NarrowRule, Narrowable, hostRules (rulesFor, verdict,
  byRequest, judge, unjudgeable), egress.checkHost,
  Allowlist.CoversWhole, trimDots; Binding.Methods, BindingListVersion
  2 when needed (v1Binding);
  pathWithin and PathPrefixOK folded into match; the Nix cache judged
- netpolicy: Rule(rule, deny, methods, path), NarrowedHost, sameRule,
  Proxy.Allowlist, Proxy.NarrowNotes, Proxy.OtherBinaries, BasePolicy,
  Proxy.SecretsWritten (after RefreshSecrets and devvm agent login
  --api-key's write);
  FormatEvent shows a blocked request's method and path and a forward's
  rule
- secrets: Def/Secret/customJSON Methods, path_pattern, CheckMethods,
  CheckPath on proxy.PathOK
- vm: RuleChange, PolicyChange(ctx, rules, RuleChange)
- cli: --method and --path on network allow, deny and rm, --method on
  secret set, METHODS in devvm secret and "methods" in its --json
- messages: bad_request_path (was bad_secret_path), bad_methods,
  rule_not_narrowable, rule_narrows, rule_narrows_nothing,
  rule_narrows_http_only, rule_narrows_unknown, proxy_other_binary,
  secrets_other_binary
- tests: TestParseRuleNarrowed, TestMatchPath, TestDenyBypasses,
  TestAllowNarrowed, TestCoversWhole, TestForRequestMethods,
  TestInterceptRules and TestInterceptSecretMethods (HTTP/1.1 kept alive
  and HTTP/2), TestNarrowedNotDecrypted, TestNixCacheRulesByPath,
  FuzzDenyBypass (paths, methods, headers, _method), TestRule,
  TestNarrowedRules, TestOtherBinaries, TestRefreshSecretsOtherBinary,
  TestNarrowNotesUnreadable, TestDefine's path of /, TestReadBindings'
  versions,
  TestCustomsUnreadable's prefix path, network_narrow.txtar (narrows
  nothing), secret_custom.txtar's --method; on 0.1.0's frozen state:
  TestV010Bindings, TestV010ProxyConfig, TestV010Rules (0.1.0's
  TestParsePolicy and TestDecide, frozen), fixture_v010_network.txtar;
  e2e network: netRequestRules
  and the basic secret's --method GET,HEAD
- docs: safety/network.md's Rules by method and path, the secrets'
  flags and an example, internals/network.md's Requests by method and
  path, the design note replacing the open-work entry, attack vectors,
  the commands page, internal/proxy/README.md, the CLI reference

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:59 -07:00
w3cjandClaude Opus 5.5 3e81767482 refactor(cli): each command carries its own docs link, group and samples
A command's metadata moves from hand-kept tables into the command itself:
an about (docs page, help group, why no --json) set as its Cobra
Annotations. msg.commandDocs, commandGroups and withoutJSON are gone;
TestDocLinks reads the links from the generated CLI reference, and help
output and the reference are byte-identical. AGENTS.md's cli and vm rows
point at new doc.go package comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 10:05:13 -07:00
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 7a26d80a17 feat(settings): the network setting for new VMs is a tier, allowlist by default
The ask setting is gone: a new VM's summary shows its tier (--network,
else the saved tier, else allowlist) and customizing it asks for the
tier, with Enter keeping the one shown, so ask added nothing.

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:01:03 -07:00
w3cjandClaude Opus 5.5 76f2021b65 docs: network tiers throughout, and the tools that ignore the proxy
Every page that spoke of network policy as on or off now speaks of the
four tiers: confined (internet, allowlist, none) or open. safety/network.md
is titled Network tiers, its company-proxy subsection is "Open VMs and
builds", and a new section lists tools that ignore HTTP(S)_PROXY on the
open tier (Node's fetch without NODE_USE_ENV_PROXY, aiohttp without
trust_env, Go programs with their own transport, Java, the Docker daemon).
internals/lima.md says how each tier reaches its proxy; design.md names
link_tier_mismatch and group_tier_mismatch; the help texts of stop,
network log, layer new, limactl and _proxy drop "network policy".

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 14:32:06 -07:00
w3cjandClaude Opus 5.5 ca8a91305b fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what)
when it may not be a message (replacing fail and the direct Die calls in
cli), and a.env returns its failure. checkLayout returns its error from the
root's PersistentPreRunE. execute alone prints a failure (showFailure): a
backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces
DieLogged), a message as it is, else what failed or output_failed, with a
corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130.

Die is now the UI's own die, for where no command can return: a question
without an answer, a run log that can't be opened. Error prints nothing once
the run is interrupted.

After INT, TERM or HUP, Main waited only for the logged command and then ran
the cleanups while the command's own code still ran. It now also waits for
the command to return, up to returnGrace (2 s), when there are cleanups to
run; a run without cleanups ends at once, so the proxy and the other
background processes still stop as soon as they are told to. A start's
undoStart stays registered once interrupted (interruptCleanup), as the
cleanups now run after the start returned.

Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old
ordering), TestSignalsWaitForAStuckCommandAWhile,
TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure;
DieLogged's tests are ErrorLogged's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:42:20 -07:00
w3cjandClaude Opus 5.5 e13839aa41 feat(cli): every command on the folder's VM takes --here and --parent, resolved in one place
The VM a folder uses is decided once, by vm's resolveFolder, from the
folder's own VM, the nearest parent folder's (with any repo of its own
in between) and the command's rule (vm.Env.Folder): by default the
folder's own, else the parent's unless a nested repo is in between,
else none (devvm makes the folder's own, other commands say no_vm).
--here takes only the folder's own; --parent takes the parent's across
a nested repo and past the folder's own, and refuses a folder inside
none with a VM (no_parent_vm). devvm asks nothing now, in a terminal
or not: use_parent_vm and use_parent_vm_repo are gone. The questions
before deleting, remaking or widening a parent's VM stay.

find resolves through it; own is the folder's own VM (adopt, --clone);
lookup and useParent are gone; Options.Here is the rule's.

cli: addFolderFlags (flags.go) adds --here and --parent into the run's
app, which vmEnv sets as the rule; the two are exclusive, and with -g
where a command has it; --clone and --parent are exclusive; devvm rm VM
takes neither (rm_vm_folder_flag). Commands: devvm, restart, stop,
update, rm, code, desktop, host, history export, tools (add, rm,
update), size, ports (add, rm), network (allow, deny, rm, log),
ssh-agent, git-protect, clone, secret use, secret unuse, layer add,
layer rm, group (join, leave), link (add, rm, publish, unpublish).

Tests: TestResolveFolder (own, parent, none, nested repo, --here,
--parent), TestFolderFlags (every folder command takes both, and no
other; refusals before anything runs; the rule each sets), the parent
tests and subfolder.txtar's cases updated for no questions and --parent.
Docs: the Commands page's subfolder section, first VM, --clone's
subfolders, the overview's subfolder VM; the CLI reference regenerated.

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:53:51 -07:00
w3cjandClaude Opus 5.5 5a9f1b71c2 feat(cli): changes that apply at the next start ask to restart now
devvm size, devvm network on and off, devvm ssh-agent and devvm
git-protect (macOS) on a running VM ask in a terminal, without
--no-input, whether to restart it now ([Y/n]): yes restarts it as devvm
restart does, no or no question (no terminal, --no-input) keeps today's
message (size_next_start, net_set_running, agent_set_running,
git_protect_next_stop). Agents' mounts ask the same question.

- one owner: Env.restartNow (Env.CanAsk, then restart_now) and
  Env.restartOr (yes: Launch.Restart; else the later message), in
  internal/vm/existing.go; UpdateAgentDirs uses restartNow
- restart_now replaces update_mounts (AnswerFor: devvm restart)
- tests: TestRestartToApply (each command: yes, no, no terminal,
  --no-input), TestUpdateAgentDirs's --no-input case
- e2e: network's no-terminal on and off say net_set_running
- docs: commands.md's restarting note and answers table, ports-size,
  ssh, safety/network, git-protection, coding-agents; CLI reference

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -07:00
w3cjandClaude Opus 5.5 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 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 5db31c92be feat(link): the per-VM proxy reaches a VM's links, and link names leave NO_PROXY
In a VM with network policy, an HTTP client that honors HTTP_PROXY now
reaches a link through the VM's proxy, so a link added while the VM runs
works at once and nothing restarts. The ssh remote forward stays the
transport for every link; the proxy is a second entrance to the same
host socket, and devvm _links's per-connection checks apply to both.

- devvm _links writes every link the client has, carried or not, to
  run/<vm>.links.json (proxy.LinkList, mode 600, written whole) whenever
  they change or the file is gone; it stays after the session, so a link
  with no socket is refused rather than asked of the rules. Forget
  removes it with the VM.
- devvm _proxy -links FILE reads it per request (regular file, no
  symlink, owner-only writes, 1 MiB, version 1, O_NONBLOCK), before any
  rule: CONNECT and absolute-form http, exact match after lower case and
  one trailing dot, NAME and NAME.devvm.internal. An entry counts only
  when its socket is proxy.LinkSocket(list folder, -vm, addr, port) and
  its address is in 127.77.0.0/16. Bytes pass as they are: no SNI check,
  interception, secrets or rules; absolute form goes in origin form
  without the proxy's headers, one connection per request, cancelled
  with the client's request; https in absolute form gets 400. No event
  for a carried link (devvm _links logs link); a dead socket gets 502
  and link_refused "not carried", after retries for a full backlog. Any
  other name under devvm.internal is refused (403, a refused block).
- vmssh.Links.Socket uses proxy.LinkSocket and LinkHash (same names).
- The link socket's accept loop only accepts, and hands a burst on whole
  (5 ms quiet, 50 ms at most, or 257 waiting) before relays start, as
  fork-heavy relay starts let macOS's 128 backlog overflow unlogged;
  past the cap, refused in the loop with link_limit. Temporary accept
  errors back off instead of ending the link.
- NO_PROXY is localhost,127.0.0.1,::1 everywhere: netpolicy.LinkEnv and
  linksNoProxy are gone, netpolicy.NoProxy is a constant, the start only
  checks the links (checkStartLinks). No dockerd or nix-daemon restart
  and no limactl edit on link changes. assets/guest/sync.sh: comment only.
- devvm network log's help says link events land there for every VM.
- Docs: using/links.md, safety/network.md, internals/network.md (Links
  through the proxy, -links), ports.md, lima.md, design.md (the proxy's
  entrance, the burst, threat-check rows for the proxy path, links added
  while running and untouched bytes, the sshd row reworded, Not covered),
  contributing, internal/proxy/README.md.
- Tests: proxy TestLinkConnect, TestLinkConnectUntouched, TestLinkForward,
  TestLinkGone, TestLinkListRefused, TestLinkDomainRefused,
  TestNoLinksFile, TestLinkSocket; vmssh TestLinksBurst, TestLinksList;
  netpolicy TestNoProxy and the -links argument; e2e lk_proxy_added and
  lk_proxy_own, and lk_cap's burst without pacing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 12:01:02 -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 0b03f334fb feat(cli): help in groups, with short texts, examples and each command's docs page
devvm --help lists the commands in groups: Your VM, Change your VM,
Images, Disk space and This machine, with help under Cobra's Additional
Commands. A group whose commands don't exist yet, such as Links between
VMs, stays out of the help.

Each command's Long is one to three sentences, and the rules it held are
on the command's docs page. Every visible command has an Example, with
the most common invocations first, each with a comment. Flag
descriptions are shorter. Each help ends with the address of the
command's docs page, and the root's also ends with the issue tracker.

- internal/cli/help.go: commandGroups, addGroups, addDocs (Cobra's usage
  template with Docs and Issues sections), examples
- internal/msg/docs.go: commandDocs, CommandDoc, CommandDocURL,
  IssuesURL; TestDocLinks checks commandDocs (user pages only)
- docgen: each reference page has a Docs section before See also
- docs: commands.md in the help's groups, with new sections on
  restarting and stopping and on deleting a VM; install.md has doctor's
  engine, feature values, Docker and CA notes; Contributing describes a
  command's help
- tests: TestExamples, TestHelpGroupsAndDocs, TestAddGroups,
  TestWithDocs, TestCheckCommandDocs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 04:39:39 -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 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 1e4c772cc5 refactor(vm): split Env's commands into types by group
Env holds the shared dependencies NewEnv sets and the helpers every
group uses: finding the folder's VM, starting it, applying its size and
ports, the image builder and the ssh config. The commands are on types
that embed *Env:

- Launch: up, restart, remove, update, ssh and code; a new VM
  (up.go), an existing one (existing.go), ssh.go, agents' mounts
- Lifecycle: stop, adopt, rm and export (lifecycle.go)
- Settings: .git protection (settings.go), size (size.go), ports
  (ports.go), SSH agent forwarding (sshagent.go)
- Net: network policy, its log and allowlist (network.go), secrets
  (secret.go)
- clones (clone.go) and syncer (sync.go), used by the others

env.go holds Env, UI, NewEnv and the shared helpers. cli's commands
call the group they need, e.g. vm.Launch{Env: env}.Up. Tests follow
their code: env_test.go holds the shared helpers, with up_test.go,
lifecycle_test.go, network_test.go and ports_test.go beside them.
The most methods on one type is 24 (Launch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 16:44:53 -06:00
w3cjandClaude Opus 5.5 4bbd35a24b refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal
flags, run log, status line, cleanup stack and interrupt flag, and its
functions are methods. ui.Main makes the run's UI on devvm's own
streams, owns signals, recovers Die and runs the cleanups; ui.New makes
one on other streams. cmd/devvm passes it to cli.Execute, and every cli
command gets it through its constructor.

Only cmd/devvm and internal/cli import internal/ui (a depguard rule).
Each other package defines the small UI interface it needs, which its
constructor takes, filling fields tests set:
- gitprotect.New, secrets.NewStore, from.NewLookup: a warn func
- ubuntu.New: LoggedCmd, Note
- netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its
  log lines drop control characters themselves (oneLine)
- sshagent.New: Info, Note, Warn, LogWriter
- tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup
- lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run),
  WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too
- backends.Registry: lima's and smolvm's
- vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout,
  LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields
- build.Builder: Terminal and LogNote fields
- sshconfig.New: its caller sets what it prints and asks

ui's tests build their own UI over buffers and run in parallel; other
packages' tests use small fakes; cli's unit tests a UI over buffers.

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

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

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

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