Problem
When polecats are nuked via gt polecat nuke, Claude child processes survive and become orphans. This leads to:
- Memory exhaustion (each Claude instance uses ~400MB)
- Observed: 142 orphaned processes consuming ~56GB RAM
- Processes accumulate over time until system becomes sluggish
Root Cause
gt polecat nuke kills the tmux session but doesn't kill the process tree. Claude processes spawned within the session continue running as orphans.
Proposed Fix
- Enhance
gt polecat nuketo kill process tree before destroying session:
# Before killing tmux session: # 1. Get pane PIDs PANE_PIDS=$(tmux list-panes -t $session -F '#{pane_pid}') # 2. Send SIGTERM to process trees (graceful) echo "$PANE_PIDS" | xargs -I{} pkill -TERM -P {} 2>/dev/null sleep 2 # 3. Force kill survivors echo "$PANE_PIDS" | xargs -I{} pkill -KILL -P {} 2>/dev/null # 4. Then kill tmux session tmux kill-session -t $session
- Add orphan detection to Witness patrol:
# Find claude processes not attached to active tmux sessions ACTIVE_TTYS=$(tmux list-panes -a -F '#{pane_tty}' | sed 's|/dev/||' | paste -sd'|') ORPHANS=$(ps aux | grep -E "claude\s*$" | grep -v -E "$ACTIVE_TTYS" | awk '{print $2}') if [ -n "$ORPHANS" ]; then echo "$ORPHANS" | xargs kill -9 # Alert mayor about cleanup fi
- Add
gt cleanupcommand for manual orphan removal
Acceptance Criteria
-
gt polecat nukekills all child processes before session - Witness patrol detects and cleans orphans during patrol
- No orphaned claude processes after nuking polecats
- Add
--dry-runflag to show what would be killed
Files to Modify
cmd/polecat.go(or equivalent nuke implementation)cmd/witness.go(patrol logic)- Add
cmd/cleanup.gofor manual cleanup command