feat(cleanup): walk every backend, reap smolmachines orphans too #79
Reference in New Issue
Block a user
Delete Branch "cleanup-cross-backend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
./cli.py cleanupwalked only the env-var-selected backend, so a leftover smolvm machine / bundle container / bundle network from a crashed smolmachines bottle survived a defaultdocker-mode cleanup indefinitely. This PR makes cleanup walk every backend.Changes
Smolmachines
cleanupmodule. Newbackend/smolmachines/cleanup.pyenumerates:claude-bottle-*(viasmolvm machine ls --json)claude-bottle-sidecars-*claude-bottle-bundle-*cleanupruns stop+delete on the machines, force-rm on the containers, network rm on the networks. Each step is best-effort so a failed rm doesn't block the rest.SmolmachinesBottleCleanupPlannow actually carries something. Docker presence is checked viahas_backend('docker')(centralized helper), late-imported to dodge the cycle.cli/cleanup.pywalks every backend inknown_backend_names(). One y/N prompt against a combined plan; each backend'scleanupruns in turn if confirmed.Docker orphan-state-dir respects all-backend live set. State dirs (
~/.claude-bottle/state/<slug>/) are shared layout. Docker remains the single owner of the orphan-state-dir bucket (only one home for it) but now consultsenumerate_active_agents()for the cross-backend live identity set, so a running smolmachines bottle's state dir isn't reaped while the VM is up._list_orphan_state_dirs(live_projects, protected_identities)— second arg is the union.Tests
test_smolmachines_cleanup.py: prepare-cleanup enumeration; cleanup ordering (machines → bundles → networks); failure-handling (best-effort, doesn't bail).test_cli_cleanup_cross_backend.py: cmd_cleanup walks both backends; short-circuits on all-empty; aborts on N; skips empty-plan backends.test_docker_cleanup.py: newtest_protected_identity_skips_dir+test_protected_overrides_no_live_projectfor the cross-backend protection.619 unit tests pass.
End-to-end check
Stacking
Rebased onto current main (
5e0130b) — PR #78 and PR #80 are already merged in, soenumerate_active_agents(),known_backend_names(), andhas_backend()are available.4859040c6fto5323fc1b535323fc1b53to346367ca32346367ca32toa3a9ec065e