Witness sends MERGE_READY to refinery on polecat completion (gt-u6siy)
Updated mol-witness-patrol formula with: - MERGE_READY mail sent after polecat verification (process-cleanups) - MERGED mail handling in inbox-check (completes cleanup) - Cleanup wisp state machine: pending → merge-requested → closed - Fallback discovery in survey-workers creates cleanup if done polecat found without existing wisp 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -46,11 +46,25 @@ Create a cleanup wisp for this polecat:
|
|||||||
```bash
|
```bash
|
||||||
bd create --wisp --title "cleanup:<polecat>" \
|
bd create --wisp --title "cleanup:<polecat>" \
|
||||||
--description "Verify and cleanup polecat <name>" \
|
--description "Verify and cleanup polecat <name>" \
|
||||||
--labels cleanup,polecat:<name>
|
--labels cleanup,polecat:<name>,state:pending
|
||||||
```
|
```
|
||||||
The wisp's existence IS the pending cleanup. Process in next step.
|
The wisp's existence IS the pending cleanup. Process in next step.
|
||||||
Mark mail as read.
|
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:<name>,state:merge-requested --status=open
|
||||||
|
|
||||||
|
# If found, proceed with polecat removal
|
||||||
|
gt session kill <rig>/polecats/<name>
|
||||||
|
|
||||||
|
# Burn the cleanup wisp
|
||||||
|
bd close <wisp-id>
|
||||||
|
```
|
||||||
|
Mark mail as read.
|
||||||
|
|
||||||
**HELP / Blocked**:
|
**HELP / Blocked**:
|
||||||
Assess the request. Can you help? If not, escalate to Mayor:
|
Assess the request. Can you help? If not, escalate to Mayor:
|
||||||
```bash
|
```bash
|
||||||
@@ -72,7 +86,9 @@ Find and process cleanup wisps (the finalizer pattern).
|
|||||||
bd list --wisp --labels=cleanup --status=open
|
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
|
1. **Extract polecat name** from wisp title/labels
|
||||||
|
|
||||||
@@ -80,26 +96,43 @@ For each cleanup wisp:
|
|||||||
```bash
|
```bash
|
||||||
cd polecats/<name>
|
cd polecats/<name>
|
||||||
git status # Must be clean
|
git status # Must be clean
|
||||||
git log origin/main..HEAD # No unpushed commits
|
git log origin/main..HEAD # Commits should be pushed
|
||||||
bd show <assigned-issue> # Issue closed or deferred
|
bd show <assigned-issue> # 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 <agent-bead> # Look for hook_bead field
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Verify productive work** (ZFC - you make the call):
|
||||||
- Check git log for commits mentioning the issue
|
- Check git log for commits mentioning the issue
|
||||||
- Legitimate exceptions: already fixed, duplicate, deferred
|
- Legitimate exceptions: already fixed, duplicate, deferred
|
||||||
- If closing as 'done' with no commits, flag for review
|
- If closing as 'done' with no commits, flag for review
|
||||||
|
|
||||||
4. **If clean**: Execute cleanup
|
5. **If clean**: Send MERGE_READY to refinery
|
||||||
```bash
|
```bash
|
||||||
gt session kill <rig>/polecats/<name>
|
gt mail send <rig>/refinery -s "MERGE_READY <polecat>" -m "Branch: <branch>
|
||||||
# Worktree removal handled by session kill
|
Issue: <issue-id>
|
||||||
|
Polecat: <polecat>
|
||||||
|
Verified: clean git state, issue closed"
|
||||||
```
|
```
|
||||||
Then burn the cleanup wisp:
|
Then update the wisp to merge-requested state:
|
||||||
```bash
|
```bash
|
||||||
bd close <wisp-id> # or bd burn <wisp-id>
|
bd update <wisp-id> --labels cleanup,polecat:<name>,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.
|
**Parallelism**: Use Task tool subagents to process multiple cleanups concurrently.
|
||||||
Each cleanup is independent - perfect for parallel execution."""
|
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) |
|
| running | Actively working | Check progress (Step 3) |
|
||||||
| idle | No work assigned | Skip (no action needed) |
|
| idle | No work assigned | Skip (no action needed) |
|
||||||
| stuck | Self-reported stuck | Handle stuck protocol |
|
| 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**
|
**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 5-15 min | Gentle nudge |
|
||||||
| agent_state=running, idle 15+ min | Direct nudge with deadline |
|
| agent_state=running, idle 15+ min | Direct nudge with deadline |
|
||||||
| agent_state=stuck | Assess and help or escalate |
|
| 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:<name> --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:<polecat>" \
|
||||||
|
--description "Discovered done polecat without cleanup wisp" \
|
||||||
|
--labels cleanup,polecat:<name>,state:pending
|
||||||
|
```
|
||||||
|
This ensures done polecats eventually get cleaned up even if mail was lost.
|
||||||
|
|
||||||
**Step 5: Execute nudges**
|
**Step 5: Execute nudges**
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Reference in New Issue
Block a user