mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
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]>
116 lines
4.5 KiB
Plaintext
116 lines
4.5 KiB
Plaintext
# gc --tool-images: also the current tool images no VM's state lists, on every
|
|
# backend and C library, or only the named tools', however new; never one a
|
|
# VM's state lists (a stopped VM's, or one deleted outside devvm), nor any
|
|
# while a VM is being made. Never a VM.
|
|
env SHARE=$XDG_DATA_HOME/devvm/tools
|
|
|
|
# Names go only with --tool-images, and only shared tools' names.
|
|
! exec devvm gc --force node
|
|
stderr '^devvm: gc_names_need_tools tool=node$'
|
|
! exec devvm gc --force --tool-images nope
|
|
stderr '^devvm: unknown_tool tool=nope '
|
|
|
|
# node (node, pnpm, bun), claude and codex, all current, built for a VM
|
|
# that's gone since. A VM deleted outside devvm still lists claude in its
|
|
# state; node's three are old, and codex was built just now.
|
|
project tl
|
|
exec devvm --tools node --agents claude,codex --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
mkdir $VMS/12345612345612
|
|
exec sh -c 'printf "{\"version\": 1, \"id\": \"x\", \"name\": \"devvm-gone-12345612345612\", \"image\": \"base\", \"dir\": \"/p\", \"backend\": \"lima\", \"tools\": {\"names\": [\"claude\"], \"made\": {\"files\": [\"%s\"]}}}\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345612/vm.json"'
|
|
json_set $SHARE/node-*.erofs.json built=2020-01-01T00:00:00Z
|
|
json_set $SHARE/pnpm-*.erofs.json built=2020-01-01T00:00:00Z
|
|
json_set $SHARE/bun-*.erofs.json built=2020-01-01T00:00:00Z
|
|
json_set $SHARE/claude-*.erofs.json built=2020-01-01T00:00:00Z
|
|
|
|
# Plain gc keeps every current one.
|
|
exec devvm gc --force
|
|
stdout '^==> nothing_to_clean$'
|
|
|
|
# --tool-images claude: claude is a VM's, so nothing.
|
|
exec devvm gc --force --tool-images claude
|
|
stdout '^==> nothing_to_clean$'
|
|
|
|
# --tool-images codex: only codex, built just now.
|
|
exec devvm gc --force --tool-images codex
|
|
stdout '^gc_tools_no_vm count=1 size=\S+ tools=codex \S+$'
|
|
stdout '^==> deleted_tools_no_vm count=1$'
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
! stdout '^codex-'
|
|
stdout '^node-'
|
|
|
|
# --tool-images: node's three, not claude's (a VM's).
|
|
exec devvm gc --force --tool-images
|
|
stdout '^gc_tools_no_vm count=3 size=\S+ tools=node \S+, pnpm \S+, bun \S+$'
|
|
stdout '^==> deleted_tools_no_vm count=3$'
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
! stdout '^(node|pnpm|bun)-'
|
|
stdout '^claude-'
|
|
! exists $SHARE/.lock
|
|
|
|
# Nothing is left of them.
|
|
exec devvm gc --force --tool-images
|
|
stdout '^==> nothing_to_clean$'
|
|
! stdout 'deleted_'
|
|
|
|
# A VM that gets node later builds it again. Without a terminal, gc deletes
|
|
# nothing unless --force.
|
|
exec devvm --tools node --agents none --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
! exec devvm gc --tool-images node
|
|
stderr '^devvm: no_input answer=--force$'
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
stdout '^node-'
|
|
|
|
# While a VM is being made (its start hangs), --tool-images keeps every
|
|
# current one no VM has, saying so; once its devvm is killed, nothing holds
|
|
# the lock.
|
|
project making git
|
|
exec sh -c ': > "$STUB_DIR/start-hangs"'
|
|
! exec devvm --network open &u&
|
|
wait_file $STUB_DIR/hanging
|
|
exec devvm gc --force --tool-images
|
|
stdout '^==> gc_tools_making count=3 tools=node \S+, pnpm \S+, bun \S+$'
|
|
! stdout 'gc_tools_no_vm|deleted_|nothing_to_clean'
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
stdout '^node-'
|
|
kill -KILL u
|
|
wait u
|
|
rm $STUB_DIR/start-hangs
|
|
rm $STUB_DIR/hanging
|
|
|
|
# Then --tool-images deletes node's three, but never claude (a VM's).
|
|
exec devvm gc --force --tool-images
|
|
stdout '^gc_tools_no_vm count=3 size=\S+ tools=node \S+, pnpm \S+, bun \S+$'
|
|
stdout '^==> deleted_tools_no_vm count=3$'
|
|
! stdout gc_tools_making
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
! stdout '^(node|pnpm|bun)-'
|
|
stdout '^claude-'
|
|
! exists $SHARE/.lock
|
|
|
|
# codex, no VM's, then a VM whose go is being built: gc --tool-images waits
|
|
# for the build, then finds the VM still being made (its start hangs once it
|
|
# runs) and keeps every current one no VM lists, go too while its VM's state
|
|
# doesn't list it yet.
|
|
project cx git
|
|
exec devvm --tools none --agents codex --network open --no-git-protect
|
|
exec devvm rm --force --no-export
|
|
project waits git
|
|
exec sh -c 'printf devvm-tools-build > "$STUB_DIR/shell-waits-on" && printf waits > "$STUB_DIR/start-hangs-running"'
|
|
! exec devvm --tools go --agents none --network open --no-git-protect &w&
|
|
wait_file $STUB_DIR/waiting
|
|
exec devvm gc --force --tool-images &g&
|
|
exec sleep 0.5
|
|
rm $STUB_DIR/shell-waits-on
|
|
wait_file $STUB_DIR/hanging
|
|
wait g
|
|
stdout '^==> gc_tools_making count=[12] tools=.*codex '
|
|
! stdout 'gc_tools_no_vm|deleted_|nothing_to_clean'
|
|
exec sh -c 'cd "$SHARE" && ls *.erofs'
|
|
stdout '^codex-'
|
|
stdout '^go-'
|
|
kill -KILL w
|
|
wait w
|
|
rm $STUB_DIR/start-hangs-running
|