12 Commits
Author SHA1 Message Date
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 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 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 d8a7d4de7f refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/,
where <hash> is the 14-hex hash of the project folder's path that the VM's
name ends with: its state, its own rules (policy), its backend's files
(backend/: record.json, key, known_hosts, proxy, ports and the port
forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb,
started, lifeline.pid, secrets.*, links.*) and its logs (logs/:
network.jsonl, proxy.log, links.log). Build VMs keep the same layout in
run/builds/<name>/. The top-level run/ holds only what isn't one VM's or
must be short: the hashed control sockets, links' link-<hash>.sock/.ctl,
the QEMU wrapper and the ports lock.

A folder's VM is found by its path's hash (state.ReadHash), with the name
and backend its state records, so devvm --backend docker then devvm in
the same folder opens the one VM, and a backend's name limit applies to
new VMs only. The state records the VM's name and its ssh alias, chosen
once at creation (sshconfig.ChooseAlias) and never recomputed. Links'
targets match recorded names, aliases and folders (project.Targets).

One teardown (vmFolders.teardown) replaces Lifecycle.forget,
undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's
leftoverFiles: it stops the proxy and link session, then the pieces
outside the folder (clone remote or .git locks, other VMs' links and the
group, host keys, the backend's leftovers), removes the folder, and
writes the ssh config. Each backend's Delete and Forget remove the VM's
backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier
one's folder was left clears it first. devvm space counts an orphan's
whole folder as leftover state and the other VMs' logs as network logs.

Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files
(secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog,
LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file,
vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and
lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the
user's cache folder for Lima's and smolvm's caches is Dirs.UserCache,
from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and
DockerVM go. vmname.HashOf and IsHash, project.Hash.

The proxy takes the links' sockets' folder (-link-sockets, devvm's run
folder) apart from the links' list, which is in the VM's run folder.

Tests: a VM made and removed (rm, gc --orphans) leaves nothing under
vms/, and with network policy has no file named for it outside its
folder (TestTeardownLeavesNothing); a new VM over an old folder starts
clean; lookup finds a VM made on another backend with a long folder name
and makes no second one (TestLookupOtherBackend, and in docker.txtar);
the alias stays put when a second VM shares the folder name
(TestChooseAlias, ssh.txtar); every socket fits under a 35-character
home with the longest VM name (TestSocketsFit); space counts an
orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by
hash and name; the proxy refuses a socket in the list's own folder.

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -07:00
w3cjandClaude Opus 5.5 ddbc377f8f test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN
and CFG by default, and adds stub_reset, catg (the one file a glob
matches), vm_name VAR NAME (the folder's VM) and project NAME [git];
script_cmds.txtar checks each. Every script is rewritten onto them, its
assertions kept; TestCommandLines leaves the scripts' own commands out.

mise run test runs scripts/test.sh: the tests as before, with the CLI
tests' devvm built with -cover for every package (CLI_GOCOVERDIR),
merged with the Go tests' counters by go tool covdata, then
scripts/coverage.sh holds each package to testdata/coverage/<os>.txt.
mise run coverage raises the baselines; coverage.txtar checks the
comparison. The macOS baseline is recorded from this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:25:09 -07:00
w3cjandClaude Opus 5.5 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 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