fix(polecat): kill orphan sessions and clear stale hooks during allocation (#448)

ReconcilePool now detects and kills orphan tmux sessions (sessions without
corresponding polecat directories). This prevents allocation from being
blocked by broken state from crashed polecats.

Changes:
- Add tmux to Manager to check for orphan sessions during reconciliation
- Add ReconcilePoolWith for testable session/directory reconciliation logic
- Always clear hook_bead slot when reopening agent beads (fixes stale hooks)
- Prune stale git worktree entries during reconciliation

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen
2026-01-13 21:37:00 +00:00
committed by GitHub
parent bd2a5ab56a
commit 65c5e05c43
10 changed files with 297 additions and 34 deletions

View File

@@ -921,7 +921,7 @@ func runRigShutdown(cmd *cobra.Command, args []string) error {
// Check all polecats for uncommitted work (unless nuclear)
if !rigShutdownNuclear {
polecatGit := git.NewGit(r.Path)
polecatMgr := polecat.NewManager(r, polecatGit)
polecatMgr := polecat.NewManager(r, polecatGit, nil) // nil tmux: just listing
polecats, err := polecatMgr.List()
if err == nil && len(polecats) > 0 {
var problemPolecats []struct {
@@ -1105,7 +1105,7 @@ func runRigStatus(cmd *cobra.Command, args []string) error {
// Polecats
polecatGit := git.NewGit(r.Path)
polecatMgr := polecat.NewManager(r, polecatGit)
polecatMgr := polecat.NewManager(r, polecatGit, t)
polecats, err := polecatMgr.List()
fmt.Printf("%s", style.Bold.Render("Polecats"))
if err != nil || len(polecats) == 0 {
@@ -1198,7 +1198,7 @@ func runRigStop(cmd *cobra.Command, args []string) error {
// Check all polecats for uncommitted work (unless nuclear)
if !rigStopNuclear {
polecatGit := git.NewGit(r.Path)
polecatMgr := polecat.NewManager(r, polecatGit)
polecatMgr := polecat.NewManager(r, polecatGit, nil) // nil tmux: just listing
polecats, err := polecatMgr.List()
if err == nil && len(polecats) > 0 {
var problemPolecats []struct {
@@ -1330,7 +1330,7 @@ func runRigRestart(cmd *cobra.Command, args []string) error {
// Check all polecats for uncommitted work (unless nuclear)
if !rigRestartNuclear {
polecatGit := git.NewGit(r.Path)
polecatMgr := polecat.NewManager(r, polecatGit)
polecatMgr := polecat.NewManager(r, polecatGit, nil) // nil tmux: just listing
polecats, err := polecatMgr.List()
if err == nil && len(polecats) > 0 {
var problemPolecats []struct {