mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
24
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a8f0517579 |
feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut in its 900 MB fails base's build, and a stall hangs it. devvm now downloads the pinned image itself through fetch.Resumable (ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage), resuming across cuts, stalls and runs, and gives Lima that file. Lima 2.3 checks a local file against the digest before it copies it. - Before downloading, it takes the image from Lima's own download cache when that holds it with the pin's SHA-256: copied into a new file of devvm's own, mode 600, hashed as it's written, capped, stopped by the context, and kept only once it checks out. Lima's cache is never changed, and a base whose dated release Ubuntu may have removed still builds again. - One devvm downloads at a time (images/locks/ubuntu-image), another waiting under ubuntu_image_waiting and looking again under the lock (TestUbuntuImageAfterWait, which fails without that second look). - The download goes through the company proxy and trusts the user's CAs (Lima.Roots, from trust.Pool, which internal/cli passes through the registry), as do the Finder's lookups (TestNewTrustsRoots, and the registry's TestOverrides). An untrusted certificate is ubuntu_untrusted, naming the CAs' folder, one from a trusted CA that's for another host, out of date or not valid yet ubuntu_bad_certificate (check the clock and what answers for the host), and any other that fails to verify (a SHA-1 signature, a CA's name constraints, a key for clients alone) ubuntu_certificate_invalid, naming Go's reason, for the lookups (the listing, the checksums, their signature: TestLookupCertificates) and the download alike (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410) ubuntu_release_gone, which names devvm rebuild base; none is retried. ubuntu_download_failed no longer starts with devvm. - fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a CertificateInvalidError that's Expired) and fetch.Unverified (any failure to verify, with its reason, so every error the other two name), beside fetch.Gone, are the one place that tells a certificate's failures apart: Transient asks Unverified, the lookups and the download ask all three, host mise asks Untrusted, and a forbidigo rule keeps x509's and tls's verification errors in internal/fetch (TestCertificateClasses, TestTransient, testdata/lint, the owners doc's row). - An https address, or a test build's file:// DEVVM_UBUNTU_URL, read from disk the same way; anything else is refused. The CLI tests' sandbox has a stand-in of this host's image in the store. - Base's record keeps the image's address, and the key is as it was: it hashes the pin (release, file, digest), not the location. - devvm gc --caches frees devvm's copies that no record names and that aren't pinned now, unchanged for an hour, a stopped .part and a killed import's .import included, and those of a kept image once its .img is there. A pin it can't read fails it. - Of Lima's cache, it frees only an entry that devvm's own state shows a build of devvm's left: a base record names its address, devvm has its own copy of the image, and the installed Lima's own templates (share/lima/templates beside limactl, Lima.Templates) don't name it. An entry no record names may be the user's own Lima's, so it stays, and none is freed when the templates can't be read, with a line in the run log naming the folder and why. A test build's DEVVM_LIMA_TEMPLATES stands in for the templates folder. - ubuntu.ParseImage reads a record's image as Image.String writes it, and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in place of Lima's own regex. - devvm space shows the copies as a cloud images row, freed by gc --caches, kept as state, as a release Ubuntu removed can't be downloaded again. 0.1.0's frozen state runs the new commands (fixture_v010_cloud_image): devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's base record keeps and never changes the entry, base builds from devvm's own copy, and gc --caches keeps that copy, frees Lima's entry the record names and devvm's own stale copies, and keeps an older entry no record names. Docs: images.md (the download, its failures, the import, gc's rules), space.md, backends/lima.md, settings.md (the lookups and the download trust your CAs), troubleshooting.md, overview.md, testing.md, tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed lines, which later commits make highlights, What to do 5 and 6, and the release page's Ubuntu's cloud image in devvm's folder. New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting, ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate, ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted. Lima.LocalImage is the seam, Lima.ImageClient the client. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
d58b24affe |
refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.
The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.
Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.
A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.
The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.
Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c1ca05bd94 |
refactor(vm): housekeeping and exports move out of cli
vm.Housekeeping owns what devvm keeps besides its VMs, and cli only renders what it returns: ListImages and ShareListing (the tool targets, worked out once in ToolTargets, for devvm images, gc, space and retention), LockGC, PlanGC (one inventory per run: the states, with --orphans the backends' lists too), GCPlan.Apply (returns GCDone, what it deleted in order, an image the backend refused among it) and Retain. gc runs on the run's one registry throughout, --caches included. vm.Exports owns an export's name (parsed without a regex), the list, the .folder file written and read, deletion and a folder's newest export; it replaces lifecycle.go's name, history.go's parse and retention's handling. One orphan definition: devvm space's leftover state is now what devvm gc --orphans would forget (Leftovers.FindIn, on space's own inventory), so a VM whose state changed in the last hour, one made in another Lima home and one being made again count as state, not leftover, and the row's retention uses the orphan's Changed time. space.txtar pins it against gc --orphans' list. gc's Short names old files and the Nix cache over its cap; the CLI reference is regenerated. using/space.md says what leftover state is. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
39c2ff4f4e |
test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of them) are one Go binary, internal/stubtest/stub, which acts as the command it's run as (argv[0]): limactl, docker, security, ssh, ssh-add, ssh-agent, ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags, tmutil, sw_vers, uname, open, code and mise, and stub, scripts' commands on the stubs' state. stub-log is gone: each stub logs its call itself, in one write to $STUB_LOG, its arguments on no other process's command line. - internal/stubtest builds the binary once, into $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link per command, which every test process and later run reuses until the sources change; a day-old folder of another build is removed. stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs' VM, Size, VMs, Keychain and SetKeychain on the state. - internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json, typed JSON under a file lock (Lima's instances with their status, size and config, the Keychain, the SSH agent and its keys, Time Machine's exclusions, the tools build VM's folder). The instances file wasn't locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes at once. - guest.go is the VM behind limactl shell and ssh alike: a --clone VM's git on vmfs, a remake's home, a base build's packages, the setup's tar, the direct connection, host keys, a forwarder's ports, link forwards. - A link session's master listens with a backlog of one and never accepts, as the Perl one did, so a killed session's socket reads as stale once probed (link_life). TestScript's cleanup stops the sandbox's masters by their -M -S arguments. - Structure: the stubtest layers cover internal/stubtest/..., the binary and its state import nothing else of devvm's; execSites lists internal/stubtest/build.go and internal/stubtest/stub/process.go. Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state: instances, size-<vm>, config-<vm>, keychain/<account>, agent-up, agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size, keychain, keychain-set, agent and agent-stop instead (build, existing, from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm, secret, size, space, ssh, ssh_agent, up). Tests: stub_test.go (every stub in-process, TestShellWords), stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima, platform, vm, tools and build tests use the state helpers and stubtest.Command. Coverage: internal/stubtest/stub and stubstate added, stubtest, build and tools raised (and lima, netpolicy on Linux). Docs: contributing (Stubs: the binary, logging, the state and the stub command, switches, the guest, adding a stub or a switch; Go test helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8ec7547ebd |
feat(cli): devvm rm VM deletes a VM whose folder is gone, and ls and space mark it
A VM whose recorded project folder is gone (nothing at its path) is marked: devvm ls writes "(gone)" after its folder and gives "folder_gone" in --json; devvm space names it in a note and in --json's "folder_gone". devvm rm takes an optional VM, by name or ssh alias, from any folder: this folder's own VM goes through rm; a VM whose folder is there, a name that isn't a VM's, and a VM its backend lost are refused. It asks in a terminal, --force answers, and without either it refuses. Agents' history is exported first unless --no-export; a stopped VM that mounts its folder is refused, as starting it would make the folder again (Lima makes a missing mount's folder); a --clone VM needs --no-clone-check. Never deleted by gc or retention. vm: FolderGone, Lifecycle.RmVM/rmGone, recordedVMs (moved from Links.projectVMs); project: Named (Targets uses it). Messages: rm_unknown_vm, rm_vm_folder_there, rm_vm_lost, rm_gone_stopped, rm_gone_clone, rm_vm_export_failed, rm_vm_failed, delete_gone_folder_vm (answered by --force), space_folder_gone. Tests: testscript rm_vm, ls; TestFolderGone, TestList, TestTargets, TestJSONShapes. Docs: commands (rm, ls, a VM whose folder is gone), space, troubleshooting, coding-agents, overview; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f6f62d28a |
refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name, alias, image, chain, from, dir, folder, backend, backend_at, created) and one section per package, each a json.RawMessage its owner decodes into its own type (state.Section, state.SetSection), what was asked for at its top level and what devvm made under "made": net (netpolicy), git (gitprotect), ports (the new internal/ports), agent (sshagent), tools (tools), secrets (secrets), and size, clone, devcontainer, desktop and links (vm, internal/vm/state.go). - state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the file again, applies a change and writes it once; a failed change, or write, writes nothing. VM.Set and its calls are gone; read-modify-write of lists (links, publish, secrets, tools, size, ports) happens inside Update. VM.Claim also holds run/claims.lock, after the VM's own; VM.Create writes a new VM's whole record once, its alias chosen (sshconfig.ChooseAlias) under the claims lock. Reads take no lock. - created replaces "net unset" as unfinished (VM.Finished). - internal/ports: the ports section (forward, host.ssh/proxy/desktop), ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy and desktop ports under the claims lock (desktop allocated without one before; run/ports.lock and netpolicy's own ports key are gone). - gitprotect: mode recorded before the backend makes the VM (NewMode; clone for --clone, which ls and git-protect share as gitprotect.Mode); made.git_id (platform.FolderID), one git_dirs list for modules and embedded git dirs, delegations, protected; Unlock takes the union of recorded and current git dirs. - links' entries, git dirs, tools and devcontainer commands are JSON lists, not strings in values; the key=value parser is gone. - vm.checkState reads every section of the folder's VM as it's found. - registry.For drops its unused Dirs. - Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate, TestVMUpdateTogether (two writers on one VM and on crossed VMs), TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether, TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded, TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
79b3ef94d4 |
refactor(cli): one backend: no --backend flag, no BACKEND column
devvm runs every VM on Lima, so the command line has no backend choice: - --backend is gone from devvm, build, rebuild, images, images rm, gc, space, doctor and setup (addBackendFlag, addBackendFilterFlag, setup's own, checkFlagValue's case, its completion); a removed flag now fails as an unknown flag (exit 2). - devvm setup no longer asks for or saves a default backend; config.toml and settings.json have no backend key (settings.KeyBackend, Values and Defaults' Backend, checkBackend, Value.With, Source.File, FromFlag). - Tables lose BACKEND: ls, images (both tables), space (both tables); doctor's FEATURE table is FEATURE and SUPPORT for Lima. space's images row is freed by images rm. - --json keeps every backend field (ls, images, tool records, space, doctor's backend, backend_source "built-in" and every backend's features). - The registry keeps Lookup, For and Default: For(d, vm) gives a VM its recorded backend and a new VM NewVMs, else Default; tests set NewVMs. vm.Env's lookups lose the flag parameter, found.flagIgnored and Options.Backend. - Messages removed: backend_unknown, backend_unknown_default, default_backend, backend_help, doctor_backend_from, backend_flag_ignored; backend_unknown_vm stays (a VM's recorded backend), linked to backends#a-vms-backend. - Docs: Backends' choosing section becomes "A VM's backend"; settings, setup, images, gc, space, doctor, commands and install pages lose --backend and BACKEND; Contributing gains "How a backend plugs in". - Tests: unit tests for For, settings, setup, doctor's table, the tables; CLI scripts check --backend as an unknown flag on devvm, build, restart, images, gc, space, doctor and setup, and a config.toml backend key as unknown; e2e's table checks lose the column. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
7cd15a0862 |
feat(retention): retention settings for what devvm keeps, all off by default
~/.config/devvm/retention holds key=value lines, written by devvm space set KEY=VALUE... (KEY= turns one off; a bad key or value is refused before the file is written; all off removes the file). Every setting is off unless set: - logs.runs: run logs kept (20 when off; ui.KeepRunLogs). - exports.age, exports.count: exports that old deleted, then all but the newest count. - tools.unused-age: current shared tool images no VM's state lists, counted from when retention first found them so (an <image>.idle record in the share, dropped when a VM lists it again). - orphans.age: what devvm keeps for VMs their backend no longer has (vm.Leftovers, as gc --orphans), once their state hasn't changed for that long. Ages as state.ParseAge (30d, 2w, 12h). Not the backends' caches (gc --caches only), and never a VM, an image, or a tool any VM's state lists. devvm's commands apply the settings at their start at most once a day (data/retention.run; again at once after a clock that went back), under a lock so two devvms never apply them at once (a dead one's lock is taken over after 10 minutes), skipping the tools while a build holds the share's lock; it says what it deleted in one line on stderr (retention_deleted). orphans.age needs the backends asked, so only devvm gc --retention applies it; gc --retention applies all of them at once. space, gc, completion and devvm's internal commands don't apply them on their own. A bad line names the file and the line, and then none applies (retention_unreadable). devvm space shows each setting beside its row (RETAIN), with what it would free now. Not done here: logs.network.size and logs.network.files, which override the proxy's log rotation defaults: rotation is another task's (the proxy rotates its logs), not on this branch; space set refuses them until it is. Messages: retention_deleted, retention_off, retention_busy, retention_unreadable, retention_failed, retention_bad, retention_saved. Docs: using/settings.md (the file, each setting, all off), the What devvm keeps page (what each setting does, RETAIN), using/images.md's Cleaning up, the CLI reference. Review (deletes only what it's told to): no file or an empty one deletes nothing (txtar, unit); a VM, an image and a tool any VM's state lists are never retention's (Idle builds on NoVM: a stopped VM's and a leftover state's tools stay until orphans.age deletes that state); two runs at once (lockRetention); a clock that jumps (retainDue, Idle and the age checks skip a negative age); the one-line report on every deletion. Tests: TestRetention (parser, set, off, bad lines), TestIdle, TestExportsToRetire, TestRetainDueAndLock; retention.txtar (refusals, space set and RETAIN, the automatic run once a day and again after a day, gc --retention with tools, a VM's tool kept). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e433e61719 |
feat(gc): gc --orphans forgets VMs their backend no longer has
A VM deleted outside devvm (limactl delete, smolvm machine delete, docker rm) left its state, logs, run files, backend files, ssh config entry and host keys, and gc kept its tools. --orphans finds each VM whose state names a backend that answers (Check and List, 30 s each) and that, asked by Inspect, doesn't have it (vm.Leftovers.Find), lists them with their project folders, asks in a terminal, and deletes what devvm keeps for each as devvm rm does after its delete (Lifecycle's tail, now forget), after asking the backend once more. Backends delete their own leftovers through backend.Forgetter: Lima its port records, sandbox profile and start record; smolvm its record, proxy file, ssh key and forwarder files; Docker its relay, networks, ssh keys, labelled volumes and commit image. Each refuses a VM it has. Never an orphan, each said with a note: a VM whose backend can't be asked or isn't this devvm's (gc_orphans_unknown); one made where this run's backend doesn't look (gc_orphan_elsewhere) - new VMs record backend_at, a hash of backend.LocationOf: Lima's home (DEVVM_LIMA_HOME), smolvm's HOME on macOS, Docker's engine ID and name - and a VM without the record counts only when its backend looks in its default place; one whose state changed in the last hour, as a VM being made has its state before its backend has it (gc_orphan_recent). When a backend a VM uses can't list its images, gc stops before deleting anything, as before. devvm space: the leftover row says gc --orphans; VMs with devvm's label that this devvm has no state for (another devvm's, a sandbox's) are named with their label's data folder (space_stray, backend.StrayFinder), and never deleted. Messages: gc_orphans, gc_orphan, forgot_orphan, gc_orphans_unknown, gc_orphan_elsewhere, gc_orphan_recent, space_stray. Docs: the What devvm keeps page (leftovers, VMs devvm has no state for, how to delete one), using/images.md's Cleaning up, the CLI reference. Review (a backend down, slow or answering garbage; a VM moved between Lima homes; smolvm under another HOME; Docker Desktop vs a Linux engine; a VM being made): down, slow (timeout) or unreadable answers make a backend unknown, never its VMs orphans; moved homes and engines are caught by backend_at; a VM being made is recent; Forget re-asks the backend and each Forgetter refuses a VM it has. Tests: gc_orphans.txtar (a live Lima VM and its files kept, a deleted one forgotten with its logs, run and port files, a Docker one's volume deleted, a smolvm one, another Lima home, no record under a non-default home, a recent state, an unknown backend; no backend delete runs; gc stops when smolvm can't list); tools.txtar (backend_at recorded). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bf03f26221 |
feat(gc): gc --exports [--older-than AGE] deletes saved exports
Exports (exports/<vm>-<date>-<time>.tar.gz, from devvm export and devvm rm) were never deleted, and each can be the only copy of a deleted VM's agent history. --exports deletes them, never as part of gc's default run; --older-than AGE (state.ParseAge: a whole number of days, weeks or hours, 30d, 2w, 12h, which retention will read too) keeps those newer, by the date in their name. Only plain files named as devvm names them: an export being written (.devvm-export-…), a folder or a file of the user's in the folder stays. The list names each export's VM and date (gc_exports, gc_export); it asks in a terminal, goes ahead without one, never deletes a VM. --older-than without --exports, or an age devvm doesn't take, is refused. devvm space's exports row says gc --exports frees them, and counts the exports as gc does. Messages: gc_exports, gc_export, deleted_exports, gc_older_than_needs_exports, gc_bad_age. Docs: coding-agents' History, using/images.md's Cleaning up, the What devvm keeps page, the CLI reference. Tests: TestParseAge; TestExports (names, order, the age boundary); gc_exports.txtar (the default run keeps them, the flags refused, 30d deletes the old one only, then every one, nothing else in the folder). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9aba7360d |
feat(gc): gc --tools [TOOL...] deletes current tool builds no VM has
gc keeps every current tool build, so a toolchain tried once stayed until a newer version came out. --tools also deletes the current builds that no VM's state lists (Share.NoVM), on every backend format and C library; with tool names (the names images use, so node takes pnpm and bun too) only those. A build whose hash was written in the last hour stays: a launch builds its tools before it records them in the VM's state. A tool any state lists stays, a stopped VM's and a leftover state's included. With --backend, only that backend's builds. Names without --tools, or a name that isn't a shared tool's, are refused. Like gc: it lists them first (gc_tools_no_vm, naming each), asks in a terminal, goes ahead without one, never deletes a VM. A VM that names a deleted tool builds it again. devvm space's tool rows say gc --tools frees the rest. Messages: gc_tools_no_vm, deleted_tools_no_vm, gc_names_need_tools, gc_unknown_tool. Docs: using/images.md's Cleaning up, internals/images.md's listing and cleaning up, the What devvm keeps page, the CLI reference. Tests: TestNoVM (a VM's, not current, missing hash, built just now, names); gc_tools.txtar (a leftover state's claude kept, a just-built codex kept, node's three deleted, names refused without --tools, an unknown name refused, node built again after). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0900ba5372 |
feat(gc): gc --backend NAME acts on one backend alone
gc reuses the root --backend flag: with it, gc deletes that backend's images, the current ones too, and its unused tool images (the backend from the build's .target record; one devvm can't tell is never one), and leaves every other backend and devvm's own files (old copies of its files, old mise) alone. Without it gc acts on every backend as before: g.backend stays empty unless passed, so the default backend file never narrows a plain gc. An image a smolvm or Docker VM was made from, or on Linux hosts a Lima image whose disk VMs use, is refused by its backend and stays (image_in_use, a warning). An unknown name is refused. devvm space's images rows say gc --backend NAME frees the rest. Docs: using/images.md's Cleaning up; Cleaning up sections on the Lima and Docker pages, and smolvm's Cleaning smolvm's caches; the What devvm keeps page; gc's help and CLI reference. Tests: gc_backend.txtar: images on Lima, smolvm and Docker; a plain gc with the default backend file set to smolvm still deletes Lima's stale image and every unused tool; --backend smolvm deletes only its base and its plain- tool image; --backend docker only Docker's base; Lima's base stays; an unknown backend is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bfc925e043 |
feat(space): devvm space shows what devvm keeps and the space it takes
devvm space [--json] lists each kind of thing devvm keeps, on every backend, with its count, size (allocated blocks, as du), whether devvm makes it again (remade, only copy, log, state, leftover), what devvm gc frees of it now and what frees the rest, then a total: VMs and images per backend, shared tool builds per backend and C library, exports, network and run logs, devvm's own mise, the copies of devvm's files, the leftover state of VMs their backend no longer has, and the rest of devvm's state. The backends' own caches come apart and outside the total: Lima's download cache, smolvm's caches on macOS (pack disks, image disks, archives, registry; never its machines' folders) and Docker's labelled volumes that aren't one VM's own. backend.UsageReporter (optional): Lima, smolvm and Docker say what their VMs and caches take. Each backend gets 30 s; one that doesn't answer is named when a VM's state uses it (space_backend_unknown), and its VMs are never counted as leftovers. Each tool build now leaves <image>.target beside it (libc, format), so listings tell a Lima, smolvm and Docker build of a version apart; tools.Listed has Target, from the record or the target it's current for; Share.Delete deletes the record too. Messages: reading_space, space_failed, space_backend_unknown, space_caches_note. Stubs: docker volume ls; smolvm machine ls fails with smolvm-ls-fails. Docs: the What devvm keeps page leads with devvm space; commands table; images' Cleaning up; CLI reference. Review: space runs only listings (limactl list, smolvm machine ls and data-dir, docker info, container ls/inspect --size, system df, volume ls), each bounded by ctx with a timeout; the txtar checks no call creates, deletes, starts, stops or edits. Backend caches aren't in the total. Sizes checked against du on the e2e sandbox data and the user's caches (Lima 9.1G, smolvm pack disks 20G, both match du -sh). APFS clones count for both, as the page says. Co-Authored-By: Claude Opus 5.5 <[email protected]> |