Cleanup hook on worktree removal — stop project daemons before iw rm #382
Labels
No labels
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#382
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Problem
./iw rmremoves the worktree directory but leaves project-spawned processes running. Two distinct pain points have accumulated:startworkflow brought up (originally documented in #147).Today the only way out is to re-create the worktree, run the project's shutdown manually, then
./iw rmagain — defeating the point.Solution: cleanup hook discovered the standard way
Add a
CleanupActiontrait + reflection-based discovery for*.hook-rm.scalafiles, matching the action-hook pattern landed in #331 (SessionAction/FixAction/RecoveryAction).Discovery & invocation
iw rmcallsenv.hooks.collectValues[CleanupAction](the same pattern the existing hooks use) before anygit worktree remove.--forcecontinues to mean "ignore dirty tree, dirty index, etc." and is passed through inCleanupContext.forceso projects can decide whether to escalate (e.g. SIGKILL instead of SIGTERM).Built-in fallback for common daemons
Ship a single default
BuildToolCleanuphook in core that handles the two specific footguns from #225 without requiring every project to write one:out/mill-daemon/exists under the worktree, runmill --no-server shutdown(or send TERM to the PIDs recorded there).~/.local/share/scalacli/bloop/state.jsonor its equivalent),bloop exit.docker-compose.ymlexists at the worktree root, rundocker compose downonly when a project hook hasn't already handled it.The fallback is opt-out via
cleanup.builtin = falsein.iw/config.conf, opt-in to extras by writing a project hook. This keeps the "I just want it to stop hogging my CPU" case fixed with no project config and lets advanced projects layer behaviour.Acceptance criteria
CleanupActiontrait incore/model/iw rmdiscoversCleanupActionvalues via the same reflection passdoctor,start, etc. userm(preserve the worktree); warnings surface butrmproceedsBuildToolCleanupdefault hook covers Mill, Bloop, docker-compose (best-effort, never blocksrm)cleanup.builtin = falsedisables the default hooktest/rm.batsproves the wiring (single hook prints expected line before worktree removal)Supersedes
Related