feat(witness): delay polecat cleanup until MR merges (gt-12hwb)

Phase 4 of local-only polecat branches: Handle conflict resolution edge case.

Problem: If polecat worktree is nuked before MR merges, the local branch
is gone and conflict resolution can't access it.

Solution: Witness now defers cleanup for polecats with pending MRs:
- HandlePolecatDone creates a cleanup wisp with "merge-requested" state
- Polecat worktree preserved until MERGED signal arrives
- HandleMerged then nukes the polecat (existing behavior)

Also updated mol-polecat-conflict-resolve.formula.toml:
- Removed fetch from origin (branches are local-only now)
- Added instructions to fetch from source polecat's worktree
- Added rig and source_polecat variables

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/gus
2026-01-06 13:11:30 -08:00
committed by Steve Yegge
parent b79e4a7c3b
commit 63af29284b
2 changed files with 58 additions and 21 deletions

View File

@@ -145,20 +145,39 @@ git stash list # Should be empty
If dirty, clean up first (stash or discard).
**2. Fetch latest state:**
**2. Fetch latest main:**
```bash
git fetch origin
git fetch origin {{branch}}:refs/remotes/origin/{{branch}}
```
**3. Checkout the branch:**
**3. Locate the source polecat's worktree:**
The branch is local-only (not pushed to origin). Find the source polecat path
from the task metadata. The path follows the pattern:
```
~/gt/<rig>/polecats/<polecat-name>
```
Extract the source polecat name from the MR metadata:
```bash
git checkout -b temp-resolve origin/{{branch}}
bd show {{original_mr}} --json | jq -r '.description' | grep -oP 'Source polecat: \K\S+'
```
**4. Fetch the branch from the source polecat's worktree:**
```bash
# The source polecat's worktree still exists (cleanup is deferred until MR merges)
SOURCE_POLECAT_PATH="$HOME/gt/{{rig}}/polecats/{{source_polecat}}"
git fetch "$SOURCE_POLECAT_PATH" {{branch}}:{{branch}}
```
**5. Checkout the branch:**
```bash
git checkout -b temp-resolve {{branch}}
```
Using `temp-resolve` as the local branch name keeps things clear.
**4. Verify the branch state:**
**6. Verify the branch state:**
```bash
git log --oneline -5 # Recent commits
git log origin/main..HEAD # Commits not on main
@@ -383,3 +402,11 @@ required = true
[vars.branch]
description = "The branch to rebase (extracted from task metadata)"
required = true
[vars.rig]
description = "The rig where the source polecat resides"
required = true
[vars.source_polecat]
description = "The name of the polecat whose local branch contains the work (extracted from MR metadata)"
required = true