# space: each kind of thing devvm keeps, with its count, size, whether # devvm makes it again, what gc frees of it now and what frees the rest, # then a total; Lima's caches apart. It changes nothing: no Lima command # but listings. env SHARE=$XDG_DATA_HOME/devvm/tools # Nothing yet: devvm's state and the total. exec devvm space stdout '^WHAT +COUNT +SIZE +KEPT +GC +FREED BY +RETAIN\n' stdout '^state +1 +\S+ +state +- +- +-\n' stdout '^total +- +\S+ +- +- +- +-\n' ! stdout '^images' ! stderr . # base and foo, then foo is stale; claude's tools, current, an old go a VM # has and one nothing has; a Lima VM, and the state of one Lima no longer # has; an export, network and run logs. mkdir $XDG_CONFIG_HOME/devvm/layers cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh exec devvm build foo project ag exec devvm --tools none --agents claude --network open --no-git-protect exec devvm rm --force --no-export exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"' exec sh -c 'cd "$SHARE" && echo x > go-1.20.0-0123456789ab.erofs && echo x > go-1.9.0-0123456789ab.erofs' json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=gnu backend=lima built=2020-01-01T00:00:00Z mkdir $VMS/12345612345601/logs $VMS/12345612345602/logs json_set $VMS/12345612345601/vm.json version:=1 id=p name=devvm-p-12345612345601 image=base dir=/p backend=lima created=2020-01-01T00:00:00Z tools.names:=["go"] tools.made.libc=gnu tools.made.files:=["go-1.20.0-0123456789ab.erofs"] # The one Lima no longer has was made in this run's Lima home, its state # unchanged for over an hour: what devvm gc --orphans would forget. exec sh -c 'printf %s "$DEVVM_LIMA_HOME" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -c1-16 > at' exec sh -c 'printf "{\"version\": 1, \"id\": \"gone\", \"name\": \"devvm-gone-12345612345602\", \"image\": \"base\", \"dir\": \"/q\", \"backend\": \"lima\", \"backend_at\": \"%s\", \"created\": \"2020-01-01T00:00:00Z\", \"tools\": {\"names\": [\"go\"], \"made\": {\"libc\": \"gnu\"}}}\n" "$(cat at)" > "$VMS/12345612345602/vm.json" && touch -t 202001010000 "$VMS/12345612345602/vm.json"' exec stub vm devvm-p-12345612345601 Stopped mkdir $DATA/exports $DATA/logs $DATA/cache/mise/2026.1.1 exec sh -c 'echo x > "$DATA/exports/devvm-old-12345612345612-20260101-000000.tar.gz"' # The VM's network and proxy logs are network logs; the gone one's are # part of its leftover state. exec sh -c 'echo x > "$VMS/12345612345601/logs/network.jsonl" && echo x > "$VMS/12345612345601/logs/proxy.log" && echo x > "$VMS/12345612345602/logs/proxy.log"' stub_reset exec devvm space stdout '^VMs +1 +\S+ +only copy +- +devvm rm +-$' stdout '^images +2 +\S+ +remade +\S+ +images rm +-$' stdout '^tools gnu +\d+ +\S+ +remade +- +gc --tool-images +-$' stdout '^tools - +1 +\S+ +remade +\S+ +gc --tool-images +-$' stdout '^history +1 +\S+ +only copy +- +gc --history +-$' stdout '^network logs +2 +\S+ +log +- +devvm rm +-$' stdout '^run logs +\d+ +\S+ +log +- +the newest 20 stay +-$' stdout '^mise +1 +' # Ubuntu's cloud image base was made from, devvm's own copy: freed by gc # --caches once nothing needs it, never counted as state. stdout '^cloud images +1 +\S+ +state +- +gc --caches +-$' stdout '^leftover state +1 +\S+ +leftover +- +gc --orphans +-$' stdout '^total +- +\S+ +- +\S+ +- +-$' ! stdout '^devvm.s files' # The VM's folder, /p, is gone: named, while the one Lima lost isn't. stderr '\Aspace_folder_gone dir=/p vm=devvm-p-12345612345601\n\z' stub_calls ! stdout 'create|clone|delete|start|stop|edit|rm |prune|shell' # Leftover state is only what devvm gc --orphans would forget: never a VM # Lima no longer has whose state changed in the last hour (it may be being # made), nor one made in another Lima home. mkdir $VMS/12345612345604 $VMS/12345612345605 exec sh -c 'printf "{\"version\": 1, \"id\": \"new\", \"name\": \"devvm-new-12345612345604\", \"image\": \"base\", \"dir\": \"/n\", \"backend\": \"lima\", \"backend_at\": \"%s\", \"created\": \"2020-01-01T00:00:00Z\"}\n" "$(cat at)" > "$VMS/12345612345604/vm.json"' json_set $VMS/12345612345605/vm.json version:=1 id=moved name=devvm-moved-12345612345605 image=base dir=/m backend=lima backend_at=0000000000000000 created=2020-01-01T00:00:00Z exec touch -t 202001010000 $VMS/12345612345605/vm.json exec devvm space stdout '^leftover state +1 +\S+ +leftover +- +gc --orphans +-$' # gc lists the same one, and without a terminal or --force deletes nothing. ! exec devvm gc --orphans stdout '^gc_orphans count=1$' stdout '^gc_orphan backend=lima dir=/q vm=devvm-gone-12345612345602$' stderr '^devvm: no_input answer=--force$' stderr '^gc_orphan_recent vm=devvm-new-12345612345604$' stderr '^gc_orphan_elsewhere vm=devvm-moved-12345612345605$' rm $VMS/12345612345604 $VMS/12345612345605 # --backend is no flag of space's. ! exec devvm space --backend lima stderr '^devvm: flag_unknown command=devvm space flag=--backend$' # --json, for scripts. exec devvm space --json stdout '^{\n "version": 1,\n "devvm": \[\n' stdout '"what": "leftover state"' stdout '"kept": "only copy"' stdout '"total": \d+' # A backend a VM's state names that doesn't answer is named, and its VMs # are never leftovers. mkdir $VMS/12345612345603 json_set $VMS/12345612345603/vm.json version:=1 id=s name=devvm-s-12345612345603 image=base dir=/s backend=lima created=2020-01-01T00:00:00Z exec sh -c 'touch "$STUB_DIR/list-fails"' exec devvm space stderr '^space_backend_unknown backend=lima$' ! stdout '^leftover state ' # A backend slower than the timeout is named the same way, and its VMs # aren't leftovers either. rm $STUB_DIR/list-fails exec sh -c 'touch "$STUB_DIR/list-hangs"' env DEVVM_TEST_LIST_TIMEOUT=10m,lima:1s exec devvm space stderr '^space_backend_unknown backend=lima$' ! stdout '^leftover state ' rm $STUB_DIR/list-hangs env DEVVM_TEST_LIST_TIMEOUT=10m # Lima's download cache, which every Lima home shares: shown apart. [darwin] mkdir $HOME/Library/Caches/lima/download/by-url-sha256/0123 [darwin] exec sh -c 'echo x > "$HOME/Library/Caches/lima/download/by-url-sha256/0123/data"' [darwin] exec devvm space [darwin] stdout '^CACHE +COUNT +SIZE +PATH\ndownload cache +1 +\S+ +\S+/Library/Caches/lima\n' [darwin] stderr '^space_caches_note$' -- foo.sh -- #!/bin/bash echo foo