mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
f4fd37343957e25ba11c00a90479dc342cd2ebb2
154
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f4fd373439 |
refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend, Caps, Features, Review/Require, the registry, backendtest.Fake), so another backend is an addition. State from a smolvm VM reads as an unknown backend (backend_unknown_vm, gc_orphans_unknown); nothing migrates it. The image keys of layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images rebuild once. Lima's port forwarder moves off smolvm's files first: newForwarderCmd and forwarderMain from internal/cli/smolvmports.go to limaports.go, and assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder at run time, so no image key changes). Removed: - internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its registry entry, registry.Experimental and backend_experimental. - The decider: backend.Decider/UsesDecider, Confinement.Decider and DeciderToken, internal/proxy/decider.go and its test, the proxy's -decider, -decider-to and -decider-token-file, netpolicy's KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in vm's forwarding and UsedPorts. - backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and agent_unchosen_stop. - vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped). - paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing called (a test helper now). - ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and bump.sh's ubuntu_image, with its part of bump.txtar. - assets/smolvm/ and assets/container/; the no-init-system branches of layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in features/desktop.sh and guest/ca.sh. - Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh, creating_from_image, packing_image, pack_failed, backend_experimental, agent_unchosen_stop; descriptions naming smolvm reworded. - Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a failing or hanging Lima listing instead (the limactl stub's list-fails and list-hangs); the --backend smolvm examples; e2e's --backend smolvm and its section (about 1,130 lines), the smol_* helpers and the link section's backend switch. - Coverage: internal/backend/smolvm's lines in both baselines. - Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm notes (Ports on Lima now holds the forwarder's description), the backends table's smolvm column, every page naming smolvm, the README, the home page's backends art, and AGENTS.md's smolvm rows and gotchas (and the Docker bind-mount gotcha, which nothing refers to). Kept: the docker layer, on Lima; --from's local Docker; --backend, the BACKEND column and setup's backend choice, which the next commit removes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1917072228 |
refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the default backend and smolvm stays experimental. The backend architecture (Backend, Caps, Require, the registry, backendtest.Fake) stays, so another backend is an addition. Removed: - internal/backend/docker, its registry entry and Names/Experimental's docker half; devvm _docker-connect and _docker-ports (internal/cli/dockerssh.go); assets/docker/unpack.sh. - Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS, DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256 ldflags vars and the CLI tests' Linux-build archive (linux_release). - Interfaces only Docker implemented, with their callers: backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix), DiskUser (ls's and size's disk-over warning, size's disk_used and --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover (gc --orphans' volumes, networks, containers and images), DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name. - The docker layer's runtime on a backend that makes VMs for it: vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet returns a bool now), the refusals at start and devvm network on, ls's "(sysbox)" and --json docker_layer, size_disk_default_unused. - The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix). - paths.Dirs.Docker and paths.VM.Lifeline. - assets/guest/tools.sh's linked-folder branch; services.sh's DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd. - Messages: every docker_* the backend used, docker_layer_runtime, net_docker_layer, net_off_docker_layer, committing_image, pulling_image, unpacking_tools, disk_over, size_disk_default_unused, gc_orphan_volume/_network/_container/_image, docker_connect_failed; gc_orphan_elsewhere reworded. - Tests: docker.txtar, the docker stub's engine (its --from half stays), the ssh stub's login-shell branch; e2e's --backend docker, --engine, the docker host VM and Docker Desktop runs. - Release: one GoReleaser pass, no Linux-build pin in the macOS builds, no Linux devvm in the Homebrew formula's libexec. Linux builds stay. - Docs: backends/docker.md and internals/docker.md, design.md's Docker notes, the Docker column of the feature table, and every page's mentions of the Docker backend, Docker Desktop as one, and Sysbox. Kept: the docker layer in Lima VMs, devcontainer docker-in-docker, --from with images only a local Docker has, Docker Hub references. State written by a Docker VM before this reads as an unknown backend (backend_unknown_vm). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
299ddb1476 |
refactor(state): image records in images/<key>/, rebuild counters per backend and --from, tool image records, cache/
- Image records are images/<key>/record.json (JSON, unknown fields ignored; name, chain, from, digest, libc, built). state.Images lists the folders; AnyImage needs a record.json; RemoveImage deletes the folder. Lima's cache cleaner reads records through state.Images. - Rebuild counters are images/rebuilds.json, keyed by (backend, from as given, name), changed under images/locks/rebuilds. image.Inputs takes them through an image.Rebuilds interface. A rebuild on one backend no longer outdates the others' images, and two --from references that wrote the same counter name (node:24, node-24) stay apart. paths.RebuildFile, RebuildName and unsafeName are gone. - Tool images: <file>.sha256, .target and .idle become one <file>.json (sha256, libc, format, backend, built, idle_since; state.ToolImage). BACKEND and LIBC read the record; the fallbacks (format matching, a VM's target, the current target) go, with toolTargets, vmToolTargets, formatBackend and gc's backendTools (toolsOn does it). Share.IdleFor owns reading idle_since. - cache/ (Dirs.Cache) holds mise/, nix-cache/ and from-digests.json. With the cache gone, from.Recorded takes the newest base record's digest for the reference, so no key changes. - Key check: the rebuild counter is the one input that moved and changes keys (deliberately: per backend and exact from). The --from digest moved to cache/ and stays an input, kept stable by the records' fallback. Records, mise and the Nix cache are outputs. - Tests: state's image, rebuild, digest and tool record tests; image key cases per backend and exact from; build.TestRebuildIsPerBackend; from.TestRecordedWithoutTheCache; cli.TestToolsOn; rebuild.txtar (Docker's and smolvm's rebuilds keep Lima's and the other --from's bases), gc_caches.txtar and from.txtar (a missing cache/); the testscript command json_set; e2e reads the JSON records. - Docs: space, images, settings (retention), internals images, overview, network, security, contributing (json_set). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ee8146a5e4 |
fix: scripts and tests work without shasum, and two CLI scripts start Lima outside devvm on bash 5.2's sh
Fedora 43 has sha256sum but no shasum (Perl's Digest::SHA), and its /bin/sh is bash 5.3, which runs the last command of an `a && b` -c string in sh's place. - install.sh's check_host stops with "needs sha256sum or shasum" before downloading; its sha256 already used either. install.txtar covers shasum alone, both, sha256sum alone and neither, with made-up sums. - scripts/release.sh and scripts/bump.sh get a sha256 helper (sha256sum, else shasum -a 256) in place of four shasum calls. - gc_orphans, release, release_head and tools scripts hash with sha256sum, else shasum. tools' old fallback never fell back (the pipeline's status was cut's). - ls and existing_agents restart a VM outside devvm with `sh -c '... && limactl start ...; exit $?'`: without the exit, bash's sh exec'd the stub, whose ha.pid then named the test runner (the pid devvm recorded), so the VM still looked confined. - The install page lists sha256sum or shasum among the script's needs. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
34e2e5ef5a |
feat(cli): devvm WORD naming a toolchain, agent or layer points to its flag
devvm node said "Did you mean devvm code?", which misleads anyone who means the tool. When the unknown word, or each name in it joined with + or a comma, is a toolchain, an agent or a layer (devvm's own or the user's), the usage error is no_command_part, with the flags that choose them: devvm node+claude -> devvm --tools node --agents claude. Any other word keeps the did-you-mean over the commands (msg.Closest). The names come from partNames, which checkPartFlag reads too. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
da93384f60 |
fix(lint): fetch.Client is its own type, and forbidigo bans http.Transport, os.Create and O_TRUNC
fetch.Client was an alias of http.Client, so &fetch.Client{} got past
NewClient's timeout and HTTPSOnly. It is now a struct only NewClient fills:
Do sends with the client's policy, Transport returns its own transport for
callers to change (ubuntu's file://, the public registry's dialer), and any
other Client fails every request with ErrNoClient, which isn't transient.
forbidigo's HTTP rule also bans http.Transport, and http.Client's Transport
field, outside fetch, the proxy and tests.
The os.WriteFile rule also bans os.Create and os.O_TRUNC, so a
truncate-in-place write outside state needs a nolint saying why. The four
left are not files written whole from memory, or are the standard library
only: tools' check log and a link session's log (a process writes them as
it runs), fetch.Download's file (streamed, removed on failure) and
daemon's pid and status files (one write, which readLine and readStatus
take as missing until its line ends). state's doc says so.
Tests: TestClientMadeByNewClient (nil and zero Clients send nothing and
aren't retried; NewClient's transport is its own); from's and build's
tests use the registry's own client trusting the TLS test server.
Fixture lines: http.Transport, os.Create, os.O_TRUNC.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4d863bb749 |
fix(cli): another part's name in --tools, --agents or --layers names the flag that takes it
The picker change's review: - --tools claude, --layers node, --agents node and the like are refused with part_other_flag, which names the flag that takes the name, as in devvm --agents claude; a name no part has keeps unknown_part or its did-you-mean. checkPartFlag checks the three parts' names together. TestCheckFlagValue, up.txtar, up_checks.txtar and setup.txtar cover it. - image.ToolName is back, with its TestValuePatterns row: ToolFile and ParseToolFile check a tool's name with it. - internals/design.md's Docker layer checks name parts_flags_ignored for --layers docker on a VM that exists, as e2e checks, in place of a message that's gone. - The home page and the README give the Claude Code token before claude's first start, the home page's list says which rows it shows checked, and the FAQ says the agents' config comes from your machine. The README says the first run asks for new VMs' size and agents before the list. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
2b25a0c7dd |
fix: the shared foundations' review: one Lima host address, a kill only for its own process, and the Linux baselines
The consolidation pass over the shared foundations: - Lima's host address on its user-mode network, 192.168.5.2, is one constant, limaHost, which the VM's proxy URL and the build proxy's both use (proxyHostDarwin and buildProxyHost went). - platform.LockFileShared had no caller: LockFileSharedWaiting with no waiting does its job, and its tests use that. image.ToolName had none either, and goes until the tools picker needs it. mise run deadcode lists only what AGENTS.md names. - tools' writeNew, a third whole-file writer, goes: the share's .sha256, .target and idle files are written through state.WriteFile. From the security audit of the phase: - daemon.Proc.Stop sends SIGKILL only to a process whose arguments still say it's this one. A process still ending, whose arguments can't be read, is waited for; so is another process given the pid since whose arguments can't be read either (a setuid one, on macOS), which would have been killed. TestProcStopKillsOnlyItsOwn fails without it. - forbidigo's signalling rule also bans os.Process's Kill and Signal outside daemon and platform; tests signal their own children, and devvm desktop's ssh child, not yet waited for, says why with a nolint. testdata/lint has a line for each. Contributing's checks table says so, and internals/network.md says which process SIGKILL goes to. testdata/coverage/linux.txt is measured again with mise run coverage on the x86_64 Linux host: it had no lines for fetch, shell and vmname, so mise run test failed on Linux, and daemon was set by hand. arm64 (the Linux host VM) agrees within a point. darwin.txt: daemon 97.8, tools 89.2. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d01a1872ca |
test(smolvm): the listed range in smolvm.txtar is two free ports
smolvm.txtar listed host ports 8000-8001 and expected no ports_ warning, so it failed where a program has port 8000, as a dev server on the Linux test machine does (ports_taken ports=8000). free_port gets -range FIRST LAST, two adjacent ports free here, and the script lists $FIRST-$LAST as it lists $LISTED and $UNLISTED. The other scripts' fixed ports are either guest ports (link publish and add) or lists whose host check nothing asserts (up_size, ports, devcontainer, the sshd and many sections of smolvm.txtar), so they pass whatever holds them. Test: with a listener on 127.0.0.1:8000, the script failed at smolvm.txtar:73 before (ports_taken count=1 ports=8000) and passes after. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
51f1dc48e7 |
test: stubs write each call-log line in one write
The stubs logged with echo "x $*" >> "$STUB_LOG", which bash can write
in pieces for a long line, so a stub running at the same time could put
its own line in the middle. Every stub now appends through
testdata/stubs/stub-log, a Perl script that writes the whole line with a
single syswrite to the file opened for appending: the call log and the
stubs' shared lists ($STUB_DIR/containers-made, unpacked, scripts,
tm-excluded). The stubs run it from their own folder (${0%/*}), and
stubtest.New links it too when it puts only the named stubs on PATH.
TestCallLinesWhole runs two open stubs at once with 100 KB arguments
while the test appends short lines of its own to the log, and checks
every call landed whole; it failed on every run with the old stubs.
TestStubsLogWithStubLog fails on any stub that appends to $STUB_LOG or
$STUB_DIR with the shell's >>.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
e9f791bc96 |
refactor: one owner for the proxy's constants, URLs, variables and tunnels
The proxy owns the links' addresses and domain and the proxy user: proxy.IsLinkAddr, proxy.LinkAddr, proxy.LinkDomain and proxy.ProxyUser replace vm.IsLinkAddr, vmssh.IsLinkAddr, vm.LinkNet, vm's linkNetAddr, vm.LinkDomain, netpolicy.LinkDomain and the proxy's own isLinkAddr and linkDomain. TestLinkAddrsAgree goes, because there's nothing left to agree. The proxy's link list now refuses an IPv4-mapped address too, as vm's parser already did. backend owns the guest's view of a proxy: ProxyUser (proxy.ProxyUser), ProxyURL, GuestProxyVars, ClientProxyVars and NewProxyPassword replace four URL builders (BuildProxy.URL, Lima's, Docker's and smolvm's), the user written out in three places (netpolicy.ProxyUser, buildProxyUser, Docker's proxyUser), the guest's variable list in three (Lima's inline loop, smolvm.proxyVars, Docker's proxyVars) and the client's in two (limaProxyVars, Docker's noClientProxy list), and the two password generators. Confinement.ProxyUser goes: Docker ignored it, and every backend now uses ProxyUser. A new VM's proxy key is NewProxyPassword's 64 hex digits, as a build proxy's was; a VM keeps the key it has. doctor reads HTTPS_PROXY through backend.ReadHostProxy. In the proxy, hijack and splice replace the three CONNECT copies (tunnels to allowed hosts, tunnels to links, interception's hijack) and the relay's pipe. A tunnel passes the bytes as they are, passes on the end of what the client sent, and ends, closing both connections, when the server's bytes end or the client has gone. A relayed connection now ends with the proxy's side too, where before it waited for both. Tests: splice_test.go characterises the allowed-host tunnel, the link tunnel and the relay (a megabyte of every byte value, a half-close answered, a client that goes away ending the tunnel), written against the code before this change; TestSpliceEnds, TestHijack and TestIsLinkAddr (every LinkAddr) are new, and so are TestProxyURL, TestNewProxyPassword and TestProxyVars. TestLinkListRefused gains a mapped address. e2e: the relaunch without a company proxy says which step failed, with the launch's output, the VM's status and the proxy's log, and a link helper that doesn't start shows its output. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5003d94cfb |
refactor: read HOME once, into paths.Dirs.Home
paths.FromEnv reads HOME, which must be absolute, and keeps it, cleaned,
as Dirs.Home; everything else takes the home folder from there. Six other
reads go: vm.NewEnv's and cli's devvm secret's os.Getenv("HOME"),
gitprotect.New's, Docker's and smolvm's os.UserHomeDir (Desktop's
settings file, the machines' location), and smolvm's Getenv("HOME")
(DiskDirs).
- vm.Env.Home and secrets.Store.Home are gone: both read Dirs.Home.
secrets.NewStore takes the Dirs alone; gitprotect.New takes the home
folder for ~ in git's paths.
- forbidigo bans os.UserHomeDir, with its line in
testdata/lint/forbidigo.go; the structure test's owners check gains
envOwners, HOME read only in internal/paths/dirs.go, with cases for a
read outside it, through a field, in paths and in a test.
Tests: TestFromEnv checks Home (and a HOME cleaned), TestNewHome (~ is
the home New is given, not the environment's), TestDiskDirs checks
Location too. Coverage unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
f2a8ddd404 |
refactor: write every file whole through state, and make private folders with state.PrivateDir
internal/state is the one writer of whole files outside the proxy: state.WriteFileMode joins state.WriteFile for another mode (0700 for the QEMU wrapper and Docker's copies of devvm's Linux build), and state.PrivateDir makes a folder the user's alone (700), refusing a file or a symbolic link there, as vmssh's runDir did. - Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's writeFile (the Seatbelt profile, the QEMU wrapper, the start record), vmssh's writeWhole and runDir, Docker's copyFile, the Linux build fetch's temporary file (fetch.Open's body is read whole, its SHA-256 checked, then written with state.WriteFileMode), and Resolve's .tmp-and-rename loop. The host's mise stays fetch.Download's. - os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions' mise.toml, the checked file, the tools build's files), sshagent (two), ubuntu's checksum files, docgen's pages and backendtest's fake tool images. - state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders): the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and socket folder, lima's run folder and the exports folder. MakePrivate and ~/.ssh keep following a link: where they live is the user's choice. - The proxy's writers are one, writeAtomic: the login files' writeJSON and the Nix cache's size file use it, its temporary files named .<name>.tmp-* as state's are. - forbidigo bans os.WriteFile outside internal/state, internal/proxy, internal/msg/gen, internal/stubtest and tests, with its line in testdata/lint/forbidigo.go. Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder refused, its folder's mode unchanged), TestWriteAtomic; mode checks on the Seatbelt profile and Docker's Linux build copy. Coverage baselines raised: lima, netpolicy, proxy, secrets, ui. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b4402a74e8 |
refactor: every HTTP client through internal/fetch
internal/fetch (standard library only) owns how devvm reaches the web: NewClient(timeout, HTTPSOnly|SameScheme) on a clone of net/http's default transport, the Client alias other packages name, Retry and Transient/TransientStatus (no answer, 408, 429, 5xx; never a refused redirect, a bad request, a body over its cap or a SHA-256 mismatch), ReadCapped, Open, Get, and Download, which keeps a file only when its SHA-256 matches and leaves nothing on any failure. - from: NewRegistry uses fetch.NewClient(HTTPSOnly); its own NewClient, httpsOnly, errRedirect and transient go; the token GET is fetch.Get; retry wraps fetch.Retry, keeping ErrNotFound and ErrUnreachable. - ubuntu: NewClient is fetch.NewClient(SameScheme) with file:// registered; sameScheme and errRedirect go; fetch is fetch.Retry over fetch.Get. - tools: mise's client is fetch.NewClient(HTTPSOnly); its download is fetch.Download, which checks the pin before the file is kept. - docker: devvm's Linux build is fetched with a client of its own (HTTPS-only redirects, a Client seam on linuxFinder) instead of http.DefaultClient, and retried twice on a failure that may pass or an archive cut short; an archive without a devvm (errArchive) isn't. forbidigo bans http.Client, DefaultClient, DefaultTransport, Get, Head, Post and PostForm outside internal/fetch, internal/proxy and tests; its line in testdata/lint/forbidigo.go fires. internal/fetch is a leaf in the structure test's layers. Tests: fetch's TestRetry, TestRetryUnanswered, TestRetryCanceled, TestTransient, TestRedirects, TestReadCapped, TestDownload; first, characterising the callers, from's TestDigestRetries and tools' TestHostMiseRedirect; docker's TestFetchLinuxRetries. Coverage baselines: fetch 95.2 (new), from 87.1 to 91.3, ubuntu 88.7 to 92.5, tools 87.9 to 88.6, docker 80.8 to 81.1. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2687eec488 |
refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns devvm's background processes: Detach and Spawn (own session, no input, reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status file), Handle (signals through the process started), Proc (a pid file checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL, the pid file removed once stopped), readiness by status file (Ready, WriteStatus, WaitReady: the pid and data, written in one line-ended write, never another start's), Alive and Signal (no pid below 1), and one lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content equality, a bounded wait past what the file held first). It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards' pid, stop and start wait, the build proxy's process and log-read port, links' link-session pid, stop and start, the proxy's watchLifeline and vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess, and the alive copies (netpolicy alive/signal, lima alive, vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go: the proxy and the forwarder say they're ready in a status file, and the build proxy's port comes from its own. forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside internal/daemon and internal/platform, with its line in testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS and puts internal/daemon among the leaves; depguard holds it to the standard library. Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file, groups refused, readiness, lifeline), characterisation tests first for the proxy's, the forwarders', the link sessions' and the build proxy's pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
82566e9010 |
refactor: shell quoting, the VM-name grammar and value patterns each in one place
internal/shell, a stdlib leaf: Quote, QuoteJoin and EnvName. They
replace the 4 shell quoters (lima's shq and shqJoin, docker's shq, vm's
and devcontainer's shellQuote) and the 4 variable-name regexes (docker's
envKey, vmssh's envName, vm's envVarName, devcontainer's envName).
lima's quoting tests move there as TestQuote and FuzzQuote.
internal/vmname, a stdlib leaf below project: Prefix, HashLen, IsVM and
SlugOf. project's vmName regex, IsVM and Prefix go (callers use vmname),
lima's projectVM, docker's hostname parsing and cli's export-name regex
use it. TestImageKey (lima) pinned imageKey before the change;
TestParseExportName covers the export names.
Value patterns exported once: from.IsDigest (lima's idPattern),
image.IsKey (build's keyLike and the keyPattern copies in lima, docker
and smolvm), image.ToolVersion (tools' versionLike) and image.ToolName,
with TestIsDigest and TestValuePatterns. state's featureName stays:
internal/state may not import internal/image.
netpolicy.PolicyFiles names a user layer's policy file only for a part
image.LayerName takes, so an image-name part such as ../x never names a
file outside the user's layers; TestPolicyFiles's ../x cases failed
without the check.
The structure test's owners check gets literals: a non-test string
literal holding '\'' outside internal/shell, or [0-9a-f]{14} outside
internal/vmname, fails, naming the owner. TestRulesFail has cases that
break and keep both. shell and vmname join the leaves' layer, and
devcontainer may import shell. Coverage baselines: shell and vmname
added at 100.0.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
32aa8fe3e6 |
refactor: one parser and formatter for port lists, and a bad entry is refused, not port 0
backend owns port lists: ValidPort, ParsePortRanges, FormatPortRanges and Ports.Has. They replace vmssh.ParseRanges and FormatRanges, vm.portsValue, vm.ParsePorts's own regex and range checks, smolvm's lists, netpolicy's forwarded parsing, publishedIn's and the forwarder's range loops, and the 1-to-65535 checks in ParseLinkPort, desktop's listener, the build proxy's log reader and Docker's checkProxy. The proxy and devcontainer keep theirs for their layer rules. vm.ParsePorts keeps only all, none and port_invalid. fix(vm): PortsBackend ignored Atoi errors, so a bad entry in a ports value (a state file edited by hand) became port 0, or a range ending at 0. It now returns port_invalid: a VM whose state holds one doesn't start, devvm ports rm parses the old value first, and group links and Published read such a value as none. TestPortsBackend's bad entries and TestAddRemovePorts's rm case failed on the old code; TestStartBadPorts covers the start. Tests: TestValidPort, TestParsePortRanges, TestFormatPortRanges, TestPortsHas; TestFlags checks a bad -only is refused. internal/backend's coverage baseline is raised to 95.8. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
088f180842 |
fix(vm): an interrupted start under network policy stops the VM and its proxy
Ctrl+C while Lima's start waited for a VM with network policy left the VM running: the hostagent runs on its own from early in the start, and an interrupt skips everything after the backend's Start, so the proxy kept running and the VM had no record of its confined start. devvm ls then showed it unenforced, and the next launch asked to restart it confined. Env.start now registers a cleanup around the backend's Start for a NetProxy start (undoStart): interrupted, it stops the VM and its proxy and says so (interrupted_start). Lima's Stop stops a VM it reports as Broken (a start cut short before its hostagent answers) with limactl stop --force, which plain limactl stop refuses. Tests: net_interrupted.txtar (tools add on a VM with network policy, its start hanging with the VM running, Ctrl+C: VM and proxy stopped, state kept, ls --json net on, the next launch confined and unasked); TestStartInterrupted (vm); TestStubStopBroken (lima). The limactl stub gains start-hangs-running. e2e network: Ctrl+C during the start stops it and its proxy, and ls shows its policy on. Coverage baselines raised for backend/lima, cli and msg. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
cefb7b9472 |
chore: extend the owner, don't copy it: the rule, the consolidation pass and the owners' checks
AGENTS.md gets the rule, linking Contributing's new "One owner for each concern" section: the checks on owners, agreement tests and the consolidation pass the reviews run. - forbidigo: testbuild.On only in internal/cli (readOverrides). - testdata/lint/forbidigo.go breaks every forbidigo rule once on a line marked "// want forbidigo"; lint:code fails unless forbidigo reports exactly those lines. - The structure test's owners rule, as forbidigo can't see arguments: exec.Command/CommandContext of "git" (literal or constant, any import name) only in internal/hostgit, tests aside; a Getenv/LookupEnv call (any function or field of that name) of a DEVVM_ variable only in internal/cli/overrides.go, or where envSettings lists it (DEVVM_NO_TOOL_CHECK, DEVVM_LIMA_HOME, DEVVM_SECRET_SERVICE, DEVVM_FROM, DEVVM_MESSAGES, DEVVM_LOGIN_SALT, DEVVM_GUESTFWD), a listed file that stops reading its variable failing. TestRulesFail's ownerCases break and keep both. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|