diff --git a/.beads/formulas/mol-witness-patrol.formula.toml b/.beads/formulas/mol-witness-patrol.formula.toml index 1eecbbde..d6fa3fb6 100644 --- a/.beads/formulas/mol-witness-patrol.formula.toml +++ b/.beads/formulas/mol-witness-patrol.formula.toml @@ -46,11 +46,25 @@ Create a cleanup wisp for this polecat: ```bash bd create --wisp --title "cleanup:" \ --description "Verify and cleanup polecat " \ - --labels cleanup,polecat: + --labels cleanup,polecat:,state:pending ``` The wisp's existence IS the pending cleanup. Process in next step. Mark mail as read. +**MERGED**: +A branch was merged successfully. Complete the cleanup. +```bash +# Find the cleanup wisp for this polecat +bd list --wisp --labels=polecat:,state:merge-requested --status=open + +# If found, proceed with polecat removal +gt session kill /polecats/ + +# Burn the cleanup wisp +bd close +``` +Mark mail as read. + **HELP / Blocked**: Assess the request. Can you help? If not, escalate to Mayor: ```bash @@ -72,7 +86,9 @@ Find and process cleanup wisps (the finalizer pattern). bd list --wisp --labels=cleanup --status=open ``` -For each cleanup wisp: +For each cleanup wisp, check its state label: + +## State: pending (needs verification → MERGE_READY) 1. **Extract polecat name** from wisp title/labels @@ -80,26 +96,43 @@ For each cleanup wisp: ```bash cd polecats/ git status # Must be clean -git log origin/main..HEAD # No unpushed commits +git log origin/main..HEAD # Commits should be pushed bd show # Issue closed or deferred ``` -3. **Verify productive work** (ZFC - you make the call): +3. **Get branch and issue info**: +```bash +# Get current branch +git rev-parse --abbrev-ref HEAD + +# Get the hook_bead from agent bead +bd show # Look for hook_bead field +``` + +4. **Verify productive work** (ZFC - you make the call): - Check git log for commits mentioning the issue - Legitimate exceptions: already fixed, duplicate, deferred - If closing as 'done' with no commits, flag for review -4. **If clean**: Execute cleanup +5. **If clean**: Send MERGE_READY to refinery ```bash -gt session kill /polecats/ -# Worktree removal handled by session kill +gt mail send /refinery -s "MERGE_READY " -m "Branch: +Issue: +Polecat: +Verified: clean git state, issue closed" ``` -Then burn the cleanup wisp: +Then update the wisp to merge-requested state: ```bash -bd close # or bd burn +bd update --labels cleanup,polecat:,state:merge-requested ``` +**Do NOT kill the polecat yet** - wait for MERGED confirmation from refinery. -5. **If dirty**: Leave wisp open, log the issue, retry next cycle. +6. **If dirty**: Leave wisp open, log the issue, retry next cycle. + +## State: merge-requested (waiting for refinery) + +Skip - waiting for MERGED mail from refinery. The inbox-check step handles +MERGED messages and completes these cleanup wisps. **Parallelism**: Use Task tool subagents to process multiple cleanups concurrently. Each cleanup is independent - perfect for parallel execution.""" @@ -155,7 +188,7 @@ Each polecat agent bead has fields in its description: | running | Actively working | Check progress (Step 3) | | idle | No work assigned | Skip (no action needed) | | stuck | Self-reported stuck | Handle stuck protocol | -| done | Work complete | Verify cleanup triggered | +| done | Work complete | Verify cleanup triggered (see Step 4a) | **Step 3: For running polecats, assess progress** @@ -182,7 +215,27 @@ Look for: | agent_state=running, idle 5-15 min | Gentle nudge | | agent_state=running, idle 15+ min | Direct nudge with deadline | | agent_state=stuck | Assess and help or escalate | -| agent_state=done, cleanup pending | Verify cleanup wisp exists | +| agent_state=done | Verify cleanup triggered (see Step 4a) | + +**Step 4a: Handle agent_state=done** + +Check if a cleanup wisp exists for this polecat: +```bash +bd list --wisp --labels=polecat: --status=open +``` + +If cleanup wisp exists: +- state:pending → Will be processed in process-cleanups +- state:merge-requested → Waiting for refinery MERGED response + +If NO cleanup wisp exists (POLECAT_DONE mail missed): +Create one to trigger the cleanup flow: +```bash +bd create --wisp --title "cleanup:" \ + --description "Discovered done polecat without cleanup wisp" \ + --labels cleanup,polecat:,state:pending +``` +This ensures done polecats eventually get cleaned up even if mail was lost. **Step 5: Execute nudges** ```bash