Files
devvm/testdata/script/move.txtar
T
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00

84 lines
2.8 KiB
Plaintext

# A moved or renamed project folder keeps its VM, only after a yes in a
# terminal or devvm adopt --force: without either every command on the
# folder's VM refuses, naming devvm adopt. Once moved, the VM is found by
# the folder its state records, from the new path alone, and its next
# start mounts the folder there. devvm adopt VM moves a VM whose folder
# is gone to a copy of it, which is never offered on its own.
project web
exec devvm --network open
vm_name WEB web
exec devvm stop
cd $WORK
mv web site
cd site
# Without a terminal: refused, nothing changed.
stub_reset
! exec devvm
stderr '^devvm: vm_moved_here vm=devvm-web-[0-9a-f]{14} was=/\S*/web$'
! exec devvm stop
stderr '^devvm: vm_moved_here vm=devvm-web-[0-9a-f]{14} was=/\S*/web$'
stub_calls
! stdout 'limactl (start|stop|edit|clone|delete)'
vm_state $WEB_dir/vm.json
stdout '^dir=/\S*/web$'
# A no in a terminal: the folder has no VM.
ttyin -stdin $WORK/no.txt
! exec devvm stop
stderr '^move_vm vm=devvm-web-[0-9a-f]{14} was=/\S*/web \[y/N\] devvm: no_vm dir=/\S*/site$'
vm_state $WEB_dir/vm.json
stdout '^dir=/\S*/web$'
# A yes: the VM's state records this folder.
ttyin -stdin $WORK/yes.txt
exec devvm stop
stdout '==> vm_adopted dir=/\S*/site vm=devvm-web-[0-9a-f]{14}$'
stdout '==> already_stopped vm=devvm-web-[0-9a-f]{14}$'
vm_state $WEB_dir/vm.json
stdout '^dir=/\S*/site$'
grep '"moved": \{\s*"from": "/\S*/web"\s*\}' $WEB_dir/vm.json
# Found by that folder from then on, asking nothing; its start mounts the
# folder where it is now, in the one edit, and its setup moves the agents'
# state from the old path, clearing the record.
stub_reset
exec devvm
! stderr 'vm_moved_here|move_vm'
stub_calls
stdout '^limactl edit --tty=false devvm-web-[0-9a-f]{14} --set \.mounts = \[\{"location":"/\S*/site","writable":true\}'
stdout '^limactl shell --workdir /\S*/site devvm-web-[0-9a-f]{14}\n\z'
exec tar -xOf $STUB_DIR/sync.tar moved
stdout '^moved_from=''/\S*/web''\nmoved_to=''/\S*/site''\nclaude_from=''-\S*-web''\nclaude_to=''-\S*-site''\n\z'
! grep '"moved"' $WEB_dir/vm.json
exec devvm ls --json
stdout '"folder": "/\S*/site",'
# A new folder at the old path gets a VM of its own, by another name.
cd $WORK
mkdir web
cd web
exec devvm --network open
exec devvm ls
stdout -count=2 '^devvm-web-[0-9a-f]{14} '
# devvm adopt VM: a copy of the folder, as on another disk, is another
# folder, never offered; adopt moves the VM there once its folder is gone.
cd $WORK
exec cp -R site copy
cd copy
! exec devvm stop
stderr '^devvm: no_vm dir=/\S*/copy$'
! exec devvm adopt $WEB --force
stderr '^devvm: adopt_folder_there dir=/\S*/site vm=devvm-web-[0-9a-f]{14}$'
rm $WORK/site
exec devvm adopt $WEB --force
stdout '==> vm_adopted dir=/\S*/copy vm=devvm-web-[0-9a-f]{14}$'
vm_state $WEB_dir/vm.json
stdout '^dir=/\S*/copy$'
-- yes.txt --
y
-- no.txt --
n