Files
gastown/.beads/formulas/mol-refinery-patrol.formula.toml
Steve Yegge ae8539d7e0 Refinery processes MERGE_READY and sends MERGED (gt-7uhts)
Updated mol-refinery-patrol formula with:
- MERGE_READY handling in inbox-check (parse branch/issue/polecat)
- Mail-based queue instead of git branch scanning
- MERGED mail sent to Witness after successful merge
- Flow diagram showing Witness→Refinery→Witness mail protocol
- Bumped formula version to 2

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 09:58:51 -08:00

237 lines
6.5 KiB
TOML

description = """
Merge queue processor patrol loop.
The Refinery is the Engineer in the engine room. You process polecat branches, merging them to main one at a time with sequential rebasing.
**The Scotty Test**: Before proceeding past any failure, ask yourself: "Would Scotty walk past a warp core leak because it existed before his shift?"
## Merge Flow
The Refinery receives MERGE_READY mail from Witnesses when polecats complete work:
```
Witness Refinery Git
│ │ │
│ MERGE_READY │ │
│─────────────────────────>│ │
│ │ │
│ (verify branch) │
│ │ fetch & rebase │
│ │──────────────────────────>│
│ │ │
│ (run tests) │
│ │ │
│ (if pass) │
│ │ merge & push │
│ │──────────────────────────>│
│ │ │
│ MERGED │ │
│<─────────────────────────│ │
│ │ │
```
After successful merge, Refinery sends MERGED mail back to Witness so it can
complete cleanup (nuke the polecat worktree)."""
formula = "mol-refinery-patrol"
version = 2
[[steps]]
id = "inbox-check"
title = "Check refinery mail"
description = """
Check mail for MERGE_READY submissions, escalations, and messages.
```bash
gt mail inbox
```
For each message:
**MERGE_READY**:
A polecat's work is ready for merge. Extract details and track for processing.
```bash
# Parse MERGE_READY message body:
# Branch: <branch>
# Issue: <issue-id>
# Polecat: <polecat-name>
# Verified: clean git state, issue closed
# Track in your merge queue for this patrol cycle:
# - Branch name
# - Issue ID
# - Polecat name (for MERGED response)
```
Mark as read. The work will be processed in queue-scan/process-branch.
**PATROL: Wake up**:
Witness detected MRs waiting but refinery idle. Acknowledge and proceed.
**HELP / Blocked**:
Assess and respond. If you can't help, escalate to Mayor.
**HANDOFF**:
Read predecessor context. Check for in-flight merges."""
[[steps]]
id = "queue-scan"
title = "Scan merge queue"
needs = ["inbox-check"]
description = """
Review the queue built from MERGE_READY messages in inbox-check.
```bash
# For each queued merge request, verify the branch exists:
git fetch origin
git branch -r | grep <branch>
```
If queue empty, skip to context-check step.
If branch doesn't exist for a queued item:
- Mail witness: Branch not found, cannot merge
- Remove from queue
Track verified branch list for this cycle."""
[[steps]]
id = "process-branch"
title = "Process next branch"
needs = ["queue-scan"]
description = """
Pick next branch from queue. Rebase on current main.
```bash
git checkout -b temp origin/<polecat-branch>
git rebase origin/main
```
If rebase conflicts and unresolvable:
- git rebase --abort
- Notify polecat/witness to fix and resubmit
- Skip to loop-check for next branch"""
[[steps]]
id = "run-tests"
title = "Run test suite"
needs = ["process-branch"]
description = """
Run the test suite.
```bash
go test ./...
```
Track results: pass count, fail count, specific failures."""
[[steps]]
id = "handle-failures"
title = "Handle test failures"
needs = ["run-tests"]
description = """
**VERIFICATION GATE**: This step enforces the Beads Promise.
If tests PASSED: This step auto-completes. Proceed to merge.
If tests FAILED:
1. Diagnose: Is this a branch regression or pre-existing on main?
2. If branch caused it:
- Abort merge
- Notify polecat: "Tests failing. Please fix and resubmit."
- Skip to loop-check
3. If pre-existing on main:
- Option A: Fix it yourself (you're the Engineer!)
- Option B: File a bead: bd create --type=bug --priority=1 --title="..."
**GATE REQUIREMENT**: You CANNOT proceed to merge-push without:
- Tests passing, OR
- Fix committed, OR
- Bead filed for the failure
This is non-negotiable. Never disavow. Never "note and proceed." """
[[steps]]
id = "merge-push"
title = "Merge and push to main"
needs = ["handle-failures"]
description = """
Merge to main and push immediately.
```bash
git checkout main
git merge --ff-only temp
git push origin main
git branch -d temp
git push origin --delete <polecat-branch> # Delete remote polecat branch
```
**CRITICAL**: After successful merge, send MERGED mail to Witness:
```bash
gt mail send <rig>/witness -s "MERGED <polecat-name>" -m "Branch: <branch>
Issue: <issue-id>
Merged-At: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
```
This signals the Witness to complete cleanup (nuke polecat worktree).
Main has moved. Any remaining branches need rebasing on new baseline."""
[[steps]]
id = "loop-check"
title = "Check for more work"
needs = ["merge-push"]
description = """
More branches to process?
If yes: Return to process-branch with next branch.
If no: Continue to generate-summary.
Track: branches processed, branches skipped (with reasons)."""
[[steps]]
id = "generate-summary"
title = "Generate handoff summary"
needs = ["loop-check"]
description = """
Summarize this patrol cycle.
Include:
- Branches processed (count, names)
- MERGED mails sent
- Test results (pass/fail)
- Issues filed (if any)
- Branches skipped (with reasons)
- Any escalations sent
This becomes the digest when the patrol is squashed."""
[[steps]]
id = "context-check"
title = "Check own context limit"
needs = ["generate-summary"]
description = """
Check own context usage.
If context is HIGH (>80%):
- Write handoff summary
- Prepare for burn/respawn
If context is LOW:
- Can continue processing"""
[[steps]]
id = "burn-or-loop"
title = "Burn and respawn or loop"
needs = ["context-check"]
description = """
End of patrol cycle decision.
If queue non-empty AND context LOW:
- Burn this wisp, start fresh patrol
- Return to inbox-check
If queue empty OR context HIGH:
- Burn wisp with summary digest
- Exit (daemon will respawn if needed)"""