docs/design/persistent-polecat-pool.md
Issue: gt-lpop Status: Design Author: Mayor
Three concepts are conflated in the polecat lifecycle:
| Concept | Lifecycle | Current behavior |
|---|---|---|
| Identity | Long-lived (name, CV, ledger) | Destroyed on nuke |
| Sandbox | Per-assignment (worktree, branch) | Destroyed on nuke |
| Session | Ephemeral (Claude context window) | = polecat lifetime |
Consequences:
IDENTITY (persistent)
Name: "furiosa"
Agent bead: gt-gastown-polecat-furiosa
CV: work history, languages, completion rate
Lifecycle: created once, never destroyed (unless explicitly retired)
SANDBOX (per-assignment, reusable)
Worktree: polecats/furiosa/gastown/
Branch: polecat/furiosa/<issue>@<timestamp>
Lifecycle: synced to main between assignments, not destroyed
SESSION (ephemeral)
Tmux: gt-gastown-furiosa
Claude context: cycles on compaction/handoff
Lifecycle: independent of identity and sandbox
┌──────────┐
┌───►│ IDLE │◄──── sync sandbox to main
│ └────┬─────┘ clear hook
│ │ gt sling
│ ▼
│ ┌──────────┐
│ │ WORKING │◄──── session active, hook set
│ └────┬─────┘
│ │ work complete
│ ▼
│ ┌──────────┐
└────┤ DONE │──── push branch, submit MR
└──────────┘
No nuke in the happy path. Polecats cycle: IDLE → WORKING → DONE → IDLE.
Pool size: Fixed per rig. Configured in rig.config.json:
{
"polecat_pool_size": 4,
"polecat_names": ["furiosa", "nux", "toast", "slit"]
}
Initialization: gt rig add or gt polecat pool init <rig> creates N polecats
with identities and worktrees. They start in IDLE state.
Dispatch: gt sling <bead> <rig> finds an IDLE polecat (already does this via
FindIdlePolecat()), attaches work, starts session. No worktree creation needed.
Completion: When a polecat finishes work:
git checkout main && git pullWhen work completes and MR is merged (or no code changes):
# In the polecat's worktree
git checkout main
git pull origin main
git branch -D polecat/furiosa/<old-issue>@<timestamp>
# Worktree is now clean, on main, ready for next assignment
When new work is slung:
# Create fresh branch from current main
git checkout -b polecat/furiosa/<new-issue>@<timestamp>
# Start working
No worktree add/remove. Just branch operations on an existing worktree.
No changes to refinery. Refinery still:
The polecat doesn't care — it already moved to main locally during DONE → IDLE.
Witness patrol behavior (shipped):
gt polecat nuke is reserved for exceptional cases:
It should be rare and manual, not part of normal workflow.
With persistent polecats, branches have clear owners:
The 219 stale branches came from nuked polecats that never cleaned up. With persistent polecats, branch lifecycle is managed by the polecat itself.
For the existing 219 stale branches:
# Delete all remote polecat branches that don't belong to active polecats
git branch -r | grep 'origin/polecat/' | grep -v 'furiosa/gt-ziiu' | grep -v 'nux/gt-uj16' \
| sed 's/origin\///' | xargs -I{} git push origin --delete {}
gt polecat done transitions to IDLE instead of triggering nukegt polecat pool init <rig> creates N persistent polecatsStatus: Polecats are allocated on-demand by gt sling via FindIdlePolecat()
and AllocateAndAdd(). Pre-allocation is unnecessary because idle polecats are
reused automatically. Pool size enforcement is a future optimization, not a blocker.
done.go)ReuseIdlePolecat()gt sling prefers idle polecats via FindIdlePolecat()gt handoff works for all roles (Mayor, Crew, Witness, Refinery, Polecats)ReconcilePool): not yet implemented| Component | Status | Key Files |
|---|---|---|
gt done (push, MR, idle, sandbox sync) | SHIPPED | internal/cmd/done.go |
gt sling (idle reuse, branch-only repair) | SHIPPED | internal/cmd/sling.go, polecat_spawn.go |
gt handoff (session cycle, all roles) | SHIPPED | internal/cmd/handoff.go |
| Witness patrol (zombie, stale, orphan detection) | SHIPPED | internal/witness/handlers.go, internal/polecat/manager.go |
| Cleanup pipeline (POLECAT_DONE → MERGE_READY → MERGED) | SHIPPED | internal/witness/handlers.go, internal/refinery/engineer.go |
| Idle polecat heresy fix (skip healthy idle) | SHIPPED | internal/witness/handlers.go |
| Restart-first policy (no auto-nuke) | SHIPPED | internal/polecat/manager.go |
| Polecat branch always deleted after merge | SHIPPED | internal/refinery/engineer.go |
| Refinery notifies mayor after merge | NOT SHIPPED | — |
| Pool size enforcement | DEFERRED | — |
ReconcilePool() | DEFERRED | — |
gt polecat pool init command | DEFERRED | — |