mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
devvm agent save refused a VM whose ~/.config/opencode held a bun.lock (which opencode's plugins' installs write), a package-lock.json, a .gitignore or a .DS_Store: the save's script sent every entry of that folder but node_modules and FolderOwn, while the host's listedPath refuses those files (fileSetting), so it saved nothing. notSettings is now their one list, as patterns path.Match and the shell's case read alike: fileSetting leaves them out and the script sends a file of those names no more, only a folder that isn't a link, which is a setting. TestAgentSaveScriptRuns plants them and a folder named old.lock, and failed with agent_save_unsafe before the fix. opencode's HistoryOwn names its native client's plugin approvals, in its state folder (cli-rs's plugin/src/loader/approval.rs and tui/src/plugins/host.rs, opencode v2.4.1): plugin-approvals.json, its .lock and the .plugin-approvals.json.<pid>.<n>.tmp it's written through, and plugin-staged, the approved trees' copies, which it reuses by their hash's name without hashing them again, so a hostile VM's export could approve a project plugin for the VM that imports it. That client doesn't ship in 2.4.1. TestHistoryExportRuns and TestHistoryImportRuns plant them, with plugin-notes.json as the control, and failed on fedora without the entries. The history scripts' framing (onInputCmd) now says why on its stderr, which goes to the VM's log, when its input was cut short: TestOnInputCutShort checks it for every cut, an empty input included, and none for a whole one, and failed before. TestHistoryScriptsOnInput holds each script under 128 KiB, Linux's limit on one argument, which bash -c "$s" passes it as. The CLI scripts match the framing's new start. Docs: the save's and the store's table say which files stay in the VM; the import's and How it works' lists name the plugin approvals; the release page gets opencode's lock files in a save and the approvals; the changelog's opencode block gets the save's fix, and the hardening line names approved plugins. The review's optional wording: the design note's `*` matches every resource, and the plain-password steps set this machine's password first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
227 lines
7.8 KiB
Plaintext
227 lines
7.8 KiB
Plaintext
# rm VM: a VM whose project folder is gone, named by its name or ssh
|
|
# alias, is deleted from any folder after asking, its agents' history
|
|
# exported first; ls and space mark it. A VM whose folder is there, a name
|
|
# that isn't a VM's, and a VM its backend lost are refused.
|
|
|
|
# A name that isn't a VM's, and a folder's name, which rm doesn't take.
|
|
! exec devvm rm devvm-nope-0123456789abcd
|
|
stderr '^devvm: rm_unknown_vm name=devvm-nope-0123456789abcd$'
|
|
project web
|
|
exec devvm --network open --no-git-protect --agents claude
|
|
vm_name WEB web
|
|
project api
|
|
exec devvm --network open --no-git-protect
|
|
vm_name API api
|
|
! exec devvm rm api --force
|
|
stderr '^devvm: rm_unknown_vm name=api$'
|
|
|
|
# Folders that are there: nothing is marked, and rm VM refuses a VM whose
|
|
# folder is there from another folder, naming that folder; named in its
|
|
# own folder, it's rm.
|
|
exec devvm ls
|
|
stdout '^devvm-api-[0-9a-f]{14} +Running +base +- +off +open +- +/\S*/api\n'
|
|
! stdout gone
|
|
exec devvm ls --json
|
|
stdout '"folder_state": "there"'
|
|
! stdout '"folder_state": "(gone|not_connected)"'
|
|
exec devvm space --json
|
|
! stdout folder_gone
|
|
cd $WORK/web
|
|
stub_reset
|
|
! exec devvm rm $API --force
|
|
stderr '^devvm: rm_vm_folder_there dir=/\S*/api vm=devvm-api-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exists $API_dir/vm.json
|
|
cd $WORK/api
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm rm $API
|
|
stderr '^rm_confirm vm=devvm-api-[0-9a-f]{14} \[y/N\] '
|
|
exists $API_dir/vm.json
|
|
|
|
# api's folder goes: ls marks it, in text and --json, and space names it.
|
|
cd $WORK/web
|
|
rm $WORK/api
|
|
exec devvm ls
|
|
stdout '^devvm-api-[0-9a-f]{14} +Running +base +- +off +open +- +/\S*/api \(gone\)\n'
|
|
stdout '^devvm-web-[0-9a-f]{14} +Running +.* +/\S*/web\n'
|
|
exec devvm ls --json
|
|
stdout '"folder": "/\S*/api",\n "folder_state": "gone",\n'
|
|
stdout '"folder": "/\S*/web",\n "folder_state": "there",\n'
|
|
exec devvm space
|
|
stderr '^space_folder_gone dir=/\S*/api vm=devvm-api-[0-9a-f]{14}$'
|
|
! stderr 'space_folder_gone .*web'
|
|
exec devvm space --json
|
|
stdout '"folder_gone": \[\n {\n "backend": "lima",\n "name": "devvm-api-[0-9a-f]{14}",\n "folder": "/\S*/api"\n }\n \]'
|
|
# gc never deletes it.
|
|
exec devvm gc --orphans --force
|
|
exists $API_dir/vm.json
|
|
|
|
# Without a terminal rm VM refuses unless --force; in one, no keeps it,
|
|
# and yes deletes it, by its ssh alias too. Its folder isn't made again.
|
|
stub_reset
|
|
! exec devvm rm $API
|
|
stderr '^devvm: no_input answer=--force$'
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm rm $API
|
|
stderr '^delete_gone_folder_vm dir=/\S*/api vm=devvm-api-[0-9a-f]{14} \[y/N\] '
|
|
stdout '==> kept vm=devvm-api-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exists $API_dir/vm.json
|
|
vm_state $API_dir/vm.json
|
|
stdout '^alias=devvm-api$'
|
|
ttyin -stdin $WORK/yes.txt
|
|
exec devvm rm devvm-api
|
|
stdout '==> deleted vm=devvm-api-[0-9a-f]{14}$'
|
|
! stdout exported
|
|
stub_calls
|
|
stdout '^limactl delete -f devvm-api-[0-9a-f]{14}$'
|
|
! stdout 'limactl (start|shell)'
|
|
! exists $API_dir
|
|
! exists $WORK/api
|
|
exec cat $DATA/ssh_config
|
|
! stdout devvm-api
|
|
|
|
# web has an agent. Stopped, its history can't be exported without
|
|
# starting it, which would make its folder again: refused, unless
|
|
# --no-export. Running, it's exported, then deleted; an export that
|
|
# fails keeps it.
|
|
cd $WORK
|
|
rm $WORK/web
|
|
exec limactl stop $WEB
|
|
stub_reset
|
|
! exec devvm rm $WEB --force
|
|
stderr '^devvm: rm_gone_stopped dir=/\S*/web vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl (start|delete)'
|
|
exists $WEB_dir/vm.json
|
|
! exists $WORK/web
|
|
exec limactl start --tty=false $WEB
|
|
exec sh -c 'echo "tar -czf" > "$STUB_DIR/shell-fails-on"'
|
|
! exec devvm rm $WEB --force
|
|
stderr '^devvm: export_failed_kept command=devvm rm devvm-web-[0-9a-f]{14} vm=devvm-web-[0-9a-f]{14}$'
|
|
exists $WEB_dir/vm.json
|
|
rm $STUB_DIR/shell-fails-on
|
|
stub_reset
|
|
exec devvm rm $WEB --force
|
|
stdout '^==> exported file=\S*/data/devvm/exports/devvm-web-[0-9a-f]{14}-[0-9]{8}-[0-9]{6}\.tar\.gz vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^==> deleted vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout 'exec ''bash'' ''-c'' ''if IFS= read -r n '
|
|
grep '^devvm_opencode_clean\(\) \{$' $STUB_DIR/history-export.sh
|
|
grep '^cd ~ && ls -d \.claude ' $STUB_DIR/history-export.sh
|
|
! stdout 'limactl start'
|
|
! exists $WEB_dir
|
|
! exists $WORK/web
|
|
catg $DATA/exports/devvm-web-*.folder
|
|
stdout '^/\S*/web$'
|
|
|
|
# A stopped VM with an agent goes with --no-export.
|
|
project agent
|
|
exec devvm --network open --no-git-protect --agents claude
|
|
vm_name AGENT agent
|
|
exec limactl stop $AGENT
|
|
cd $WORK
|
|
rm $WORK/agent
|
|
exec devvm rm $AGENT --force --no-export
|
|
! stdout exported
|
|
stdout '^==> deleted vm=devvm-agent-[0-9a-f]{14}$'
|
|
! exists $AGENT_dir
|
|
|
|
# A --clone VM's work can't be fetched into a repo that's gone: refused
|
|
# unless --no-clone-check, which warns.
|
|
mkdir $VMS/f7999f634f79ad
|
|
cp $WORK/clone.json $VMS/f7999f634f79ad/vm.json
|
|
exec stub vm devvm-cl-f7999f634f79ad Running
|
|
! exec devvm rm devvm-cl-f7999f634f79ad --force
|
|
stderr '^devvm: rm_gone_clone dir=/p/cl vm=devvm-cl-f7999f634f79ad$'
|
|
exec devvm rm devvm-cl-f7999f634f79ad --force --no-clone-check --no-export
|
|
stderr '^devvm: clone_check_skipped command=devvm rm vm=devvm-cl-f7999f634f79ad$'
|
|
stdout '^==> deleted vm=devvm-cl-f7999f634f79ad$'
|
|
! exists $VMS/f7999f634f79ad
|
|
|
|
# A folder that was on another device, as on a disk that isn't connected:
|
|
# ls and space mark it not connected, and rm VM refuses it, --force too,
|
|
# without a terminal; in one it asks, which --force doesn't answer.
|
|
project usb
|
|
exec devvm --network open --no-git-protect
|
|
vm_name USB usb
|
|
cd $WORK
|
|
rm $WORK/usb
|
|
json_set $USB_dir/vm.json folder=999999999:1
|
|
exec devvm ls
|
|
stdout '^devvm-usb-[0-9a-f]{14} +Running +.* +/\S*/usb \(not connected\)\n'
|
|
exec devvm ls --json
|
|
stdout '"folder": "/\S*/usb",\n "folder_state": "not_connected",\n'
|
|
exec devvm space
|
|
stderr '^space_folder_not_connected dir=/\S*/usb vm=devvm-usb-[0-9a-f]{14}$'
|
|
! stderr 'space_folder_gone .*usb'
|
|
exec devvm space --json
|
|
stdout '"folder_not_connected": \[\n {\n "backend": "lima",\n "name": "devvm-usb-[0-9a-f]{14}",\n "folder": "/\S*/usb"\n }\n \]'
|
|
stub_reset
|
|
! exec devvm rm $USB --force
|
|
stderr '^devvm: rm_vm_not_connected dir=/\S*/usb vm=devvm-usb-[0-9a-f]{14}$'
|
|
ttyin -stdin $WORK/no.txt
|
|
exec devvm rm $USB --force
|
|
stderr '^delete_not_connected_folder_vm dir=/\S*/usb vm=devvm-usb-[0-9a-f]{14} \[y/N\] '
|
|
stdout '==> kept vm=devvm-usb-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exists $USB_dir/vm.json
|
|
ttyin -stdin $WORK/yes.txt
|
|
exec devvm rm $USB --force
|
|
stdout '^==> deleted vm=devvm-usb-[0-9a-f]{14}$'
|
|
! exists $USB_dir
|
|
|
|
# A VM its backend lost: gc --orphans' to forget.
|
|
mkdir $VMS/be79df76493187
|
|
cp $WORK/lost.json $VMS/be79df76493187/vm.json
|
|
! exec devvm rm devvm-lost-be79df76493187 --force
|
|
stderr '^devvm: rm_vm_lost vm=devvm-lost-be79df76493187$'
|
|
exists $VMS/be79df76493187/vm.json
|
|
|
|
# A VM whose state records a folder with a VM of its own (a vm.json
|
|
# changed by hand), named in that folder: refused as one whose folder is
|
|
# there, and the folder's own VM stays.
|
|
project mine
|
|
exec devvm --network open
|
|
vm_name MINE mine
|
|
mkdir $VMS/0123456789ab03
|
|
cp $WORK/lost.json $VMS/0123456789ab03/vm.json
|
|
json_set $VMS/0123456789ab03/vm.json name=devvm-odd-0123456789ab03 dir=$WORK/mine
|
|
exec stub vm devvm-odd-0123456789ab03 Stopped
|
|
! exec devvm rm devvm-odd-0123456789ab03 --force
|
|
stderr '^devvm: rm_vm_folder_there dir=/\S*/mine vm=devvm-odd-0123456789ab03$'
|
|
exists $VMS/0123456789ab03/vm.json
|
|
exists $MINE_dir/vm.json
|
|
|
|
-- yes.txt --
|
|
y
|
|
-- no.txt --
|
|
n
|
|
-- clone.json --
|
|
{
|
|
"version": 1,
|
|
"id": "0123456789abcdef0123456789abcd01",
|
|
"name": "devvm-cl-f7999f634f79ad",
|
|
"image": "base",
|
|
"dir": "/p/cl",
|
|
"backend": "lima",
|
|
"created": "2026-01-01T00:00:00Z",
|
|
"clone": {"on": true},
|
|
"git": {"mode": "clone"},
|
|
"net": {"tier": "open"}
|
|
}
|
|
-- lost.json --
|
|
{
|
|
"version": 1,
|
|
"id": "0123456789abcdef0123456789abcd02",
|
|
"name": "devvm-lost-be79df76493187",
|
|
"image": "base",
|
|
"dir": "/p/lost",
|
|
"backend": "lima",
|
|
"created": "2026-01-01T00:00:00Z",
|
|
"net": {"tier": "open"}
|
|
}
|