Skip to content

Clean up Compose resources and listeners for removed worktrees - #30

Merged
sangdth merged 1 commit into
masterfrom
feat/compose-worktree-cleanup-2111
Nov 21, 2026
Merged

sangdth merged 1 commit into
masterfrom
feat/compose-worktree-cleanup-2111

Conversation

@sangdth

@sangdth sangdth commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add src/clean.rs, which tears down a removed worktree's Docker Compose containers, networks, and volumes by com.docker.compose.project=<label>, and stops TCP listeners left on a freed 127.0.1.x own-block address.
  • Record whether a root domain came from a worktree with a new optional worktree flag on store::Domain (omitted from JSON when false), populated by scan::propose and lodo dev's auto-register path.
  • Run the cleanup from lodo prune (including --worktree and the menu bar's Prune Missing Projects) and from worktree slot reclaim in lodo dev, printing stopped ... summaries to stdout and note ... warnings to stderr.
  • Resolve the Docker binary from a candidate list so cleanup works under launchd's minimal PATH; add /bin/kill as a known tool path.
  • Skip cleanup when another remaining project still uses the same compose label or the same own-block IP, when the project uses --compose none, or for non-worktree projects, so main-checkout Docker resources are never touched.
  • Protect daemons from being killed: Docker/OrbStack/vpnkit/Colima/QEMU helpers, caddy, dnsmasq, lodo, and com.apple.* processes are ignored, as are the current process and non-matching or forwarded sockets.
  • Docker and lsof/kill calls are best-effort with timeouts; a stopped Docker daemon only produces a note when a compose file is linked.
  • Document the behavior in docs/reference.md and AGENTS.md.

Testing

  • cargo fmt --all -- --check — passed.
  • cargo clippy --all-targets --locked -- -D warnings — passed.
  • cargo test --locked — passed: 136 library tests, 2 e2e_dataplane tests (including the Swift self-tests). New coverage checks Docker removal order, listener parsing and protected-process skipping, non-worktree IP-only cleanup, compose none and shared label/IP skips, daemon-failure notes, and kill error handling.
  • cargo install --path . --locked — built and installed the binary.
  • Not run: the destructive real-Mac e2e_system.rs suite, and no manual run against live Docker containers or a restarted menu bar app.

- stop dev servers listening on a freed 127.0.1.x address in `lodo prune` and worktree slot reclaim in `lodo dev`
- remove the worktree's Compose containers, networks, and volumes by `com.docker.compose.project` label
- track the `worktree` flag on domains so legacy entries are detected from disk
@sangdth
sangdth merged commit 4be5572 into master Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant